mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-01 22:23:23 -10:00
Compare commits
342
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6394bd0e05 | ||
|
|
fa719811ac | ||
|
|
174f225e9d | ||
|
|
e916448940 | ||
|
|
bb44e0bbce | ||
|
|
191d44fc43 | ||
|
|
a2f0cbaa58 | ||
|
|
a9d9a66f13 | ||
|
|
37060c28e5 | ||
|
|
7205c21e76 | ||
|
|
ceef722d01 | ||
|
|
dfe0bb55ee | ||
|
|
6fd82592ce | ||
|
|
39187b5192 | ||
|
|
729862401d | ||
|
|
34d0d68bdf | ||
|
|
82e9cbeb0d | ||
|
|
2020dd5535 | ||
|
|
0c0f53e25c | ||
|
|
3dbe0714dd | ||
|
|
9067bac11d | ||
|
|
74471f3742 | ||
|
|
370f80376a | ||
|
|
ed3aac289a | ||
|
|
11b52a6536 | ||
|
|
b6185fc79c | ||
|
|
8fd7d5438e | ||
|
|
a513171f80 | ||
|
|
ff9e177617 | ||
|
|
db3519a9ec | ||
|
|
258e351d12 | ||
|
|
cd14f4d346 | ||
|
|
df631629b1 | ||
|
|
af0269b036 | ||
|
|
d37dbf988d | ||
|
|
cc7ed88f28 | ||
|
|
07442ab4a1 | ||
|
|
dbe6a18d82 | ||
|
|
7dd007c2ed | ||
|
|
9c6a8f503d | ||
|
|
0c459361a1 | ||
|
|
72d3457e8d | ||
|
|
e1f0c1d05d | ||
|
|
74bcc51b99 | ||
|
|
7e4f956056 | ||
|
|
1fb9798b69 | ||
|
|
9f6a84bc43 | ||
|
|
8cef921d18 | ||
|
|
b04c3db504 | ||
|
|
d04d7cf158 | ||
|
|
2b8bdd5c7f | ||
|
|
2a44494726 | ||
|
|
8f30db54d9 | ||
|
|
b09ac1abe7 | ||
|
|
012d4869c1 | ||
|
|
3597c9c1d5 | ||
|
|
3b4bef0696 | ||
|
|
d899303743 | ||
|
|
5773685183 | ||
|
|
d40ba77ebf | ||
|
|
a8c46d182c | ||
|
|
d80e20a1c3 | ||
|
|
1ce4fad939 | ||
|
|
9167a242db | ||
|
|
09e96924ec | ||
|
|
69ff4e9dbd | ||
|
|
0434349d6a | ||
|
|
e007221223 | ||
|
|
4622317288 | ||
|
|
ffac613ff9 | ||
|
|
aba5288247 | ||
|
|
4f7cb96931 | ||
|
|
fafc2e4b33 | ||
|
|
83ef70f24a | ||
|
|
de17c16e1f | ||
|
|
9462695b64 | ||
|
|
5eb089588e | ||
|
|
2039f70c23 | ||
|
|
082a9fc256 | ||
|
|
36a013c956 | ||
|
|
c4c4b32b81 | ||
|
|
804b6ab08d | ||
|
|
81b168a702 | ||
|
|
5c6892078a | ||
|
|
18a21890ff | ||
|
|
6629fa6473 | ||
|
|
2a7996ce0e | ||
|
|
8ec131fb59 | ||
|
|
30d061750d | ||
|
|
c5f5dc5bad | ||
|
|
d2df336c58 | ||
|
|
b299b12b17 | ||
|
|
c248df6161 | ||
|
|
7d5625d5f7 | ||
|
|
cc21d131e3 | ||
|
|
41a5bda61f | ||
|
|
5163f6e864 | ||
|
|
6173d56bdc | ||
|
|
f39942d217 | ||
|
|
5dde87088f | ||
|
|
3fa017e24b | ||
|
|
35924dbe8c | ||
|
|
88aa905668 | ||
|
|
b93c5c84c8 | ||
|
|
f203baee5b | ||
|
|
5e3be62385 | ||
|
|
b391493bc6 | ||
|
|
57f9f4c9f5 | ||
|
|
7ebc79037c | ||
|
|
ea299062eb | ||
|
|
e03dd1a6c2 | ||
|
|
535d2eb34a | ||
|
|
beb8eab90c | ||
|
|
8d67694fbf | ||
|
|
02510b2436 | ||
|
|
b57a2297f2 | ||
|
|
43fab08210 | ||
|
|
915080e6b1 | ||
|
|
9f59ddcc4f | ||
|
|
999ceb2c1d | ||
|
|
307331a42a | ||
|
|
6728dd464b | ||
|
|
bb45bcc8de | ||
|
|
096109c804 | ||
|
|
7ae1fcc88c | ||
|
|
299e0bc52a | ||
|
|
74f0529e24 | ||
|
|
614971158c | ||
|
|
afa328b1b2 | ||
|
|
868dab5dc2 | ||
|
|
29bb3bf350 | ||
|
|
dbf45b44b7 | ||
|
|
d0d888bc6d | ||
|
|
19abbad0da | ||
|
|
f48aba6de7 | ||
|
|
cb2ae96bf6 | ||
|
|
848f874ca1 | ||
|
|
a1a86bf902 | ||
|
|
c727a05459 | ||
|
|
eb05143e24 | ||
|
|
0c709e6195 | ||
|
|
dc88aa49b4 | ||
|
|
dc2ffbf6d8 | ||
|
|
d3bf9367f2 | ||
|
|
c502715a74 | ||
|
|
b9a61d2154 | ||
|
|
9525204c5d | ||
|
|
f79d556b4f | ||
|
|
41ae9ece21 | ||
|
|
40480d2bf4 | ||
|
|
e389e937a7 | ||
|
|
73b48d914f | ||
|
|
3999bf3244 | ||
|
|
a3441a43a6 | ||
|
|
49a3aaac4a | ||
|
|
027866ce23 | ||
|
|
04babf6c6f | ||
|
|
d2b8117310 | ||
|
|
0c4b9aef7b | ||
|
|
431c829f33 | ||
|
|
be7398ec06 | ||
|
|
be59ce1f48 | ||
|
|
eacad66dbe | ||
|
|
66dbb62824 | ||
|
|
d47d251286 | ||
|
|
348af56fae | ||
|
|
09866b9baa | ||
|
|
e1daf40e3e | ||
|
|
de3ea06d59 | ||
|
|
fe46a160ce | ||
|
|
8033c42abd | ||
|
|
4713c69fa2 | ||
|
|
d68bf60838 | ||
|
|
57fa5ca551 | ||
|
|
8610774f79 | ||
|
|
76ba04832b | ||
|
|
644f5de21b | ||
|
|
dcc0da8297 | ||
|
|
41193c50fa | ||
|
|
da0266005a | ||
|
|
eacdccbb3e | ||
|
|
65e8c51928 | ||
|
|
e470436f19 | ||
|
|
b60c2c74f3 | ||
|
|
fe1b69708c | ||
|
|
a1678e85db | ||
|
|
8212d18cf5 | ||
|
|
6c412ddf1c | ||
|
|
862ad4be53 | ||
|
|
aac2ad563a | ||
|
|
eb41f58a4e | ||
|
|
5543b41167 | ||
|
|
31d85f6a6b | ||
|
|
9c49a2533c | ||
|
|
c6faf5fd73 | ||
|
|
069def25cb | ||
|
|
3733a1e804 | ||
|
|
5b06a3f785 | ||
|
|
baaf73aaac | ||
|
|
345c22aa80 | ||
|
|
26bb2a0865 | ||
|
|
e6ea832410 | ||
|
|
22d0cc8d38 | ||
|
|
898829d5c7 | ||
|
|
72bb3c7571 | ||
|
|
48c437f0ab | ||
|
|
07d00c2174 | ||
|
|
3243a06f51 | ||
|
|
1c3f96be38 | ||
|
|
df9e7219db | ||
|
|
e83421f511 | ||
|
|
2b311b3cce | ||
|
|
4b5db3749c | ||
|
|
a1497a782c | ||
|
|
3c547d7bb7 | ||
|
|
3b43502e3a | ||
|
|
078517421f | ||
|
|
afc7055619 | ||
|
|
53425683d4 | ||
|
|
ef5a63186a | ||
|
|
4a0e0accd7 | ||
|
|
73e47683de | ||
|
|
115e94a31e | ||
|
|
5fd5f6999d | ||
|
|
602e97b725 | ||
|
|
97b766dfcd | ||
|
|
fb8cf78db6 | ||
|
|
c5238ac21b | ||
|
|
99917a99cd | ||
|
|
55ed56908f | ||
|
|
139e310025 | ||
|
|
bed93b1dcb | ||
|
|
73b4ac5cd8 | ||
|
|
00e8277b83 | ||
|
|
a8ea3a357b | ||
|
|
f8051485c1 | ||
|
|
807c80b259 | ||
|
|
686a3c3dc2 | ||
|
|
a381d8277c | ||
|
|
8647b09bfd | ||
|
|
9153014fa0 | ||
|
|
f6d4446ea8 | ||
|
|
f1e247ee6b | ||
|
|
a49668769d | ||
|
|
97d949d9da | ||
|
|
040093b1a5 | ||
|
|
5d4e53dc81 | ||
|
|
3ebee80226 | ||
|
|
c56651312b | ||
|
|
869ca150e7 | ||
|
|
910628f396 | ||
|
|
251241dc90 | ||
|
|
03a23e5c6e | ||
|
|
a68fc29ceb | ||
|
|
0014803d23 | ||
|
|
5118f7b47c | ||
|
|
1c1d7bda2c | ||
|
|
bdae662c94 | ||
|
|
0108d4e323 | ||
|
|
4305793bad | ||
|
|
d2d51eeff0 | ||
|
|
3be42b28c1 | ||
|
|
ee70ef8771 | ||
|
|
5f9fe0f8d0 | ||
|
|
7589acc9e8 | ||
|
|
94f539bdac | ||
|
|
e637fd2386 | ||
|
|
6e785bee32 | ||
|
|
f883e4f7b8 | ||
|
|
5daa7bb7a4 | ||
|
|
b0a84d0525 | ||
|
|
f1f84ba223 | ||
|
|
db830f26cb | ||
|
|
61a606dade | ||
|
|
2d95575edb | ||
|
|
d707483ce3 | ||
|
|
e2deb622c2 | ||
|
|
6e792a557e | ||
|
|
ea2138cf90 | ||
|
|
992f3cb78e | ||
|
|
828b2ff676 | ||
|
|
a231a8272c | ||
|
|
f2604b35dc | ||
|
|
fc05630f1f | ||
|
|
ad960ddbce | ||
|
|
239a69680c | ||
|
|
f4f1df70f2 | ||
|
|
782e9e6554 | ||
|
|
64de0113f1 | ||
|
|
84db615abc | ||
|
|
7c6a56cc63 | ||
|
|
a20600b917 | ||
|
|
4986fd4111 | ||
|
|
96639424e2 | ||
|
|
6ac733bf09 | ||
|
|
25d82d3311 | ||
|
|
f9800fe5a0 | ||
|
|
542d991b4c | ||
|
|
d1d6963eba | ||
|
|
7058b807cd | ||
|
|
f49d2561cb | ||
|
|
a63e5f1971 | ||
|
|
ebbc8a3d8e | ||
|
|
08b2d3ba9a | ||
|
|
72fbd9f97c | ||
|
|
5b6d0419d9 | ||
|
|
9df9eeeb18 | ||
|
|
5b6321a237 | ||
|
|
5e0c455842 | ||
|
|
4d687b13cf | ||
|
|
d7b8193716 | ||
|
|
2e51813417 | ||
|
|
90f445e1c9 | ||
|
|
143d288cba | ||
|
|
13a2ccc46f | ||
|
|
ea2b7d7079 | ||
|
|
0b52786ce1 | ||
|
|
e36469149a | ||
|
|
e5fc266be5 | ||
|
|
3e4cd634cc | ||
|
|
06976f82e7 | ||
|
|
fe7c6c90a8 | ||
|
|
960a4b537a | ||
|
|
c756b1e762 | ||
|
|
06921ec84f | ||
|
|
8cb1cec656 | ||
|
|
a46657d185 | ||
|
|
28acf422cb | ||
|
|
a7d5da8857 | ||
|
|
931a548be3 | ||
|
|
bcddbd0f6a | ||
|
|
b3dfdb5a3b | ||
|
|
6ccc51fd20 | ||
|
|
0ea5709a32 | ||
|
|
67a2698dac | ||
|
|
eea4acfa5c | ||
|
|
c99d32efe6 | ||
|
|
9fa7591beb | ||
|
|
066263f377 | ||
|
|
20c1a35211 | ||
|
|
ea6112b165 | ||
|
|
e222100afe |
No files matched your search
@@ -46,7 +46,6 @@ qemu-monitor.texi
|
||||
patches
|
||||
pc-bios/bios-pq/status
|
||||
pc-bios/vgabios-pq/status
|
||||
pc-bios/optionrom/linuxboot.bin
|
||||
pc-bios/optionrom/multiboot.bin
|
||||
pc-bios/optionrom/multiboot.raw
|
||||
.stgit-*
|
||||
@@ -1,3 +1,190 @@
|
||||
version 0.12.5
|
||||
- audio/alsa: Handle SND_PCM_STATE_SETUP in alsa_poll_handler
|
||||
- block: Handle multiwrite errors only when all requests have completed
|
||||
- block: Fix early failure in multiwrite
|
||||
- vpc: Use bdrv_(p)write_sync for metadata writes
|
||||
- vmdk: Use bdrv_(p)write_sync for metadata writes
|
||||
- qcow2: Use bdrv_(p)write_sync for metadata writes
|
||||
- qcow: Use bdrv_(p)write_sync for metadata writes
|
||||
- block: Add bdrv_(p)write_sync
|
||||
- qcow2: Restore L1 entry on l2_allocate failure
|
||||
- block/vdi: Fix image opening and creation for odd disk sizes
|
||||
- block/vpc: Fix conversion from size to disk geometry
|
||||
- qcow2: Remove abort on free_clusters failure
|
||||
- vmdk: Fix COW
|
||||
- qcow2: Fix creation of large images
|
||||
- vmdk: fix double free
|
||||
- qemu-options: add documentation for stdio signal=on|off
|
||||
- target-arm : fix parallel saturated subtraction implementation
|
||||
- target-arm : fix thumb2 parallel add/sub opcode decoding
|
||||
- target-arm: fix addsub/subadd implementation
|
||||
- target-i386: fix xchg rax,r8
|
||||
- block/vvfat.c: fix warnings with _FORTIFY_SOURCE
|
||||
- audio/alsa: Spelling typo (paramters)
|
||||
- target-mips: fix DINSU instruction
|
||||
- Correct definitions for FD_CMD_SAVE and FD_CMD_RESTORE
|
||||
- qcow2: Fix corruption after error in update_refcount
|
||||
- qcow2: Fix corruption after refblock allocation
|
||||
- block: Fix multiwrite with overlapping requests
|
||||
- qcow2: Fix error handling in l2_allocate
|
||||
- qcow2: Clear L2 table cache after write error
|
||||
- ide: Fix ide_dma_cancel
|
||||
- usb-bus: fix no params
|
||||
- Avoid crash on '-usbdevice <device>' without parameters
|
||||
- Fix -usbdevice crash
|
||||
- Fix multiboot compilation
|
||||
- Fix missing symbols in .rel/.rela.plt sections
|
||||
- target-ppc: fix RFI by clearing some bits of MSR
|
||||
- Fix typo in balloon help
|
||||
- arm_timer: fix oneshot mode
|
||||
- arm_timer: reload timer when enabled
|
||||
- qemu-sockets: avoid strlen of NULL pointer
|
||||
- block: fix aio_flush segfaults for read-only protocols (e.g. curl)
|
||||
- virtio-blk: fix barrier support
|
||||
- block: fix sector comparism in multiwrite_req_compare
|
||||
- pci: irq_state vmstate breakage
|
||||
- qemu-img: use the heap instead of the huge stack array for win32
|
||||
|
||||
version 0.12.4
|
||||
- Workaround for broken OSS_GETVERSION on FreeBSD, part two (Juergen Lock)
|
||||
- oss: fix fragment setting (malc)
|
||||
- oss: issue OSS_GETVERSION ioctl only when needed (malc)
|
||||
- oss: refactor code around policy setting (malc)
|
||||
- oss: workaround for cases when OSS_GETVERSION is not defined (malc)
|
||||
- block: Free iovec arrays allocated by multiwrite_merge() (Stefan Hajnoczi)
|
||||
- lsi: fix segfault in lsi_command_complete (Gerd Hoffmann)
|
||||
- lsi: pass lsi_request to lsi_reselect (Gerd Hoffmann)
|
||||
- lsi: move dma_len+dma_buf into lsi_request (Gerd Hoffmann)
|
||||
- lsi: move current_dev into lsi_request (Gerd Hoffmann)
|
||||
- lsi: have lsi_request for the whole life time of the request. (Gerd Hoffmann)
|
||||
- lsi: use QTAILQ for lsi_queue (Gerd Hoffmann)
|
||||
- tcp/mips: Change TCG_AREG0 (fp -> s0) (Stefan Weil)
|
||||
- sh_pci: fix memory and I/O access (Aurelien Jarno)
|
||||
- Fix incoming migration with iothread (Marcelo Tosatti)
|
||||
- Fix SIGFPE for vnc display of width/height = 1 (Chris Webb)
|
||||
- net: remove broken net_set_boot_mask() boot device validation (Eduardo Habkost)
|
||||
- qcow2: Remove request from in-flight list after error (Kevin Wolf)
|
||||
- qcow2: Don't ignore immediate read/write failures (Kevin Wolf)
|
||||
- block: Fix multiwrite memory leak in error case (Kevin Wolf)
|
||||
- block: Fix error code in multiwrite for immediate failures (Kevin Wolf)
|
||||
- block: Fix multiwrite error handling (Kevin Wolf)
|
||||
- scsi-disk: fix buffer overflow (Gerd Hoffmann)
|
||||
- qcow2: Rewrite alloc_refcount_block/grow_refcount_table (Kevin Wolf)
|
||||
- qcow2: Factor next_refcount_table_size out (Kevin Wolf)
|
||||
- block: avoid creating too large iovecs in multiwrite_merge (Christoph Hellwig)
|
||||
- json-parser: Fix segfault on malformed input (Kevin Wolf)
|
||||
- linux-user: switch default ppc64 CPU to 970fx from 970 (Aurelien Jarno)
|
||||
- target-sh4: MMU: fix store queue addresses (Aurelien Jarno)
|
||||
- target-sh4: MMU: fix ITLB priviledge check (Aurelien Jarno)
|
||||
- target-sh4: MMU: fix mem_idx computation (Aurelien Jarno)
|
||||
- sh7750: handle MMUCR TI bit (Aurelien Jarno)
|
||||
- UHCI spurious interrut fix (Paul Brook)
|
||||
- tcg/mips: fix branch offset during retranslation (Aurelien Jarno)
|
||||
- tcg/arm: correctly save/restore registers in prologue/epilogue (Aurelien Jarno)
|
||||
- workaround for cmd646 bmdma register access while no dma is active (Igor V. Kovalenko)
|
||||
- Fix corner case in chardev udp: parameter (Jan Kiszka)
|
||||
- Don't set default monitor when there is a mux'ed one (Jan Kiszka)
|
||||
- spelling typo (compatibilty) in hw/fw_cfg.c (Vagrant Cascadian)
|
||||
- fdc: fix drive property handling. (Gerd Hoffmann)
|
||||
- target-i386: fix commit c22549204a6edc431e8e4358e61bd56386ff6957 (TeLeMan)
|
||||
- target-i386: fix SIB decoding with index = 4 (Aurelien Jarno)
|
||||
- Fix segfault with ram_size > 4095M without kvm (Ryan Harper)
|
||||
- target-i386: Fix long jumps/calls in long mode with REX.W set (malc)
|
||||
- target-i386: fix lddqu SSE instruction (Aurelien Jarno)
|
||||
- qemu-char.c: drop debug printfs from qemu_chr_parse_compat (Jan Kiszka)
|
||||
- fix undefined shifts by >32 (Paolo Bonzini)
|
||||
- Fix qemu -net user,hostfwd= example (Aurelien Jarno)
|
||||
|
||||
version 0.12.3
|
||||
- kvm: Fix eflags corruption in kvm mode (Jan Kiszka)
|
||||
- qcow2: Fix access after end of array (Kevin Wolf)
|
||||
- ide save/restore pio/atapi cmd transfer fields and io buffer (Marcelo Tosatti)
|
||||
- net: Monitor command set_link finds only VLAN clients, fix (Markus Armbruster)
|
||||
- net: info network shows only VLAN clients, fix (Markus Armbruster)
|
||||
- net: net_check_clients() checks only VLAN clients, fix (Markus Armbruster)
|
||||
- net: Fix bogus "Warning: vlan 0 with no nics" with -device (Markus Armbruster)
|
||||
- net: net_check_clients() runs too early to see -device, fix (Markus Armbruster)
|
||||
- net: Remove unused net_client_uninit() (Markus Armbruster)
|
||||
- don't dereference NULL after failed strdup (Jim Meyering)
|
||||
- virtio-net: fix network stall under load (Tom Lendacky)
|
||||
- json: fix PRId64 on Win32 (Roy Tam)
|
||||
- fix inet_parse typo (Marcelo Tosatti)
|
||||
- iothread: fix vcpu stop with smp tcg (Marcelo Tosatti)
|
||||
- segfault due to buffer overrun in usb-serial (David S. Ahern)
|
||||
- qcow2: Fix signedness bugs (Kevin Wolf)
|
||||
- Do not ignore error, if open file failed (-serial /dev/tty) (Evgeniy Dushistov)
|
||||
- pc-bios: update to newer version of (stable) seabios (Anthony Liguori)
|
||||
- target-mips: fix ROTR and DROTR by zero (Aurelien Jarno)
|
||||
- target-mips: fix CpU exception for coprocessor 0 (Nathan Froyd)
|
||||
- tcg/mips: fix crash in tcg_out_qemu_ld() (Aurelien Jarno)
|
||||
- target-mips: don't call cpu_loop_exit() from helper.c (Aurelien Jarno)
|
||||
- virtio-blk: Fix error cases which ignored rerror/werror (Kevin Wolf)
|
||||
- virtio-blk: Fix restart after read error (Kevin Wolf)
|
||||
- virtio_blk: Factor virtio_blk_handle_request out (Kevin Wolf)
|
||||
- cirrus: Properly re-register cirrus_linear_io_addr on vram unmap (Jan Kiszka)
|
||||
- qcow2: Don't ignore qcow2_alloc_clusters return value (Kevin Wolf)
|
||||
- qcow2: Don't ignore update_refcount return value (Kevin Wolf)
|
||||
- qcow2: Allow updating no refcounts (Kevin Wolf)
|
||||
- qcow2: Improve error handling in update_refcount (Kevin Wolf)
|
||||
- qcow2: Fix error handling in grow_refcount_table (Kevin Wolf)
|
||||
- block: Return original error codes in bdrv_pread/write (Kevin Wolf)
|
||||
- qcow2: Return 0/-errno in qcow2_alloc_cluster_offset (Kevin Wolf)
|
||||
- qcow2: Return 0/-errno in get_cluster_table (Kevin Wolf)
|
||||
- qcow2: Fix error handling in qcow_save_vmstate (Kevin Wolf)
|
||||
- qcow2: Fix error handling in qcow2_grow_l1_table (Kevin Wolf)
|
||||
- win32/sdl: Fix toggle full screen (Herve Poussineau)
|
||||
- win32: pair qemu_memalign() with qemu_vfree() (Herve Poussineau)
|
||||
- vnc_refresh: calling vnc_update_client might free vs (Stefano Stabellini)
|
||||
- Musicpal: Fix descriptor walk in eth_send (Jan Kiszka)
|
||||
- Musicpal: Fix wm8750 I2C address (Jan Kiszka)
|
||||
- fix savevm command without id or tag (Marcelo Tosatti)
|
||||
- reduce number of reinjects on ACK (Gleb Natapov)
|
||||
- QMP: Fix asynchronous events delivery (Luiz Capitulino)
|
||||
- Documentation: Add missing documentation for qdev related command line options (Stefan Weil)
|
||||
- pc: add driver version compat properties (Gerd Hoffmann)
|
||||
- scsi: device version property (Gerd Hoffmann)
|
||||
- ide: device version property (Gerd Hoffmann)
|
||||
- QMP: Emit asynchronous events on all QMP monitors (Adam Litke)
|
||||
- Fix QEMU_WARN_UNUSED_RESULT (Kevin Wolf)
|
||||
|
||||
version 0.12.2:
|
||||
- Qemu's internal TFTP server breaks lock-step-iness of TFTP (Milan Plzik)
|
||||
- osdep.c: Fix accept4 fallback (Kevin Wolf)
|
||||
- pc: add rombar to compat properties for pc-0.10 and pc-0.11 (Gerd Hoffmann)
|
||||
- pci: allow loading roms via fw_cfg. (Gerd Hoffmann)
|
||||
- roms: rework rom loading via fw (Gerd Hoffmann)
|
||||
- fw_cfg: rom loader tweaks. (Gerd Hoffmann)
|
||||
- roms: minor fixes and cleanups. (Gerd Hoffmann)
|
||||
- pc: add machine type for 0.12 (Gerd Hoffmann)
|
||||
- loader: more ignores for rom intended to be loaded by the bios (Aurelien Jarno)
|
||||
- vnc_refresh: return if vd->timer is NULL (Stefano Stabellini)
|
||||
- QMP: Don't free async event's 'data' (Luiz Capitulino)
|
||||
- Handle TFTP ERROR from client (Thomas Horsten)
|
||||
- dmg: fix ->open failure (Christoph Hellwig)
|
||||
- virtio-pci: thinko fix (Michael S. Tsirkin)
|
||||
- pc-bios: Update README (SeaBIOS) (Stefan Weil)
|
||||
- vmware_vga: Check cursor dimensions passed from guest to avoid buffer overflow (Roland Dreier)
|
||||
- remove pending exception on vcpu reset. (Gleb Natapov)
|
||||
- Fix CPU topology initialization (Jiri Denemark)
|
||||
- MCE: Fix bug of IA32_MCG_STATUS after system reset (Huang Ying)
|
||||
- linuxboot: fix gdt address calculation (Avi Kivity)
|
||||
- QMP: Drop wrong assert() (Luiz Capitulino)
|
||||
- vnc: Fix artifacts in hextile decoding (Anthony Liguori)
|
||||
- target-i386: Fix "call im" on x86_64 when executing 32-bit code (Aurelien Jarno)
|
||||
- Add missing newline at the end of options list (Michael Tokarev)
|
||||
- Don't load options roms intended to be loaded by the bios in qemu (Avi Kivity)
|
||||
- USB: Improve usbdevice error messages (Scott Tsai)
|
||||
- cpu-all.h: fix cpu_get_real_ticks() #ifdef (Aurelien Jarno)
|
||||
- alpha: fix compile (Blue Swirl)
|
||||
- user_only: compile everything with -fpie (Kirill A. Shutemov)
|
||||
- fdc/sparc32: don't hang on detection under OBP (Artyom Tarasenko)
|
||||
- scsi-disk: Inquiry with allocation length of CDB < 36 (v4) (Artyom Tarasenko)
|
||||
- e1000: fix init values for command register (Michael S. Tsirkin)
|
||||
|
||||
version 0.12.1:
|
||||
- loader: fix rom loading at address 0 (fixes target-arm) (Aurelien Jarno)
|
||||
- loader: fix rom_copy (fixes multiboot) (Kevin Wolf)
|
||||
|
||||
version 0.12.0:
|
||||
|
||||
- Update to SeaBIOS 0.5.0
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ Main loop Fabrice Bellard (new maintainer needed)
|
||||
TCG Fabrice Bellard
|
||||
IDE device ?
|
||||
SCSI device Paul Brook
|
||||
PCI layer Michael S. Tsirkin
|
||||
PCI layer ?
|
||||
USB layer ?
|
||||
Block layer ?
|
||||
Graphic layer ?
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Makefile for QEMU.
|
||||
|
||||
# This needs to be defined before rules.mak
|
||||
GENERATED_HEADERS = config-host.h
|
||||
|
||||
ifneq ($(wildcard config-host.mak),)
|
||||
@@ -7,7 +8,7 @@ ifneq ($(wildcard config-host.mak),)
|
||||
all: build-all
|
||||
include config-host.mak
|
||||
include $(SRC_PATH)/rules.mak
|
||||
config-host.mak: $(SRC_PATH)/configure
|
||||
config-host.mak: configure
|
||||
@echo $@ is out-of-date, running configure
|
||||
@sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
|
||||
else
|
||||
@@ -24,7 +25,7 @@ configure: ;
|
||||
.PHONY: all clean cscope distclean dvi html info install install-doc \
|
||||
recurse-all speed tar tarbin test build-all
|
||||
|
||||
$(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
|
||||
VPATH=$(SRC_PATH):$(SRC_PATH)/hw
|
||||
|
||||
LIBS+=-lz $(LIBS_TOOLS)
|
||||
|
||||
@@ -42,22 +43,12 @@ config-all-devices.mak: $(SUBDIR_DEVICES_MAK)
|
||||
|
||||
%/config-devices.mak: default-configs/%.mak
|
||||
$(call quiet-command,cat $< > $@.tmp, " GEN $@")
|
||||
@if test -f $@; then \
|
||||
if cmp -s $@.old $@ || cmp -s $@ $@.tmp; then \
|
||||
mv $@.tmp $@; \
|
||||
cp -p $@ $@.old; \
|
||||
else \
|
||||
if test -f $@.old; then \
|
||||
echo "WARNING: $@ (user modified) out of date.";\
|
||||
else \
|
||||
echo "WARNING: $@ out of date.";\
|
||||
fi; \
|
||||
echo "Run \"make defconfig\" to regenerate."; \
|
||||
rm $@.tmp; \
|
||||
fi; \
|
||||
@if test -f $@ ; then \
|
||||
echo "WARNING: $@ out of date." ;\
|
||||
echo "Run \"make defconfig\" to regenerate." ; \
|
||||
rm $@.tmp ; \
|
||||
else \
|
||||
mv $@.tmp $@; \
|
||||
cp -p $@ $@.old; \
|
||||
mv $@.tmp $@ ; \
|
||||
fi
|
||||
|
||||
defconfig:
|
||||
@@ -75,10 +66,7 @@ SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
|
||||
subdir-%: $(GENERATED_HEADERS)
|
||||
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
|
||||
|
||||
include $(SRC_PATH)/Makefile.objs
|
||||
|
||||
$(common-obj-y): $(GENERATED_HEADERS)
|
||||
$(filter %-softmmu,$(SUBDIR_RULES)): $(common-obj-y)
|
||||
$(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a
|
||||
|
||||
$(filter %-user,$(SUBDIR_RULES)): libuser.a
|
||||
|
||||
@@ -93,8 +81,124 @@ ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
|
||||
|
||||
recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
|
||||
|
||||
#######################################################################
|
||||
# QObject
|
||||
qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
|
||||
qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
|
||||
qobject-obj-y += qerror.o
|
||||
|
||||
#######################################################################
|
||||
# block-obj-y is code used by both qemu system emulation and qemu-img
|
||||
|
||||
block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
|
||||
block-obj-y += nbd.o block.o aio.o aes.o osdep.o
|
||||
block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
|
||||
block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
|
||||
|
||||
block-nested-y += cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o
|
||||
block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o
|
||||
block-nested-y += parallels.o nbd.o
|
||||
block-nested-$(CONFIG_WIN32) += raw-win32.o
|
||||
block-nested-$(CONFIG_POSIX) += raw-posix.o
|
||||
block-nested-$(CONFIG_CURL) += curl.o
|
||||
|
||||
block-obj-y += $(addprefix block/, $(block-nested-y))
|
||||
|
||||
net-obj-y = net.o
|
||||
net-nested-y = queue.o checksum.o util.o
|
||||
net-nested-y += socket.o
|
||||
net-nested-y += dump.o
|
||||
net-nested-$(CONFIG_POSIX) += tap.o
|
||||
net-nested-$(CONFIG_LINUX) += tap-linux.o
|
||||
net-nested-$(CONFIG_WIN32) += tap-win32.o
|
||||
net-nested-$(CONFIG_BSD) += tap-bsd.o
|
||||
net-nested-$(CONFIG_SOLARIS) += tap-solaris.o
|
||||
net-nested-$(CONFIG_AIX) += tap-aix.o
|
||||
net-nested-$(CONFIG_SLIRP) += slirp.o
|
||||
net-nested-$(CONFIG_VDE) += vde.o
|
||||
net-obj-y += $(addprefix net/, $(net-nested-y))
|
||||
|
||||
######################################################################
|
||||
# libqemu_common.a: Target independent part of system emulation. The
|
||||
# long term path is to suppress *all* target specific code in case of
|
||||
# system emulation, i.e. a single QEMU executable should support all
|
||||
# CPUs and machines.
|
||||
|
||||
obj-y = $(block-obj-y)
|
||||
obj-y += $(net-obj-y)
|
||||
obj-y += $(qobject-obj-y)
|
||||
obj-y += readline.o console.o
|
||||
|
||||
obj-y += tcg-runtime.o host-utils.o
|
||||
obj-y += irq.o ioport.o
|
||||
obj-$(CONFIG_PTIMER) += ptimer.o
|
||||
obj-$(CONFIG_MAX7310) += max7310.o
|
||||
obj-$(CONFIG_WM8750) += wm8750.o
|
||||
obj-$(CONFIG_TWL92230) += twl92230.o
|
||||
obj-$(CONFIG_TSC2005) += tsc2005.o
|
||||
obj-$(CONFIG_LM832X) += lm832x.o
|
||||
obj-$(CONFIG_TMP105) += tmp105.o
|
||||
obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
|
||||
obj-$(CONFIG_SSD0303) += ssd0303.o
|
||||
obj-$(CONFIG_SSD0323) += ssd0323.o
|
||||
obj-$(CONFIG_ADS7846) += ads7846.o
|
||||
obj-$(CONFIG_MAX111X) += max111x.o
|
||||
obj-$(CONFIG_DS1338) += ds1338.o
|
||||
obj-y += i2c.o smbus.o smbus_eeprom.o
|
||||
obj-y += eeprom93xx.o
|
||||
obj-y += scsi-disk.o cdrom.o
|
||||
obj-y += scsi-generic.o scsi-bus.o
|
||||
obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
|
||||
obj-y += usb-serial.o usb-net.o usb-bus.o
|
||||
obj-$(CONFIG_SSI) += ssi.o
|
||||
obj-$(CONFIG_SSI_SD) += ssi-sd.o
|
||||
obj-$(CONFIG_SD) += sd.o
|
||||
obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o
|
||||
obj-y += bt-hci-csr.o
|
||||
obj-y += buffered_file.o migration.o migration-tcp.o qemu-sockets.o
|
||||
obj-y += qemu-char.o aio.o savevm.o
|
||||
obj-y += msmouse.o ps2.o
|
||||
obj-y += qdev.o qdev-properties.o
|
||||
obj-y += qemu-config.o block-migration.o
|
||||
|
||||
obj-$(CONFIG_BRLAPI) += baum.o
|
||||
obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
|
||||
|
||||
audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
|
||||
|
||||
audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
|
||||
audio-obj-$(CONFIG_SDL) += sdlaudio.o
|
||||
audio-obj-$(CONFIG_OSS) += ossaudio.o
|
||||
audio-obj-$(CONFIG_COREAUDIO) += coreaudio.o
|
||||
audio-obj-$(CONFIG_ALSA) += alsaaudio.o
|
||||
audio-obj-$(CONFIG_DSOUND) += dsoundaudio.o
|
||||
audio-obj-$(CONFIG_FMOD) += fmodaudio.o
|
||||
audio-obj-$(CONFIG_ESD) += esdaudio.o
|
||||
audio-obj-$(CONFIG_PA) += paaudio.o
|
||||
audio-obj-$(CONFIG_WINWAVE) += winwaveaudio.o
|
||||
audio-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
|
||||
audio-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
|
||||
audio-obj-y += wavcapture.o
|
||||
obj-y += $(addprefix audio/, $(audio-obj-y))
|
||||
|
||||
obj-y += keymaps.o
|
||||
obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
|
||||
obj-$(CONFIG_CURSES) += curses.o
|
||||
obj-y += vnc.o acl.o d3des.o
|
||||
obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
|
||||
obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
|
||||
obj-$(CONFIG_COCOA) += cocoa.o
|
||||
obj-$(CONFIG_IOTHREAD) += qemu-thread.o
|
||||
|
||||
slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
|
||||
slirp-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
|
||||
slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
|
||||
obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y))
|
||||
|
||||
# xen backend driver support
|
||||
obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o
|
||||
obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o
|
||||
|
||||
QEMU_CFLAGS+=$(CURL_CFLAGS)
|
||||
|
||||
cocoa.o: cocoa.m
|
||||
@@ -125,23 +229,17 @@ curses.o: curses.c keymaps.h curses_keys.h
|
||||
|
||||
bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
|
||||
|
||||
libqemu_common.a: $(obj-y)
|
||||
|
||||
######################################################################
|
||||
|
||||
qemu-img.o: qemu-img-cmds.h
|
||||
|
||||
obj-y = qemu-img.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
|
||||
qemu-img$(EXESUF): qemu-img.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
|
||||
|
||||
qemu-img$(EXESUF): $(obj-y)
|
||||
qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
|
||||
|
||||
obj-y = qemu-nbd.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
|
||||
$(obj-y): $(GENERATED_HEADERS)
|
||||
|
||||
qemu-nbd$(EXESUF): $(obj-y)
|
||||
|
||||
obj-y = qemu-io.o qemu-tool.o cmd.o $(block-obj-y) $(qobject-obj-y)
|
||||
$(obj-y): $(GENERATED_HEADERS)
|
||||
|
||||
qemu-io$(EXESUF): $(obj-y)
|
||||
qemu-io$(EXESUF): qemu-io.o qemu-tool.o cmd.o $(block-obj-y) $(qobject-obj-y)
|
||||
|
||||
qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
|
||||
$(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@," GEN $@")
|
||||
|
||||
+32
-3
@@ -7,16 +7,45 @@ include $(SRC_PATH)/rules.mak
|
||||
|
||||
.PHONY: all
|
||||
|
||||
$(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
|
||||
VPATH=$(SRC_PATH):$(SRC_PATH)/hw
|
||||
|
||||
QEMU_CFLAGS+=-I.. -I$(SRC_PATH)/fpu
|
||||
|
||||
include $(SRC_PATH)/Makefile.objs
|
||||
obj-y =
|
||||
obj-y += loader.o
|
||||
obj-y += virtio.o
|
||||
obj-y += fw_cfg.o
|
||||
obj-y += watchdog.o
|
||||
obj-$(CONFIG_ECC) += ecc.o
|
||||
obj-$(CONFIG_NAND) += nand.o
|
||||
|
||||
all: $(hw-obj-y)
|
||||
obj-$(CONFIG_M48T59) += m48t59.o
|
||||
obj-$(CONFIG_ESCC) += escc.o
|
||||
|
||||
# PCI watchdog devices
|
||||
obj-y += wdt_i6300esb.o
|
||||
|
||||
obj-y += msix.o
|
||||
|
||||
# PCI network cards
|
||||
obj-y += ne2000.o
|
||||
|
||||
obj-$(CONFIG_SMC91C111) += smc91c111.o
|
||||
obj-$(CONFIG_LAN9118) += lan9118.o
|
||||
|
||||
# SCSI layer
|
||||
obj-y += lsi53c895a.o
|
||||
obj-$(CONFIG_ESP) += esp.o
|
||||
|
||||
obj-y += dma-helpers.o sysbus.o isa-bus.o
|
||||
obj-$(CONFIG_QDEV_ADDR) += qdev-addr.o
|
||||
|
||||
all: $(HWLIB)
|
||||
# Dummy command so that make thinks it has done something
|
||||
@true
|
||||
|
||||
$(HWLIB): $(obj-y)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.d *.a *~
|
||||
|
||||
|
||||
-155
@@ -1,155 +0,0 @@
|
||||
#######################################################################
|
||||
# QObject
|
||||
qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
|
||||
qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
|
||||
qobject-obj-y += qerror.o
|
||||
|
||||
#######################################################################
|
||||
# block-obj-y is code used by both qemu system emulation and qemu-img
|
||||
|
||||
block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
|
||||
block-obj-y += nbd.o block.o aio.o aes.o osdep.o
|
||||
block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
|
||||
block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
|
||||
|
||||
block-nested-y += cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o
|
||||
block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o
|
||||
block-nested-y += parallels.o nbd.o
|
||||
block-nested-$(CONFIG_WIN32) += raw-win32.o
|
||||
block-nested-$(CONFIG_POSIX) += raw-posix.o
|
||||
block-nested-$(CONFIG_CURL) += curl.o
|
||||
|
||||
block-obj-y += $(addprefix block/, $(block-nested-y))
|
||||
|
||||
net-obj-y = net.o
|
||||
net-nested-y = queue.o checksum.o util.o
|
||||
net-nested-y += socket.o
|
||||
net-nested-y += dump.o
|
||||
net-nested-$(CONFIG_POSIX) += tap.o
|
||||
net-nested-$(CONFIG_LINUX) += tap-linux.o
|
||||
net-nested-$(CONFIG_WIN32) += tap-win32.o
|
||||
net-nested-$(CONFIG_BSD) += tap-bsd.o
|
||||
net-nested-$(CONFIG_SOLARIS) += tap-solaris.o
|
||||
net-nested-$(CONFIG_AIX) += tap-aix.o
|
||||
net-nested-$(CONFIG_SLIRP) += slirp.o
|
||||
net-nested-$(CONFIG_VDE) += vde.o
|
||||
net-obj-y += $(addprefix net/, $(net-nested-y))
|
||||
|
||||
######################################################################
|
||||
# libqemu_common.a: Target independent part of system emulation. The
|
||||
# long term path is to suppress *all* target specific code in case of
|
||||
# system emulation, i.e. a single QEMU executable should support all
|
||||
# CPUs and machines.
|
||||
|
||||
common-obj-y = $(block-obj-y)
|
||||
common-obj-y += $(net-obj-y)
|
||||
common-obj-y += $(qobject-obj-y)
|
||||
common-obj-y += readline.o console.o
|
||||
|
||||
common-obj-y += tcg-runtime.o host-utils.o
|
||||
common-obj-y += irq.o ioport.o
|
||||
common-obj-$(CONFIG_PTIMER) += ptimer.o
|
||||
common-obj-$(CONFIG_MAX7310) += max7310.o
|
||||
common-obj-$(CONFIG_WM8750) += wm8750.o
|
||||
common-obj-$(CONFIG_TWL92230) += twl92230.o
|
||||
common-obj-$(CONFIG_TSC2005) += tsc2005.o
|
||||
common-obj-$(CONFIG_LM832X) += lm832x.o
|
||||
common-obj-$(CONFIG_TMP105) += tmp105.o
|
||||
common-obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
|
||||
common-obj-$(CONFIG_SSD0303) += ssd0303.o
|
||||
common-obj-$(CONFIG_SSD0323) += ssd0323.o
|
||||
common-obj-$(CONFIG_ADS7846) += ads7846.o
|
||||
common-obj-$(CONFIG_MAX111X) += max111x.o
|
||||
common-obj-$(CONFIG_DS1338) += ds1338.o
|
||||
common-obj-y += i2c.o smbus.o smbus_eeprom.o
|
||||
common-obj-y += eeprom93xx.o
|
||||
common-obj-y += scsi-disk.o cdrom.o
|
||||
common-obj-y += scsi-generic.o scsi-bus.o
|
||||
common-obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
|
||||
common-obj-y += usb-serial.o usb-net.o usb-bus.o
|
||||
common-obj-$(CONFIG_SSI) += ssi.o
|
||||
common-obj-$(CONFIG_SSI_SD) += ssi-sd.o
|
||||
common-obj-$(CONFIG_SD) += sd.o
|
||||
common-obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o
|
||||
common-obj-y += bt-hci-csr.o
|
||||
common-obj-y += buffered_file.o migration.o migration-tcp.o qemu-sockets.o
|
||||
common-obj-y += qemu-char.o savevm.o #aio.o
|
||||
common-obj-y += msmouse.o ps2.o
|
||||
common-obj-y += qdev.o qdev-properties.o
|
||||
common-obj-y += qemu-config.o block-migration.o
|
||||
|
||||
common-obj-$(CONFIG_BRLAPI) += baum.o
|
||||
common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
|
||||
|
||||
audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
|
||||
audio-obj-$(CONFIG_SDL) += sdlaudio.o
|
||||
audio-obj-$(CONFIG_OSS) += ossaudio.o
|
||||
audio-obj-$(CONFIG_COREAUDIO) += coreaudio.o
|
||||
audio-obj-$(CONFIG_ALSA) += alsaaudio.o
|
||||
audio-obj-$(CONFIG_DSOUND) += dsoundaudio.o
|
||||
audio-obj-$(CONFIG_FMOD) += fmodaudio.o
|
||||
audio-obj-$(CONFIG_ESD) += esdaudio.o
|
||||
audio-obj-$(CONFIG_PA) += paaudio.o
|
||||
audio-obj-$(CONFIG_WINWAVE) += winwaveaudio.o
|
||||
audio-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
|
||||
audio-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
|
||||
audio-obj-y += wavcapture.o
|
||||
common-obj-y += $(addprefix audio/, $(audio-obj-y))
|
||||
|
||||
common-obj-y += keymaps.o
|
||||
common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
|
||||
common-obj-$(CONFIG_CURSES) += curses.o
|
||||
common-obj-y += vnc.o acl.o d3des.o
|
||||
common-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
|
||||
common-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
|
||||
common-obj-$(CONFIG_COCOA) += cocoa.o
|
||||
common-obj-$(CONFIG_IOTHREAD) += qemu-thread.o
|
||||
|
||||
slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
|
||||
slirp-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
|
||||
slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
|
||||
common-obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y))
|
||||
|
||||
# xen backend driver support
|
||||
common-obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o
|
||||
common-obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o
|
||||
|
||||
######################################################################
|
||||
# libuser
|
||||
|
||||
user-obj-y =
|
||||
user-obj-y += envlist.o path.o
|
||||
user-obj-y += tcg-runtime.o host-utils.o
|
||||
user-obj-y += cutils.o cache-utils.o
|
||||
|
||||
######################################################################
|
||||
# libhw
|
||||
|
||||
hw-obj-y =
|
||||
hw-obj-y += loader.o
|
||||
hw-obj-y += virtio.o
|
||||
hw-obj-y += fw_cfg.o
|
||||
hw-obj-y += watchdog.o
|
||||
hw-obj-$(CONFIG_ECC) += ecc.o
|
||||
hw-obj-$(CONFIG_NAND) += nand.o
|
||||
|
||||
hw-obj-$(CONFIG_M48T59) += m48t59.o
|
||||
hw-obj-$(CONFIG_ESCC) += escc.o
|
||||
|
||||
# PCI watchdog devices
|
||||
hw-obj-y += wdt_i6300esb.o
|
||||
|
||||
hw-obj-y += msix.o
|
||||
|
||||
# PCI network cards
|
||||
hw-obj-y += ne2000.o
|
||||
|
||||
hw-obj-$(CONFIG_SMC91C111) += smc91c111.o
|
||||
hw-obj-$(CONFIG_LAN9118) += lan9118.o
|
||||
|
||||
# SCSI layer
|
||||
hw-obj-y += lsi53c895a.o
|
||||
hw-obj-$(CONFIG_ESP) += esp.o
|
||||
|
||||
hw-obj-y += dma-helpers.o sysbus.o isa-bus.o
|
||||
hw-obj-$(CONFIG_QDEV_ADDR) += qdev-addr.o
|
||||
+14
-34
@@ -1,21 +1,17 @@
|
||||
# -*- Mode: makefile -*-
|
||||
|
||||
# This needs to be defined before rules.mak
|
||||
GENERATED_HEADERS = config-target.h
|
||||
|
||||
include ../config-host.mak
|
||||
include config-devices.mak
|
||||
include config-target.mak
|
||||
include $(SRC_PATH)/rules.mak
|
||||
ifneq ($(HWDIR),)
|
||||
include $(HWDIR)/config.mak
|
||||
endif
|
||||
|
||||
TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
|
||||
$(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
|
||||
VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
|
||||
QEMU_CFLAGS+= -I.. -I$(TARGET_PATH) -DNEED_CPU_H
|
||||
|
||||
include $(SRC_PATH)/Makefile.objs
|
||||
|
||||
ifdef CONFIG_USER_ONLY
|
||||
# user emulator name
|
||||
QEMU_PROG=qemu-$(TARGET_ARCH2)
|
||||
@@ -68,10 +64,10 @@ libobj-$(CONFIG_S390_DIS) += s390-dis.o
|
||||
libobj-$(CONFIG_SH4_DIS) += sh4-dis.o
|
||||
libobj-$(CONFIG_SPARC_DIS) += sparc-dis.o
|
||||
|
||||
$(libobj-y): $(GENERATED_HEADERS)
|
||||
|
||||
# libqemu
|
||||
|
||||
libqemu.a: $(libobj-y)
|
||||
|
||||
translate.o: translate.c cpu.h
|
||||
|
||||
translate-all.o: translate-all.c cpu.h
|
||||
@@ -91,8 +87,7 @@ signal.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
|
||||
|
||||
ifdef CONFIG_LINUX_USER
|
||||
|
||||
$(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR))
|
||||
|
||||
VPATH+=:$(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
|
||||
QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
|
||||
obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \
|
||||
elfload.o linuxload.o uaccess.o gdbstub.o
|
||||
@@ -111,10 +106,7 @@ obj-arm-y += arm-semi.o
|
||||
|
||||
obj-m68k-y += m68k-sim.o m68k-semi.o
|
||||
|
||||
$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
|
||||
|
||||
obj-y += $(addprefix ../libuser/, $(user-obj-y))
|
||||
obj-y += $(libobj-y)
|
||||
ARLIBS=../libuser/libuser.a libqemu.a
|
||||
|
||||
endif #CONFIG_LINUX_USER
|
||||
|
||||
@@ -123,8 +115,7 @@ endif #CONFIG_LINUX_USER
|
||||
|
||||
ifdef CONFIG_DARWIN_USER
|
||||
|
||||
$(call set-vpath, $(SRC_PATH)/darwin-user)
|
||||
|
||||
VPATH+=:$(SRC_PATH)/darwin-user
|
||||
QEMU_CFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
|
||||
|
||||
# Leave some space for the regular program loading zone
|
||||
@@ -137,10 +128,7 @@ obj-y = main.o commpage.o machload.o mmap.o signal.o syscall.o thunk.o \
|
||||
|
||||
obj-i386-y += ioport-user.o
|
||||
|
||||
$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
|
||||
|
||||
obj-y += $(addprefix ../libuser/, $(user-obj-y))
|
||||
obj-y += $(libobj-y)
|
||||
ARLIBS=../libuser/libuser.a libqemu.a
|
||||
|
||||
endif #CONFIG_DARWIN_USER
|
||||
|
||||
@@ -149,8 +137,7 @@ endif #CONFIG_DARWIN_USER
|
||||
|
||||
ifdef CONFIG_BSD_USER
|
||||
|
||||
$(call set-vpath, $(SRC_PATH)/bsd-user)
|
||||
|
||||
VPATH+=:$(SRC_PATH)/bsd-user
|
||||
QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH)
|
||||
|
||||
obj-y = main.o bsdload.o elfload.o mmap.o signal.o strace.o syscall.o \
|
||||
@@ -158,10 +145,7 @@ obj-y = main.o bsdload.o elfload.o mmap.o signal.o strace.o syscall.o \
|
||||
|
||||
obj-i386-y += ioport-user.o
|
||||
|
||||
$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
|
||||
|
||||
obj-y += $(addprefix ../libuser/, $(user-obj-y))
|
||||
obj-y += $(libobj-y)
|
||||
ARLIBS=../libuser/libuser.a libqemu.a
|
||||
|
||||
endif #CONFIG_BSD_USER
|
||||
|
||||
@@ -210,7 +194,7 @@ obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
|
||||
obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
|
||||
obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
|
||||
obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
|
||||
obj-i386-y += ne2000-isa.o debugcon.o multiboot.o
|
||||
obj-i386-y += ne2000-isa.o
|
||||
|
||||
# shared objects
|
||||
obj-ppc-y = ppc.o ide/core.o ide/qdev.o ide/isa.o ide/pci.o ide/macio.o
|
||||
@@ -319,21 +303,17 @@ vl.o: qemu-options.h
|
||||
|
||||
monitor.o: qemu-monitor.h
|
||||
|
||||
$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
|
||||
|
||||
obj-y += $(addprefix ../, $(common-obj-y))
|
||||
obj-y += $(libobj-y)
|
||||
obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))
|
||||
ARLIBS=../libqemu_common.a libqemu.a $(HWLIB)
|
||||
|
||||
endif # CONFIG_SOFTMMU
|
||||
|
||||
obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
|
||||
|
||||
$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)
|
||||
$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(ARLIBS)
|
||||
$(call LINK,$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y))
|
||||
|
||||
|
||||
gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/feature_to_c.sh
|
||||
gdbstub-xml.c: $(TARGET_XML_FILES) feature_to_c.sh
|
||||
$(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@")
|
||||
|
||||
qemu-options.h: $(SRC_PATH)/qemu-options.hx
|
||||
|
||||
+12
-3
@@ -6,16 +6,25 @@ include $(SRC_PATH)/rules.mak
|
||||
|
||||
.PHONY: all
|
||||
|
||||
$(call set-vpath, $(SRC_PATH))
|
||||
# Do not take %.o from $(SRC_PATH), only %.c and %.h
|
||||
# All %.o for user targets should be built with -fpie, when
|
||||
# configured with --enable-user-pie, so we don't want to
|
||||
# take %.o from $(SRC_PATH), since they built without -fpie
|
||||
vpath %.c %.h $(SRC_PATH)
|
||||
|
||||
QEMU_CFLAGS+=-I..
|
||||
|
||||
include $(SRC_PATH)/Makefile.objs
|
||||
obj-y =
|
||||
obj-y += envlist.o path.o
|
||||
obj-y += tcg-runtime.o host-utils.o
|
||||
obj-y += cutils.o cache-utils.o
|
||||
|
||||
all: $(user-obj-y)
|
||||
all: libuser.a
|
||||
# Dummy command so that make thinks it has done something
|
||||
@true
|
||||
|
||||
libuser.a: $(obj-y)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.d *.a *~
|
||||
|
||||
|
||||
@@ -113,7 +113,9 @@ void qemu_aio_flush(void)
|
||||
qemu_aio_wait();
|
||||
|
||||
QLIST_FOREACH(node, &aio_handlers, node) {
|
||||
ret |= node->io_flush(node->opaque);
|
||||
if (node->io_flush) {
|
||||
ret |= node->io_flush(node->opaque);
|
||||
}
|
||||
}
|
||||
} while (qemu_bh_poll() || ret > 0);
|
||||
}
|
||||
|
||||
+5
-1
@@ -213,6 +213,10 @@ static void alsa_poll_handler (void *opaque)
|
||||
|
||||
state = snd_pcm_state (hlp->handle);
|
||||
switch (state) {
|
||||
case SND_PCM_STATE_SETUP:
|
||||
alsa_recover (hlp->handle);
|
||||
break;
|
||||
|
||||
case SND_PCM_STATE_XRUN:
|
||||
alsa_recover (hlp->handle);
|
||||
break;
|
||||
@@ -665,7 +669,7 @@ static int alsa_open (int in, struct alsa_params_req *req,
|
||||
(obt->fmt != req->fmt ||
|
||||
obt->nchannels != req->nchannels ||
|
||||
obt->freq != req->freq)) {
|
||||
dolog ("Audio paramters for %s\n", typ);
|
||||
dolog ("Audio parameters for %s\n", typ);
|
||||
alsa_dump_info (req, obt);
|
||||
}
|
||||
|
||||
|
||||
+50
-29
@@ -38,6 +38,10 @@
|
||||
#define AUDIO_CAP "oss"
|
||||
#include "audio_int.h"
|
||||
|
||||
#if defined OSS_GETVERSION && defined SNDCTL_DSP_POLICY
|
||||
#define USE_DSP_POLICY
|
||||
#endif
|
||||
|
||||
typedef struct OSSVoiceOut {
|
||||
HWVoiceOut hw;
|
||||
void *pcm_buf;
|
||||
@@ -236,16 +240,39 @@ static void oss_dump_info (struct oss_params *req, struct oss_params *obt)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_DSP_POLICY
|
||||
static int oss_get_version (int fd, int *version, const char *typ)
|
||||
{
|
||||
if (ioctl (fd, OSS_GETVERSION, &version)) {
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
/*
|
||||
* Looks like atm (20100109) FreeBSD knows OSS_GETVERSION
|
||||
* since 7.x, but currently only on the mixer device (or in
|
||||
* the Linuxolator), and in the native version that part of
|
||||
* the code is in fact never reached so the ioctl fails anyway.
|
||||
* Until this is fixed, just check the errno and if its what
|
||||
* FreeBSD's sound drivers return atm assume they are new enough.
|
||||
*/
|
||||
if (errno == EINVAL) {
|
||||
*version = 0x040000;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
oss_logerr2 (errno, typ, "Failed to get OSS version\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int oss_open (int in, struct oss_params *req,
|
||||
struct oss_params *obt, int *pfd)
|
||||
{
|
||||
int fd;
|
||||
#ifdef OSS_GETVERSION
|
||||
int version;
|
||||
#endif
|
||||
int oflags = conf.exclusive ? O_EXCL : 0;
|
||||
audio_buf_info abinfo;
|
||||
int fmt, freq, nchannels;
|
||||
int setfragment = 1;
|
||||
const char *dspname = in ? conf.devpath_in : conf.devpath_out;
|
||||
const char *typ = in ? "ADC" : "DAC";
|
||||
|
||||
@@ -283,36 +310,30 @@ static int oss_open (int in, struct oss_params *req,
|
||||
goto err;
|
||||
}
|
||||
|
||||
#ifdef OSS_GETVERSION
|
||||
if (ioctl (fd, OSS_GETVERSION, &version)) {
|
||||
oss_logerr2 (errno, typ, "Failed to get OSS version\n");
|
||||
version = 0;
|
||||
}
|
||||
#ifdef USE_DSP_POLICY
|
||||
if (conf.policy >= 0) {
|
||||
int version;
|
||||
|
||||
if (conf.debug) {
|
||||
dolog ("OSS version = %#x\n", version);
|
||||
}
|
||||
#endif
|
||||
if (!oss_get_version (fd, &version, typ)) {
|
||||
if (conf.debug) {
|
||||
dolog ("OSS version = %#x\n", version);
|
||||
}
|
||||
|
||||
#ifdef SNDCTL_DSP_POLICY
|
||||
if (conf.policy >= 0
|
||||
#ifdef OSS_GETVERSION
|
||||
&& version >= 0x040000
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
int policy = conf.policy;
|
||||
if (ioctl (fd, SNDCTL_DSP_POLICY, &policy)) {
|
||||
oss_logerr2 (errno, typ, "Failed to set timing policy to %d\n",
|
||||
conf.policy);
|
||||
goto err;
|
||||
if (version >= 0x040000) {
|
||||
int policy = conf.policy;
|
||||
if (ioctl (fd, SNDCTL_DSP_POLICY, &policy)) {
|
||||
oss_logerr2 (errno, typ,
|
||||
"Failed to set timing policy to %d\n",
|
||||
conf.policy);
|
||||
goto err;
|
||||
}
|
||||
setfragment = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
||||
if (setfragment) {
|
||||
int mmmmssss = (req->nfrags << 16) | ctz32 (req->fragsize);
|
||||
if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &mmmmssss)) {
|
||||
oss_logerr2 (errno, typ, "Failed to set buffer length (%d, %d)\n",
|
||||
@@ -868,7 +889,7 @@ static struct audio_option oss_options[] = {
|
||||
.valp = &conf.exclusive,
|
||||
.descr = "Open device in exclusive mode (vmix wont work)"
|
||||
},
|
||||
#ifdef SNDCTL_DSP_POLICY
|
||||
#ifdef USE_DSP_POLICY
|
||||
{
|
||||
.name = "POLICY",
|
||||
.tag = AUD_OPT_INT,
|
||||
|
||||
@@ -396,8 +396,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
|
||||
if (is_protocol)
|
||||
snprintf(backing_filename, sizeof(backing_filename),
|
||||
"%s", filename);
|
||||
else if (!realpath(filename, backing_filename))
|
||||
return -errno;
|
||||
else
|
||||
realpath(filename, backing_filename);
|
||||
|
||||
bdrv_qcow2 = bdrv_find_format("qcow2");
|
||||
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
|
||||
@@ -452,6 +452,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
|
||||
(flags & (BDRV_O_CACHE_MASK|BDRV_O_NATIVE_AIO));
|
||||
else
|
||||
open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
|
||||
|
||||
bs->open_flags = open_flags;
|
||||
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv))
|
||||
ret = -ENOTSUP;
|
||||
else
|
||||
@@ -691,6 +693,7 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
||||
uint8_t tmp_buf[BDRV_SECTOR_SIZE];
|
||||
int len, nb_sectors, count;
|
||||
int64_t sector_num;
|
||||
int ret;
|
||||
|
||||
count = count1;
|
||||
/* first read to align to sector start */
|
||||
@@ -699,8 +702,8 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
||||
len = count;
|
||||
sector_num = offset >> BDRV_SECTOR_BITS;
|
||||
if (len > 0) {
|
||||
if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0)
|
||||
return -EIO;
|
||||
if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0)
|
||||
return ret;
|
||||
memcpy(buf, tmp_buf + (offset & (BDRV_SECTOR_SIZE - 1)), len);
|
||||
count -= len;
|
||||
if (count == 0)
|
||||
@@ -712,8 +715,8 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
||||
/* read the sectors "in place" */
|
||||
nb_sectors = count >> BDRV_SECTOR_BITS;
|
||||
if (nb_sectors > 0) {
|
||||
if (bdrv_read(bs, sector_num, buf, nb_sectors) < 0)
|
||||
return -EIO;
|
||||
if ((ret = bdrv_read(bs, sector_num, buf, nb_sectors)) < 0)
|
||||
return ret;
|
||||
sector_num += nb_sectors;
|
||||
len = nb_sectors << BDRV_SECTOR_BITS;
|
||||
buf += len;
|
||||
@@ -722,8 +725,8 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
||||
|
||||
/* add data from the last sector */
|
||||
if (count > 0) {
|
||||
if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0)
|
||||
return -EIO;
|
||||
if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0)
|
||||
return ret;
|
||||
memcpy(buf, tmp_buf, count);
|
||||
}
|
||||
return count1;
|
||||
@@ -735,6 +738,7 @@ int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
|
||||
uint8_t tmp_buf[BDRV_SECTOR_SIZE];
|
||||
int len, nb_sectors, count;
|
||||
int64_t sector_num;
|
||||
int ret;
|
||||
|
||||
count = count1;
|
||||
/* first write to align to sector start */
|
||||
@@ -743,11 +747,11 @@ int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
|
||||
len = count;
|
||||
sector_num = offset >> BDRV_SECTOR_BITS;
|
||||
if (len > 0) {
|
||||
if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0)
|
||||
return -EIO;
|
||||
if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0)
|
||||
return ret;
|
||||
memcpy(tmp_buf + (offset & (BDRV_SECTOR_SIZE - 1)), buf, len);
|
||||
if (bdrv_write(bs, sector_num, tmp_buf, 1) < 0)
|
||||
return -EIO;
|
||||
if ((ret = bdrv_write(bs, sector_num, tmp_buf, 1)) < 0)
|
||||
return ret;
|
||||
count -= len;
|
||||
if (count == 0)
|
||||
return count1;
|
||||
@@ -758,8 +762,8 @@ int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
|
||||
/* write the sectors "in place" */
|
||||
nb_sectors = count >> BDRV_SECTOR_BITS;
|
||||
if (nb_sectors > 0) {
|
||||
if (bdrv_write(bs, sector_num, buf, nb_sectors) < 0)
|
||||
return -EIO;
|
||||
if ((ret = bdrv_write(bs, sector_num, buf, nb_sectors)) < 0)
|
||||
return ret;
|
||||
sector_num += nb_sectors;
|
||||
len = nb_sectors << BDRV_SECTOR_BITS;
|
||||
buf += len;
|
||||
@@ -768,15 +772,52 @@ int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
|
||||
|
||||
/* add data from the last sector */
|
||||
if (count > 0) {
|
||||
if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0)
|
||||
return -EIO;
|
||||
if ((ret = bdrv_read(bs, sector_num, tmp_buf, 1)) < 0)
|
||||
return ret;
|
||||
memcpy(tmp_buf, buf, count);
|
||||
if (bdrv_write(bs, sector_num, tmp_buf, 1) < 0)
|
||||
return -EIO;
|
||||
if ((ret = bdrv_write(bs, sector_num, tmp_buf, 1)) < 0)
|
||||
return ret;
|
||||
}
|
||||
return count1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes to the file and ensures that no writes are reordered across this
|
||||
* request (acts as a barrier)
|
||||
*
|
||||
* Returns 0 on success, -errno in error cases.
|
||||
*/
|
||||
int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset,
|
||||
const void *buf, int count)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = bdrv_pwrite(bs, offset, buf, count);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* No flush needed for cache=writethrough, it uses O_DSYNC */
|
||||
if ((bs->open_flags & BDRV_O_CACHE_MASK) != 0) {
|
||||
bdrv_flush(bs);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes to the file and ensures that no writes are reordered across this
|
||||
* request (acts as a barrier)
|
||||
*
|
||||
* Returns 0 on success, -errno in error cases.
|
||||
*/
|
||||
int bdrv_write_sync(BlockDriverState *bs, int64_t sector_num,
|
||||
const uint8_t *buf, int nb_sectors)
|
||||
{
|
||||
return bdrv_pwrite_sync(bs, BDRV_SECTOR_SIZE * sector_num,
|
||||
buf, BDRV_SECTOR_SIZE * nb_sectors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate file to 'offset' bytes (needed only for file protocols)
|
||||
*/
|
||||
@@ -1606,8 +1647,11 @@ static void multiwrite_user_cb(MultiwriteCB *mcb)
|
||||
|
||||
for (i = 0; i < mcb->num_callbacks; i++) {
|
||||
mcb->callbacks[i].cb(mcb->callbacks[i].opaque, mcb->error);
|
||||
if (mcb->callbacks[i].free_qiov) {
|
||||
qemu_iovec_destroy(mcb->callbacks[i].free_qiov);
|
||||
}
|
||||
qemu_free(mcb->callbacks[i].free_qiov);
|
||||
qemu_free(mcb->callbacks[i].free_buf);
|
||||
qemu_vfree(mcb->callbacks[i].free_buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1615,23 +1659,32 @@ static void multiwrite_cb(void *opaque, int ret)
|
||||
{
|
||||
MultiwriteCB *mcb = opaque;
|
||||
|
||||
if (ret < 0) {
|
||||
if (ret < 0 && !mcb->error) {
|
||||
mcb->error = ret;
|
||||
multiwrite_user_cb(mcb);
|
||||
}
|
||||
|
||||
mcb->num_requests--;
|
||||
if (mcb->num_requests == 0) {
|
||||
if (mcb->error == 0) {
|
||||
multiwrite_user_cb(mcb);
|
||||
}
|
||||
multiwrite_user_cb(mcb);
|
||||
qemu_free(mcb);
|
||||
}
|
||||
}
|
||||
|
||||
static int multiwrite_req_compare(const void *a, const void *b)
|
||||
{
|
||||
return (((BlockRequest*) a)->sector - ((BlockRequest*) b)->sector);
|
||||
const BlockRequest *req1 = a, *req2 = b;
|
||||
|
||||
/*
|
||||
* Note that we can't simply subtract req2->sector from req1->sector
|
||||
* here as that could overflow the return value.
|
||||
*/
|
||||
if (req1->sector > req2->sector) {
|
||||
return 1;
|
||||
} else if (req1->sector < req2->sector) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1667,6 +1720,10 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,
|
||||
merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]);
|
||||
}
|
||||
|
||||
if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) {
|
||||
merge = 0;
|
||||
}
|
||||
|
||||
if (merge) {
|
||||
size_t size;
|
||||
QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));
|
||||
@@ -1690,7 +1747,7 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,
|
||||
// Add the second request
|
||||
qemu_iovec_concat(qiov, reqs[i].qiov, reqs[i].qiov->size);
|
||||
|
||||
reqs[outidx].nb_sectors += reqs[i].nb_sectors;
|
||||
reqs[outidx].nb_sectors = qiov->size >> 9;
|
||||
reqs[outidx].qiov = qiov;
|
||||
|
||||
mcb->callbacks[i].free_qiov = reqs[outidx].qiov;
|
||||
@@ -1742,8 +1799,29 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
|
||||
// Check for mergable requests
|
||||
num_reqs = multiwrite_merge(bs, reqs, num_reqs, mcb);
|
||||
|
||||
// Run the aio requests
|
||||
/*
|
||||
* Run the aio requests. As soon as one request can't be submitted
|
||||
* successfully, fail all requests that are not yet submitted (we must
|
||||
* return failure for all requests anyway)
|
||||
*
|
||||
* num_requests cannot be set to the right value immediately: If
|
||||
* bdrv_aio_writev fails for some request, num_requests would be too high
|
||||
* and therefore multiwrite_cb() would never recognize the multiwrite
|
||||
* request as completed. We also cannot use the loop variable i to set it
|
||||
* when the first request fails because the callback may already have been
|
||||
* called for previously submitted requests. Thus, num_requests must be
|
||||
* incremented for each request that is submitted.
|
||||
*
|
||||
* The problem that callbacks may be called early also means that we need
|
||||
* to take care that num_requests doesn't become 0 before all requests are
|
||||
* submitted - multiwrite_cb() would consider the multiwrite request
|
||||
* completed. A dummy request that is "completed" by a manual call to
|
||||
* multiwrite_cb() takes care of this.
|
||||
*/
|
||||
mcb->num_requests = 1;
|
||||
|
||||
for (i = 0; i < num_reqs; i++) {
|
||||
mcb->num_requests++;
|
||||
acb = bdrv_aio_writev(bs, reqs[i].sector, reqs[i].qiov,
|
||||
reqs[i].nb_sectors, multiwrite_cb, mcb);
|
||||
|
||||
@@ -1751,22 +1829,25 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
|
||||
// We can only fail the whole thing if no request has been
|
||||
// submitted yet. Otherwise we'll wait for the submitted AIOs to
|
||||
// complete and report the error in the callback.
|
||||
if (mcb->num_requests == 0) {
|
||||
reqs[i].error = EIO;
|
||||
if (i == 0) {
|
||||
goto fail;
|
||||
} else {
|
||||
mcb->error = EIO;
|
||||
multiwrite_cb(mcb, -EIO);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
mcb->num_requests++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Complete the dummy request */
|
||||
multiwrite_cb(mcb, 0);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
free(mcb);
|
||||
for (i = 0; i < mcb->num_callbacks; i++) {
|
||||
reqs[i].error = -EIO;
|
||||
}
|
||||
qemu_free(mcb);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,10 @@ int bdrv_pread(BlockDriverState *bs, int64_t offset,
|
||||
void *buf, int count);
|
||||
int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
|
||||
const void *buf, int count);
|
||||
int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset,
|
||||
const void *buf, int count);
|
||||
int bdrv_write_sync(BlockDriverState *bs, int64_t sector_num,
|
||||
const uint8_t *buf, int nb_sectors);
|
||||
int bdrv_truncate(BlockDriverState *bs, int64_t offset);
|
||||
int64_t bdrv_getlength(BlockDriverState *bs);
|
||||
void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
|
||||
|
||||
+4
-12
@@ -146,9 +146,7 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
|
||||
bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
|
||||
}
|
||||
|
||||
if (lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET) == (off_t)-1) {
|
||||
goto fail;
|
||||
}
|
||||
lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET);
|
||||
|
||||
s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
|
||||
s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
|
||||
@@ -199,13 +197,9 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
|
||||
// bitmap_offset, block_offset);
|
||||
|
||||
// read in bitmap for current extent
|
||||
if (lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET) ==
|
||||
(off_t)-1) {
|
||||
return -1;
|
||||
}
|
||||
lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET);
|
||||
|
||||
if (read(s->fd, &bitmap_entry, 1) != 1)
|
||||
return -1;
|
||||
read(s->fd, &bitmap_entry, 1);
|
||||
|
||||
if (!((bitmap_entry >> (extent_offset % 8)) & 1))
|
||||
{
|
||||
@@ -214,9 +208,7 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
|
||||
return -1; // not allocated
|
||||
}
|
||||
|
||||
if (lseek(s->fd, block_offset, SEEK_SET) == (off_t)-1) {
|
||||
return -1;
|
||||
}
|
||||
lseek(s->fd, block_offset, SEEK_SET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -309,7 +309,7 @@ static int curl_open(BlockDriverState *bs, const char *filename, int flags)
|
||||
|
||||
static int inited = 0;
|
||||
|
||||
file = strdup(filename);
|
||||
file = qemu_strdup(filename);
|
||||
s->readahead_size = READ_AHEAD_SIZE;
|
||||
|
||||
/* Parse a trailing ":readahead=#:" param, if present. */
|
||||
|
||||
+14
-14
@@ -90,24 +90,21 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
|
||||
|
||||
/* read offset of info blocks */
|
||||
if(lseek(s->fd,-0x1d8,SEEK_END)<0) {
|
||||
dmg_close:
|
||||
close(s->fd);
|
||||
/* open raw instead */
|
||||
bs->drv=bdrv_find_format("raw");
|
||||
return bs->drv->bdrv_open(bs, filename, flags);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
info_begin=read_off(s->fd);
|
||||
if(info_begin==0)
|
||||
goto dmg_close;
|
||||
goto fail;
|
||||
if(lseek(s->fd,info_begin,SEEK_SET)<0)
|
||||
goto dmg_close;
|
||||
goto fail;
|
||||
if(read_uint32(s->fd)!=0x100)
|
||||
goto dmg_close;
|
||||
goto fail;
|
||||
if((count = read_uint32(s->fd))==0)
|
||||
goto dmg_close;
|
||||
goto fail;
|
||||
info_end = info_begin+count;
|
||||
if(lseek(s->fd,0xf8,SEEK_CUR)<0)
|
||||
goto dmg_close;
|
||||
goto fail;
|
||||
|
||||
/* read offsets */
|
||||
last_in_offset = last_out_offset = 0;
|
||||
@@ -116,14 +113,14 @@ dmg_close:
|
||||
|
||||
count = read_uint32(s->fd);
|
||||
if(count==0)
|
||||
goto dmg_close;
|
||||
goto fail;
|
||||
type = read_uint32(s->fd);
|
||||
if(type!=0x6d697368 || count<244)
|
||||
lseek(s->fd,count-4,SEEK_CUR);
|
||||
else {
|
||||
int new_size, chunk_count;
|
||||
if(lseek(s->fd,200,SEEK_CUR)<0)
|
||||
goto dmg_close;
|
||||
goto fail;
|
||||
chunk_count = (count-204)/40;
|
||||
new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
|
||||
s->types = qemu_realloc(s->types, new_size/2);
|
||||
@@ -142,7 +139,7 @@ dmg_close:
|
||||
chunk_count--;
|
||||
i--;
|
||||
if(lseek(s->fd,36,SEEK_CUR)<0)
|
||||
goto dmg_close;
|
||||
goto fail;
|
||||
continue;
|
||||
}
|
||||
read_uint32(s->fd);
|
||||
@@ -163,11 +160,14 @@ dmg_close:
|
||||
s->compressed_chunk = qemu_malloc(max_compressed_size+1);
|
||||
s->uncompressed_chunk = qemu_malloc(512*max_sectors_per_chunk);
|
||||
if(inflateInit(&s->zstream) != Z_OK)
|
||||
goto dmg_close;
|
||||
goto fail;
|
||||
|
||||
s->current_chunk = s->n_chunks;
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
close(s->fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int is_sector_in_chunk(BDRVDMGState* s,
|
||||
|
||||
+10
-8
@@ -277,8 +277,9 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
|
||||
/* update the L1 entry */
|
||||
s->l1_table[l1_index] = l2_offset;
|
||||
tmp = cpu_to_be64(l2_offset);
|
||||
if (bdrv_pwrite(s->hd, s->l1_table_offset + l1_index * sizeof(tmp),
|
||||
&tmp, sizeof(tmp)) != sizeof(tmp))
|
||||
if (bdrv_pwrite_sync(s->hd,
|
||||
s->l1_table_offset + l1_index * sizeof(tmp),
|
||||
&tmp, sizeof(tmp)) < 0)
|
||||
return 0;
|
||||
new_l2_table = 1;
|
||||
}
|
||||
@@ -306,8 +307,8 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
|
||||
l2_table = s->l2_cache + (min_index << s->l2_bits);
|
||||
if (new_l2_table) {
|
||||
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
|
||||
if (bdrv_pwrite(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
|
||||
s->l2_size * sizeof(uint64_t))
|
||||
if (bdrv_pwrite_sync(s->hd, l2_offset, l2_table,
|
||||
s->l2_size * sizeof(uint64_t)) < 0)
|
||||
return 0;
|
||||
} else {
|
||||
if (bdrv_pread(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
|
||||
@@ -372,8 +373,8 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
|
||||
/* update L2 table */
|
||||
tmp = cpu_to_be64(cluster_offset);
|
||||
l2_table[l2_index] = tmp;
|
||||
if (bdrv_pwrite(s->hd,
|
||||
l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp))
|
||||
if (bdrv_pwrite_sync(s->hd, l2_offset + l2_index * sizeof(tmp),
|
||||
&tmp, sizeof(tmp)) < 0)
|
||||
return 0;
|
||||
}
|
||||
return cluster_offset;
|
||||
@@ -821,8 +822,9 @@ static int qcow_make_empty(BlockDriverState *bs)
|
||||
int ret;
|
||||
|
||||
memset(s->l1_table, 0, l1_length);
|
||||
if (bdrv_pwrite(s->hd, s->l1_table_offset, s->l1_table, l1_length) < 0)
|
||||
return -1;
|
||||
if (bdrv_pwrite_sync(s->hd, s->l1_table_offset, s->l1_table,
|
||||
l1_length) < 0)
|
||||
return -1;
|
||||
ret = bdrv_truncate(s->hd, s->l1_table_offset + l1_length);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
+107
-63
@@ -33,7 +33,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int new_l1_size, new_l1_size2, ret, i;
|
||||
uint64_t *new_l1_table;
|
||||
uint64_t new_l1_table_offset;
|
||||
int64_t new_l1_table_offset;
|
||||
uint8_t data[12];
|
||||
|
||||
new_l1_size = s->l1_size;
|
||||
@@ -55,11 +55,15 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
|
||||
|
||||
/* write new table (align to cluster) */
|
||||
new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2);
|
||||
if (new_l1_table_offset < 0) {
|
||||
qemu_free(new_l1_table);
|
||||
return new_l1_table_offset;
|
||||
}
|
||||
|
||||
for(i = 0; i < s->l1_size; i++)
|
||||
new_l1_table[i] = cpu_to_be64(new_l1_table[i]);
|
||||
ret = bdrv_pwrite(s->hd, new_l1_table_offset, new_l1_table, new_l1_size2);
|
||||
if (ret != new_l1_size2)
|
||||
ret = bdrv_pwrite_sync(s->hd, new_l1_table_offset, new_l1_table, new_l1_size2);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
for(i = 0; i < s->l1_size; i++)
|
||||
new_l1_table[i] = be64_to_cpu(new_l1_table[i]);
|
||||
@@ -67,9 +71,10 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
|
||||
/* set new table */
|
||||
cpu_to_be32w((uint32_t*)data, new_l1_size);
|
||||
cpu_to_be64w((uint64_t*)(data + 4), new_l1_table_offset);
|
||||
if (bdrv_pwrite(s->hd, offsetof(QCowHeader, l1_size), data,
|
||||
sizeof(data)) != sizeof(data))
|
||||
ret = bdrv_pwrite_sync(s->hd, offsetof(QCowHeader, l1_size), data,sizeof(data));
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
qemu_free(s->l1_table);
|
||||
qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
|
||||
s->l1_table_offset = new_l1_table_offset;
|
||||
@@ -77,8 +82,9 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
|
||||
s->l1_size = new_l1_size;
|
||||
return 0;
|
||||
fail:
|
||||
qemu_free(s->l1_table);
|
||||
return -EIO;
|
||||
qemu_free(new_l1_table);
|
||||
qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void qcow2_l2_cache_reset(BlockDriverState *bs)
|
||||
@@ -182,17 +188,17 @@ static int write_l1_entry(BDRVQcowState *s, int l1_index)
|
||||
{
|
||||
uint64_t buf[L1_ENTRIES_PER_SECTOR];
|
||||
int l1_start_index;
|
||||
int i;
|
||||
int i, ret;
|
||||
|
||||
l1_start_index = l1_index & ~(L1_ENTRIES_PER_SECTOR - 1);
|
||||
for (i = 0; i < L1_ENTRIES_PER_SECTOR; i++) {
|
||||
buf[i] = cpu_to_be64(s->l1_table[l1_start_index + i]);
|
||||
}
|
||||
|
||||
if (bdrv_pwrite(s->hd, s->l1_table_offset + 8 * l1_start_index,
|
||||
buf, sizeof(buf)) != sizeof(buf))
|
||||
{
|
||||
return -1;
|
||||
ret = bdrv_pwrite_sync(s->hd, s->l1_table_offset + 8 * l1_start_index,
|
||||
buf, sizeof(buf));
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -213,18 +219,16 @@ static uint64_t *l2_allocate(BlockDriverState *bs, int l1_index)
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int min_index;
|
||||
uint64_t old_l2_offset;
|
||||
uint64_t *l2_table, l2_offset;
|
||||
uint64_t *l2_table;
|
||||
int64_t l2_offset;
|
||||
int ret;
|
||||
|
||||
old_l2_offset = s->l1_table[l1_index];
|
||||
|
||||
/* allocate a new l2 entry */
|
||||
|
||||
l2_offset = qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_t));
|
||||
|
||||
/* update the L1 entry */
|
||||
|
||||
s->l1_table[l1_index] = l2_offset | QCOW_OFLAG_COPIED;
|
||||
if (write_l1_entry(s, l1_index) < 0) {
|
||||
if (l2_offset < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -241,13 +245,20 @@ static uint64_t *l2_allocate(BlockDriverState *bs, int l1_index)
|
||||
if (bdrv_pread(s->hd, old_l2_offset,
|
||||
l2_table, s->l2_size * sizeof(uint64_t)) !=
|
||||
s->l2_size * sizeof(uint64_t))
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
/* write the l2 table to the file */
|
||||
if (bdrv_pwrite(s->hd, l2_offset,
|
||||
l2_table, s->l2_size * sizeof(uint64_t)) !=
|
||||
s->l2_size * sizeof(uint64_t))
|
||||
return NULL;
|
||||
ret = bdrv_pwrite_sync(s->hd, l2_offset, l2_table,
|
||||
s->l2_size * sizeof(uint64_t));
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* update the L1 entry */
|
||||
s->l1_table[l1_index] = l2_offset | QCOW_OFLAG_COPIED;
|
||||
if (write_l1_entry(s, l1_index) < 0) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* update the l2 cache entry */
|
||||
|
||||
@@ -255,6 +266,11 @@ static uint64_t *l2_allocate(BlockDriverState *bs, int l1_index)
|
||||
s->l2_cache_counts[min_index] = 1;
|
||||
|
||||
return l2_table;
|
||||
|
||||
fail:
|
||||
s->l1_table[l1_index] = old_l2_offset;
|
||||
qcow2_l2_cache_reset(bs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size,
|
||||
@@ -370,8 +386,8 @@ static int copy_sectors(BlockDriverState *bs, uint64_t start_sect,
|
||||
s->cluster_data, n, 1,
|
||||
&s->aes_encrypt_key);
|
||||
}
|
||||
ret = bdrv_write(s->hd, (cluster_offset >> 9) + n_start,
|
||||
s->cluster_data, n);
|
||||
ret = bdrv_write_sync(s->hd, (cluster_offset >> 9) + n_start,
|
||||
s->cluster_data, n);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
return 0;
|
||||
@@ -479,8 +495,8 @@ out:
|
||||
* the l2 table offset in the qcow2 file and the cluster index
|
||||
* in the l2 table are given to the caller.
|
||||
*
|
||||
* Returns 0 on success, -errno in failure case
|
||||
*/
|
||||
|
||||
static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
|
||||
uint64_t **new_l2_table,
|
||||
uint64_t *new_l2_offset,
|
||||
@@ -496,8 +512,9 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
|
||||
l1_index = offset >> (s->l2_bits + s->cluster_bits);
|
||||
if (l1_index >= s->l1_size) {
|
||||
ret = qcow2_grow_l1_table(bs, l1_index + 1);
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
l2_offset = s->l1_table[l1_index];
|
||||
|
||||
@@ -507,14 +524,16 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
|
||||
/* load the l2 table in memory */
|
||||
l2_offset &= ~QCOW_OFLAG_COPIED;
|
||||
l2_table = l2_load(bs, l2_offset);
|
||||
if (l2_table == NULL)
|
||||
return 0;
|
||||
if (l2_table == NULL) {
|
||||
return -EIO;
|
||||
}
|
||||
} else {
|
||||
if (l2_offset)
|
||||
qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t));
|
||||
l2_table = l2_allocate(bs, l1_index);
|
||||
if (l2_table == NULL)
|
||||
return 0;
|
||||
if (l2_table == NULL) {
|
||||
return -EIO;
|
||||
}
|
||||
l2_offset = s->l1_table[l1_index] & ~QCOW_OFLAG_COPIED;
|
||||
}
|
||||
|
||||
@@ -526,7 +545,7 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
|
||||
*new_l2_offset = l2_offset;
|
||||
*new_l2_index = l2_index;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -548,12 +567,14 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int l2_index, ret;
|
||||
uint64_t l2_offset, *l2_table, cluster_offset;
|
||||
uint64_t l2_offset, *l2_table;
|
||||
int64_t cluster_offset;
|
||||
int nb_csectors;
|
||||
|
||||
ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index);
|
||||
if (ret == 0)
|
||||
if (ret < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cluster_offset = be64_to_cpu(l2_table[l2_index]);
|
||||
if (cluster_offset & QCOW_OFLAG_COPIED)
|
||||
@@ -563,6 +584,10 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
|
||||
qcow2_free_any_clusters(bs, cluster_offset, 1);
|
||||
|
||||
cluster_offset = qcow2_alloc_bytes(bs, compressed_size);
|
||||
if (cluster_offset < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
nb_csectors = ((cluster_offset + compressed_size - 1) >> 9) -
|
||||
(cluster_offset >> 9);
|
||||
|
||||
@@ -574,10 +599,10 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
|
||||
/* compressed clusters never have the copied flag */
|
||||
|
||||
l2_table[l2_index] = cpu_to_be64(cluster_offset);
|
||||
if (bdrv_pwrite(s->hd,
|
||||
if (bdrv_pwrite_sync(s->hd,
|
||||
l2_offset + l2_index * sizeof(uint64_t),
|
||||
l2_table + l2_index,
|
||||
sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
sizeof(uint64_t)) < 0)
|
||||
return 0;
|
||||
|
||||
return cluster_offset;
|
||||
@@ -595,22 +620,23 @@ static int write_l2_entries(BDRVQcowState *s, uint64_t *l2_table,
|
||||
int start_offset = (8 * l2_index) & ~511;
|
||||
int end_offset = (8 * (l2_index + num) + 511) & ~511;
|
||||
size_t len = end_offset - start_offset;
|
||||
int ret;
|
||||
|
||||
if (bdrv_pwrite(s->hd, l2_offset + start_offset, &l2_table[l2_start_index],
|
||||
len) != len)
|
||||
{
|
||||
return -1;
|
||||
ret = bdrv_pwrite_sync(s->hd, l2_offset + start_offset,
|
||||
&l2_table[l2_start_index], len);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
|
||||
QCowL2Meta *m)
|
||||
int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int i, j = 0, l2_index, ret;
|
||||
uint64_t *old_cluster, start_sect, l2_offset, *l2_table;
|
||||
uint64_t cluster_offset = m->cluster_offset;
|
||||
|
||||
if (m->nb_clusters == 0)
|
||||
return 0;
|
||||
@@ -633,10 +659,11 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = -EIO;
|
||||
/* update L2 table */
|
||||
if (!get_cluster_table(bs, m->offset, &l2_table, &l2_offset, &l2_index))
|
||||
ret = get_cluster_table(bs, m->offset, &l2_table, &l2_offset, &l2_index);
|
||||
if (ret < 0) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i = 0; i < m->nb_clusters; i++) {
|
||||
/* if two concurrent writes happen to the same unallocated cluster
|
||||
@@ -652,8 +679,9 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
|
||||
(i << s->cluster_bits)) | QCOW_OFLAG_COPIED);
|
||||
}
|
||||
|
||||
if (write_l2_entries(s, l2_table, l2_offset, l2_index, m->nb_clusters) < 0) {
|
||||
ret = -1;
|
||||
ret = write_l2_entries(s, l2_table, l2_offset, l2_index, m->nb_clusters);
|
||||
if (ret < 0) {
|
||||
qcow2_l2_cache_reset(bs);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -670,30 +698,36 @@ err:
|
||||
/*
|
||||
* alloc_cluster_offset
|
||||
*
|
||||
* For a given offset of the disk image, return cluster offset in
|
||||
* qcow2 file.
|
||||
*
|
||||
* For a given offset of the disk image, return cluster offset in qcow2 file.
|
||||
* If the offset is not found, allocate a new cluster.
|
||||
*
|
||||
* Return the cluster offset if successful,
|
||||
* Return 0, otherwise.
|
||||
* If the cluster was already allocated, m->nb_clusters is set to 0,
|
||||
* m->depends_on is set to NULL and the other fields in m are meaningless.
|
||||
*
|
||||
* If the cluster is newly allocated, m->nb_clusters is set to the number of
|
||||
* contiguous clusters that have been allocated. This may be 0 if the request
|
||||
* conflict with another write request in flight; in this case, m->depends_on
|
||||
* is set and the remaining fields of m are meaningless.
|
||||
*
|
||||
* If m->nb_clusters is non-zero, the other fields of m are valid and contain
|
||||
* information about the first allocated cluster.
|
||||
*
|
||||
* Return 0 on success and -errno in error cases
|
||||
*/
|
||||
|
||||
uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
|
||||
uint64_t offset,
|
||||
int n_start, int n_end,
|
||||
int *num, QCowL2Meta *m)
|
||||
int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
|
||||
int n_start, int n_end, int *num, QCowL2Meta *m)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int l2_index, ret;
|
||||
uint64_t l2_offset, *l2_table, cluster_offset;
|
||||
uint64_t l2_offset, *l2_table;
|
||||
int64_t cluster_offset;
|
||||
unsigned int nb_clusters, i = 0;
|
||||
QCowL2Meta *old_alloc;
|
||||
|
||||
ret = get_cluster_table(bs, offset, &l2_table, &l2_offset, &l2_index);
|
||||
if (ret == 0)
|
||||
return 0;
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
nb_clusters = size_to_clusters(s, n_end << 9);
|
||||
|
||||
@@ -709,6 +743,7 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
|
||||
|
||||
cluster_offset &= ~QCOW_OFLAG_COPIED;
|
||||
m->nb_clusters = 0;
|
||||
m->depends_on = NULL;
|
||||
|
||||
goto out;
|
||||
}
|
||||
@@ -723,12 +758,15 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
|
||||
while (i < nb_clusters) {
|
||||
i += count_contiguous_clusters(nb_clusters - i, s->cluster_size,
|
||||
&l2_table[l2_index], i, 0);
|
||||
|
||||
if(be64_to_cpu(l2_table[l2_index + i]))
|
||||
if ((i >= nb_clusters) || be64_to_cpu(l2_table[l2_index + i])) {
|
||||
break;
|
||||
}
|
||||
|
||||
i += count_contiguous_free_clusters(nb_clusters - i,
|
||||
&l2_table[l2_index + i]);
|
||||
if (i >= nb_clusters) {
|
||||
break;
|
||||
}
|
||||
|
||||
cluster_offset = be64_to_cpu(l2_table[l2_index + i]);
|
||||
|
||||
@@ -736,6 +774,7 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
|
||||
(cluster_offset & QCOW_OFLAG_COMPRESSED))
|
||||
break;
|
||||
}
|
||||
assert(i <= nb_clusters);
|
||||
nb_clusters = i;
|
||||
|
||||
/*
|
||||
@@ -779,6 +818,10 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
|
||||
/* allocate a new cluster */
|
||||
|
||||
cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size);
|
||||
if (cluster_offset < 0) {
|
||||
QLIST_REMOVE(m, next_in_flight);
|
||||
return cluster_offset;
|
||||
}
|
||||
|
||||
/* save info needed for meta data update */
|
||||
m->offset = offset;
|
||||
@@ -787,10 +830,11 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
|
||||
|
||||
out:
|
||||
m->nb_available = MIN(nb_clusters << (s->cluster_bits - 9), n_end);
|
||||
m->cluster_offset = cluster_offset;
|
||||
|
||||
*num = m->nb_available - n_start;
|
||||
|
||||
return cluster_offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
|
||||
|
||||
+319
-119
@@ -27,7 +27,7 @@
|
||||
#include "block/qcow2.h"
|
||||
|
||||
static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size);
|
||||
static int update_refcount(BlockDriverState *bs,
|
||||
static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
|
||||
int64_t offset, int64_t length,
|
||||
int addend);
|
||||
|
||||
@@ -42,8 +42,8 @@ static int write_refcount_block(BDRVQcowState *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bdrv_pwrite(s->hd, s->refcount_block_cache_offset,
|
||||
s->refcount_block_cache, size) != size)
|
||||
if (bdrv_pwrite_sync(s->hd, s->refcount_block_cache_offset,
|
||||
s->refcount_block_cache, size) < 0)
|
||||
{
|
||||
return -EIO;
|
||||
}
|
||||
@@ -123,121 +123,273 @@ static int get_refcount(BlockDriverState *bs, int64_t cluster_index)
|
||||
return be16_to_cpu(s->refcount_block_cache[block_index]);
|
||||
}
|
||||
|
||||
static int grow_refcount_table(BlockDriverState *bs, int min_size)
|
||||
/*
|
||||
* Rounds the refcount table size up to avoid growing the table for each single
|
||||
* refcount block that is allocated.
|
||||
*/
|
||||
static unsigned int next_refcount_table_size(BDRVQcowState *s,
|
||||
unsigned int min_size)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int new_table_size, new_table_size2, refcount_table_clusters, i, ret;
|
||||
uint64_t *new_table;
|
||||
int64_t table_offset;
|
||||
uint8_t data[12];
|
||||
int old_table_size;
|
||||
int64_t old_table_offset;
|
||||
unsigned int min_clusters = (min_size >> (s->cluster_bits - 3)) + 1;
|
||||
unsigned int refcount_table_clusters =
|
||||
MAX(1, s->refcount_table_size >> (s->cluster_bits - 3));
|
||||
|
||||
if (min_size <= s->refcount_table_size)
|
||||
return 0;
|
||||
/* compute new table size */
|
||||
refcount_table_clusters = s->refcount_table_size >> (s->cluster_bits - 3);
|
||||
for(;;) {
|
||||
if (refcount_table_clusters == 0) {
|
||||
refcount_table_clusters = 1;
|
||||
} else {
|
||||
refcount_table_clusters = (refcount_table_clusters * 3 + 1) / 2;
|
||||
}
|
||||
new_table_size = refcount_table_clusters << (s->cluster_bits - 3);
|
||||
if (min_size <= new_table_size)
|
||||
break;
|
||||
while (min_clusters > refcount_table_clusters) {
|
||||
refcount_table_clusters = (refcount_table_clusters * 3 + 1) / 2;
|
||||
}
|
||||
#ifdef DEBUG_ALLOC2
|
||||
printf("grow_refcount_table from %d to %d\n",
|
||||
s->refcount_table_size,
|
||||
new_table_size);
|
||||
#endif
|
||||
new_table_size2 = new_table_size * sizeof(uint64_t);
|
||||
new_table = qemu_mallocz(new_table_size2);
|
||||
memcpy(new_table, s->refcount_table,
|
||||
s->refcount_table_size * sizeof(uint64_t));
|
||||
for(i = 0; i < s->refcount_table_size; i++)
|
||||
cpu_to_be64s(&new_table[i]);
|
||||
/* Note: we cannot update the refcount now to avoid recursion */
|
||||
table_offset = alloc_clusters_noref(bs, new_table_size2);
|
||||
ret = bdrv_pwrite(s->hd, table_offset, new_table, new_table_size2);
|
||||
if (ret != new_table_size2)
|
||||
goto fail;
|
||||
for(i = 0; i < s->refcount_table_size; i++)
|
||||
be64_to_cpus(&new_table[i]);
|
||||
|
||||
cpu_to_be64w((uint64_t*)data, table_offset);
|
||||
cpu_to_be32w((uint32_t*)(data + 8), refcount_table_clusters);
|
||||
if (bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_offset),
|
||||
data, sizeof(data)) != sizeof(data))
|
||||
goto fail;
|
||||
qemu_free(s->refcount_table);
|
||||
old_table_offset = s->refcount_table_offset;
|
||||
old_table_size = s->refcount_table_size;
|
||||
s->refcount_table = new_table;
|
||||
s->refcount_table_size = new_table_size;
|
||||
s->refcount_table_offset = table_offset;
|
||||
|
||||
update_refcount(bs, table_offset, new_table_size2, 1);
|
||||
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
|
||||
return 0;
|
||||
fail:
|
||||
qemu_free(new_table);
|
||||
return -EIO;
|
||||
return refcount_table_clusters << (s->cluster_bits - 3);
|
||||
}
|
||||
|
||||
|
||||
/* Checks if two offsets are described by the same refcount block */
|
||||
static int in_same_refcount_block(BDRVQcowState *s, uint64_t offset_a,
|
||||
uint64_t offset_b)
|
||||
{
|
||||
uint64_t block_a = offset_a >> (2 * s->cluster_bits - REFCOUNT_SHIFT);
|
||||
uint64_t block_b = offset_b >> (2 * s->cluster_bits - REFCOUNT_SHIFT);
|
||||
|
||||
return (block_a == block_b);
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads a refcount block. If it doesn't exist yet, it is allocated first
|
||||
* (including growing the refcount table if needed).
|
||||
*
|
||||
* Returns the offset of the refcount block on success or -errno in error case
|
||||
*/
|
||||
static int64_t alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int64_t offset, refcount_block_offset;
|
||||
unsigned int refcount_table_index;
|
||||
int ret;
|
||||
uint64_t data64;
|
||||
int cache = cache_refcount_updates;
|
||||
|
||||
/* Find L1 index and grow refcount table if needed */
|
||||
/* Find the refcount block for the given cluster */
|
||||
refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
|
||||
if (refcount_table_index >= s->refcount_table_size) {
|
||||
ret = grow_refcount_table(bs, refcount_table_index + 1);
|
||||
if (ret < 0)
|
||||
|
||||
if (refcount_table_index < s->refcount_table_size) {
|
||||
|
||||
uint64_t refcount_block_offset =
|
||||
s->refcount_table[refcount_table_index];
|
||||
|
||||
/* If it's already there, we're done */
|
||||
if (refcount_block_offset) {
|
||||
if (refcount_block_offset != s->refcount_block_cache_offset) {
|
||||
ret = load_refcount_block(bs, refcount_block_offset);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return refcount_block_offset;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we came here, we need to allocate something. Something is at least
|
||||
* a cluster for the new refcount block. It may also include a new refcount
|
||||
* table if the old refcount table is too small.
|
||||
*
|
||||
* Note that allocating clusters here needs some special care:
|
||||
*
|
||||
* - We can't use the normal qcow2_alloc_clusters(), it would try to
|
||||
* increase the refcount and very likely we would end up with an endless
|
||||
* recursion. Instead we must place the refcount blocks in a way that
|
||||
* they can describe them themselves.
|
||||
*
|
||||
* - We need to consider that at this point we are inside update_refcounts
|
||||
* and doing the initial refcount increase. This means that some clusters
|
||||
* have already been allocated by the caller, but their refcount isn't
|
||||
* accurate yet. free_cluster_index tells us where this allocation ends
|
||||
* as long as we don't overwrite it by freeing clusters.
|
||||
*
|
||||
* - alloc_clusters_noref and qcow2_free_clusters may load a different
|
||||
* refcount block into the cache
|
||||
*/
|
||||
|
||||
if (cache_refcount_updates) {
|
||||
ret = write_refcount_block(s);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Load or allocate the refcount block */
|
||||
refcount_block_offset = s->refcount_table[refcount_table_index];
|
||||
if (!refcount_block_offset) {
|
||||
if (cache_refcount_updates) {
|
||||
write_refcount_block(s);
|
||||
cache_refcount_updates = 0;
|
||||
}
|
||||
/* create a new refcount block */
|
||||
/* Note: we cannot update the refcount now to avoid recursion */
|
||||
offset = alloc_clusters_noref(bs, s->cluster_size);
|
||||
/* Allocate the refcount block itself and mark it as used */
|
||||
uint64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
|
||||
|
||||
#ifdef DEBUG_ALLOC2
|
||||
fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
|
||||
" at %" PRIx64 "\n",
|
||||
refcount_table_index, cluster_index << s->cluster_bits, new_block);
|
||||
#endif
|
||||
|
||||
if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
|
||||
/* Zero the new refcount block before updating it */
|
||||
memset(s->refcount_block_cache, 0, s->cluster_size);
|
||||
ret = bdrv_pwrite(s->hd, offset, s->refcount_block_cache, s->cluster_size);
|
||||
if (ret != s->cluster_size)
|
||||
return -EINVAL;
|
||||
s->refcount_table[refcount_table_index] = offset;
|
||||
data64 = cpu_to_be64(offset);
|
||||
ret = bdrv_pwrite(s->hd, s->refcount_table_offset +
|
||||
refcount_table_index * sizeof(uint64_t),
|
||||
&data64, sizeof(data64));
|
||||
if (ret != sizeof(data64))
|
||||
return -EINVAL;
|
||||
s->refcount_block_cache_offset = new_block;
|
||||
|
||||
refcount_block_offset = offset;
|
||||
s->refcount_block_cache_offset = offset;
|
||||
update_refcount(bs, offset, s->cluster_size, 1);
|
||||
cache_refcount_updates = cache;
|
||||
/* The block describes itself, need to update the cache */
|
||||
int block_index = (new_block >> s->cluster_bits) &
|
||||
((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
|
||||
s->refcount_block_cache[block_index] = cpu_to_be16(1);
|
||||
} else {
|
||||
if (refcount_block_offset != s->refcount_block_cache_offset) {
|
||||
if (load_refcount_block(bs, refcount_block_offset) < 0)
|
||||
return -EIO;
|
||||
/* Described somewhere else. This can recurse at most twice before we
|
||||
* arrive at a block that describes itself. */
|
||||
ret = update_refcount(bs, new_block, s->cluster_size, 1);
|
||||
if (ret < 0) {
|
||||
goto fail_block;
|
||||
}
|
||||
|
||||
/* Initialize the new refcount block only after updating its refcount,
|
||||
* update_refcount uses the refcount cache itself */
|
||||
memset(s->refcount_block_cache, 0, s->cluster_size);
|
||||
s->refcount_block_cache_offset = new_block;
|
||||
}
|
||||
|
||||
return refcount_block_offset;
|
||||
/* Now the new refcount block needs to be written to disk */
|
||||
ret = bdrv_pwrite_sync(s->hd, new_block, s->refcount_block_cache,
|
||||
s->cluster_size);
|
||||
if (ret < 0) {
|
||||
goto fail_block;
|
||||
}
|
||||
|
||||
/* If the refcount table is big enough, just hook the block up there */
|
||||
if (refcount_table_index < s->refcount_table_size) {
|
||||
uint64_t data64 = cpu_to_be64(new_block);
|
||||
ret = bdrv_pwrite_sync(s->hd,
|
||||
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
|
||||
&data64, sizeof(data64));
|
||||
if (ret < 0) {
|
||||
goto fail_block;
|
||||
}
|
||||
|
||||
s->refcount_table[refcount_table_index] = new_block;
|
||||
return new_block;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we come here, we need to grow the refcount table. Again, a new
|
||||
* refcount table needs some space and we can't simply allocate to avoid
|
||||
* endless recursion.
|
||||
*
|
||||
* Therefore let's grab new refcount blocks at the end of the image, which
|
||||
* will describe themselves and the new refcount table. This way we can
|
||||
* reference them only in the new table and do the switch to the new
|
||||
* refcount table at once without producing an inconsistent state in
|
||||
* between.
|
||||
*/
|
||||
/* Calculate the number of refcount blocks needed so far */
|
||||
uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);
|
||||
uint64_t blocks_used = (s->free_cluster_index +
|
||||
refcount_block_clusters - 1) / refcount_block_clusters;
|
||||
|
||||
/* And now we need at least one block more for the new metadata */
|
||||
uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
|
||||
uint64_t last_table_size;
|
||||
uint64_t blocks_clusters;
|
||||
do {
|
||||
uint64_t table_clusters = size_to_clusters(s, table_size);
|
||||
blocks_clusters = 1 +
|
||||
((table_clusters + refcount_block_clusters - 1)
|
||||
/ refcount_block_clusters);
|
||||
uint64_t meta_clusters = table_clusters + blocks_clusters;
|
||||
|
||||
last_table_size = table_size;
|
||||
table_size = next_refcount_table_size(s, blocks_used +
|
||||
((meta_clusters + refcount_block_clusters - 1)
|
||||
/ refcount_block_clusters));
|
||||
|
||||
} while (last_table_size != table_size);
|
||||
|
||||
#ifdef DEBUG_ALLOC2
|
||||
fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
|
||||
s->refcount_table_size, table_size);
|
||||
#endif
|
||||
|
||||
/* Create the new refcount table and blocks */
|
||||
uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
|
||||
s->cluster_size;
|
||||
uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
|
||||
uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size);
|
||||
uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t));
|
||||
|
||||
assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
|
||||
|
||||
/* Fill the new refcount table */
|
||||
memcpy(new_table, s->refcount_table,
|
||||
s->refcount_table_size * sizeof(uint64_t));
|
||||
new_table[refcount_table_index] = new_block;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < blocks_clusters; i++) {
|
||||
new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
|
||||
}
|
||||
|
||||
/* Fill the refcount blocks */
|
||||
uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
|
||||
int block = 0;
|
||||
for (i = 0; i < table_clusters + blocks_clusters; i++) {
|
||||
new_blocks[block++] = cpu_to_be16(1);
|
||||
}
|
||||
|
||||
/* Write refcount blocks to disk */
|
||||
ret = bdrv_pwrite_sync(s->hd, meta_offset, new_blocks,
|
||||
blocks_clusters * s->cluster_size);
|
||||
qemu_free(new_blocks);
|
||||
if (ret < 0) {
|
||||
goto fail_table;
|
||||
}
|
||||
|
||||
/* Write refcount table to disk */
|
||||
for(i = 0; i < table_size; i++) {
|
||||
cpu_to_be64s(&new_table[i]);
|
||||
}
|
||||
|
||||
ret = bdrv_pwrite_sync(s->hd, table_offset, new_table,
|
||||
table_size * sizeof(uint64_t));
|
||||
if (ret < 0) {
|
||||
goto fail_table;
|
||||
}
|
||||
|
||||
for(i = 0; i < table_size; i++) {
|
||||
cpu_to_be64s(&new_table[i]);
|
||||
}
|
||||
|
||||
/* Hook up the new refcount table in the qcow2 header */
|
||||
uint8_t data[12];
|
||||
cpu_to_be64w((uint64_t*)data, table_offset);
|
||||
cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
|
||||
ret = bdrv_pwrite_sync(s->hd, offsetof(QCowHeader, refcount_table_offset),
|
||||
data, sizeof(data));
|
||||
if (ret < 0) {
|
||||
goto fail_table;
|
||||
}
|
||||
|
||||
/* And switch it in memory */
|
||||
uint64_t old_table_offset = s->refcount_table_offset;
|
||||
uint64_t old_table_size = s->refcount_table_size;
|
||||
|
||||
qemu_free(s->refcount_table);
|
||||
s->refcount_table = new_table;
|
||||
s->refcount_table_size = table_size;
|
||||
s->refcount_table_offset = table_offset;
|
||||
|
||||
/* Free old table. Remember, we must not change free_cluster_index */
|
||||
uint64_t old_free_cluster_index = s->free_cluster_index;
|
||||
qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
|
||||
s->free_cluster_index = old_free_cluster_index;
|
||||
|
||||
ret = load_refcount_block(bs, new_block);
|
||||
if (ret < 0) {
|
||||
goto fail_block;
|
||||
}
|
||||
|
||||
return new_block;
|
||||
|
||||
fail_table:
|
||||
qemu_free(new_table);
|
||||
fail_block:
|
||||
s->refcount_block_cache_offset = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define REFCOUNTS_PER_SECTOR (512 >> REFCOUNT_SHIFT)
|
||||
@@ -245,43 +397,52 @@ static int write_refcount_block_entries(BDRVQcowState *s,
|
||||
int64_t refcount_block_offset, int first_index, int last_index)
|
||||
{
|
||||
size_t size;
|
||||
int ret;
|
||||
|
||||
if (cache_refcount_updates) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (first_index < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
first_index &= ~(REFCOUNTS_PER_SECTOR - 1);
|
||||
last_index = (last_index + REFCOUNTS_PER_SECTOR)
|
||||
& ~(REFCOUNTS_PER_SECTOR - 1);
|
||||
|
||||
size = (last_index - first_index) << REFCOUNT_SHIFT;
|
||||
if (bdrv_pwrite(s->hd,
|
||||
ret = bdrv_pwrite_sync(s->hd,
|
||||
refcount_block_offset + (first_index << REFCOUNT_SHIFT),
|
||||
&s->refcount_block_cache[first_index], size) != size)
|
||||
{
|
||||
return -EIO;
|
||||
&s->refcount_block_cache[first_index], size);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXX: cache several refcount block clusters ? */
|
||||
static int update_refcount(BlockDriverState *bs,
|
||||
int64_t offset, int64_t length,
|
||||
int addend)
|
||||
static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
|
||||
int64_t offset, int64_t length, int addend)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int64_t start, last, cluster_offset;
|
||||
int64_t refcount_block_offset = 0;
|
||||
int64_t table_index = -1, old_table_index;
|
||||
int first_index = -1, last_index = -1;
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG_ALLOC2
|
||||
printf("update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n",
|
||||
offset, length, addend);
|
||||
#endif
|
||||
if (length <= 0)
|
||||
if (length < 0) {
|
||||
return -EINVAL;
|
||||
} else if (length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
start = offset & ~(s->cluster_size - 1);
|
||||
last = (offset + length - 1) & ~(s->cluster_size - 1);
|
||||
for(cluster_offset = start; cluster_offset <= last;
|
||||
@@ -289,6 +450,7 @@ static int update_refcount(BlockDriverState *bs,
|
||||
{
|
||||
int block_index, refcount;
|
||||
int64_t cluster_index = cluster_offset >> s->cluster_bits;
|
||||
int64_t new_block;
|
||||
|
||||
/* Only write refcount block to disk when we are done with it */
|
||||
old_table_index = table_index;
|
||||
@@ -306,10 +468,12 @@ static int update_refcount(BlockDriverState *bs,
|
||||
}
|
||||
|
||||
/* Load the refcount block and allocate it if needed */
|
||||
refcount_block_offset = alloc_refcount_block(bs, cluster_index);
|
||||
if (refcount_block_offset < 0) {
|
||||
return refcount_block_offset;
|
||||
new_block = alloc_refcount_block(bs, cluster_index);
|
||||
if (new_block < 0) {
|
||||
ret = new_block;
|
||||
goto fail;
|
||||
}
|
||||
refcount_block_offset = new_block;
|
||||
|
||||
/* we can update the count and save it */
|
||||
block_index = cluster_index &
|
||||
@@ -323,24 +487,38 @@ static int update_refcount(BlockDriverState *bs,
|
||||
|
||||
refcount = be16_to_cpu(s->refcount_block_cache[block_index]);
|
||||
refcount += addend;
|
||||
if (refcount < 0 || refcount > 0xffff)
|
||||
return -EINVAL;
|
||||
if (refcount < 0 || refcount > 0xffff) {
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
if (refcount == 0 && cluster_index < s->free_cluster_index) {
|
||||
s->free_cluster_index = cluster_index;
|
||||
}
|
||||
s->refcount_block_cache[block_index] = cpu_to_be16(refcount);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
fail:
|
||||
|
||||
/* Write last changed block to disk */
|
||||
if (refcount_block_offset != 0) {
|
||||
if (write_refcount_block_entries(s, refcount_block_offset,
|
||||
first_index, last_index) < 0)
|
||||
{
|
||||
return -EIO;
|
||||
return ret < 0 ? ret : -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
/*
|
||||
* Try do undo any updates if an error is returned (This may succeed in
|
||||
* some cases like ENOSPC for allocating a new refcount block)
|
||||
*/
|
||||
if (ret < 0) {
|
||||
int dummy;
|
||||
dummy = update_refcount(bs, offset, cluster_offset - offset, -addend);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* addend must be 1 or -1 */
|
||||
@@ -390,9 +568,13 @@ retry:
|
||||
int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size)
|
||||
{
|
||||
int64_t offset;
|
||||
int ret;
|
||||
|
||||
offset = alloc_clusters_noref(bs, size);
|
||||
update_refcount(bs, offset, size, 1);
|
||||
ret = update_refcount(bs, offset, size, 1);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
@@ -407,6 +589,9 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
|
||||
assert(size > 0 && size <= s->cluster_size);
|
||||
if (s->free_byte_offset == 0) {
|
||||
s->free_byte_offset = qcow2_alloc_clusters(bs, s->cluster_size);
|
||||
if (s->free_byte_offset < 0) {
|
||||
return s->free_byte_offset;
|
||||
}
|
||||
}
|
||||
redo:
|
||||
free_in_cluster = s->cluster_size -
|
||||
@@ -422,6 +607,9 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
|
||||
update_cluster_refcount(bs, offset >> s->cluster_bits, 1);
|
||||
} else {
|
||||
offset = qcow2_alloc_clusters(bs, s->cluster_size);
|
||||
if (offset < 0) {
|
||||
return offset;
|
||||
}
|
||||
cluster_offset = s->free_byte_offset & ~(s->cluster_size - 1);
|
||||
if ((cluster_offset + s->cluster_size) == offset) {
|
||||
/* we are lucky: contiguous data */
|
||||
@@ -439,7 +627,13 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
|
||||
void qcow2_free_clusters(BlockDriverState *bs,
|
||||
int64_t offset, int64_t size)
|
||||
{
|
||||
update_refcount(bs, offset, size, -1);
|
||||
int ret;
|
||||
|
||||
ret = update_refcount(bs, offset, size, -1);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "qcow2_free_clusters failed: %s\n", strerror(-ret));
|
||||
/* TODO Remember the clusters to free them later and avoid leaking */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -549,9 +743,15 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
|
||||
if (offset & QCOW_OFLAG_COMPRESSED) {
|
||||
nb_csectors = ((offset >> s->csize_shift) &
|
||||
s->csize_mask) + 1;
|
||||
if (addend != 0)
|
||||
update_refcount(bs, (offset & s->cluster_offset_mask) & ~511,
|
||||
nb_csectors * 512, addend);
|
||||
if (addend != 0) {
|
||||
int ret;
|
||||
ret = update_refcount(bs,
|
||||
(offset & s->cluster_offset_mask) & ~511,
|
||||
nb_csectors * 512, addend);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
/* compressed clusters are never modified */
|
||||
refcount = 2;
|
||||
} else {
|
||||
@@ -572,8 +772,8 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
|
||||
}
|
||||
}
|
||||
if (l2_modified) {
|
||||
if (bdrv_pwrite(s->hd,
|
||||
l2_offset, l2_table, l2_size) != l2_size)
|
||||
if (bdrv_pwrite_sync(s->hd,
|
||||
l2_offset, l2_table, l2_size) < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -594,8 +794,8 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
|
||||
if (l1_modified) {
|
||||
for(i = 0; i < l1_size; i++)
|
||||
cpu_to_be64s(&l1_table[i]);
|
||||
if (bdrv_pwrite(s->hd, l1_table_offset, l1_table,
|
||||
l1_size2) != l1_size2)
|
||||
if (bdrv_pwrite_sync(s->hd, l1_table_offset, l1_table,
|
||||
l1_size2) < 0)
|
||||
goto fail;
|
||||
for(i = 0; i < l1_size; i++)
|
||||
be64_to_cpus(&l1_table[i]);
|
||||
|
||||
+21
-13
@@ -139,6 +139,9 @@ static int qcow_write_snapshots(BlockDriverState *bs)
|
||||
|
||||
snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size);
|
||||
offset = snapshots_offset;
|
||||
if (offset < 0) {
|
||||
return offset;
|
||||
}
|
||||
|
||||
for(i = 0; i < s->nb_snapshots; i++) {
|
||||
sn = s->snapshots + i;
|
||||
@@ -155,25 +158,25 @@ static int qcow_write_snapshots(BlockDriverState *bs)
|
||||
h.id_str_size = cpu_to_be16(id_str_size);
|
||||
h.name_size = cpu_to_be16(name_size);
|
||||
offset = align_offset(offset, 8);
|
||||
if (bdrv_pwrite(s->hd, offset, &h, sizeof(h)) != sizeof(h))
|
||||
if (bdrv_pwrite_sync(s->hd, offset, &h, sizeof(h)) < 0)
|
||||
goto fail;
|
||||
offset += sizeof(h);
|
||||
if (bdrv_pwrite(s->hd, offset, sn->id_str, id_str_size) != id_str_size)
|
||||
if (bdrv_pwrite_sync(s->hd, offset, sn->id_str, id_str_size) < 0)
|
||||
goto fail;
|
||||
offset += id_str_size;
|
||||
if (bdrv_pwrite(s->hd, offset, sn->name, name_size) != name_size)
|
||||
if (bdrv_pwrite_sync(s->hd, offset, sn->name, name_size) < 0)
|
||||
goto fail;
|
||||
offset += name_size;
|
||||
}
|
||||
|
||||
/* update the various header fields */
|
||||
data64 = cpu_to_be64(snapshots_offset);
|
||||
if (bdrv_pwrite(s->hd, offsetof(QCowHeader, snapshots_offset),
|
||||
&data64, sizeof(data64)) != sizeof(data64))
|
||||
if (bdrv_pwrite_sync(s->hd, offsetof(QCowHeader, snapshots_offset),
|
||||
&data64, sizeof(data64)) < 0)
|
||||
goto fail;
|
||||
data32 = cpu_to_be32(s->nb_snapshots);
|
||||
if (bdrv_pwrite(s->hd, offsetof(QCowHeader, nb_snapshots),
|
||||
&data32, sizeof(data32)) != sizeof(data32))
|
||||
if (bdrv_pwrite_sync(s->hd, offsetof(QCowHeader, nb_snapshots),
|
||||
&data32, sizeof(data32)) < 0)
|
||||
goto fail;
|
||||
|
||||
/* free the old snapshot table */
|
||||
@@ -235,6 +238,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
|
||||
QCowSnapshot *snapshots1, sn1, *sn = &sn1;
|
||||
int i, ret;
|
||||
uint64_t *l1_table = NULL;
|
||||
int64_t l1_table_offset;
|
||||
|
||||
memset(sn, 0, sizeof(*sn));
|
||||
|
||||
@@ -263,7 +267,12 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
|
||||
goto fail;
|
||||
|
||||
/* create the L1 table of the snapshot */
|
||||
sn->l1_table_offset = qcow2_alloc_clusters(bs, s->l1_size * sizeof(uint64_t));
|
||||
l1_table_offset = qcow2_alloc_clusters(bs, s->l1_size * sizeof(uint64_t));
|
||||
if (l1_table_offset < 0) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sn->l1_table_offset = l1_table_offset;
|
||||
sn->l1_size = s->l1_size;
|
||||
|
||||
if (s->l1_size != 0) {
|
||||
@@ -275,9 +284,8 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
|
||||
for(i = 0; i < s->l1_size; i++) {
|
||||
l1_table[i] = cpu_to_be64(s->l1_table[i]);
|
||||
}
|
||||
if (bdrv_pwrite(s->hd, sn->l1_table_offset,
|
||||
l1_table, s->l1_size * sizeof(uint64_t)) !=
|
||||
(s->l1_size * sizeof(uint64_t)))
|
||||
if (bdrv_pwrite_sync(s->hd, sn->l1_table_offset,
|
||||
l1_table, s->l1_size * sizeof(uint64_t)) < 0)
|
||||
goto fail;
|
||||
qemu_free(l1_table);
|
||||
l1_table = NULL;
|
||||
@@ -326,8 +334,8 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
|
||||
if (bdrv_pread(s->hd, sn->l1_table_offset,
|
||||
s->l1_table, l1_size2) != l1_size2)
|
||||
goto fail;
|
||||
if (bdrv_pwrite(s->hd, s->l1_table_offset,
|
||||
s->l1_table, l1_size2) != l1_size2)
|
||||
if (bdrv_pwrite_sync(s->hd, s->l1_table_offset,
|
||||
s->l1_table, l1_size2) < 0)
|
||||
goto fail;
|
||||
for(i = 0;i < s->l1_size; i++) {
|
||||
be64_to_cpus(&s->l1_table[i]);
|
||||
|
||||
+65
-31
@@ -467,8 +467,10 @@ static void qcow_aio_read_cb(void *opaque, int ret)
|
||||
acb->hd_aiocb = bdrv_aio_readv(s->hd,
|
||||
(acb->cluster_offset >> 9) + index_in_cluster,
|
||||
&acb->hd_qiov, acb->n, qcow_aio_read_cb, acb);
|
||||
if (acb->hd_aiocb == NULL)
|
||||
if (acb->hd_aiocb == NULL) {
|
||||
ret = -EIO;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -561,7 +563,7 @@ static void qcow_aio_write_cb(void *opaque, int ret)
|
||||
acb->hd_aiocb = NULL;
|
||||
|
||||
if (ret >= 0) {
|
||||
ret = qcow2_alloc_cluster_link_l2(bs, acb->cluster_offset, &acb->l2meta);
|
||||
ret = qcow2_alloc_cluster_link_l2(bs, &acb->l2meta);
|
||||
}
|
||||
|
||||
run_dependent_requests(&acb->l2meta);
|
||||
@@ -585,21 +587,23 @@ static void qcow_aio_write_cb(void *opaque, int ret)
|
||||
n_end > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors)
|
||||
n_end = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors;
|
||||
|
||||
acb->cluster_offset = qcow2_alloc_cluster_offset(bs, acb->sector_num << 9,
|
||||
index_in_cluster,
|
||||
n_end, &acb->n, &acb->l2meta);
|
||||
ret = qcow2_alloc_cluster_offset(bs, acb->sector_num << 9,
|
||||
index_in_cluster, n_end, &acb->n, &acb->l2meta);
|
||||
if (ret < 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
acb->cluster_offset = acb->l2meta.cluster_offset;
|
||||
|
||||
/* Need to wait for another request? If so, we are done for now. */
|
||||
if (!acb->cluster_offset && acb->l2meta.depends_on != NULL) {
|
||||
if (acb->l2meta.nb_clusters == 0 && acb->l2meta.depends_on != NULL) {
|
||||
QLIST_INSERT_HEAD(&acb->l2meta.depends_on->dependent_requests,
|
||||
acb, next_depend);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!acb->cluster_offset || (acb->cluster_offset & 511) != 0) {
|
||||
ret = -EIO;
|
||||
goto done;
|
||||
}
|
||||
assert((acb->cluster_offset & 511) == 0);
|
||||
|
||||
if (s->crypt_method) {
|
||||
if (!acb->cluster_data) {
|
||||
acb->cluster_data = qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS *
|
||||
@@ -618,11 +622,17 @@ static void qcow_aio_write_cb(void *opaque, int ret)
|
||||
(acb->cluster_offset >> 9) + index_in_cluster,
|
||||
&acb->hd_qiov, acb->n,
|
||||
qcow_aio_write_cb, acb);
|
||||
if (acb->hd_aiocb == NULL)
|
||||
goto done;
|
||||
if (acb->hd_aiocb == NULL) {
|
||||
ret = -EIO;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
if (acb->l2meta.nb_clusters != 0) {
|
||||
QLIST_REMOVE(&acb->l2meta, next_in_flight);
|
||||
}
|
||||
done:
|
||||
if (acb->qiov->niov > 1)
|
||||
qemu_vfree(acb->orig_buf);
|
||||
@@ -683,27 +693,27 @@ static int get_bits_from_size(size_t size)
|
||||
static int preallocate(BlockDriverState *bs)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
uint64_t cluster_offset = 0;
|
||||
uint64_t nb_sectors;
|
||||
uint64_t offset;
|
||||
int num;
|
||||
int ret;
|
||||
QCowL2Meta meta;
|
||||
|
||||
nb_sectors = bdrv_getlength(bs) >> 9;
|
||||
offset = 0;
|
||||
QLIST_INIT(&meta.dependent_requests);
|
||||
meta.cluster_offset = 0;
|
||||
|
||||
while (nb_sectors) {
|
||||
num = MIN(nb_sectors, INT_MAX >> 9);
|
||||
cluster_offset = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num,
|
||||
&meta);
|
||||
ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &meta);
|
||||
|
||||
if (cluster_offset == 0) {
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qcow2_alloc_cluster_link_l2(bs, cluster_offset, &meta) < 0) {
|
||||
qcow2_free_any_clusters(bs, cluster_offset, meta.nb_clusters);
|
||||
if (qcow2_alloc_cluster_link_l2(bs, &meta) < 0) {
|
||||
qcow2_free_any_clusters(bs, meta.cluster_offset, meta.nb_clusters);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -722,10 +732,10 @@ static int preallocate(BlockDriverState *bs)
|
||||
* all of the allocated clusters (otherwise we get failing reads after
|
||||
* EOF). Extend the image to the last allocated sector.
|
||||
*/
|
||||
if (cluster_offset != 0) {
|
||||
if (meta.cluster_offset != 0) {
|
||||
uint8_t buf[512];
|
||||
memset(buf, 0, 512);
|
||||
bdrv_write(s->hd, (cluster_offset >> 9) + num - 1, buf, 1);
|
||||
bdrv_write(s->hd, (meta.cluster_offset >> 9) + num - 1, buf, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -737,10 +747,11 @@ static int qcow_create2(const char *filename, int64_t total_size,
|
||||
{
|
||||
|
||||
int fd, header_size, backing_filename_len, l1_size, i, shift, l2_bits;
|
||||
int ref_clusters, backing_format_len = 0;
|
||||
int ref_clusters, reftable_clusters, backing_format_len = 0;
|
||||
int rounded_ext_bf_len = 0;
|
||||
QCowHeader header;
|
||||
uint64_t tmp, offset;
|
||||
uint64_t old_ref_clusters;
|
||||
QCowCreateState s1, *s = &s1;
|
||||
QCowExtension ext_bf = {0, 0};
|
||||
|
||||
@@ -799,17 +810,37 @@ static int qcow_create2(const char *filename, int64_t total_size,
|
||||
header.l1_size = cpu_to_be32(l1_size);
|
||||
offset += align_offset(l1_size * sizeof(uint64_t), s->cluster_size);
|
||||
|
||||
s->refcount_table = qemu_mallocz(s->cluster_size);
|
||||
/* count how many refcount blocks needed */
|
||||
|
||||
#define NUM_CLUSTERS(bytes) \
|
||||
(((bytes) + (s->cluster_size) - 1) / (s->cluster_size))
|
||||
|
||||
ref_clusters = NUM_CLUSTERS(NUM_CLUSTERS(offset) * sizeof(uint16_t));
|
||||
|
||||
do {
|
||||
uint64_t image_clusters;
|
||||
old_ref_clusters = ref_clusters;
|
||||
|
||||
/* Number of clusters used for the refcount table */
|
||||
reftable_clusters = NUM_CLUSTERS(ref_clusters * sizeof(uint64_t));
|
||||
|
||||
/* Number of clusters that the whole image will have */
|
||||
image_clusters = NUM_CLUSTERS(offset) + ref_clusters
|
||||
+ reftable_clusters;
|
||||
|
||||
/* Number of refcount blocks needed for the image */
|
||||
ref_clusters = NUM_CLUSTERS(image_clusters * sizeof(uint16_t));
|
||||
|
||||
} while (ref_clusters != old_ref_clusters);
|
||||
|
||||
s->refcount_table = qemu_mallocz(reftable_clusters * s->cluster_size);
|
||||
|
||||
s->refcount_table_offset = offset;
|
||||
header.refcount_table_offset = cpu_to_be64(offset);
|
||||
header.refcount_table_clusters = cpu_to_be32(1);
|
||||
offset += s->cluster_size;
|
||||
header.refcount_table_clusters = cpu_to_be32(reftable_clusters);
|
||||
offset += (reftable_clusters * s->cluster_size);
|
||||
s->refcount_block_offset = offset;
|
||||
|
||||
/* count how many refcount blocks needed */
|
||||
tmp = offset >> s->cluster_bits;
|
||||
ref_clusters = (tmp >> (s->cluster_bits - REFCOUNT_SHIFT)) + 1;
|
||||
for (i=0; i < ref_clusters; i++) {
|
||||
s->refcount_table[i] = cpu_to_be64(offset);
|
||||
offset += s->cluster_size;
|
||||
@@ -821,7 +852,8 @@ static int qcow_create2(const char *filename, int64_t total_size,
|
||||
qcow2_create_refcount_update(s, 0, header_size);
|
||||
qcow2_create_refcount_update(s, s->l1_table_offset,
|
||||
l1_size * sizeof(uint64_t));
|
||||
qcow2_create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
|
||||
qcow2_create_refcount_update(s, s->refcount_table_offset,
|
||||
reftable_clusters * s->cluster_size);
|
||||
qcow2_create_refcount_update(s, s->refcount_block_offset,
|
||||
ref_clusters * s->cluster_size);
|
||||
|
||||
@@ -849,7 +881,8 @@ static int qcow_create2(const char *filename, int64_t total_size,
|
||||
write(fd, &tmp, sizeof(tmp));
|
||||
}
|
||||
lseek(fd, s->refcount_table_offset, SEEK_SET);
|
||||
write(fd, s->refcount_table, s->cluster_size);
|
||||
write(fd, s->refcount_table,
|
||||
reftable_clusters * s->cluster_size);
|
||||
|
||||
lseek(fd, s->refcount_block_offset, SEEK_SET);
|
||||
write(fd, s->refcount_block, ref_clusters * s->cluster_size);
|
||||
@@ -1056,12 +1089,13 @@ static int qcow_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int growable = bs->growable;
|
||||
int ret;
|
||||
|
||||
bs->growable = 1;
|
||||
bdrv_pwrite(bs, qcow_vm_state_offset(s) + pos, buf, size);
|
||||
ret = bdrv_pwrite(bs, qcow_vm_state_offset(s) + pos, buf, size);
|
||||
bs->growable = growable;
|
||||
|
||||
return size;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int qcow_load_vmstate(BlockDriverState *bs, uint8_t *buf,
|
||||
|
||||
+4
-6
@@ -135,6 +135,7 @@ struct QCowAIOCB;
|
||||
typedef struct QCowL2Meta
|
||||
{
|
||||
uint64_t offset;
|
||||
uint64_t cluster_offset;
|
||||
int n_start;
|
||||
int nb_available;
|
||||
int nb_clusters;
|
||||
@@ -191,16 +192,13 @@ void qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
|
||||
|
||||
uint64_t qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
|
||||
int *num);
|
||||
uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
|
||||
uint64_t offset,
|
||||
int n_start, int n_end,
|
||||
int *num, QCowL2Meta *m);
|
||||
int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
|
||||
int n_start, int n_end, int *num, QCowL2Meta *m);
|
||||
uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
|
||||
uint64_t offset,
|
||||
int compressed_size);
|
||||
|
||||
int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
|
||||
QCowL2Meta *m);
|
||||
int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m);
|
||||
|
||||
/* qcow2-snapshot.c functions */
|
||||
int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info);
|
||||
|
||||
+1
-1
@@ -595,7 +595,7 @@ static void raw_close(BlockDriverState *bs)
|
||||
close(s->fd);
|
||||
s->fd = -1;
|
||||
if (s->aligned_buf != NULL)
|
||||
qemu_free(s->aligned_buf);
|
||||
qemu_vfree(s->aligned_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-7
@@ -399,6 +399,15 @@ static int vdi_open(BlockDriverState *bs, const char *filename, int flags)
|
||||
vdi_header_print(&header);
|
||||
#endif
|
||||
|
||||
if (header.disk_size % SECTOR_SIZE != 0) {
|
||||
/* 'VBoxManage convertfromraw' can create images with odd disk sizes.
|
||||
We accept them but round the disk size to the next multiple of
|
||||
SECTOR_SIZE. */
|
||||
logout("odd disk size %" PRIu64 " B, round up\n", header.disk_size);
|
||||
header.disk_size += SECTOR_SIZE - 1;
|
||||
header.disk_size &= ~(SECTOR_SIZE - 1);
|
||||
}
|
||||
|
||||
if (header.version != VDI_VERSION_1_1) {
|
||||
logout("unsupported version %u.%u\n",
|
||||
header.version >> 16, header.version & 0xffff);
|
||||
@@ -411,18 +420,15 @@ static int vdi_open(BlockDriverState *bs, const char *filename, int flags)
|
||||
/* We only support data blocks which start on a sector boundary. */
|
||||
logout("unsupported data offset 0x%x B\n", header.offset_data);
|
||||
goto fail;
|
||||
} else if (header.disk_size % SECTOR_SIZE != 0) {
|
||||
logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
|
||||
goto fail;
|
||||
} else if (header.sector_size != SECTOR_SIZE) {
|
||||
logout("unsupported sector size %u B\n", header.sector_size);
|
||||
goto fail;
|
||||
} else if (header.block_size != 1 * MiB) {
|
||||
logout("unsupported block size %u B\n", header.block_size);
|
||||
goto fail;
|
||||
} else if ((header.disk_size + header.block_size - 1) / header.block_size !=
|
||||
(uint64_t)header.blocks_in_image) {
|
||||
logout("unexpected block number %u B\n", header.blocks_in_image);
|
||||
} else if (header.disk_size >
|
||||
(uint64_t)header.blocks_in_image * header.block_size) {
|
||||
logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
|
||||
goto fail;
|
||||
} else if (!uuid_is_null(header.uuid_link)) {
|
||||
logout("link uuid != 0, unsupported\n");
|
||||
@@ -834,7 +840,10 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
blocks = bytes / block_size;
|
||||
/* We need enough blocks to store the given disk size,
|
||||
so always round up. */
|
||||
blocks = (bytes + block_size - 1) / block_size;
|
||||
|
||||
bmap_size = blocks * sizeof(uint32_t);
|
||||
bmap_size = ((bmap_size + SECTOR_SIZE - 1) & ~(SECTOR_SIZE -1));
|
||||
|
||||
|
||||
+17
-30
@@ -87,14 +87,6 @@ typedef struct VmdkMetaData {
|
||||
int valid;
|
||||
} VmdkMetaData;
|
||||
|
||||
typedef struct ActiveBDRVState{
|
||||
BlockDriverState *hd; // active image handler
|
||||
uint64_t cluster_offset; // current write offset
|
||||
}ActiveBDRVState;
|
||||
|
||||
static ActiveBDRVState activeBDRV;
|
||||
|
||||
|
||||
static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
|
||||
{
|
||||
uint32_t magic;
|
||||
@@ -161,7 +153,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
|
||||
pstrcat(desc, sizeof(desc), tmp_desc);
|
||||
}
|
||||
|
||||
if (bdrv_pwrite(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE)
|
||||
if (bdrv_pwrite_sync(s->hd, 0x200, desc, DESC_SIZE) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
@@ -285,7 +277,6 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)
|
||||
goto fail_rgd;
|
||||
if (write(snp_fd, rgd_buf, gd_size) == -1)
|
||||
goto fail_rgd;
|
||||
qemu_free(rgd_buf);
|
||||
|
||||
/* write GD */
|
||||
gd_buf = qemu_malloc(gd_size);
|
||||
@@ -298,6 +289,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)
|
||||
if (write(snp_fd, gd_buf, gd_size) == -1)
|
||||
goto fail_gd;
|
||||
qemu_free(gd_buf);
|
||||
qemu_free(rgd_buf);
|
||||
|
||||
close(p_fd);
|
||||
close(snp_fd);
|
||||
@@ -458,30 +450,28 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, VmdkMetaData *m_data,
|
||||
static int get_whole_cluster(BlockDriverState *bs, uint64_t cluster_offset,
|
||||
uint64_t offset, int allocate)
|
||||
{
|
||||
uint64_t parent_cluster_offset;
|
||||
BDRVVmdkState *s = bs->opaque;
|
||||
uint8_t whole_grain[s->cluster_sectors*512]; // 128 sectors * 512 bytes each = grain size 64KB
|
||||
|
||||
// we will be here if it's first write on non-exist grain(cluster).
|
||||
// try to read from parent image, if exist
|
||||
if (bs->backing_hd) {
|
||||
BDRVVmdkState *ps = bs->backing_hd->opaque;
|
||||
int ret;
|
||||
|
||||
if (!vmdk_is_cid_valid(bs))
|
||||
return -1;
|
||||
|
||||
parent_cluster_offset = get_cluster_offset(bs->backing_hd, NULL,
|
||||
offset, allocate);
|
||||
ret = bdrv_read(bs->backing_hd, offset >> 9, whole_grain,
|
||||
s->cluster_sectors);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (parent_cluster_offset) {
|
||||
BDRVVmdkState *act_s = activeBDRV.hd->opaque;
|
||||
|
||||
if (bdrv_pread(ps->hd, parent_cluster_offset, whole_grain, ps->cluster_sectors*512) != ps->cluster_sectors*512)
|
||||
return -1;
|
||||
|
||||
//Write grain only into the active image
|
||||
if (bdrv_pwrite(act_s->hd, activeBDRV.cluster_offset << 9, whole_grain, sizeof(whole_grain)) != sizeof(whole_grain))
|
||||
return -1;
|
||||
//Write grain only into the active image
|
||||
ret = bdrv_write(s->hd, cluster_offset, whole_grain,
|
||||
s->cluster_sectors);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -492,14 +482,14 @@ static int vmdk_L2update(BlockDriverState *bs, VmdkMetaData *m_data)
|
||||
BDRVVmdkState *s = bs->opaque;
|
||||
|
||||
/* update L2 table */
|
||||
if (bdrv_pwrite(s->hd, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
|
||||
&(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))
|
||||
if (bdrv_pwrite_sync(s->hd, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
|
||||
&(m_data->offset), sizeof(m_data->offset)) < 0)
|
||||
return -1;
|
||||
/* update backup L2 table */
|
||||
if (s->l1_backup_table_offset != 0) {
|
||||
m_data->l2_offset = s->l1_backup_table[m_data->l1_index];
|
||||
if (bdrv_pwrite(s->hd, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
|
||||
&(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))
|
||||
if (bdrv_pwrite_sync(s->hd, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
|
||||
&(m_data->offset), sizeof(m_data->offset)) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -567,9 +557,6 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, VmdkMetaData *m_data,
|
||||
cluster_offset >>= 9;
|
||||
tmp = cpu_to_le32(cluster_offset);
|
||||
l2_table[l2_index] = tmp;
|
||||
// Save the active image state
|
||||
activeBDRV.cluster_offset = cluster_offset;
|
||||
activeBDRV.hd = bs;
|
||||
}
|
||||
/* First of all we write grain itself, to avoid race condition
|
||||
* that may to corrupt the image.
|
||||
|
||||
+17
-13
@@ -266,7 +266,7 @@ static inline int64_t get_sector_offset(BlockDriverState *bs,
|
||||
|
||||
s->last_bitmap_offset = bitmap_offset;
|
||||
memset(bitmap, 0xff, s->bitmap_size);
|
||||
bdrv_pwrite(s->hd, bitmap_offset, bitmap, s->bitmap_size);
|
||||
bdrv_pwrite_sync(s->hd, bitmap_offset, bitmap, s->bitmap_size);
|
||||
}
|
||||
|
||||
// printf("sector: %" PRIx64 ", index: %x, offset: %x, bioff: %" PRIx64 ", bloff: %" PRIx64 "\n",
|
||||
@@ -316,7 +316,7 @@ static int rewrite_footer(BlockDriverState* bs)
|
||||
BDRVVPCState *s = bs->opaque;
|
||||
int64_t offset = s->free_data_block_offset;
|
||||
|
||||
ret = bdrv_pwrite(s->hd, offset, s->footer_buf, HEADER_SIZE);
|
||||
ret = bdrv_pwrite_sync(s->hd, offset, s->footer_buf, HEADER_SIZE);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -351,7 +351,8 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num)
|
||||
|
||||
// Initialize the block's bitmap
|
||||
memset(bitmap, 0xff, s->bitmap_size);
|
||||
bdrv_pwrite(s->hd, s->free_data_block_offset, bitmap, s->bitmap_size);
|
||||
bdrv_pwrite_sync(s->hd, s->free_data_block_offset, bitmap,
|
||||
s->bitmap_size);
|
||||
|
||||
// Write new footer (the old one will be overwritten)
|
||||
s->free_data_block_offset += s->block_size + s->bitmap_size;
|
||||
@@ -362,7 +363,7 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num)
|
||||
// Write BAT entry to disk
|
||||
bat_offset = s->bat_offset + (4 * index);
|
||||
bat_value = be32_to_cpu(s->pagetable[index]);
|
||||
ret = bdrv_pwrite(s->hd, bat_offset, &bat_value, 4);
|
||||
ret = bdrv_pwrite_sync(s->hd, bat_offset, &bat_value, 4);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
@@ -470,9 +471,7 @@ static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
|
||||
}
|
||||
}
|
||||
|
||||
// Note: Rounding up deviates from the Virtual PC behaviour
|
||||
// However, we need this to avoid truncating images in qemu-img convert
|
||||
*cyls = (cyls_times_heads + *heads - 1) / *heads;
|
||||
*cyls = cyls_times_heads / *heads;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -484,9 +483,9 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options)
|
||||
struct vhd_dyndisk_header* dyndisk_header =
|
||||
(struct vhd_dyndisk_header*) buf;
|
||||
int fd, i;
|
||||
uint16_t cyls;
|
||||
uint8_t heads;
|
||||
uint8_t secs_per_cyl;
|
||||
uint16_t cyls = 0;
|
||||
uint8_t heads = 0;
|
||||
uint8_t secs_per_cyl = 0;
|
||||
size_t block_size, num_bat_entries;
|
||||
int64_t total_sectors = 0;
|
||||
|
||||
@@ -503,9 +502,14 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options)
|
||||
if (fd < 0)
|
||||
return -EIO;
|
||||
|
||||
// Calculate matching total_size and geometry
|
||||
if (calculate_geometry(total_sectors, &cyls, &heads, &secs_per_cyl))
|
||||
return -EFBIG;
|
||||
/* Calculate matching total_size and geometry. Increase the number of
|
||||
sectors requested until we get enough (or fail). */
|
||||
for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) {
|
||||
if (calculate_geometry(total_sectors + i,
|
||||
&cyls, &heads, &secs_per_cyl)) {
|
||||
return -EFBIG;
|
||||
}
|
||||
}
|
||||
total_sectors = (int64_t) cyls * heads * secs_per_cyl;
|
||||
|
||||
// Prepare the Hard Disk Footer
|
||||
|
||||
+12
-7
@@ -868,7 +868,8 @@ static int init_directories(BDRVVVFATState* s,
|
||||
{
|
||||
direntry_t* entry=array_get_next(&(s->directory));
|
||||
entry->attributes=0x28; /* archive | volume label */
|
||||
snprintf((char*)entry->name,11,"QEMU VVFAT");
|
||||
memcpy(entry->name,"QEMU VVF",8);
|
||||
memcpy(entry->extension,"AT ",3);
|
||||
}
|
||||
|
||||
/* Now build FAT, and write back information into directory */
|
||||
@@ -882,7 +883,7 @@ static int init_directories(BDRVVVFATState* s,
|
||||
mapping->dir_index = 0;
|
||||
mapping->info.dir.parent_mapping_index = -1;
|
||||
mapping->first_mapping_index = -1;
|
||||
mapping->path = strdup(dirname);
|
||||
mapping->path = qemu_strdup(dirname);
|
||||
i = strlen(mapping->path);
|
||||
if (i > 0 && mapping->path[i - 1] == '/')
|
||||
mapping->path[i - 1] = '\0';
|
||||
@@ -1632,10 +1633,10 @@ static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s,
|
||||
|
||||
/* rename */
|
||||
if (strcmp(basename, basename2))
|
||||
schedule_rename(s, cluster_num, strdup(path));
|
||||
schedule_rename(s, cluster_num, qemu_strdup(path));
|
||||
} else if (is_file(direntry))
|
||||
/* new file */
|
||||
schedule_new_file(s, strdup(path), cluster_num);
|
||||
schedule_new_file(s, qemu_strdup(path), cluster_num);
|
||||
else {
|
||||
assert(0);
|
||||
return 0;
|
||||
@@ -1752,10 +1753,10 @@ static int check_directory_consistency(BDRVVVFATState *s,
|
||||
mapping->mode &= ~MODE_DELETED;
|
||||
|
||||
if (strcmp(basename, basename2))
|
||||
schedule_rename(s, cluster_num, strdup(path));
|
||||
schedule_rename(s, cluster_num, qemu_strdup(path));
|
||||
} else
|
||||
/* new directory */
|
||||
schedule_mkdir(s, cluster_num, strdup(path));
|
||||
schedule_mkdir(s, cluster_num, qemu_strdup(path));
|
||||
|
||||
lfn_init(&lfn);
|
||||
do {
|
||||
@@ -2256,7 +2257,11 @@ static int commit_one_file(BDRVVVFATState* s,
|
||||
c = c1;
|
||||
}
|
||||
|
||||
ftruncate(fd, size);
|
||||
if (ftruncate(fd, size)) {
|
||||
perror("ftruncate()");
|
||||
close(fd);
|
||||
return -4;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return commit_mappings(s, first_cluster, dir_index);
|
||||
|
||||
@@ -127,6 +127,7 @@ struct BlockDriverState {
|
||||
int64_t total_sectors; /* if we are reading a disk image, give its
|
||||
size in sectors */
|
||||
int read_only; /* if true, the media is read only */
|
||||
int open_flags; /* flags used to open the file, re-used for re-open */
|
||||
int removable; /* if true, the media can be removed */
|
||||
int locked; /* if true, the media cannot temporarily be ejected */
|
||||
int encrypted; /* if true, the media is encrypted */
|
||||
|
||||
@@ -28,13 +28,6 @@
|
||||
#include "console.h"
|
||||
#include "sysemu.h"
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_4
|
||||
#define MAC_OS_X_VERSION_10_4 1040
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_5
|
||||
#define MAC_OS_X_VERSION_10_5 1050
|
||||
#endif
|
||||
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
@@ -236,7 +229,7 @@ int keymap[] =
|
||||
*/
|
||||
};
|
||||
|
||||
static int cocoa_keycode_to_qemu(int keycode)
|
||||
int cocoa_keycode_to_qemu(int keycode)
|
||||
{
|
||||
if((sizeof(keymap)/sizeof(int)) <= keycode)
|
||||
{
|
||||
@@ -305,11 +298,6 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) drawRect:(NSRect) rect
|
||||
{
|
||||
COCOA_DEBUG("QemuCocoaView: drawRect\n");
|
||||
@@ -327,7 +315,7 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
screen.bitsPerComponent, //bitsPerComponent
|
||||
screen.bitsPerPixel, //bitsPerPixel
|
||||
(screen.width * (screen.bitsPerComponent/2)), //bytesPerRow
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
#if __LITTLE_ENDIAN__
|
||||
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), //colorspace for OS X >= 10.4
|
||||
kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst,
|
||||
#else
|
||||
@@ -339,7 +327,7 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
0, //interpolate
|
||||
kCGRenderingIntentDefault //intent
|
||||
);
|
||||
// test if host supports "CGImageCreateWithImageInRect" at compile time
|
||||
// test if host support "CGImageCreateWithImageInRect" at compiletime
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
|
||||
if (CGImageCreateWithImageInRect == NULL) { // test if "CGImageCreateWithImageInRect" is supported on host at runtime
|
||||
#endif
|
||||
@@ -349,11 +337,7 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
} else {
|
||||
// selective drawing code (draws only dirty rectangles) (OS X >= 10.4)
|
||||
const NSRect *rectList;
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
NSInteger rectCount;
|
||||
#else
|
||||
int rectCount;
|
||||
#endif
|
||||
int i;
|
||||
CGImageRef clipImageRef;
|
||||
CGRect clipRect;
|
||||
@@ -419,7 +403,7 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
} else {
|
||||
if (qemu_name)
|
||||
[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]];
|
||||
[normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO];
|
||||
[normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:YES];
|
||||
}
|
||||
screen.width = w;
|
||||
screen.height = h;
|
||||
@@ -436,8 +420,8 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
isFullscreen = FALSE;
|
||||
[self ungrabMouse];
|
||||
[self setContentDimensions];
|
||||
// test if host supports "exitFullScreenModeWithOptions" at compile time
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
// test if host support "enterFullScreenMode:withOptions" at compiletime
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
|
||||
if ([NSView respondsToSelector:@selector(exitFullScreenModeWithOptions:)]) { // test if "exitFullScreenModeWithOptions" is supported on host at runtime
|
||||
[self exitFullScreenModeWithOptions:nil];
|
||||
} else {
|
||||
@@ -446,15 +430,15 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
[normalWindow setContentView: self];
|
||||
[normalWindow makeKeyAndOrderFront: self];
|
||||
[NSMenu setMenuBarVisible:YES];
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
|
||||
}
|
||||
#endif
|
||||
} else { // switch from desktop to fullscreen
|
||||
isFullscreen = TRUE;
|
||||
[self grabMouse];
|
||||
[self setContentDimensions];
|
||||
// test if host supports "enterFullScreenMode:withOptions" at compile time
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
// test if host support "enterFullScreenMode:withOptions" at compiletime
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
|
||||
if ([NSView respondsToSelector:@selector(enterFullScreenMode:withOptions:)]) { // test if "enterFullScreenMode:withOptions" is supported on host at runtime
|
||||
[self enterFullScreenMode:[NSScreen mainScreen] withOptions:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:NO], NSFullScreenModeAllScreens,
|
||||
@@ -470,7 +454,7 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
[fullScreenWindow setHasShadow:NO];
|
||||
[fullScreenWindow setContentView:self];
|
||||
[fullScreenWindow makeKeyAndOrderFront:self];
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -740,7 +724,6 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
[normalWindow setAcceptsMouseMovedEvents:YES];
|
||||
[normalWindow setTitle:[NSString stringWithFormat:@"QEMU"]];
|
||||
[normalWindow setContentView:cocoaView];
|
||||
[normalWindow useOptimizedDrawing:YES];
|
||||
[normalWindow makeKeyAndOrderFront:self];
|
||||
[normalWindow center];
|
||||
|
||||
@@ -784,11 +767,6 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)startEmulationWithArgc:(int)argc argv:(char**)argv
|
||||
{
|
||||
COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");
|
||||
@@ -805,7 +783,7 @@ static int cocoa_keycode_to_qemu(int keycode)
|
||||
if(returnCode == NSCancelButton) {
|
||||
exit(0);
|
||||
} else if(returnCode == NSOKButton) {
|
||||
const char *bin = "qemu";
|
||||
char *bin = "qemu";
|
||||
char *img = (char*)[ [ sheet filename ] cStringUsingEncoding:NSASCIIStringEncoding];
|
||||
|
||||
char **argv = (char**)malloc( sizeof(char*)*3 );
|
||||
@@ -861,16 +839,6 @@ int main (int argc, const char * argv[]) {
|
||||
gArgc = argc;
|
||||
gArgv = (char **)argv;
|
||||
CPSProcessSerNum PSN;
|
||||
int i;
|
||||
|
||||
/* In case we don't need to display a window, let's not do that */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "-vnc") ||
|
||||
!strcmp(argv[i], "-nographic") ||
|
||||
!strcmp(argv[i], "-curses")) {
|
||||
return qemu_main(gArgc, gArgv);
|
||||
}
|
||||
}
|
||||
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
[NSApplication sharedApplication];
|
||||
@@ -954,7 +922,7 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h)
|
||||
w * [cocoaView cdx],
|
||||
h * [cocoaView cdy]);
|
||||
}
|
||||
[cocoaView setNeedsDisplayInRect:rect];
|
||||
[cocoaView displayRect:rect];
|
||||
}
|
||||
|
||||
static void cocoa_resize(DisplayState *ds)
|
||||
|
||||
@@ -1707,6 +1707,37 @@ elif compile_prog "" "-lrt" ; then
|
||||
LIBS="-lrt $LIBS"
|
||||
fi
|
||||
|
||||
# Determine what linker flags to use to force archive inclusion
|
||||
check_linker_flags()
|
||||
{
|
||||
w2=
|
||||
if test "$2" ; then
|
||||
w2=-Wl,$2
|
||||
fi
|
||||
compile_prog "" "-Wl,$1 ${w2}"
|
||||
}
|
||||
|
||||
cat > $TMPC << EOF
|
||||
int main(void) { }
|
||||
EOF
|
||||
if check_linker_flags --whole-archive --no-whole-archive ; then
|
||||
# GNU ld
|
||||
arlibs_begin="-Wl,--whole-archive"
|
||||
arlibs_end="-Wl,--no-whole-archive"
|
||||
elif check_linker_flags -z,allextract -z,defaultextract ; then
|
||||
# Solaris ld
|
||||
arlibs_begin="-Wl,-z,allextract"
|
||||
arlibs_end="-Wl,-z,defaultextract"
|
||||
elif check_linker_flags -all_load ; then
|
||||
# Mac OS X
|
||||
arlibs_begin="-all_load"
|
||||
arlibs_end=""
|
||||
else
|
||||
echo "Error: your linker does not support --whole-archive or -z."
|
||||
echo "Please report to [email protected]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
|
||||
"$aix" != "yes" ; then
|
||||
libs_softmmu="-lutil $libs_softmmu"
|
||||
@@ -1991,6 +2022,9 @@ qemu_version=`head $source_path/VERSION`
|
||||
echo "VERSION=$qemu_version" >>$config_host_mak
|
||||
echo "PKGVERSION=$pkgversion" >>$config_host_mak
|
||||
echo "SRC_PATH=$source_path" >> $config_host_mak
|
||||
if [ "$source_path_used" = "yes" ]; then
|
||||
echo "VPATH=$source_path" >> $config_host_mak
|
||||
fi
|
||||
echo "TARGET_DIRS=$target_list" >> $config_host_mak
|
||||
if [ "$docs" = "yes" ] ; then
|
||||
echo "BUILD_DOCS=yes" >> $config_host_mak
|
||||
@@ -2107,7 +2141,7 @@ esac
|
||||
tools=
|
||||
if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
|
||||
tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
|
||||
if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
|
||||
if [ "$linux" = "yes" ] ; then
|
||||
tools="qemu-nbd\$(EXESUF) $tools"
|
||||
if [ "$check_utests" = "yes" ]; then
|
||||
tools="check-qint check-qstring check-qdict check-qlist $tools"
|
||||
@@ -2393,7 +2427,7 @@ fi
|
||||
if test "$target_softmmu" = "yes" ; then
|
||||
echo "CONFIG_SOFTMMU=y" >> $config_target_mak
|
||||
echo "LIBS+=$libs_softmmu" >> $config_target_mak
|
||||
echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
|
||||
echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_target_mak
|
||||
echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
|
||||
fi
|
||||
if test "$target_user_only" = "yes" ; then
|
||||
@@ -2414,7 +2448,7 @@ if test ! -z "$gdb_xml_files" ; then
|
||||
fi
|
||||
|
||||
case "$target_arch2" in
|
||||
alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
|
||||
arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
|
||||
echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
|
||||
;;
|
||||
*)
|
||||
@@ -2610,6 +2644,7 @@ for hwlib in 32 64; do
|
||||
mkdir -p $d
|
||||
rm -f $d/Makefile
|
||||
ln -s $source_path/Makefile.hw $d/Makefile
|
||||
echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
|
||||
echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
|
||||
done
|
||||
|
||||
|
||||
+7
-5
@@ -232,11 +232,13 @@ int cpu_exec(CPUState *env1)
|
||||
|
||||
env_to_regs();
|
||||
#if defined(TARGET_I386)
|
||||
/* put eflags in CPU temporary format */
|
||||
CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
|
||||
DF = 1 - (2 * ((env->eflags >> 10) & 1));
|
||||
CC_OP = CC_OP_EFLAGS;
|
||||
env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
|
||||
if (!kvm_enabled()) {
|
||||
/* put eflags in CPU temporary format */
|
||||
CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
|
||||
DF = 1 - (2 * ((env->eflags >> 10) & 1));
|
||||
CC_OP = CC_OP_EFLAGS;
|
||||
env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
|
||||
}
|
||||
#elif defined(TARGET_SPARC)
|
||||
#elif defined(TARGET_M68K)
|
||||
env->cc_op = CC_OP_FLAGS;
|
||||
|
||||
+6
-6
@@ -82,9 +82,9 @@ static inline uint64_t cpu_ppc_get_tb (CPUState *env)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t cpu_ppc_load_tbl (CPUState *env)
|
||||
uint32_t cpu_ppc_load_tbl (CPUState *env)
|
||||
{
|
||||
return cpu_ppc_get_tb(env);
|
||||
return cpu_ppc_get_tb(env) & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
uint32_t cpu_ppc_load_tbu (CPUState *env)
|
||||
@@ -92,9 +92,9 @@ uint32_t cpu_ppc_load_tbu (CPUState *env)
|
||||
return cpu_ppc_get_tb(env) >> 32;
|
||||
}
|
||||
|
||||
uint64_t cpu_ppc_load_atbl (CPUState *env)
|
||||
uint32_t cpu_ppc_load_atbl (CPUState *env)
|
||||
{
|
||||
return cpu_ppc_get_tb(env);
|
||||
return cpu_ppc_get_tb(env) & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
uint32_t cpu_ppc_load_atbu (CPUState *env)
|
||||
@@ -113,12 +113,12 @@ uint32_t cpu_ppc601_load_rtcl (CPUState *env)
|
||||
}
|
||||
|
||||
/* XXX: to be fixed */
|
||||
int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp)
|
||||
int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, target_ulong *valp)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val)
|
||||
int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
|
||||
CONFIG_USB_OHCI=y
|
||||
CONFIG_PTIMER=y
|
||||
CONFIG_ISA_MMIO=y
|
||||
@@ -2,3 +2,4 @@
|
||||
|
||||
CONFIG_USB_OHCI=y
|
||||
CONFIG_PTIMER=y
|
||||
CONFIG_ISA_MMIO=y
|
||||
+3
-3
@@ -69,9 +69,9 @@ extern int printf(const char *, ...);
|
||||
#define AREG1 "r14"
|
||||
#define AREG2 "r15"
|
||||
#elif defined(__mips__)
|
||||
#define AREG0 "fp"
|
||||
#define AREG1 "s0"
|
||||
#define AREG2 "s1"
|
||||
#define AREG0 "s0"
|
||||
#define AREG1 "s1"
|
||||
#define AREG2 "fp"
|
||||
#elif defined(__sparc__)
|
||||
#ifdef CONFIG_SOLARIS
|
||||
#define AREG0 "g2"
|
||||
|
||||
@@ -192,11 +192,7 @@ static int io_mem_watch;
|
||||
#endif
|
||||
|
||||
/* log support */
|
||||
#ifdef WIN32
|
||||
static const char *logfilename = "qemu.log";
|
||||
#else
|
||||
static const char *logfilename = "/tmp/qemu.log";
|
||||
#endif
|
||||
FILE *logfile;
|
||||
int loglevel;
|
||||
static int log_append = 0;
|
||||
@@ -1530,22 +1526,24 @@ void cpu_set_log_filename(const char *filename)
|
||||
|
||||
static void cpu_unlink_tb(CPUState *env)
|
||||
{
|
||||
#if defined(CONFIG_USE_NPTL)
|
||||
/* FIXME: TB unchaining isn't SMP safe. For now just ignore the
|
||||
problem and hope the cpu will stop of its own accord. For userspace
|
||||
emulation this often isn't actually as bad as it sounds. Often
|
||||
signals are used primarily to interrupt blocking syscalls. */
|
||||
#else
|
||||
TranslationBlock *tb;
|
||||
static spinlock_t interrupt_lock = SPIN_LOCK_UNLOCKED;
|
||||
|
||||
tb = env->current_tb;
|
||||
/* if the cpu is currently executing code, we must unlink it and
|
||||
all the potentially executing TB */
|
||||
if (tb) {
|
||||
spin_lock(&interrupt_lock);
|
||||
if (tb && !testandset(&interrupt_lock)) {
|
||||
env->current_tb = NULL;
|
||||
tb_reset_jump_recursive(tb);
|
||||
spin_unlock(&interrupt_lock);
|
||||
resetlock(&interrupt_lock);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* mask must never be zero, except for A20 change call */
|
||||
@@ -2917,7 +2915,7 @@ static int get_free_io_mem_idx(void)
|
||||
io_mem_used[i] = 1;
|
||||
return i;
|
||||
}
|
||||
fprintf(stderr, "RAN out out io_mem_idx, max %d !\n", IO_MEM_NB_ENTRIES);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -3309,7 +3307,7 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
|
||||
if (is_write) {
|
||||
cpu_physical_memory_write(bounce.addr, bounce.buffer, access_len);
|
||||
}
|
||||
qemu_free(bounce.buffer);
|
||||
qemu_vfree(bounce.buffer);
|
||||
bounce.buffer = NULL;
|
||||
cpu_notify_map_clients();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
#if defined(CONFIG_SOLARIS) && \
|
||||
((CONFIG_SOLARIS_VERSION <= 9 ) || \
|
||||
((CONFIG_SOLARIS_VERSION == 10) && (__GNUC__ < 4))) \
|
||||
((CONFIG_SOLARIS_VERSION >= 10) && (__GNUC__ < 4))) \
|
||||
|| (defined(__OpenBSD__) && (OpenBSD < 200811))
|
||||
/*
|
||||
* C99 7.12.3 classification macros
|
||||
|
||||
@@ -61,7 +61,7 @@ typedef struct {
|
||||
*----------------------------------------------------------------------------*/
|
||||
#if defined(TARGET_SPARC)
|
||||
#define float32_default_nan make_float32(0x7FFFFFFF)
|
||||
#elif defined(TARGET_POWERPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA)
|
||||
#elif defined(TARGET_POWERPC) || defined(TARGET_ARM)
|
||||
#define float32_default_nan make_float32(0x7FC00000)
|
||||
#elif defined(TARGET_HPPA)
|
||||
#define float32_default_nan make_float32(0x7FA00000)
|
||||
@@ -189,7 +189,7 @@ static float32 propagateFloat32NaN( float32 a, float32 b STATUS_PARAM)
|
||||
*----------------------------------------------------------------------------*/
|
||||
#if defined(TARGET_SPARC)
|
||||
#define float64_default_nan make_float64(LIT64( 0x7FFFFFFFFFFFFFFF ))
|
||||
#elif defined(TARGET_POWERPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA)
|
||||
#elif defined(TARGET_POWERPC) || defined(TARGET_ARM)
|
||||
#define float64_default_nan make_float64(LIT64( 0x7FF8000000000000 ))
|
||||
#elif defined(TARGET_HPPA)
|
||||
#define float64_default_nan make_float64(LIT64( 0x7FF4000000000000 ))
|
||||
|
||||
@@ -187,7 +187,6 @@ typedef struct float_status {
|
||||
signed char float_detect_tininess;
|
||||
signed char float_rounding_mode;
|
||||
signed char float_exception_flags;
|
||||
signed char float_exception_mask;
|
||||
#ifdef FLOATX80
|
||||
signed char floatx80_rounding_precision;
|
||||
#endif
|
||||
|
||||
@@ -1053,7 +1053,7 @@ static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)
|
||||
case 34: GET_REGL(env->active_tc.HI[0]);
|
||||
case 35: GET_REGL(env->CP0_BadVAddr);
|
||||
case 36: GET_REGL((int32_t)env->CP0_Cause);
|
||||
case 37: GET_REGL(env->active_tc.PC | !!(env->hflags & MIPS_HFLAG_M16));
|
||||
case 37: GET_REGL(env->active_tc.PC);
|
||||
case 72: GET_REGL(0); /* fp */
|
||||
case 89: GET_REGL((int32_t)env->CP0_PRid);
|
||||
}
|
||||
@@ -1114,14 +1114,7 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)
|
||||
case 34: env->active_tc.HI[0] = tmp; break;
|
||||
case 35: env->CP0_BadVAddr = tmp; break;
|
||||
case 36: env->CP0_Cause = tmp; break;
|
||||
case 37:
|
||||
env->active_tc.PC = tmp & ~(target_ulong)1;
|
||||
if (tmp & 1) {
|
||||
env->hflags |= MIPS_HFLAG_M16;
|
||||
} else {
|
||||
env->hflags &= ~(MIPS_HFLAG_M16);
|
||||
}
|
||||
break;
|
||||
case 37: env->active_tc.PC = tmp; break;
|
||||
case 72: /* fp, ignored */ break;
|
||||
default:
|
||||
if (n > 89)
|
||||
@@ -1665,12 +1658,7 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
|
||||
#elif defined (TARGET_SH4)
|
||||
s->c_cpu->pc = pc;
|
||||
#elif defined (TARGET_MIPS)
|
||||
s->c_cpu->active_tc.PC = pc & ~(target_ulong)1;
|
||||
if (pc & 1) {
|
||||
s->c_cpu->hflags |= MIPS_HFLAG_M16;
|
||||
} else {
|
||||
s->c_cpu->hflags &= ~(MIPS_HFLAG_M16);
|
||||
}
|
||||
s->c_cpu->active_tc.PC = pc;
|
||||
#elif defined (TARGET_MICROBLAZE)
|
||||
s->c_cpu->sregs[SR_PC] = pc;
|
||||
#elif defined (TARGET_CRIS)
|
||||
|
||||
@@ -1284,42 +1284,37 @@ static int ac97_initfn (PCIDevice *dev)
|
||||
pci_config_set_vendor_id (c, PCI_VENDOR_ID_INTEL); /* ro */
|
||||
pci_config_set_device_id (c, PCI_DEVICE_ID_INTEL_82801AA_5); /* ro */
|
||||
|
||||
/* TODO: no need to override */
|
||||
c[PCI_COMMAND] = 0x00; /* pcicmd pci command rw, ro */
|
||||
c[PCI_COMMAND + 1] = 0x00;
|
||||
c[0x04] = 0x00; /* pcicmd pci command rw, ro */
|
||||
c[0x05] = 0x00;
|
||||
|
||||
/* TODO: */
|
||||
c[PCI_STATUS] = PCI_STATUS_FAST_BACK; /* pcists pci status rwc, ro */
|
||||
c[PCI_STATUS + 1] = PCI_STATUS_DEVSEL_MEDIUM >> 8;
|
||||
c[0x06] = 0x80; /* pcists pci status rwc, ro */
|
||||
c[0x07] = 0x02;
|
||||
|
||||
c[PCI_REVISION_ID] = 0x01; /* rid revision ro */
|
||||
c[PCI_CLASS_PROG] = 0x00; /* pi programming interface ro */
|
||||
c[0x08] = 0x01; /* rid revision ro */
|
||||
c[0x09] = 0x00; /* pi programming interface ro */
|
||||
pci_config_set_class (c, PCI_CLASS_MULTIMEDIA_AUDIO); /* ro */
|
||||
c[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; /* headtyp header type ro */
|
||||
|
||||
/* TODO set when bar is registered. no need to override. */
|
||||
/* nabmar native audio mixer base address rw */
|
||||
c[PCI_BASE_ADDRESS_0] = PCI_BASE_ADDRESS_SPACE_IO;
|
||||
c[PCI_BASE_ADDRESS_0 + 1] = 0x00;
|
||||
c[PCI_BASE_ADDRESS_0 + 2] = 0x00;
|
||||
c[PCI_BASE_ADDRESS_0 + 3] = 0x00;
|
||||
c[0x10] = 0x01; /* nabmar native audio mixer base
|
||||
address rw */
|
||||
c[0x11] = 0x00;
|
||||
c[0x12] = 0x00;
|
||||
c[0x13] = 0x00;
|
||||
|
||||
/* TODO set when bar is registered. no need to override. */
|
||||
/* nabmbar native audio bus mastering base address rw */
|
||||
c[PCI_BASE_ADDRESS_0 + 4] = PCI_BASE_ADDRESS_SPACE_IO;
|
||||
c[PCI_BASE_ADDRESS_0 + 5] = 0x00;
|
||||
c[PCI_BASE_ADDRESS_0 + 6] = 0x00;
|
||||
c[PCI_BASE_ADDRESS_0 + 7] = 0x00;
|
||||
c[0x14] = 0x01; /* nabmbar native audio bus mastering
|
||||
base address rw */
|
||||
c[0x15] = 0x00;
|
||||
c[0x16] = 0x00;
|
||||
c[0x17] = 0x00;
|
||||
|
||||
c[PCI_SUBSYSTEM_VENDOR_ID] = 0x86; /* svid subsystem vendor id rwo */
|
||||
c[PCI_SUBSYSTEM_VENDOR_ID + 1] = 0x80;
|
||||
c[0x2c] = 0x86; /* svid subsystem vendor id rwo */
|
||||
c[0x2d] = 0x80;
|
||||
|
||||
c[PCI_SUBSYSTEM_ID] = 0x00; /* sid subsystem id rwo */
|
||||
c[PCI_SUBSYSTEM_ID + 1] = 0x00;
|
||||
c[0x2e] = 0x00; /* sid subsystem id rwo */
|
||||
c[0x2f] = 0x00;
|
||||
|
||||
c[PCI_INTERRUPT_LINE] = 0x00; /* intr_ln interrupt line rw */
|
||||
/* TODO: RST# value should be 0. */
|
||||
c[PCI_INTERRUPT_PIN] = 0x01; /* intr_pn interrupt pin ro */
|
||||
c[0x3c] = 0x00; /* intr_ln interrupt line rw */
|
||||
c[0x3d] = 0x01; /* intr_pn interrupt pin ro */
|
||||
|
||||
pci_register_bar (&s->dev, 0, 256 * 4, PCI_BASE_ADDRESS_SPACE_IO,
|
||||
ac97_map);
|
||||
|
||||
@@ -437,7 +437,7 @@ static void pm_write_config(PCIDevice *d,
|
||||
uint32_t address, uint32_t val, int len)
|
||||
{
|
||||
pci_default_write_config(d, address, val, len);
|
||||
if (range_covers_byte(address, len, 0x80))
|
||||
if (address == 0x80)
|
||||
pm_io_space_update((PIIX4PMState *)d);
|
||||
}
|
||||
|
||||
|
||||
+8
-35
@@ -1060,17 +1060,8 @@ void call_pal (CPUState *env, int palcode)
|
||||
{
|
||||
target_long ret;
|
||||
|
||||
qemu_log("%s: palcode %02x\n", __func__, palcode);
|
||||
switch (palcode) {
|
||||
case 0x80:
|
||||
/* BPT */
|
||||
qemu_log("BPT\n");
|
||||
/* FIXME: Sends SIGTRAP, si_code=TRAP_BRKPT. */
|
||||
exit(1);
|
||||
case 0x81:
|
||||
/* BUGCHK */
|
||||
qemu_log("BUGCHK\n");
|
||||
/* FIXME: Sends SIGTRAP, si_code=SI_FAULT. */
|
||||
exit(1);
|
||||
case 0x83:
|
||||
/* CALLSYS */
|
||||
qemu_log("CALLSYS n " TARGET_FMT_ld "\n", env->ir[0]);
|
||||
@@ -1085,37 +1076,19 @@ void call_pal (CPUState *env, int palcode)
|
||||
env->ir[IR_V0] = -ret;
|
||||
}
|
||||
break;
|
||||
case 0x86:
|
||||
/* IMB */
|
||||
qemu_log("IMB\n");
|
||||
/* ??? We can probably elide the code using page_unprotect that is
|
||||
checking for self-modifying code. Instead we could simply call
|
||||
tb_flush here. Until we work out the changes required to turn
|
||||
off the extra write protection, this can be a no-op. */
|
||||
break;
|
||||
case 0x9E:
|
||||
/* RDUNIQUE */
|
||||
env->ir[IR_V0] = env->unique;
|
||||
qemu_log("RDUNIQUE: " TARGET_FMT_lx "\n", env->unique);
|
||||
/* Handled in the translator for usermode. */
|
||||
abort();
|
||||
break;
|
||||
case 0x9F:
|
||||
/* WRUNIQUE */
|
||||
qemu_log("WRUNIQUE: " TARGET_FMT_lx "\n", env->ir[IR_A0]);
|
||||
/* Handled in the translator for usermode. */
|
||||
abort();
|
||||
case 0xAA:
|
||||
/* GENTRAP */
|
||||
qemu_log("GENTRAP: " TARGET_FMT_lx "\n", env->ir[IR_A0]);
|
||||
/* FIXME: This is supposed to send a signal:
|
||||
SIGFPE:
|
||||
GEN_INTOVF, GEN_INTDIV, GEN_FLTOVF, GEN_FLTDIV,
|
||||
GEN_FLTUND, GEN_FLTINV, GEN_FLTINE, GEN_ROPRAND
|
||||
SIGTRAP:
|
||||
others
|
||||
with various settings of si_code. */
|
||||
exit(1);
|
||||
env->unique = env->ir[IR_A0];
|
||||
qemu_log("WRUNIQUE: " TARGET_FMT_lx "\n", env->unique);
|
||||
break;
|
||||
default:
|
||||
qemu_log("%s: unhandled palcode %02x\n", __func__, palcode);
|
||||
qemu_log("%s: unhandled palcode %02x\n",
|
||||
__func__, palcode);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,8 +225,6 @@ PCIBus *pci_apb_init(target_phys_addr_t special_base,
|
||||
d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
|
||||
pci_apb_set_irq, pci_pbm_map_irq, pic,
|
||||
0, 32);
|
||||
pci_bus_set_mem_base(d->host_state.bus, mem_base);
|
||||
|
||||
pci_create_simple(d->host_state.bus, 0, "pbm");
|
||||
/* APB secondary busses */
|
||||
*bus2 = pci_bridge_init(d->host_state.bus, PCI_DEVFN(1, 0),
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ static void arm_timer_recalibrate(arm_timer_state *s, int reload)
|
||||
{
|
||||
uint32_t limit;
|
||||
|
||||
if ((s->control & TIMER_CTRL_PERIODIC) == 0) {
|
||||
if ((s->control & (TIMER_CTRL_PERIODIC | TIMER_CTRL_ONESHOT)) == 0) {
|
||||
/* Free running. */
|
||||
if (s->control & TIMER_CTRL_32BIT)
|
||||
limit = 0xffffffff;
|
||||
@@ -113,7 +113,7 @@ static void arm_timer_write(void *opaque, target_phys_addr_t offset,
|
||||
case 1: freq >>= 4; break;
|
||||
case 2: freq >>= 8; break;
|
||||
}
|
||||
arm_timer_recalibrate(s, 0);
|
||||
arm_timer_recalibrate(s, s->control & TIMER_CTRL_ENABLE);
|
||||
ptimer_set_freq(s->timer, freq);
|
||||
if (s->control & TIMER_CTRL_ENABLE) {
|
||||
/* Restart the timer if still enabled. */
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ typedef struct QEMUMachine {
|
||||
QEMUMachineInitFunc *init;
|
||||
int use_scsi;
|
||||
int max_cpus;
|
||||
unsigned int no_serial:1,
|
||||
int no_serial:1,
|
||||
no_parallel:1,
|
||||
use_virtcon:1,
|
||||
no_vga:1,
|
||||
|
||||
+4
-2
@@ -2585,9 +2585,11 @@ static void map_linear_vram(CirrusVGAState *s)
|
||||
|
||||
static void unmap_linear_vram(CirrusVGAState *s)
|
||||
{
|
||||
if (s->vga.map_addr && s->vga.lfb_addr && s->vga.lfb_end)
|
||||
if (s->vga.map_addr && s->vga.lfb_addr && s->vga.lfb_end) {
|
||||
s->vga.map_addr = s->vga.map_end = 0;
|
||||
|
||||
cpu_register_physical_memory(s->vga.lfb_addr, s->vga.vram_size,
|
||||
s->cirrus_linear_io_addr);
|
||||
}
|
||||
cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x20000,
|
||||
s->vga.vga_io_memory);
|
||||
}
|
||||
|
||||
-107
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* QEMU Bochs-style debug console ("port E9") emulation
|
||||
*
|
||||
* Copyright (c) 2003-2004 Fabrice Bellard
|
||||
* Copyright (c) 2008 Citrix Systems, Inc.
|
||||
* Copyright (c) Intel Corporation; author: H. Peter Anvin
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hw.h"
|
||||
#include "qemu-char.h"
|
||||
#include "isa.h"
|
||||
#include "pc.h"
|
||||
|
||||
//#define DEBUG_DEBUGCON
|
||||
|
||||
typedef struct DebugconState {
|
||||
CharDriverState *chr;
|
||||
uint32_t readback;
|
||||
} DebugconState;
|
||||
|
||||
typedef struct ISADebugconState {
|
||||
ISADevice dev;
|
||||
uint32_t iobase;
|
||||
DebugconState state;
|
||||
} ISADebugconState;
|
||||
|
||||
static void debugcon_ioport_write(void *opaque, uint32_t addr, uint32_t val)
|
||||
{
|
||||
DebugconState *s = opaque;
|
||||
unsigned char ch = val;
|
||||
|
||||
#ifdef DEBUG_DEBUGCON
|
||||
printf("debugcon: write addr=0x%04x val=0x%02x\n", addr, val);
|
||||
#endif
|
||||
|
||||
qemu_chr_write(s->chr, &ch, 1);
|
||||
}
|
||||
|
||||
|
||||
static uint32_t debugcon_ioport_read(void *opaque, uint32_t addr)
|
||||
{
|
||||
DebugconState *s = opaque;
|
||||
|
||||
#ifdef DEBUG_DEBUGCON
|
||||
printf("debugcon: read addr=0x%04x\n", addr, val);
|
||||
#endif
|
||||
|
||||
return s->readback;
|
||||
}
|
||||
|
||||
static void debugcon_init_core(DebugconState *s)
|
||||
{
|
||||
if (!s->chr) {
|
||||
fprintf(stderr, "Can't create debugcon device, empty char device\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
qemu_chr_add_handlers(s->chr, NULL, NULL, NULL, s);
|
||||
}
|
||||
|
||||
static int debugcon_isa_initfn(ISADevice *dev)
|
||||
{
|
||||
ISADebugconState *isa = DO_UPCAST(ISADebugconState, dev, dev);
|
||||
DebugconState *s = &isa->state;
|
||||
|
||||
debugcon_init_core(s);
|
||||
register_ioport_write(isa->iobase, 1, 1, debugcon_ioport_write, s);
|
||||
register_ioport_read(isa->iobase, 1, 1, debugcon_ioport_read, s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ISADeviceInfo debugcon_isa_info = {
|
||||
.qdev.name = "isa-debugcon",
|
||||
.qdev.size = sizeof(ISADebugconState),
|
||||
.init = debugcon_isa_initfn,
|
||||
.qdev.props = (Property[]) {
|
||||
DEFINE_PROP_HEX32("iobase", ISADebugconState, iobase, 0xe9),
|
||||
DEFINE_PROP_CHR("chardev", ISADebugconState, state.chr),
|
||||
DEFINE_PROP_HEX32("readback", ISADebugconState, state.readback, 0xe9),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
},
|
||||
};
|
||||
|
||||
static void debugcon_register_devices(void)
|
||||
{
|
||||
isa_qdev_register(&debugcon_isa_info);
|
||||
}
|
||||
|
||||
device_init(debugcon_register_devices)
|
||||
+4
-10
@@ -1,9 +1,6 @@
|
||||
/*
|
||||
* QEMU e1000 emulation
|
||||
*
|
||||
* Software developer's manual:
|
||||
* http://download.intel.com/design/network/manuals/8254x_GBe_SDM.pdf
|
||||
*
|
||||
* Nir Peleg, Tutis Systems Ltd. for Qumranet Inc.
|
||||
* Copyright (c) 2008 Qumranet
|
||||
* Based on work done by:
|
||||
@@ -1092,15 +1089,12 @@ static int pci_e1000_init(PCIDevice *pci_dev)
|
||||
|
||||
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
|
||||
pci_config_set_device_id(pci_conf, E1000_DEVID);
|
||||
/* TODO: we have no capabilities, so why is this bit set? */
|
||||
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_CAP_LIST);
|
||||
pci_conf[PCI_REVISION_ID] = 0x03;
|
||||
*(uint16_t *)(pci_conf+0x06) = cpu_to_le16(0x0010);
|
||||
pci_conf[0x08] = 0x03;
|
||||
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
|
||||
/* TODO: RST# value should be 0, PCI spec 6.2.4 */
|
||||
pci_conf[PCI_CACHE_LINE_SIZE] = 0x10;
|
||||
pci_conf[0x0c] = 0x10;
|
||||
|
||||
/* TODO: RST# value should be 0 if programmable, PCI spec 6.2.4 */
|
||||
pci_conf[PCI_INTERRUPT_PIN] = 1; // interrupt pin 0
|
||||
pci_conf[0x3d] = 1; // interrupt pin 0
|
||||
|
||||
d->mmio_index = cpu_register_io_memory(e1000_mmio_read,
|
||||
e1000_mmio_write, d);
|
||||
|
||||
+17
-32
@@ -412,24 +412,19 @@ static void pci_reset(EEPRO100State * s)
|
||||
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
|
||||
/* PCI Device ID depends on device and is set below. */
|
||||
/* PCI Command */
|
||||
/* TODO: this is the default, do not override. */
|
||||
PCI_CONFIG_16(PCI_COMMAND, 0x0000);
|
||||
/* PCI Status */
|
||||
/* TODO: this seems to make no sense. */
|
||||
/* TODO: Value at RST# should be 0. */
|
||||
PCI_CONFIG_16(PCI_STATUS,
|
||||
PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_SIG_TARGET_ABORT);
|
||||
PCI_CONFIG_16(PCI_STATUS, 0x2800);
|
||||
/* PCI Revision ID */
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x08);
|
||||
/* TODO: this is the default, do not override. */
|
||||
/* PCI Class Code */
|
||||
PCI_CONFIG_8(PCI_CLASS_PROG, 0x00);
|
||||
PCI_CONFIG_8(0x09, 0x00);
|
||||
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
|
||||
/* PCI Cache Line Size */
|
||||
/* check cache line size!!! */
|
||||
//~ PCI_CONFIG_8(0x0c, 0x00);
|
||||
/* PCI Latency Timer */
|
||||
PCI_CONFIG_8(PCI_LATENCY_TIMER, 0x20); // latency timer = 32 clocks
|
||||
PCI_CONFIG_8(0x0d, 0x20); // latency timer = 32 clocks
|
||||
/* PCI Header Type */
|
||||
/* BIST (built-in self test) */
|
||||
#if defined(TARGET_I386)
|
||||
@@ -451,20 +446,16 @@ static void pci_reset(EEPRO100State * s)
|
||||
#endif
|
||||
#endif
|
||||
/* Expansion ROM Base Address (depends on boot disable!!!) */
|
||||
/* TODO: not needed, set when BAR is registered */
|
||||
PCI_CONFIG_32(PCI_ROM_ADDRESS, PCI_BASE_ADDRESS_SPACE_MEMORY);
|
||||
PCI_CONFIG_32(0x30, 0x00000000);
|
||||
/* Capability Pointer */
|
||||
/* TODO: revisions with power_management 1 use this but
|
||||
* do not set new capability list bit in status register. */
|
||||
PCI_CONFIG_8(PCI_CAPABILITY_LIST, 0xdc);
|
||||
PCI_CONFIG_8(0x34, 0xdc);
|
||||
/* Interrupt Line */
|
||||
/* Interrupt Pin */
|
||||
/* TODO: RST# value should be 0 */
|
||||
PCI_CONFIG_8(PCI_INTERRUPT_PIN, 1); // interrupt pin 0
|
||||
PCI_CONFIG_8(0x3d, 1); // interrupt pin 0
|
||||
/* Minimum Grant */
|
||||
PCI_CONFIG_8(PCI_MIN_GNT, 0x08);
|
||||
PCI_CONFIG_8(0x3e, 0x08);
|
||||
/* Maximum Latency */
|
||||
PCI_CONFIG_8(PCI_MAX_LAT, 0x18);
|
||||
PCI_CONFIG_8(0x3f, 0x18);
|
||||
|
||||
switch (device) {
|
||||
case i82550:
|
||||
@@ -488,57 +479,52 @@ static void pci_reset(EEPRO100State * s)
|
||||
case i82557A:
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x01);
|
||||
PCI_CONFIG_8(PCI_CAPABILITY_LIST, 0x00);
|
||||
PCI_CONFIG_8(0x34, 0x00);
|
||||
power_management = 0;
|
||||
break;
|
||||
case i82557B:
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x02);
|
||||
PCI_CONFIG_8(PCI_CAPABILITY_LIST, 0x00);
|
||||
PCI_CONFIG_8(0x34, 0x00);
|
||||
power_management = 0;
|
||||
break;
|
||||
case i82557C:
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x03);
|
||||
PCI_CONFIG_8(PCI_CAPABILITY_LIST, 0x00);
|
||||
PCI_CONFIG_8(0x34, 0x00);
|
||||
power_management = 0;
|
||||
break;
|
||||
case i82558A:
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
|
||||
PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
|
||||
PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
|
||||
PCI_CONFIG_16(PCI_STATUS, 0x0290);
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x04);
|
||||
s->stats_size = 76;
|
||||
s->has_extended_tcb_support = 1;
|
||||
break;
|
||||
case i82558B:
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
|
||||
PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
|
||||
PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
|
||||
PCI_CONFIG_16(PCI_STATUS, 0x0290);
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x05);
|
||||
s->stats_size = 76;
|
||||
s->has_extended_tcb_support = 1;
|
||||
break;
|
||||
case i82559A:
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
|
||||
PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
|
||||
PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
|
||||
PCI_CONFIG_16(PCI_STATUS, 0x0290);
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x06);
|
||||
s->stats_size = 80;
|
||||
s->has_extended_tcb_support = 1;
|
||||
break;
|
||||
case i82559B:
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
|
||||
PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
|
||||
PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
|
||||
PCI_CONFIG_16(PCI_STATUS, 0x0290);
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x07);
|
||||
s->stats_size = 80;
|
||||
s->has_extended_tcb_support = 1;
|
||||
break;
|
||||
case i82559C:
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
|
||||
PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
|
||||
PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
|
||||
PCI_CONFIG_16(PCI_STATUS, 0x0290);
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x08);
|
||||
// TODO: Windows wants revision id 0x0c.
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x0c);
|
||||
@@ -551,8 +537,7 @@ static void pci_reset(EEPRO100State * s)
|
||||
break;
|
||||
case i82559ER:
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82551IT);
|
||||
PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
|
||||
PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
|
||||
PCI_CONFIG_16(PCI_STATUS, 0x0290);
|
||||
PCI_CONFIG_8(PCI_REVISION_ID, 0x09);
|
||||
s->stats_size = 80;
|
||||
s->has_extended_tcb_support = 1;
|
||||
|
||||
+2
-7
@@ -149,14 +149,9 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (nsyms) {
|
||||
syms = qemu_realloc(syms, nsyms * sizeof(*syms));
|
||||
syms = qemu_realloc(syms, nsyms * sizeof(*syms));
|
||||
|
||||
qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
|
||||
} else {
|
||||
qemu_free(syms);
|
||||
syms = NULL;
|
||||
}
|
||||
qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
|
||||
|
||||
/* String table */
|
||||
if (symtab->sh_link >= ehdr->e_shnum)
|
||||
|
||||
+14
-15
@@ -1000,28 +1000,27 @@ static int es1370_initfn (PCIDevice *dev)
|
||||
|
||||
pci_config_set_vendor_id (c, PCI_VENDOR_ID_ENSONIQ);
|
||||
pci_config_set_device_id (c, PCI_DEVICE_ID_ENSONIQ_ES1370);
|
||||
c[PCI_STATUS + 1] = PCI_STATUS_DEVSEL_SLOW >> 8;
|
||||
c[0x07] = 2 << 1;
|
||||
pci_config_set_class (c, PCI_CLASS_MULTIMEDIA_AUDIO);
|
||||
|
||||
#if 1
|
||||
c[PCI_SUBSYSTEM_VENDOR_ID] = 0x42;
|
||||
c[PCI_SUBSYSTEM_VENDOR_ID + 1] = 0x49;
|
||||
c[PCI_SUBSYSTEM_ID] = 0x4c;
|
||||
c[PCI_SUBSYSTEM_ID + 1] = 0x4c;
|
||||
c[0x2c] = 0x42;
|
||||
c[0x2d] = 0x49;
|
||||
c[0x2e] = 0x4c;
|
||||
c[0x2f] = 0x4c;
|
||||
#else
|
||||
c[PCI_SUBSYSTEM_VENDOR_ID] = 0x74;
|
||||
c[PCI_SUBSYSTEM_VENDOR_ID + 1] = 0x12;
|
||||
c[PCI_SUBSYSTEM_ID] = 0x71;
|
||||
c[PCI_SUBSYSTEM_ID + 1] = 0x13;
|
||||
c[PCI_CAPABILITY_LIST] = 0xdc;
|
||||
c[PCI_INTERRUPT_LINE] = 10;
|
||||
c[0x2c] = 0x74;
|
||||
c[0x2d] = 0x12;
|
||||
c[0x2e] = 0x71;
|
||||
c[0x2f] = 0x13;
|
||||
c[0x34] = 0xdc;
|
||||
c[0x3c] = 10;
|
||||
c[0xdc] = 0x00;
|
||||
#endif
|
||||
|
||||
/* TODO: RST# value should be 0. */
|
||||
c[PCI_INTERRUPT_PIN] = 1;
|
||||
c[PCI_MIN_GNT] = 0x0c;
|
||||
c[PCI_MAX_LAT] = 0x80;
|
||||
c[0x3d] = 1;
|
||||
c[0x3e] = 0x0c;
|
||||
c[0x3f] = 0x80;
|
||||
|
||||
pci_register_bar (&s->dev, 0, 256, PCI_BASE_ADDRESS_SPACE_IO, es1370_map);
|
||||
qemu_register_reset (es1370_on_reset, s);
|
||||
|
||||
@@ -370,9 +370,9 @@ enum {
|
||||
FD_CMD_PART_ID = 0x18,
|
||||
FD_CMD_SCAN_LOW_OR_EQUAL = 0x19,
|
||||
FD_CMD_SCAN_HIGH_OR_EQUAL = 0x1d,
|
||||
FD_CMD_SAVE = 0x2c,
|
||||
FD_CMD_SAVE = 0x2e,
|
||||
FD_CMD_OPTION = 0x33,
|
||||
FD_CMD_RESTORE = 0x4c,
|
||||
FD_CMD_RESTORE = 0x4e,
|
||||
FD_CMD_DRIVE_SPECIFICATION_COMMAND = 0x8e,
|
||||
FD_CMD_RELATIVE_SEEK_OUT = 0x8f,
|
||||
FD_CMD_FORMAT_AND_WRITE = 0xcd,
|
||||
@@ -1860,8 +1860,12 @@ fdctrl_t *fdctrl_init_isa(DriveInfo **fds)
|
||||
ISADevice *dev;
|
||||
|
||||
dev = isa_create("isa-fdc");
|
||||
qdev_prop_set_drive(&dev->qdev, "driveA", fds[0]);
|
||||
qdev_prop_set_drive(&dev->qdev, "driveB", fds[1]);
|
||||
if (fds[0]) {
|
||||
qdev_prop_set_drive(&dev->qdev, "driveA", fds[0]);
|
||||
}
|
||||
if (fds[1]) {
|
||||
qdev_prop_set_drive(&dev->qdev, "driveB", fds[1]);
|
||||
}
|
||||
if (qdev_init(&dev->qdev) < 0)
|
||||
return NULL;
|
||||
return &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
|
||||
@@ -1879,8 +1883,12 @@ fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
|
||||
sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev);
|
||||
fdctrl = &sys->state;
|
||||
fdctrl->dma_chann = dma_chann; /* FIXME */
|
||||
qdev_prop_set_drive(dev, "driveA", fds[0]);
|
||||
qdev_prop_set_drive(dev, "driveB", fds[1]);
|
||||
if (fds[0]) {
|
||||
qdev_prop_set_drive(dev, "driveA", fds[0]);
|
||||
}
|
||||
if (fds[1]) {
|
||||
qdev_prop_set_drive(dev, "driveB", fds[1]);
|
||||
}
|
||||
qdev_init_nofail(dev);
|
||||
sysbus_connect_irq(&sys->busdev, 0, irq);
|
||||
sysbus_mmio_map(&sys->busdev, 0, mmio_base);
|
||||
@@ -1896,7 +1904,9 @@ fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base,
|
||||
fdctrl_t *fdctrl;
|
||||
|
||||
dev = qdev_create(NULL, "SUNW,fdtwo");
|
||||
qdev_prop_set_drive(dev, "drive", fds[0]);
|
||||
if (fds[0]) {
|
||||
qdev_prop_set_drive(dev, "drive", fds[0]);
|
||||
}
|
||||
qdev_init_nofail(dev);
|
||||
sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev);
|
||||
fdctrl = &sys->state;
|
||||
|
||||
+12
-8
@@ -179,7 +179,7 @@ static int get_uint32_as_uint16(QEMUFile *f, void *pv, size_t size)
|
||||
|
||||
static void put_unused(QEMUFile *f, void *pv, size_t size)
|
||||
{
|
||||
fprintf(stderr, "uint32_as_uint16 is only used for backward compatibilty.\n");
|
||||
fprintf(stderr, "uint32_as_uint16 is only used for backward compatibility.\n");
|
||||
fprintf(stderr, "This functions shouldn't be called.\n");
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename,
|
||||
uint8_t *data, uint32_t len)
|
||||
{
|
||||
const char *basename;
|
||||
int index;
|
||||
int i, index;
|
||||
|
||||
if (!s->files) {
|
||||
int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
|
||||
@@ -300,13 +300,17 @@ int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename,
|
||||
} else {
|
||||
basename = filename;
|
||||
}
|
||||
if (dir) {
|
||||
snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
|
||||
"%s/%s", dir, basename);
|
||||
} else {
|
||||
snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
|
||||
"%s", basename);
|
||||
|
||||
snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
|
||||
"%s/%s", dir, basename);
|
||||
for (i = 0; i < index; i++) {
|
||||
if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {
|
||||
FW_CFG_DPRINTF("%s: skip duplicate: %s\n", __FUNCTION__,
|
||||
s->files->f[index].name);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
s->files->f[index].size = cpu_to_be32(len);
|
||||
s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
|
||||
FW_CFG_DPRINTF("%s: #%d: %s (%d bytes)\n", __FUNCTION__,
|
||||
|
||||
+12
-1
@@ -1082,6 +1082,17 @@ static void gt64120_reset(void *opaque)
|
||||
gt64120_pci_mapping(s);
|
||||
}
|
||||
|
||||
static uint32_t gt64120_read_config(PCIDevice *d, uint32_t address, int len)
|
||||
{
|
||||
return pci_default_read_config(d, address, len);
|
||||
}
|
||||
|
||||
static void gt64120_write_config(PCIDevice *d, uint32_t address, uint32_t val,
|
||||
int len)
|
||||
{
|
||||
pci_default_write_config(d, address, val, len);
|
||||
}
|
||||
|
||||
static void gt64120_save(QEMUFile* f, void *opaque)
|
||||
{
|
||||
PCIDevice *d = opaque;
|
||||
@@ -1114,7 +1125,7 @@ PCIBus *pci_gt64120_init(qemu_irq *pic)
|
||||
pic, 144, 4);
|
||||
s->ISD_handle = cpu_register_io_memory(gt64120_read, gt64120_write, s);
|
||||
d = pci_register_device(s->pci->bus, "GT64120 PCI Bus", sizeof(PCIDevice),
|
||||
0, NULL, NULL);
|
||||
0, gt64120_read_config, gt64120_write_config);
|
||||
|
||||
/* FIXME: Malta specific hw assumptions ahead */
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
#ifndef HW_IDE_H
|
||||
#define HW_IDE_H
|
||||
|
||||
#include "qdev.h"
|
||||
#include "isa.h"
|
||||
#include "pci.h"
|
||||
|
||||
/* ide-isa.c */
|
||||
int isa_ide_init(int iobase, int iobase2, int isairq,
|
||||
DriveInfo *hd0, DriveInfo *hd1);
|
||||
ISADevice *isa_ide_init(int iobase, int iobase2, int isairq,
|
||||
DriveInfo *hd0, DriveInfo *hd1);
|
||||
|
||||
/* ide-pci.c */
|
||||
void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table,
|
||||
int secondary_ide_enabled);
|
||||
void pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
|
||||
void pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
|
||||
PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
|
||||
PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
|
||||
|
||||
/* ide-macio.c */
|
||||
int pmac_ide_init (DriveInfo **hd_table, qemu_irq irq,
|
||||
@@ -22,4 +23,6 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2,
|
||||
qemu_irq irq, int shift,
|
||||
DriveInfo *hd0, DriveInfo *hd1);
|
||||
|
||||
void ide_get_bs(BlockDriverState *bs[], BusState *qbus);
|
||||
|
||||
#endif /* HW_IDE_H */
|
||||
+3
-4
@@ -206,8 +206,8 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
|
||||
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CMD);
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_CMD_646);
|
||||
|
||||
pci_conf[PCI_REVISION_ID] = 0x07; // IDE controller revision
|
||||
pci_conf[PCI_CLASS_PROG] = 0x8f;
|
||||
pci_conf[0x08] = 0x07; // IDE controller revision
|
||||
pci_conf[0x09] = 0x8f;
|
||||
|
||||
pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE);
|
||||
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
||||
@@ -224,8 +224,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
|
||||
pci_register_bar(dev, 3, 0x4, PCI_BASE_ADDRESS_SPACE_IO, ide_map);
|
||||
pci_register_bar(dev, 4, 0x10, PCI_BASE_ADDRESS_SPACE_IO, bmdma_map);
|
||||
|
||||
/* TODO: RST# value should be 0 */
|
||||
pci_conf[PCI_INTERRUPT_PIN] = 0x01; // interrupt on pin 1
|
||||
pci_conf[0x3d] = 0x01; // interrupt on pin 1
|
||||
|
||||
irq = qemu_allocate_irqs(cmd646_set_irq, d, 2);
|
||||
ide_bus_new(&d->bus[0], &d->dev.qdev);
|
||||
|
||||
+73
-13
@@ -115,7 +115,7 @@ static void ide_identify(IDEState *s)
|
||||
put_le16(p + 20, 3); /* XXX: retired, remove ? */
|
||||
put_le16(p + 21, 512); /* cache size in sectors */
|
||||
put_le16(p + 22, 4); /* ecc bytes */
|
||||
padstr((char *)(p + 23), QEMU_VERSION, 8); /* firmware version */
|
||||
padstr((char *)(p + 23), s->version, 8); /* firmware version */
|
||||
padstr((char *)(p + 27), "QEMU HARDDISK", 40); /* model */
|
||||
#if MAX_MULT_SECTORS > 1
|
||||
put_le16(p + 47, 0x8000 | MAX_MULT_SECTORS);
|
||||
@@ -186,7 +186,7 @@ static void ide_atapi_identify(IDEState *s)
|
||||
put_le16(p + 20, 3); /* buffer type */
|
||||
put_le16(p + 21, 512); /* cache size in sectors */
|
||||
put_le16(p + 22, 4); /* ecc bytes */
|
||||
padstr((char *)(p + 23), QEMU_VERSION, 8); /* firmware version */
|
||||
padstr((char *)(p + 23), s->version, 8); /* firmware version */
|
||||
padstr((char *)(p + 27), "QEMU DVD-ROM", 40); /* model */
|
||||
put_le16(p + 48, 1); /* dword I/O (XXX: should not be set on CDROM) */
|
||||
#ifdef USE_DMA_CDROM
|
||||
@@ -238,7 +238,7 @@ static void ide_cfata_identify(IDEState *s)
|
||||
put_le16(p + 8, s->nb_sectors); /* Sectors per card */
|
||||
padstr((char *)(p + 10), s->drive_serial_str, 20); /* serial number */
|
||||
put_le16(p + 22, 0x0004); /* ECC bytes */
|
||||
padstr((char *) (p + 23), QEMU_VERSION, 8); /* Firmware Revision */
|
||||
padstr((char *) (p + 23), s->version, 8); /* Firmware Revision */
|
||||
padstr((char *) (p + 27), "QEMU MICRODRIVE", 40);/* Model number */
|
||||
#if MAX_MULT_SECTORS > 1
|
||||
put_le16(p + 47, 0x8000 | MAX_MULT_SECTORS);
|
||||
@@ -1591,7 +1591,7 @@ static void ide_atapi_cmd(IDEState *s)
|
||||
buf[7] = 0; /* reserved */
|
||||
padstr8(buf + 8, 8, "QEMU");
|
||||
padstr8(buf + 16, 16, "QEMU DVD-ROM");
|
||||
padstr8(buf + 32, 4, QEMU_VERSION);
|
||||
padstr8(buf + 32, 4, s->version);
|
||||
ide_atapi_cmd_reply(s, 36, max_len);
|
||||
break;
|
||||
case GPCMD_GET_CONFIGURATION:
|
||||
@@ -2590,7 +2590,7 @@ void ide_bus_reset(IDEBus *bus)
|
||||
ide_clear_hob(bus);
|
||||
}
|
||||
|
||||
void ide_init_drive(IDEState *s, DriveInfo *dinfo)
|
||||
void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version)
|
||||
{
|
||||
int cylinders, heads, secs;
|
||||
uint64_t nb_sectors;
|
||||
@@ -2619,6 +2619,11 @@ void ide_init_drive(IDEState *s, DriveInfo *dinfo)
|
||||
if (strlen(s->drive_serial_str) == 0)
|
||||
snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),
|
||||
"QM%05d", s->drive_serial);
|
||||
if (version) {
|
||||
pstrcpy(s->version, sizeof(s->version), version);
|
||||
} else {
|
||||
pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);
|
||||
}
|
||||
ide_reset(s);
|
||||
}
|
||||
|
||||
@@ -2635,13 +2640,14 @@ void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
|
||||
s->unit = i;
|
||||
s->drive_serial = drive_serial++;
|
||||
s->io_buffer = qemu_blockalign(s->bs, IDE_DMA_BUF_SECTORS*512 + 4);
|
||||
s->io_buffer_total_len = IDE_DMA_BUF_SECTORS*512 + 4;
|
||||
s->smart_selftest_data = qemu_blockalign(s->bs, 512);
|
||||
s->sector_write_timer = qemu_new_timer(vm_clock,
|
||||
ide_sector_write_timer_cb, s);
|
||||
if (i == 0)
|
||||
ide_init_drive(s, hd0);
|
||||
ide_init_drive(s, hd0, NULL);
|
||||
if (i == 1)
|
||||
ide_init_drive(s, hd1);
|
||||
ide_init_drive(s, hd1, NULL);
|
||||
}
|
||||
bus->irq = irq;
|
||||
}
|
||||
@@ -2669,6 +2675,25 @@ static bool is_identify_set(void *opaque, int version_id)
|
||||
return s->identify_set != 0;
|
||||
}
|
||||
|
||||
static EndTransferFunc* transfer_end_table[] = {
|
||||
ide_sector_read,
|
||||
ide_sector_write,
|
||||
ide_transfer_stop,
|
||||
ide_atapi_cmd_reply_end,
|
||||
ide_atapi_cmd,
|
||||
};
|
||||
|
||||
static int transfer_end_table_idx(EndTransferFunc *fn)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(transfer_end_table); i++)
|
||||
if (transfer_end_table[i] == fn)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int ide_drive_post_load(void *opaque, int version_id)
|
||||
{
|
||||
IDEState *s = opaque;
|
||||
@@ -2679,14 +2704,42 @@ static int ide_drive_post_load(void *opaque, int version_id)
|
||||
s->cdrom_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (s->cur_io_buffer_len) {
|
||||
s->end_transfer_func = transfer_end_table[s->end_transfer_fn_idx];
|
||||
s->data_ptr = s->io_buffer + s->cur_io_buffer_offset;
|
||||
s->data_end = s->data_ptr + s->cur_io_buffer_len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ide_drive_pre_save(void *opaque)
|
||||
{
|
||||
IDEState *s = opaque;
|
||||
|
||||
s->cur_io_buffer_len = 0;
|
||||
|
||||
if (!(s->status & DRQ_STAT))
|
||||
return;
|
||||
|
||||
s->cur_io_buffer_offset = s->data_ptr - s->io_buffer;
|
||||
s->cur_io_buffer_len = s->data_end - s->data_ptr;
|
||||
|
||||
s->end_transfer_fn_idx = transfer_end_table_idx(s->end_transfer_func);
|
||||
if (s->end_transfer_fn_idx == -1) {
|
||||
fprintf(stderr, "%s: invalid end_transfer_func for DRQ_STAT\n",
|
||||
__func__);
|
||||
s->end_transfer_fn_idx = 2;
|
||||
}
|
||||
}
|
||||
|
||||
const VMStateDescription vmstate_ide_drive = {
|
||||
.name = "ide_drive",
|
||||
.version_id = 3,
|
||||
.version_id = 4,
|
||||
.minimum_version_id = 0,
|
||||
.minimum_version_id_old = 0,
|
||||
.pre_save = ide_drive_pre_save,
|
||||
.post_load = ide_drive_post_load,
|
||||
.fields = (VMStateField []) {
|
||||
VMSTATE_INT32(mult_sectors, IDEState),
|
||||
@@ -2709,7 +2762,14 @@ const VMStateDescription vmstate_ide_drive = {
|
||||
VMSTATE_UINT8(sense_key, IDEState),
|
||||
VMSTATE_UINT8(asc, IDEState),
|
||||
VMSTATE_UINT8_V(cdrom_changed, IDEState, 3),
|
||||
/* XXX: if a transfer is pending, we do not save it yet */
|
||||
VMSTATE_INT32_V(req_nb_sectors, IDEState, 4),
|
||||
VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len, 4,
|
||||
vmstate_info_uint8, uint8_t),
|
||||
VMSTATE_INT32_V(cur_io_buffer_offset, IDEState, 4),
|
||||
VMSTATE_INT32_V(cur_io_buffer_len, IDEState, 4),
|
||||
VMSTATE_UINT8_V(end_transfer_fn_idx, IDEState, 4),
|
||||
VMSTATE_INT32_V(elementary_transfer_size, IDEState, 4),
|
||||
VMSTATE_INT32_V(packet_transfer_size, IDEState, 4),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
@@ -2767,10 +2827,6 @@ static void ide_dma_restart(IDEState *s, int is_read)
|
||||
void ide_dma_cancel(BMDMAState *bm)
|
||||
{
|
||||
if (bm->status & BM_STATUS_DMAING) {
|
||||
bm->status &= ~BM_STATUS_DMAING;
|
||||
/* cancel DMA request */
|
||||
bm->unit = -1;
|
||||
bm->dma_cb = NULL;
|
||||
if (bm->aiocb) {
|
||||
#ifdef DEBUG_AIO
|
||||
printf("aio_cancel\n");
|
||||
@@ -2778,6 +2834,10 @@ void ide_dma_cancel(BMDMAState *bm)
|
||||
bdrv_aio_cancel(bm->aiocb);
|
||||
bm->aiocb = NULL;
|
||||
}
|
||||
bm->status &= ~BM_STATUS_DMAING;
|
||||
/* cancel DMA request */
|
||||
bm->unit = -1;
|
||||
bm->dma_cb = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -397,6 +397,7 @@ struct IDEState {
|
||||
/* set for lba48 access */
|
||||
uint8_t lba48;
|
||||
BlockDriverState *bs;
|
||||
char version[9];
|
||||
/* ATAPI specific */
|
||||
uint8_t sense_key;
|
||||
uint8_t asc;
|
||||
@@ -416,6 +417,11 @@ struct IDEState {
|
||||
uint8_t *data_ptr;
|
||||
uint8_t *data_end;
|
||||
uint8_t *io_buffer;
|
||||
/* PIO save/restore */
|
||||
int32_t io_buffer_total_len;
|
||||
int cur_io_buffer_offset;
|
||||
int cur_io_buffer_len;
|
||||
uint8_t end_transfer_fn_idx;
|
||||
QEMUTimer *sector_write_timer; /* only used for win2k install hack */
|
||||
uint32_t irq_count; /* counts IRQs when using win2k install hack */
|
||||
/* CF-ATA extended error */
|
||||
@@ -449,6 +455,7 @@ struct IDEDevice {
|
||||
DeviceState qdev;
|
||||
uint32_t unit;
|
||||
DriveInfo *dinfo;
|
||||
char *version;
|
||||
};
|
||||
|
||||
typedef int (*ide_qdev_initfn)(IDEDevice *dev);
|
||||
@@ -549,7 +556,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr);
|
||||
void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);
|
||||
uint32_t ide_data_readl(void *opaque, uint32_t addr);
|
||||
|
||||
void ide_init_drive(IDEState *s, DriveInfo *dinfo);
|
||||
void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version);
|
||||
void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
|
||||
qemu_irq irq);
|
||||
void ide_init_ioport(IDEBus *bus, int iobase, int iobase2);
|
||||
|
||||
+4
-4
@@ -75,8 +75,8 @@ static int isa_ide_initfn(ISADevice *dev)
|
||||
return 0;
|
||||
};
|
||||
|
||||
int isa_ide_init(int iobase, int iobase2, int isairq,
|
||||
DriveInfo *hd0, DriveInfo *hd1)
|
||||
ISADevice *isa_ide_init(int iobase, int iobase2, int isairq,
|
||||
DriveInfo *hd0, DriveInfo *hd1)
|
||||
{
|
||||
ISADevice *dev;
|
||||
ISAIDEState *s;
|
||||
@@ -86,14 +86,14 @@ int isa_ide_init(int iobase, int iobase2, int isairq,
|
||||
qdev_prop_set_uint32(&dev->qdev, "iobase2", iobase2);
|
||||
qdev_prop_set_uint32(&dev->qdev, "irq", isairq);
|
||||
if (qdev_init(&dev->qdev) < 0)
|
||||
return -1;
|
||||
return NULL;
|
||||
|
||||
s = DO_UPCAST(ISAIDEState, dev, dev);
|
||||
if (hd0)
|
||||
ide_create_drive(&s->bus, 0, hd0);
|
||||
if (hd1)
|
||||
ide_create_drive(&s->bus, 1, hd1);
|
||||
return 0;
|
||||
return dev;
|
||||
}
|
||||
|
||||
static ISADeviceInfo isa_ide_info = {
|
||||
|
||||
+9
-10
@@ -107,13 +107,10 @@ static void piix3_reset(void *opaque)
|
||||
ide_dma_reset(&d->bmdma[i]);
|
||||
}
|
||||
|
||||
/* TODO: this is the default. do not override. */
|
||||
pci_conf[PCI_COMMAND] = 0x00;
|
||||
/* TODO: this is the default. do not override. */
|
||||
pci_conf[PCI_COMMAND + 1] = 0x00;
|
||||
/* TODO: use pci_set_word */
|
||||
pci_conf[PCI_STATUS] = PCI_STATUS_FAST_BACK;
|
||||
pci_conf[PCI_STATUS + 1] = PCI_STATUS_DEVSEL_MEDIUM >> 8;
|
||||
pci_conf[0x04] = 0x00;
|
||||
pci_conf[0x05] = 0x00;
|
||||
pci_conf[0x06] = 0x80; /* FBC */
|
||||
pci_conf[0x07] = 0x02; // PCI_status_devsel_medium
|
||||
pci_conf[0x20] = 0x01; /* BMIBA: 20-23h */
|
||||
}
|
||||
|
||||
@@ -121,7 +118,7 @@ static int pci_piix_ide_initfn(PCIIDEState *d)
|
||||
{
|
||||
uint8_t *pci_conf = d->dev.config;
|
||||
|
||||
pci_conf[PCI_CLASS_PROG] = 0x80; // legacy ATA mode
|
||||
pci_conf[0x09] = 0x80; // legacy ATA mode
|
||||
pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE);
|
||||
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
||||
|
||||
@@ -161,22 +158,24 @@ static int pci_piix4_ide_initfn(PCIDevice *dev)
|
||||
|
||||
/* hd_table must contain 4 block drivers */
|
||||
/* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
|
||||
void pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
|
||||
PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
|
||||
{
|
||||
PCIDevice *dev;
|
||||
|
||||
dev = pci_create_simple(bus, devfn, "piix3-ide");
|
||||
pci_ide_create_devs(dev, hd_table);
|
||||
return dev;
|
||||
}
|
||||
|
||||
/* hd_table must contain 4 block drivers */
|
||||
/* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */
|
||||
void pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
|
||||
PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
|
||||
{
|
||||
PCIDevice *dev;
|
||||
|
||||
dev = pci_create_simple(bus, devfn, "piix4-ide");
|
||||
pci_ide_create_devs(dev, hd_table);
|
||||
return dev;
|
||||
}
|
||||
|
||||
static PCIDeviceInfo piix_ide_info[] = {
|
||||
|
||||
+9
-1
@@ -90,6 +90,13 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive)
|
||||
return DO_UPCAST(IDEDevice, qdev, dev);
|
||||
}
|
||||
|
||||
void ide_get_bs(BlockDriverState *bs[], BusState *qbus)
|
||||
{
|
||||
IDEBus *bus = DO_UPCAST(IDEBus, qbus, qbus);
|
||||
bs[0] = bus->master ? bus->master->dinfo->bdrv : NULL;
|
||||
bs[1] = bus->slave ? bus->slave->dinfo->bdrv : NULL;
|
||||
}
|
||||
|
||||
/* --------------------------------- */
|
||||
|
||||
typedef struct IDEDrive {
|
||||
@@ -99,7 +106,7 @@ typedef struct IDEDrive {
|
||||
static int ide_drive_initfn(IDEDevice *dev)
|
||||
{
|
||||
IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
|
||||
ide_init_drive(bus->ifs + dev->unit, dev->dinfo);
|
||||
ide_init_drive(bus->ifs + dev->unit, dev->dinfo, dev->version);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -110,6 +117,7 @@ static IDEDeviceInfo ide_drive_info = {
|
||||
.qdev.props = (Property[]) {
|
||||
DEFINE_PROP_UINT32("unit", IDEDrive, dev.unit, -1),
|
||||
DEFINE_PROP_DRIVE("drive", IDEDrive, dev.dinfo),
|
||||
DEFINE_PROP_STRING("ver", IDEDrive, dev.version),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
}
|
||||
};
|
||||
|
||||
+5
-89
@@ -40,8 +40,8 @@ do { fprintf(stderr, "lan9118: error: " fmt , ## __VA_ARGS__);} while (0)
|
||||
#define CSR_TX_FIFO_INF 0x80
|
||||
#define CSR_PMT_CTRL 0x84
|
||||
#define CSR_GPIO_CFG 0x88
|
||||
#define CSR_GPT_CFG 0x8c
|
||||
#define CSR_GPT_CNT 0x90
|
||||
#define CSR_GPT_CFG 0x8c /* TODO */
|
||||
#define CSR_GPT_CNT 0x90 /* TODO */
|
||||
#define CSR_WORD_SWAP 0x98
|
||||
#define CSR_FREE_RUN 0x9c
|
||||
#define CSR_RX_DROP 0xa0
|
||||
@@ -52,7 +52,6 @@ do { fprintf(stderr, "lan9118: error: " fmt , ## __VA_ARGS__);} while (0)
|
||||
#define CSR_E2P_DATA 0xb4
|
||||
|
||||
/* IRQ_CFG */
|
||||
#define IRQ_INT 0x00001000
|
||||
#define IRQ_EN 0x00000100
|
||||
#define IRQ_POL 0x00000010
|
||||
#define IRQ_TYPE 0x00000001
|
||||
@@ -118,16 +117,6 @@ do { fprintf(stderr, "lan9118: error: " fmt , ## __VA_ARGS__);} while (0)
|
||||
#define MAC_CR_RXEN 0x00000004
|
||||
#define MAC_CR_RESERVED 0x7f404213
|
||||
|
||||
#define PHY_INT_ENERGYON 0x80
|
||||
#define PHY_INT_AUTONEG_COMPLETE 0x40
|
||||
#define PHY_INT_FAULT 0x20
|
||||
#define PHY_INT_DOWN 0x10
|
||||
#define PHY_INT_AUTONEG_LP 0x08
|
||||
#define PHY_INT_PARFAULT 0x04
|
||||
#define PHY_INT_AUTONEG_PAGE 0x02
|
||||
|
||||
#define GPT_TIMER_EN 0x20000000
|
||||
|
||||
enum tx_state {
|
||||
TX_IDLE,
|
||||
TX_B,
|
||||
@@ -152,7 +141,6 @@ typedef struct {
|
||||
NICConf conf;
|
||||
qemu_irq irq;
|
||||
int mmio_index;
|
||||
ptimer_state *timer;
|
||||
|
||||
uint32_t irq_cfg;
|
||||
uint32_t int_sts;
|
||||
@@ -163,7 +151,6 @@ typedef struct {
|
||||
uint32_t hw_cfg;
|
||||
uint32_t pmt_ctrl;
|
||||
uint32_t gpio_cfg;
|
||||
uint32_t gpt_cfg;
|
||||
uint32_t word_swap;
|
||||
uint32_t free_timer_start;
|
||||
uint32_t mac_cmd;
|
||||
@@ -182,8 +169,6 @@ typedef struct {
|
||||
uint32_t phy_status;
|
||||
uint32_t phy_control;
|
||||
uint32_t phy_advertise;
|
||||
uint32_t phy_int;
|
||||
uint32_t phy_int_mask;
|
||||
|
||||
int eeprom_writable;
|
||||
uint8_t eeprom[8];
|
||||
@@ -219,11 +204,6 @@ static void lan9118_update(lan9118_state *s)
|
||||
|
||||
/* TODO: Implement FIFO level IRQs. */
|
||||
level = (s->int_sts & s->int_en) != 0;
|
||||
if (level) {
|
||||
s->irq_cfg |= IRQ_INT;
|
||||
} else {
|
||||
s->irq_cfg &= ~IRQ_INT;
|
||||
}
|
||||
if ((s->irq_cfg & IRQ_EN) == 0) {
|
||||
level = 0;
|
||||
}
|
||||
@@ -251,28 +231,14 @@ static void lan9118_reload_eeprom(lan9118_state *s)
|
||||
lan9118_mac_changed(s);
|
||||
}
|
||||
|
||||
static void phy_update_irq(lan9118_state *s)
|
||||
{
|
||||
if (s->phy_int & s->phy_int_mask) {
|
||||
s->int_sts |= PHY_INT;
|
||||
} else {
|
||||
s->int_sts &= ~PHY_INT;
|
||||
}
|
||||
lan9118_update(s);
|
||||
}
|
||||
|
||||
static void phy_update_link(lan9118_state *s)
|
||||
{
|
||||
/* Autonegotiation status mirrors link status. */
|
||||
if (s->nic->nc.link_down) {
|
||||
s->phy_status &= ~0x0024;
|
||||
s->phy_int |= PHY_INT_DOWN;
|
||||
} else {
|
||||
s->phy_status |= 0x0024;
|
||||
s->phy_int |= PHY_INT_ENERGYON;
|
||||
s->phy_int |= PHY_INT_AUTONEG_COMPLETE;
|
||||
}
|
||||
phy_update_irq(s);
|
||||
}
|
||||
|
||||
static void lan9118_set_link(VLANClientState *nc)
|
||||
@@ -282,11 +248,9 @@ static void lan9118_set_link(VLANClientState *nc)
|
||||
|
||||
static void phy_reset(lan9118_state *s)
|
||||
{
|
||||
s->phy_status = 0x7809;
|
||||
s->phy_status = 0x7805;
|
||||
s->phy_control = 0x3000;
|
||||
s->phy_advertise = 0x01e1;
|
||||
s->phy_int_mask = 0;
|
||||
s->phy_int = 0;
|
||||
phy_update_link(s);
|
||||
}
|
||||
|
||||
@@ -328,10 +292,6 @@ static void lan9118_reset(DeviceState *d)
|
||||
s->e2p_data = 0;
|
||||
s->free_timer_start = qemu_get_clock(vm_clock) / 40;
|
||||
|
||||
ptimer_stop(s->timer);
|
||||
ptimer_set_count(s->timer, 0xffff);
|
||||
s->gpt_cfg = 0xffff;
|
||||
|
||||
s->mac_cr = MAC_CR_PRMS;
|
||||
s->mac_hashh = 0;
|
||||
s->mac_hashl = 0;
|
||||
@@ -680,8 +640,6 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val)
|
||||
|
||||
static uint32_t do_phy_read(lan9118_state *s, int reg)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
switch (reg) {
|
||||
case 0: /* Basic Control */
|
||||
return s->phy_control;
|
||||
@@ -698,13 +656,6 @@ static uint32_t do_phy_read(lan9118_state *s, int reg)
|
||||
case 6: /* Auto-neg Expansion */
|
||||
return 1;
|
||||
/* TODO 17, 18, 27, 29, 30, 31 */
|
||||
case 29: /* Interrupt source. */
|
||||
val = s->phy_int;
|
||||
s->phy_int = 0;
|
||||
phy_update_irq(s);
|
||||
return val;
|
||||
case 30: /* Interrupt mask */
|
||||
return s->phy_int_mask;
|
||||
default:
|
||||
BADF("PHY read reg %d\n", reg);
|
||||
return 0;
|
||||
@@ -728,11 +679,7 @@ static void do_phy_write(lan9118_state *s, int reg, uint32_t val)
|
||||
case 4: /* Auto-neg advertisment */
|
||||
s->phy_advertise = (val & 0x2d7f) | 0x80;
|
||||
break;
|
||||
/* TODO 17, 18, 27, 31 */
|
||||
case 30: /* Interrupt mask */
|
||||
s->phy_int_mask = val & 0xff;
|
||||
phy_update_irq(s);
|
||||
break;
|
||||
/* TODO 17, 18, 27, 29, 30, 31 */
|
||||
default:
|
||||
BADF("PHY write reg %d = 0x%04x\n", reg, val);
|
||||
}
|
||||
@@ -873,15 +820,6 @@ static void lan9118_eeprom_cmd(lan9118_state *s, int cmd, int addr)
|
||||
}
|
||||
}
|
||||
|
||||
static void lan9118_tick(void *opaque)
|
||||
{
|
||||
lan9118_state *s = (lan9118_state *)opaque;
|
||||
if (s->int_en & GPT_INT) {
|
||||
s->int_sts |= GPT_INT;
|
||||
}
|
||||
lan9118_update(s);
|
||||
}
|
||||
|
||||
static void lan9118_writel(void *opaque, target_phys_addr_t offset,
|
||||
uint32_t val)
|
||||
{
|
||||
@@ -897,7 +835,7 @@ static void lan9118_writel(void *opaque, target_phys_addr_t offset,
|
||||
switch (offset) {
|
||||
case CSR_IRQ_CFG:
|
||||
/* TODO: Implement interrupt deassertion intervals. */
|
||||
s->irq_cfg = (s->irq_cfg & IRQ_INT) | (val & IRQ_EN);
|
||||
s->irq_cfg = (val & IRQ_EN);
|
||||
break;
|
||||
case CSR_INT_STS:
|
||||
s->int_sts &= ~val;
|
||||
@@ -967,18 +905,6 @@ static void lan9118_writel(void *opaque, target_phys_addr_t offset,
|
||||
/* Probably just enabling LEDs. */
|
||||
s->gpio_cfg = val & 0x7777071f;
|
||||
break;
|
||||
case CSR_GPT_CFG:
|
||||
if ((s->gpt_cfg ^ val) & GPT_TIMER_EN) {
|
||||
if (val & GPT_TIMER_EN) {
|
||||
ptimer_set_count(s->timer, val & 0xffff);
|
||||
ptimer_run(s->timer, 0);
|
||||
} else {
|
||||
ptimer_stop(s->timer);
|
||||
ptimer_set_count(s->timer, 0xffff);
|
||||
}
|
||||
}
|
||||
s->gpt_cfg = val & (GPT_TIMER_EN | 0xffff);
|
||||
break;
|
||||
case CSR_WORD_SWAP:
|
||||
/* Ignored because we're in 32-bit mode. */
|
||||
s->word_swap = val;
|
||||
@@ -1062,10 +988,6 @@ static uint32_t lan9118_readl(void *opaque, target_phys_addr_t offset)
|
||||
return s->pmt_ctrl;
|
||||
case CSR_GPIO_CFG:
|
||||
return s->gpio_cfg;
|
||||
case CSR_GPT_CFG:
|
||||
return s->gpt_cfg;
|
||||
case CSR_GPT_CNT:
|
||||
return ptimer_get_count(s->timer);
|
||||
case CSR_WORD_SWAP:
|
||||
return s->word_swap;
|
||||
case CSR_FREE_RUN:
|
||||
@@ -1119,7 +1041,6 @@ static NetClientInfo net_lan9118_info = {
|
||||
static int lan9118_init1(SysBusDevice *dev)
|
||||
{
|
||||
lan9118_state *s = FROM_SYSBUS(lan9118_state, dev);
|
||||
QEMUBH *bh;
|
||||
int i;
|
||||
|
||||
s->mmio_index = cpu_register_io_memory(lan9118_readfn,
|
||||
@@ -1138,11 +1059,6 @@ static int lan9118_init1(SysBusDevice *dev)
|
||||
s->pmt_ctrl = 1;
|
||||
s->txp = &s->tx_packet;
|
||||
|
||||
bh = qemu_bh_new(lan9118_tick, s);
|
||||
s->timer = ptimer_init(bh);
|
||||
ptimer_set_freq(s->timer, 10000);
|
||||
ptimer_set_limit(s->timer, 0xffff, 1);
|
||||
|
||||
/* ??? Save/restore. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
+26
-23
@@ -535,6 +535,7 @@ struct Rom {
|
||||
QTAILQ_ENTRY(Rom) next;
|
||||
};
|
||||
|
||||
static FWCfgState *fw_cfg;
|
||||
static QTAILQ_HEAD(, Rom) roms = QTAILQ_HEAD_INITIALIZER(roms);
|
||||
int rom_enable_driver_roms;
|
||||
|
||||
@@ -556,7 +557,7 @@ static void rom_insert(Rom *rom)
|
||||
QTAILQ_INSERT_TAIL(&roms, rom, next);
|
||||
}
|
||||
|
||||
int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
|
||||
int rom_add_file(const char *file, const char *fw_dir,
|
||||
target_phys_addr_t addr)
|
||||
{
|
||||
Rom *rom;
|
||||
@@ -576,8 +577,10 @@ int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
|
||||
goto err;
|
||||
}
|
||||
|
||||
rom->fw_dir = fw_dir ? qemu_strdup(fw_dir) : NULL;
|
||||
rom->fw_file = fw_file ? qemu_strdup(fw_file) : NULL;
|
||||
if (fw_dir) {
|
||||
rom->fw_dir = qemu_strdup(fw_dir);
|
||||
rom->fw_file = qemu_strdup(file);
|
||||
}
|
||||
rom->addr = addr;
|
||||
rom->romsize = lseek(fd, 0, SEEK_END);
|
||||
rom->data = qemu_mallocz(rom->romsize);
|
||||
@@ -590,6 +593,8 @@ int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
|
||||
}
|
||||
close(fd);
|
||||
rom_insert(rom);
|
||||
if (rom->fw_file && fw_cfg)
|
||||
fw_cfg_add_file(fw_cfg, rom->fw_dir, rom->fw_file, rom->data, rom->romsize);
|
||||
return 0;
|
||||
|
||||
err:
|
||||
@@ -621,14 +626,14 @@ int rom_add_vga(const char *file)
|
||||
{
|
||||
if (!rom_enable_driver_roms)
|
||||
return 0;
|
||||
return rom_add_file(file, "vgaroms", file, 0);
|
||||
return rom_add_file(file, "vgaroms", 0);
|
||||
}
|
||||
|
||||
int rom_add_option(const char *file)
|
||||
{
|
||||
if (!rom_enable_driver_roms)
|
||||
return 0;
|
||||
return rom_add_file(file, "genroms", file, 0);
|
||||
return rom_add_file(file, "genroms", 0);
|
||||
}
|
||||
|
||||
static void rom_reset(void *unused)
|
||||
@@ -639,8 +644,9 @@ static void rom_reset(void *unused)
|
||||
if (rom->fw_file) {
|
||||
continue;
|
||||
}
|
||||
if (rom->data == NULL)
|
||||
if (rom->data == NULL) {
|
||||
continue;
|
||||
}
|
||||
cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
|
||||
if (rom->isrom) {
|
||||
/* rom needs to be written only once */
|
||||
@@ -678,16 +684,9 @@ int rom_load_all(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rom_load_fw(void *fw_cfg)
|
||||
void rom_set_fw(void *f)
|
||||
{
|
||||
Rom *rom;
|
||||
|
||||
QTAILQ_FOREACH(rom, &roms, next) {
|
||||
if (!rom->fw_file)
|
||||
continue;
|
||||
fw_cfg_add_file(fw_cfg, rom->fw_dir, rom->fw_file, rom->data, rom->romsize);
|
||||
}
|
||||
return 0;
|
||||
fw_cfg = f;
|
||||
}
|
||||
|
||||
static Rom *find_rom(target_phys_addr_t addr)
|
||||
@@ -698,10 +697,12 @@ static Rom *find_rom(target_phys_addr_t addr)
|
||||
if (rom->fw_file) {
|
||||
continue;
|
||||
}
|
||||
if (rom->addr > addr)
|
||||
if (rom->addr > addr) {
|
||||
continue;
|
||||
if (rom->addr + rom->romsize < addr)
|
||||
}
|
||||
if (rom->addr + rom->romsize < addr) {
|
||||
continue;
|
||||
}
|
||||
return rom;
|
||||
}
|
||||
return NULL;
|
||||
@@ -723,12 +724,15 @@ int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size)
|
||||
if (rom->fw_file) {
|
||||
continue;
|
||||
}
|
||||
if (rom->addr + rom->romsize < addr)
|
||||
if (rom->addr + rom->romsize < addr) {
|
||||
continue;
|
||||
if (rom->addr > end)
|
||||
}
|
||||
if (rom->addr > end) {
|
||||
break;
|
||||
if (!rom->data)
|
||||
}
|
||||
if (!rom->data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
d = dest + (rom->addr - addr);
|
||||
s = rom->data;
|
||||
@@ -771,10 +775,9 @@ void do_info_roms(Monitor *mon)
|
||||
rom->isrom ? "rom" : "ram",
|
||||
rom->name);
|
||||
} else {
|
||||
monitor_printf(mon, "fw=%s%s%s"
|
||||
monitor_printf(mon, "fw=%s/%s"
|
||||
" size=0x%06zx name=\"%s\" \n",
|
||||
rom->fw_dir ? rom->fw_dir : "",
|
||||
rom->fw_dir ? "/" : "",
|
||||
rom->fw_dir,
|
||||
rom->fw_file,
|
||||
rom->romsize,
|
||||
rom->name);
|
||||
|
||||
+4
-3
@@ -19,18 +19,19 @@ void pstrcpy_targphys(const char *name,
|
||||
target_phys_addr_t dest, int buf_size,
|
||||
const char *source);
|
||||
|
||||
int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
|
||||
|
||||
int rom_add_file(const char *file, const char *fw_dir,
|
||||
target_phys_addr_t addr);
|
||||
int rom_add_blob(const char *name, const void *blob, size_t len,
|
||||
target_phys_addr_t addr);
|
||||
int rom_load_all(void);
|
||||
int rom_load_fw(void *fw_cfg);
|
||||
void rom_set_fw(void *f);
|
||||
int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size);
|
||||
void *rom_ptr(target_phys_addr_t addr);
|
||||
void do_info_roms(Monitor *mon);
|
||||
|
||||
#define rom_add_file_fixed(_f, _a) \
|
||||
rom_add_file(_f, NULL, NULL, _a)
|
||||
rom_add_file(_f, NULL, _a)
|
||||
#define rom_add_blob_fixed(_f, _b, _l, _a) \
|
||||
rom_add_blob(_f, _b, _l, _a)
|
||||
|
||||
|
||||
+89
-99
@@ -173,11 +173,15 @@ do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__);} while (0)
|
||||
/* Flag set if this is a tagged command. */
|
||||
#define LSI_TAG_VALID (1 << 16)
|
||||
|
||||
typedef struct {
|
||||
typedef struct lsi_request {
|
||||
uint32_t tag;
|
||||
SCSIDevice *dev;
|
||||
uint32_t dma_len;
|
||||
uint8_t *dma_buf;
|
||||
uint32_t pending;
|
||||
int out;
|
||||
} lsi_queue;
|
||||
QTAILQ_ENTRY(lsi_request) next;
|
||||
} lsi_request;
|
||||
|
||||
typedef struct {
|
||||
PCIDevice dev;
|
||||
@@ -198,16 +202,13 @@ typedef struct {
|
||||
* 3 if a DMA operation is in progress. */
|
||||
int waiting;
|
||||
SCSIBus bus;
|
||||
SCSIDevice *current_dev;
|
||||
SCSIDevice *select_dev;
|
||||
int current_lun;
|
||||
/* The tag is a combination of the device ID and the SCSI tag. */
|
||||
uint32_t current_tag;
|
||||
uint32_t current_dma_len;
|
||||
uint32_t select_tag;
|
||||
int command_complete;
|
||||
uint8_t *dma_buf;
|
||||
lsi_queue *queue;
|
||||
int queue_len;
|
||||
int active_commands;
|
||||
QTAILQ_HEAD(, lsi_request) queue;
|
||||
lsi_request *current;
|
||||
|
||||
uint32_t dsa;
|
||||
uint32_t temp;
|
||||
@@ -370,7 +371,7 @@ static int lsi_dma_64bit(LSIState *s)
|
||||
static uint8_t lsi_reg_readb(LSIState *s, int offset);
|
||||
static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val);
|
||||
static void lsi_execute_script(LSIState *s);
|
||||
static void lsi_reselect(LSIState *s, uint32_t tag);
|
||||
static void lsi_reselect(LSIState *s, lsi_request *p);
|
||||
|
||||
static inline uint32_t read_dword(LSIState *s, uint32_t addr)
|
||||
{
|
||||
@@ -391,9 +392,9 @@ static void lsi_stop_script(LSIState *s)
|
||||
|
||||
static void lsi_update_irq(LSIState *s)
|
||||
{
|
||||
int i;
|
||||
int level;
|
||||
static int last_level;
|
||||
lsi_request *p;
|
||||
|
||||
/* It's unclear whether the DIP/SIP bits should be cleared when the
|
||||
Interrupt Status Registers are cleared or when istat0 is read.
|
||||
@@ -427,9 +428,9 @@ static void lsi_update_irq(LSIState *s)
|
||||
if (!level && lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON)) {
|
||||
DPRINTF("Handled IRQs & disconnected, looking for pending "
|
||||
"processes\n");
|
||||
for (i = 0; i < s->active_commands; i++) {
|
||||
if (s->queue[i].pending) {
|
||||
lsi_reselect(s, s->queue[i].tag);
|
||||
QTAILQ_FOREACH(p, &s->queue, next) {
|
||||
if (p->pending) {
|
||||
lsi_reselect(s, p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -508,15 +509,16 @@ static void lsi_do_dma(LSIState *s, int out)
|
||||
uint32_t count;
|
||||
target_phys_addr_t addr;
|
||||
|
||||
if (!s->current_dma_len) {
|
||||
assert(s->current);
|
||||
if (!s->current->dma_len) {
|
||||
/* Wait until data is available. */
|
||||
DPRINTF("DMA no data available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
count = s->dbc;
|
||||
if (count > s->current_dma_len)
|
||||
count = s->current_dma_len;
|
||||
if (count > s->current->dma_len)
|
||||
count = s->current->dma_len;
|
||||
|
||||
addr = s->dnad;
|
||||
/* both 40 and Table Indirect 64-bit DMAs store upper bits in dnad64 */
|
||||
@@ -532,29 +534,29 @@ static void lsi_do_dma(LSIState *s, int out)
|
||||
s->dnad += count;
|
||||
s->dbc -= count;
|
||||
|
||||
if (s->dma_buf == NULL) {
|
||||
s->dma_buf = s->current_dev->info->get_buf(s->current_dev,
|
||||
s->current_tag);
|
||||
if (s->current->dma_buf == NULL) {
|
||||
s->current->dma_buf = s->current->dev->info->get_buf(s->current->dev,
|
||||
s->current->tag);
|
||||
}
|
||||
|
||||
/* ??? Set SFBR to first data byte. */
|
||||
if (out) {
|
||||
cpu_physical_memory_read(addr, s->dma_buf, count);
|
||||
cpu_physical_memory_read(addr, s->current->dma_buf, count);
|
||||
} else {
|
||||
cpu_physical_memory_write(addr, s->dma_buf, count);
|
||||
cpu_physical_memory_write(addr, s->current->dma_buf, count);
|
||||
}
|
||||
s->current_dma_len -= count;
|
||||
if (s->current_dma_len == 0) {
|
||||
s->dma_buf = NULL;
|
||||
s->current->dma_len -= count;
|
||||
if (s->current->dma_len == 0) {
|
||||
s->current->dma_buf = NULL;
|
||||
if (out) {
|
||||
/* Write the data. */
|
||||
s->current_dev->info->write_data(s->current_dev, s->current_tag);
|
||||
s->current->dev->info->write_data(s->current->dev, s->current->tag);
|
||||
} else {
|
||||
/* Request any remaining data. */
|
||||
s->current_dev->info->read_data(s->current_dev, s->current_tag);
|
||||
s->current->dev->info->read_data(s->current->dev, s->current->tag);
|
||||
}
|
||||
} else {
|
||||
s->dma_buf += count;
|
||||
s->current->dma_buf += count;
|
||||
lsi_resume_script(s);
|
||||
}
|
||||
}
|
||||
@@ -563,15 +565,14 @@ static void lsi_do_dma(LSIState *s, int out)
|
||||
/* Add a command to the queue. */
|
||||
static void lsi_queue_command(LSIState *s)
|
||||
{
|
||||
lsi_queue *p;
|
||||
lsi_request *p = s->current;
|
||||
|
||||
DPRINTF("Queueing tag=0x%x\n", s->current_tag);
|
||||
if (s->queue_len == s->active_commands) {
|
||||
s->queue_len++;
|
||||
s->queue = qemu_realloc(s->queue, s->queue_len * sizeof(lsi_queue));
|
||||
}
|
||||
p = &s->queue[s->active_commands++];
|
||||
p->tag = s->current_tag;
|
||||
assert(s->current != NULL);
|
||||
assert(s->current->dma_len == 0);
|
||||
QTAILQ_INSERT_TAIL(&s->queue, s->current, next);
|
||||
s->current = NULL;
|
||||
|
||||
p->pending = 0;
|
||||
p->out = (s->sstat1 & PHASE_MASK) == PHASE_DO;
|
||||
}
|
||||
@@ -588,45 +589,29 @@ static void lsi_add_msg_byte(LSIState *s, uint8_t data)
|
||||
}
|
||||
|
||||
/* Perform reselection to continue a command. */
|
||||
static void lsi_reselect(LSIState *s, uint32_t tag)
|
||||
static void lsi_reselect(LSIState *s, lsi_request *p)
|
||||
{
|
||||
lsi_queue *p;
|
||||
int n;
|
||||
int id;
|
||||
|
||||
p = NULL;
|
||||
for (n = 0; n < s->active_commands; n++) {
|
||||
p = &s->queue[n];
|
||||
if (p->tag == tag)
|
||||
break;
|
||||
}
|
||||
if (n == s->active_commands) {
|
||||
BADF("Reselected non-existant command tag=0x%x\n", tag);
|
||||
return;
|
||||
}
|
||||
id = (tag >> 8) & 0xf;
|
||||
assert(s->current == NULL);
|
||||
QTAILQ_REMOVE(&s->queue, p, next);
|
||||
s->current = p;
|
||||
|
||||
id = (p->tag >> 8) & 0xf;
|
||||
s->ssid = id | 0x80;
|
||||
/* LSI53C700 Family Compatibility, see LSI53C895A 4-73 */
|
||||
if (!(s->dcntl & LSI_DCNTL_COM)) {
|
||||
if (!s->dcntl & LSI_DCNTL_COM) {
|
||||
s->sfbr = 1 << (id & 0x7);
|
||||
}
|
||||
DPRINTF("Reselected target %d\n", id);
|
||||
s->current_dev = s->bus.devs[id];
|
||||
s->current_tag = tag;
|
||||
s->scntl1 |= LSI_SCNTL1_CON;
|
||||
lsi_set_phase(s, PHASE_MI);
|
||||
s->msg_action = p->out ? 2 : 3;
|
||||
s->current_dma_len = p->pending;
|
||||
s->dma_buf = NULL;
|
||||
s->current->dma_len = p->pending;
|
||||
lsi_add_msg_byte(s, 0x80);
|
||||
if (s->current_tag & LSI_TAG_VALID) {
|
||||
if (s->current->tag & LSI_TAG_VALID) {
|
||||
lsi_add_msg_byte(s, 0x20);
|
||||
lsi_add_msg_byte(s, tag & 0xff);
|
||||
}
|
||||
|
||||
s->active_commands--;
|
||||
if (n != s->active_commands) {
|
||||
s->queue[n] = s->queue[s->active_commands];
|
||||
lsi_add_msg_byte(s, p->tag & 0xff);
|
||||
}
|
||||
|
||||
if (lsi_irq_on_rsl(s)) {
|
||||
@@ -638,10 +623,9 @@ static void lsi_reselect(LSIState *s, uint32_t tag)
|
||||
the device was reselected, nonzero if the IO is deferred. */
|
||||
static int lsi_queue_tag(LSIState *s, uint32_t tag, uint32_t arg)
|
||||
{
|
||||
lsi_queue *p;
|
||||
int i;
|
||||
for (i = 0; i < s->active_commands; i++) {
|
||||
p = &s->queue[i];
|
||||
lsi_request *p;
|
||||
|
||||
QTAILQ_FOREACH(p, &s->queue, next) {
|
||||
if (p->tag == tag) {
|
||||
if (p->pending) {
|
||||
BADF("Multiple IO pending for tag %d\n", tag);
|
||||
@@ -656,10 +640,10 @@ static int lsi_queue_tag(LSIState *s, uint32_t tag, uint32_t arg)
|
||||
(lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON) &&
|
||||
!(s->istat0 & (LSI_ISTAT0_SIP | LSI_ISTAT0_DIP)))) {
|
||||
/* Reselect device. */
|
||||
lsi_reselect(s, tag);
|
||||
lsi_reselect(s, p);
|
||||
return 0;
|
||||
} else {
|
||||
DPRINTF("Queueing IO tag=0x%x\n", tag);
|
||||
DPRINTF("Queueing IO tag=0x%x\n", tag);
|
||||
p->pending = arg;
|
||||
return 1;
|
||||
}
|
||||
@@ -687,11 +671,15 @@ static void lsi_command_complete(SCSIBus *bus, int reason, uint32_t tag,
|
||||
} else {
|
||||
lsi_set_phase(s, PHASE_ST);
|
||||
}
|
||||
|
||||
qemu_free(s->current);
|
||||
s->current = NULL;
|
||||
|
||||
lsi_resume_script(s);
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->waiting == 1 || tag != s->current_tag ||
|
||||
if (s->waiting == 1 || !s->current || tag != s->current->tag ||
|
||||
(lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) {
|
||||
if (lsi_queue_tag(s, tag, arg))
|
||||
return;
|
||||
@@ -699,7 +687,7 @@ static void lsi_command_complete(SCSIBus *bus, int reason, uint32_t tag,
|
||||
|
||||
/* host adapter (re)connected */
|
||||
DPRINTF("Data ready tag=0x%x len=%d\n", tag, arg);
|
||||
s->current_dma_len = arg;
|
||||
s->current->dma_len = arg;
|
||||
s->command_complete = 1;
|
||||
if (!s->waiting)
|
||||
return;
|
||||
@@ -721,14 +709,20 @@ static void lsi_do_command(LSIState *s)
|
||||
cpu_physical_memory_read(s->dnad, buf, s->dbc);
|
||||
s->sfbr = buf[0];
|
||||
s->command_complete = 0;
|
||||
n = s->current_dev->info->send_command(s->current_dev, s->current_tag, buf,
|
||||
s->current_lun);
|
||||
|
||||
assert(s->current == NULL);
|
||||
s->current = qemu_mallocz(sizeof(lsi_request));
|
||||
s->current->tag = s->select_tag;
|
||||
s->current->dev = s->select_dev;
|
||||
|
||||
n = s->current->dev->info->send_command(s->current->dev, s->current->tag, buf,
|
||||
s->current_lun);
|
||||
if (n > 0) {
|
||||
lsi_set_phase(s, PHASE_DI);
|
||||
s->current_dev->info->read_data(s->current_dev, s->current_tag);
|
||||
s->current->dev->info->read_data(s->current->dev, s->current->tag);
|
||||
} else if (n < 0) {
|
||||
lsi_set_phase(s, PHASE_DO);
|
||||
s->current_dev->info->write_data(s->current_dev, s->current_tag);
|
||||
s->current->dev->info->write_data(s->current->dev, s->current->tag);
|
||||
}
|
||||
|
||||
if (!s->command_complete) {
|
||||
@@ -851,16 +845,16 @@ static void lsi_do_msgout(LSIState *s)
|
||||
}
|
||||
break;
|
||||
case 0x20: /* SIMPLE queue */
|
||||
s->current_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
|
||||
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
|
||||
DPRINTF("SIMPLE queue tag=0x%x\n", s->current_tag & 0xff);
|
||||
break;
|
||||
case 0x21: /* HEAD of queue */
|
||||
BADF("HEAD queue not implemented\n");
|
||||
s->current_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
|
||||
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
|
||||
break;
|
||||
case 0x22: /* ORDERED queue */
|
||||
BADF("ORDERED queue not implemented\n");
|
||||
s->current_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
|
||||
s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
|
||||
break;
|
||||
default:
|
||||
if ((msg & 0x80) == 0) {
|
||||
@@ -905,17 +899,17 @@ static void lsi_memcpy(LSIState *s, uint32_t dest, uint32_t src, int count)
|
||||
|
||||
static void lsi_wait_reselect(LSIState *s)
|
||||
{
|
||||
int i;
|
||||
lsi_request *p;
|
||||
|
||||
DPRINTF("Wait Reselect\n");
|
||||
if (s->current_dma_len)
|
||||
BADF("Reselect with pending DMA\n");
|
||||
for (i = 0; i < s->active_commands; i++) {
|
||||
if (s->queue[i].pending) {
|
||||
lsi_reselect(s, s->queue[i].tag);
|
||||
|
||||
QTAILQ_FOREACH(p, &s->queue, next) {
|
||||
if (p->pending) {
|
||||
lsi_reselect(s, p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s->current_dma_len == 0) {
|
||||
if (s->current == NULL) {
|
||||
s->waiting = 1;
|
||||
}
|
||||
}
|
||||
@@ -1093,8 +1087,8 @@ again:
|
||||
/* ??? Linux drivers compain when this is set. Maybe
|
||||
it only applies in low-level mode (unimplemented).
|
||||
lsi_script_scsi_interrupt(s, LSI_SIST0_CMP, 0); */
|
||||
s->current_dev = s->bus.devs[id];
|
||||
s->current_tag = id << 8;
|
||||
s->select_dev = s->bus.devs[id];
|
||||
s->select_tag = id << 8;
|
||||
s->scntl1 |= LSI_SCNTL1_CON;
|
||||
if (insn & (1 << 3)) {
|
||||
s->socl |= LSI_SOCL_ATN;
|
||||
@@ -2006,9 +2000,11 @@ static void lsi_pre_save(void *opaque)
|
||||
{
|
||||
LSIState *s = opaque;
|
||||
|
||||
assert(s->dma_buf == NULL);
|
||||
assert(s->current_dma_len == 0);
|
||||
assert(s->active_commands == 0);
|
||||
if (s->current) {
|
||||
assert(s->current->dma_buf == NULL);
|
||||
assert(s->current->dma_len == 0);
|
||||
}
|
||||
assert(QTAILQ_EMPTY(&s->queue));
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_lsi_scsi = {
|
||||
@@ -2101,8 +2097,6 @@ static int lsi_scsi_uninit(PCIDevice *d)
|
||||
cpu_unregister_io_memory(s->mmio_io_addr);
|
||||
cpu_unregister_io_memory(s->ram_io_addr);
|
||||
|
||||
qemu_free(s->queue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2120,29 +2114,25 @@ static int lsi_scsi_init(PCIDevice *dev)
|
||||
/* PCI base class code */
|
||||
pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_SCSI);
|
||||
/* PCI subsystem ID */
|
||||
pci_conf[PCI_SUBSYSTEM_ID] = 0x00;
|
||||
pci_conf[PCI_SUBSYSTEM_ID + 1] = 0x10;
|
||||
pci_conf[0x2e] = 0x00;
|
||||
pci_conf[0x2f] = 0x10;
|
||||
/* PCI latency timer = 255 */
|
||||
pci_conf[PCI_LATENCY_TIMER] = 0xff;
|
||||
/* TODO: RST# value should be 0 */
|
||||
pci_conf[0x0d] = 0xff;
|
||||
/* Interrupt pin 1 */
|
||||
pci_conf[PCI_INTERRUPT_PIN] = 0x01;
|
||||
pci_conf[0x3d] = 0x01;
|
||||
|
||||
s->mmio_io_addr = cpu_register_io_memory(lsi_mmio_readfn,
|
||||
lsi_mmio_writefn, s);
|
||||
s->ram_io_addr = cpu_register_io_memory(lsi_ram_readfn,
|
||||
lsi_ram_writefn, s);
|
||||
|
||||
/* TODO: use dev and get rid of cast below */
|
||||
pci_register_bar((struct PCIDevice *)s, 0, 256,
|
||||
PCI_BASE_ADDRESS_SPACE_IO, lsi_io_mapfunc);
|
||||
pci_register_bar((struct PCIDevice *)s, 1, 0x400,
|
||||
PCI_BASE_ADDRESS_SPACE_MEMORY, lsi_mmio_mapfunc);
|
||||
pci_register_bar((struct PCIDevice *)s, 2, 0x2000,
|
||||
PCI_BASE_ADDRESS_SPACE_MEMORY, lsi_ram_mapfunc);
|
||||
s->queue = qemu_malloc(sizeof(lsi_queue));
|
||||
s->queue_len = 1;
|
||||
s->active_commands = 0;
|
||||
QTAILQ_INIT(&s->queue);
|
||||
|
||||
lsi_soft_reset(s);
|
||||
|
||||
|
||||
+39
-46
@@ -184,19 +184,19 @@ static void dump_dbdma_cmd(dbdma_cmd *cmd)
|
||||
static void dbdma_cmdptr_load(DBDMA_channel *ch)
|
||||
{
|
||||
DBDMA_DPRINTF("dbdma_cmdptr_load 0x%08x\n",
|
||||
ch->regs[DBDMA_CMDPTR_LO]);
|
||||
cpu_physical_memory_read(ch->regs[DBDMA_CMDPTR_LO],
|
||||
be32_to_cpu(ch->regs[DBDMA_CMDPTR_LO]));
|
||||
cpu_physical_memory_read(be32_to_cpu(ch->regs[DBDMA_CMDPTR_LO]),
|
||||
(uint8_t*)&ch->current, sizeof(dbdma_cmd));
|
||||
}
|
||||
|
||||
static void dbdma_cmdptr_save(DBDMA_channel *ch)
|
||||
{
|
||||
DBDMA_DPRINTF("dbdma_cmdptr_save 0x%08x\n",
|
||||
ch->regs[DBDMA_CMDPTR_LO]);
|
||||
be32_to_cpu(ch->regs[DBDMA_CMDPTR_LO]));
|
||||
DBDMA_DPRINTF("xfer_status 0x%08x res_count 0x%04x\n",
|
||||
le16_to_cpu(ch->current.xfer_status),
|
||||
le16_to_cpu(ch->current.res_count));
|
||||
cpu_physical_memory_write(ch->regs[DBDMA_CMDPTR_LO],
|
||||
cpu_physical_memory_write(be32_to_cpu(ch->regs[DBDMA_CMDPTR_LO]),
|
||||
(uint8_t*)&ch->current, sizeof(dbdma_cmd));
|
||||
}
|
||||
|
||||
@@ -204,8 +204,8 @@ static void kill_channel(DBDMA_channel *ch)
|
||||
{
|
||||
DBDMA_DPRINTF("kill_channel\n");
|
||||
|
||||
ch->regs[DBDMA_STATUS] |= DEAD;
|
||||
ch->regs[DBDMA_STATUS] &= ~ACTIVE;
|
||||
ch->regs[DBDMA_STATUS] |= cpu_to_be32(DEAD);
|
||||
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~ACTIVE);
|
||||
|
||||
qemu_irq_raise(ch->irq);
|
||||
}
|
||||
@@ -230,10 +230,10 @@ static void conditional_interrupt(DBDMA_channel *ch)
|
||||
return;
|
||||
}
|
||||
|
||||
status = ch->regs[DBDMA_STATUS] & DEVSTAT;
|
||||
status = be32_to_cpu(ch->regs[DBDMA_STATUS]) & DEVSTAT;
|
||||
|
||||
sel_mask = (ch->regs[DBDMA_INTR_SEL] >> 16) & 0x0f;
|
||||
sel_value = ch->regs[DBDMA_INTR_SEL] & 0x0f;
|
||||
sel_mask = (be32_to_cpu(ch->regs[DBDMA_INTR_SEL]) >> 16) & 0x0f;
|
||||
sel_value = be32_to_cpu(ch->regs[DBDMA_INTR_SEL]) & 0x0f;
|
||||
|
||||
cond = (status & sel_mask) == (sel_value & sel_mask);
|
||||
|
||||
@@ -268,10 +268,10 @@ static int conditional_wait(DBDMA_channel *ch)
|
||||
return 1;
|
||||
}
|
||||
|
||||
status = ch->regs[DBDMA_STATUS] & DEVSTAT;
|
||||
status = be32_to_cpu(ch->regs[DBDMA_STATUS]) & DEVSTAT;
|
||||
|
||||
sel_mask = (ch->regs[DBDMA_WAIT_SEL] >> 16) & 0x0f;
|
||||
sel_value = ch->regs[DBDMA_WAIT_SEL] & 0x0f;
|
||||
sel_mask = (be32_to_cpu(ch->regs[DBDMA_WAIT_SEL]) >> 16) & 0x0f;
|
||||
sel_value = be32_to_cpu(ch->regs[DBDMA_WAIT_SEL]) & 0x0f;
|
||||
|
||||
cond = (status & sel_mask) == (sel_value & sel_mask);
|
||||
|
||||
@@ -292,10 +292,10 @@ static void next(DBDMA_channel *ch)
|
||||
{
|
||||
uint32_t cp;
|
||||
|
||||
ch->regs[DBDMA_STATUS] &= ~BT;
|
||||
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~BT);
|
||||
|
||||
cp = ch->regs[DBDMA_CMDPTR_LO];
|
||||
ch->regs[DBDMA_CMDPTR_LO] = cp + sizeof(dbdma_cmd);
|
||||
cp = be32_to_cpu(ch->regs[DBDMA_CMDPTR_LO]);
|
||||
ch->regs[DBDMA_CMDPTR_LO] = cpu_to_be32(cp + sizeof(dbdma_cmd));
|
||||
dbdma_cmdptr_load(ch);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ static void branch(DBDMA_channel *ch)
|
||||
dbdma_cmd *current = &ch->current;
|
||||
|
||||
ch->regs[DBDMA_CMDPTR_LO] = current->cmd_dep;
|
||||
ch->regs[DBDMA_STATUS] |= BT;
|
||||
ch->regs[DBDMA_STATUS] |= cpu_to_be32(BT);
|
||||
dbdma_cmdptr_load(ch);
|
||||
}
|
||||
|
||||
@@ -331,10 +331,10 @@ static void conditional_branch(DBDMA_channel *ch)
|
||||
return;
|
||||
}
|
||||
|
||||
status = ch->regs[DBDMA_STATUS] & DEVSTAT;
|
||||
status = be32_to_cpu(ch->regs[DBDMA_STATUS]) & DEVSTAT;
|
||||
|
||||
sel_mask = (ch->regs[DBDMA_BRANCH_SEL] >> 16) & 0x0f;
|
||||
sel_value = ch->regs[DBDMA_BRANCH_SEL] & 0x0f;
|
||||
sel_mask = (be32_to_cpu(ch->regs[DBDMA_BRANCH_SEL]) >> 16) & 0x0f;
|
||||
sel_value = be32_to_cpu(ch->regs[DBDMA_BRANCH_SEL]) & 0x0f;
|
||||
|
||||
cond = (status & sel_mask) == (sel_value & sel_mask);
|
||||
|
||||
@@ -365,19 +365,19 @@ static void dbdma_end(DBDMA_io *io)
|
||||
if (conditional_wait(ch))
|
||||
goto wait;
|
||||
|
||||
current->xfer_status = cpu_to_le16(ch->regs[DBDMA_STATUS]);
|
||||
current->res_count = cpu_to_le16(io->len);
|
||||
current->xfer_status = cpu_to_le16(be32_to_cpu(ch->regs[DBDMA_STATUS]));
|
||||
current->res_count = cpu_to_le16(be32_to_cpu(io->len));
|
||||
dbdma_cmdptr_save(ch);
|
||||
if (io->is_last)
|
||||
ch->regs[DBDMA_STATUS] &= ~FLUSH;
|
||||
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~FLUSH);
|
||||
|
||||
conditional_interrupt(ch);
|
||||
conditional_branch(ch);
|
||||
|
||||
wait:
|
||||
ch->processing = 0;
|
||||
if ((ch->regs[DBDMA_STATUS] & RUN) &&
|
||||
(ch->regs[DBDMA_STATUS] & ACTIVE))
|
||||
if ((ch->regs[DBDMA_STATUS] & cpu_to_be32(RUN)) &&
|
||||
(ch->regs[DBDMA_STATUS] & cpu_to_be32(ACTIVE)))
|
||||
channel_run(ch);
|
||||
}
|
||||
|
||||
@@ -456,9 +456,9 @@ static void load_word(DBDMA_channel *ch, int key, uint32_t addr,
|
||||
if (conditional_wait(ch))
|
||||
goto wait;
|
||||
|
||||
current->xfer_status = cpu_to_le16(ch->regs[DBDMA_STATUS]);
|
||||
current->xfer_status = cpu_to_le16(be32_to_cpu(ch->regs[DBDMA_STATUS]));
|
||||
dbdma_cmdptr_save(ch);
|
||||
ch->regs[DBDMA_STATUS] &= ~FLUSH;
|
||||
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~FLUSH);
|
||||
|
||||
conditional_interrupt(ch);
|
||||
next(ch);
|
||||
@@ -494,9 +494,9 @@ static void store_word(DBDMA_channel *ch, int key, uint32_t addr,
|
||||
if (conditional_wait(ch))
|
||||
goto wait;
|
||||
|
||||
current->xfer_status = cpu_to_le16(ch->regs[DBDMA_STATUS]);
|
||||
current->xfer_status = cpu_to_le16(be32_to_cpu(ch->regs[DBDMA_STATUS]));
|
||||
dbdma_cmdptr_save(ch);
|
||||
ch->regs[DBDMA_STATUS] &= ~FLUSH;
|
||||
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~FLUSH);
|
||||
|
||||
conditional_interrupt(ch);
|
||||
next(ch);
|
||||
@@ -512,7 +512,7 @@ static void nop(DBDMA_channel *ch)
|
||||
if (conditional_wait(ch))
|
||||
goto wait;
|
||||
|
||||
current->xfer_status = cpu_to_le16(ch->regs[DBDMA_STATUS]);
|
||||
current->xfer_status = cpu_to_le16(be32_to_cpu(ch->regs[DBDMA_STATUS]));
|
||||
dbdma_cmdptr_save(ch);
|
||||
|
||||
conditional_interrupt(ch);
|
||||
@@ -524,7 +524,7 @@ wait:
|
||||
|
||||
static void stop(DBDMA_channel *ch)
|
||||
{
|
||||
ch->regs[DBDMA_STATUS] &= ~(ACTIVE|DEAD|FLUSH);
|
||||
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~(ACTIVE|DEAD|FLUSH));
|
||||
|
||||
/* the stop command does not increment command pointer */
|
||||
}
|
||||
@@ -541,7 +541,7 @@ static void channel_run(DBDMA_channel *ch)
|
||||
|
||||
/* clear WAKE flag at command fetch */
|
||||
|
||||
ch->regs[DBDMA_STATUS] &= ~WAKE;
|
||||
ch->regs[DBDMA_STATUS] &= cpu_to_be32(~WAKE);
|
||||
|
||||
cmd = le16_to_cpu(current->command) & COMMAND_MASK;
|
||||
|
||||
@@ -618,7 +618,7 @@ static void DBDMA_run (DBDMA_channel *ch)
|
||||
int channel;
|
||||
|
||||
for (channel = 0; channel < DBDMA_CHANNELS; channel++, ch++) {
|
||||
uint32_t status = ch->regs[DBDMA_STATUS];
|
||||
uint32_t status = be32_to_cpu(ch->regs[DBDMA_STATUS]);
|
||||
if (!ch->processing && (status & RUN) && (status & ACTIVE))
|
||||
channel_run(ch);
|
||||
}
|
||||
@@ -660,12 +660,12 @@ dbdma_control_write(DBDMA_channel *ch)
|
||||
uint16_t mask, value;
|
||||
uint32_t status;
|
||||
|
||||
mask = (ch->regs[DBDMA_CONTROL] >> 16) & 0xffff;
|
||||
value = ch->regs[DBDMA_CONTROL] & 0xffff;
|
||||
mask = (be32_to_cpu(ch->regs[DBDMA_CONTROL]) >> 16) & 0xffff;
|
||||
value = be32_to_cpu(ch->regs[DBDMA_CONTROL]) & 0xffff;
|
||||
|
||||
value &= (RUN | PAUSE | FLUSH | WAKE | DEVSTAT);
|
||||
|
||||
status = ch->regs[DBDMA_STATUS];
|
||||
status = be32_to_cpu(ch->regs[DBDMA_STATUS]);
|
||||
|
||||
status = (value & mask) | (status & ~mask);
|
||||
|
||||
@@ -677,14 +677,14 @@ dbdma_control_write(DBDMA_channel *ch)
|
||||
}
|
||||
if (status & PAUSE)
|
||||
status &= ~ACTIVE;
|
||||
if ((ch->regs[DBDMA_STATUS] & RUN) && !(status & RUN)) {
|
||||
if ((be32_to_cpu(ch->regs[DBDMA_STATUS]) & RUN) && !(status & RUN)) {
|
||||
/* RUN is cleared */
|
||||
status &= ~(ACTIVE|DEAD);
|
||||
}
|
||||
|
||||
DBDMA_DPRINTF(" status 0x%08x\n", status);
|
||||
|
||||
ch->regs[DBDMA_STATUS] = status;
|
||||
ch->regs[DBDMA_STATUS] = cpu_to_be32(status);
|
||||
|
||||
if (status & ACTIVE)
|
||||
qemu_bh_schedule(dbdma_bh);
|
||||
@@ -703,14 +703,10 @@ static void dbdma_writel (void *opaque,
|
||||
DBDMA_DPRINTF("channel 0x%x reg 0x%x\n",
|
||||
(uint32_t)addr >> DBDMA_CHANNEL_SHIFT, reg);
|
||||
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
value = bswap32(value);
|
||||
#endif
|
||||
|
||||
/* cmdptr cannot be modified if channel is RUN or ACTIVE */
|
||||
|
||||
if (reg == DBDMA_CMDPTR_LO &&
|
||||
(ch->regs[DBDMA_STATUS] & (RUN | ACTIVE)))
|
||||
(ch->regs[DBDMA_STATUS] & cpu_to_be32(RUN | ACTIVE)))
|
||||
return;
|
||||
|
||||
ch->regs[reg] = value;
|
||||
@@ -721,7 +717,7 @@ static void dbdma_writel (void *opaque,
|
||||
break;
|
||||
case DBDMA_CMDPTR_LO:
|
||||
/* 16-byte aligned */
|
||||
ch->regs[DBDMA_CMDPTR_LO] &= ~0xf;
|
||||
ch->regs[DBDMA_CMDPTR_LO] &= cpu_to_be32(~0xf);
|
||||
dbdma_cmdptr_load(ch);
|
||||
break;
|
||||
case DBDMA_STATUS:
|
||||
@@ -786,9 +782,6 @@ static uint32_t dbdma_readl (void *opaque, target_phys_addr_t addr)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
value = bswap32(value);
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
|
||||
//#define DEBUG_CMOS
|
||||
|
||||
#define RTC_REINJECT_ON_ACK_COUNT 1000
|
||||
#define RTC_REINJECT_ON_ACK_COUNT 20
|
||||
|
||||
#define RTC_SECONDS 0
|
||||
#define RTC_SECONDS_ALARM 1
|
||||
|
||||
@@ -175,7 +175,7 @@ void msix_write_config(PCIDevice *dev, uint32_t addr,
|
||||
unsigned enable_pos = dev->msix_cap + MSIX_CONTROL_OFFSET;
|
||||
int vector;
|
||||
|
||||
if (!range_covers_byte(addr, len, enable_pos)) {
|
||||
if (addr + len <= enable_pos || addr > enable_pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
-331
@@ -1,331 +0,0 @@
|
||||
/*
|
||||
* QEMU PC System Emulator
|
||||
*
|
||||
* Copyright (c) 2003-2004 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "hw.h"
|
||||
#include "fw_cfg.h"
|
||||
#include "multiboot.h"
|
||||
#include "loader.h"
|
||||
#include "elf.h"
|
||||
#include "sysemu.h"
|
||||
|
||||
/* Show multiboot debug output */
|
||||
//#define DEBUG_MULTIBOOT
|
||||
|
||||
#ifdef DEBUG_MULTIBOOT
|
||||
#define mb_debug(a...) fprintf(stderr, ## a)
|
||||
#else
|
||||
#define mb_debug(a...)
|
||||
#endif
|
||||
|
||||
#define MULTIBOOT_STRUCT_ADDR 0x9000
|
||||
|
||||
#if MULTIBOOT_STRUCT_ADDR > 0xf0000
|
||||
#error multiboot struct needs to fit in 16 bit real mode
|
||||
#endif
|
||||
|
||||
enum {
|
||||
/* Multiboot info */
|
||||
MBI_FLAGS = 0,
|
||||
MBI_MEM_LOWER = 4,
|
||||
MBI_MEM_UPPER = 8,
|
||||
MBI_BOOT_DEVICE = 12,
|
||||
MBI_CMDLINE = 16,
|
||||
MBI_MODS_COUNT = 20,
|
||||
MBI_MODS_ADDR = 24,
|
||||
MBI_MMAP_ADDR = 48,
|
||||
|
||||
MBI_SIZE = 88,
|
||||
|
||||
/* Multiboot modules */
|
||||
MB_MOD_START = 0,
|
||||
MB_MOD_END = 4,
|
||||
MB_MOD_CMDLINE = 8,
|
||||
|
||||
MB_MOD_SIZE = 16,
|
||||
|
||||
/* Region offsets */
|
||||
ADDR_E820_MAP = MULTIBOOT_STRUCT_ADDR + 0,
|
||||
ADDR_MBI = ADDR_E820_MAP + 0x500,
|
||||
|
||||
/* Multiboot flags */
|
||||
MULTIBOOT_FLAGS_MEMORY = 1 << 0,
|
||||
MULTIBOOT_FLAGS_BOOT_DEVICE = 1 << 1,
|
||||
MULTIBOOT_FLAGS_CMDLINE = 1 << 2,
|
||||
MULTIBOOT_FLAGS_MODULES = 1 << 3,
|
||||
MULTIBOOT_FLAGS_MMAP = 1 << 6,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
/* buffer holding kernel, cmdlines and mb_infos */
|
||||
void *mb_buf;
|
||||
/* address in target */
|
||||
target_phys_addr_t mb_buf_phys;
|
||||
/* size of mb_buf in bytes */
|
||||
unsigned mb_buf_size;
|
||||
/* offset of mb-info's in bytes */
|
||||
target_phys_addr_t offset_mbinfo;
|
||||
/* offset in buffer for cmdlines in bytes */
|
||||
target_phys_addr_t offset_cmdlines;
|
||||
/* offset of modules in bytes */
|
||||
target_phys_addr_t offset_mods;
|
||||
/* available slots for mb modules infos */
|
||||
int mb_mods_avail;
|
||||
/* currently used slots of mb modules */
|
||||
int mb_mods_count;
|
||||
} MultibootState;
|
||||
|
||||
static uint32_t mb_add_cmdline(MultibootState *s, const char *cmdline)
|
||||
{
|
||||
int len = strlen(cmdline) + 1;
|
||||
target_phys_addr_t p = s->offset_cmdlines;
|
||||
|
||||
pstrcpy((char *)s->mb_buf + p, len, cmdline);
|
||||
s->offset_cmdlines += len;
|
||||
return s->mb_buf_phys + p;
|
||||
}
|
||||
|
||||
static void mb_add_mod(MultibootState *s,
|
||||
target_phys_addr_t start, target_phys_addr_t end,
|
||||
target_phys_addr_t cmdline_phys)
|
||||
{
|
||||
char *p;
|
||||
assert(s->mb_mods_count < s->mb_mods_avail);
|
||||
|
||||
p = (char *)s->mb_buf + s->offset_mbinfo + MB_MOD_SIZE * s->mb_mods_count;
|
||||
|
||||
stl_p(p + MB_MOD_START, start);
|
||||
stl_p(p + MB_MOD_END, end);
|
||||
stl_p(p + MB_MOD_CMDLINE, cmdline_phys);
|
||||
|
||||
mb_debug("mod%02d: %08x - %08x\n", s->mb_mods_count, start, end);
|
||||
|
||||
s->mb_mods_count++;
|
||||
}
|
||||
|
||||
int load_multiboot(void *fw_cfg,
|
||||
FILE *f,
|
||||
const char *kernel_filename,
|
||||
const char *initrd_filename,
|
||||
const char *kernel_cmdline,
|
||||
int kernel_file_size,
|
||||
uint8_t *header)
|
||||
{
|
||||
int i, is_multiboot = 0;
|
||||
uint32_t flags = 0;
|
||||
uint32_t mh_entry_addr;
|
||||
uint32_t mh_load_addr;
|
||||
uint32_t mb_kernel_size;
|
||||
MultibootState mbs;
|
||||
uint8_t bootinfo[MBI_SIZE];
|
||||
uint8_t *mb_bootinfo_data;
|
||||
|
||||
/* Ok, let's see if it is a multiboot image.
|
||||
The header is 12x32bit long, so the latest entry may be 8192 - 48. */
|
||||
for (i = 0; i < (8192 - 48); i += 4) {
|
||||
if (ldl_p(header+i) == 0x1BADB002) {
|
||||
uint32_t checksum = ldl_p(header+i+8);
|
||||
flags = ldl_p(header+i+4);
|
||||
checksum += flags;
|
||||
checksum += (uint32_t)0x1BADB002;
|
||||
if (!checksum) {
|
||||
is_multiboot = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_multiboot)
|
||||
return 0; /* no multiboot */
|
||||
|
||||
mb_debug("qemu: I believe we found a multiboot image!\n");
|
||||
memset(bootinfo, 0, sizeof(bootinfo));
|
||||
memset(&mbs, 0, sizeof(mbs));
|
||||
|
||||
if (flags & 0x00000004) { /* MULTIBOOT_HEADER_HAS_VBE */
|
||||
fprintf(stderr, "qemu: multiboot knows VBE. we don't.\n");
|
||||
}
|
||||
if (!(flags & 0x00010000)) { /* MULTIBOOT_HEADER_HAS_ADDR */
|
||||
uint64_t elf_entry;
|
||||
uint64_t elf_low, elf_high;
|
||||
int kernel_size;
|
||||
fclose(f);
|
||||
kernel_size = load_elf(kernel_filename, 0, &elf_entry, &elf_low, &elf_high,
|
||||
0, ELF_MACHINE, 0);
|
||||
if (kernel_size < 0) {
|
||||
fprintf(stderr, "Error while loading elf kernel\n");
|
||||
exit(1);
|
||||
}
|
||||
mh_load_addr = elf_low;
|
||||
mb_kernel_size = elf_high - elf_low;
|
||||
mh_entry_addr = elf_entry;
|
||||
|
||||
mbs.mb_buf = qemu_malloc(mb_kernel_size);
|
||||
if (rom_copy(mbs.mb_buf, mh_load_addr, mb_kernel_size) != mb_kernel_size) {
|
||||
fprintf(stderr, "Error while fetching elf kernel from rom\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
mb_debug("qemu: loading multiboot-elf kernel (%#x bytes) with entry %#zx\n",
|
||||
mb_kernel_size, (size_t)mh_entry_addr);
|
||||
} else {
|
||||
/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */
|
||||
uint32_t mh_header_addr = ldl_p(header+i+12);
|
||||
mh_load_addr = ldl_p(header+i+16);
|
||||
uint32_t mb_kernel_text_offset = i - (mh_header_addr - mh_load_addr);
|
||||
|
||||
mh_entry_addr = ldl_p(header+i+28);
|
||||
mb_kernel_size = kernel_file_size - mb_kernel_text_offset;
|
||||
|
||||
/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE.
|
||||
uint32_t mh_mode_type = ldl_p(header+i+32);
|
||||
uint32_t mh_width = ldl_p(header+i+36);
|
||||
uint32_t mh_height = ldl_p(header+i+40);
|
||||
uint32_t mh_depth = ldl_p(header+i+44); */
|
||||
|
||||
mb_debug("multiboot: mh_header_addr = %#x\n", mh_header_addr);
|
||||
mb_debug("multiboot: mh_load_addr = %#x\n", mh_load_addr);
|
||||
mb_debug("multiboot: mh_load_end_addr = %#x\n", ldl_p(header+i+20));
|
||||
mb_debug("multiboot: mh_bss_end_addr = %#x\n", ldl_p(header+i+24));
|
||||
mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x\n",
|
||||
mb_kernel_size, mh_load_addr);
|
||||
|
||||
mbs.mb_buf = qemu_malloc(mb_kernel_size);
|
||||
fseek(f, mb_kernel_text_offset, SEEK_SET);
|
||||
if (fread(mbs.mb_buf, 1, mb_kernel_size, f) != mb_kernel_size) {
|
||||
fprintf(stderr, "fread() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
mbs.mb_buf_phys = mh_load_addr;
|
||||
|
||||
mbs.mb_buf_size = TARGET_PAGE_ALIGN(mb_kernel_size);
|
||||
mbs.offset_mbinfo = mbs.mb_buf_size;
|
||||
|
||||
/* Calculate space for cmdlines and mb_mods */
|
||||
mbs.mb_buf_size += strlen(kernel_filename) + 1;
|
||||
mbs.mb_buf_size += strlen(kernel_cmdline) + 1;
|
||||
if (initrd_filename) {
|
||||
const char *r = initrd_filename;
|
||||
mbs.mb_buf_size += strlen(r) + 1;
|
||||
mbs.mb_mods_avail = 1;
|
||||
while ((r = strchr(r, ','))) {
|
||||
mbs.mb_mods_avail++;
|
||||
r++;
|
||||
}
|
||||
mbs.mb_buf_size += MB_MOD_SIZE * mbs.mb_mods_avail;
|
||||
}
|
||||
|
||||
mbs.mb_buf_size = TARGET_PAGE_ALIGN(mbs.mb_buf_size);
|
||||
|
||||
/* enlarge mb_buf to hold cmdlines and mb-info structs */
|
||||
mbs.mb_buf = qemu_realloc(mbs.mb_buf, mbs.mb_buf_size);
|
||||
mbs.offset_cmdlines = mbs.offset_mbinfo + mbs.mb_mods_avail * MB_MOD_SIZE;
|
||||
|
||||
if (initrd_filename) {
|
||||
char *next_initrd;
|
||||
|
||||
mbs.offset_mods = mbs.mb_buf_size;
|
||||
|
||||
do {
|
||||
char *next_space;
|
||||
uint32_t mb_mod_length;
|
||||
uint32_t offs = mbs.mb_buf_size;
|
||||
|
||||
next_initrd = strchr(initrd_filename, ',');
|
||||
if (next_initrd)
|
||||
*next_initrd = '\0';
|
||||
/* if a space comes after the module filename, treat everything
|
||||
after that as parameters */
|
||||
target_phys_addr_t c = mb_add_cmdline(&mbs, initrd_filename);
|
||||
if ((next_space = strchr(initrd_filename, ' ')))
|
||||
*next_space = '\0';
|
||||
mb_debug("multiboot loading module: %s\n", initrd_filename);
|
||||
mb_mod_length = get_image_size(initrd_filename);
|
||||
if (mb_mod_length < 0) {
|
||||
fprintf(stderr, "failed to get %s image size\n", initrd_filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
mbs.mb_buf_size = TARGET_PAGE_ALIGN(mb_mod_length + mbs.mb_buf_size);
|
||||
mbs.mb_buf = qemu_realloc(mbs.mb_buf, mbs.mb_buf_size);
|
||||
|
||||
load_image(initrd_filename, (unsigned char *)mbs.mb_buf + offs);
|
||||
mb_add_mod(&mbs, mbs.mb_buf_phys + offs,
|
||||
mbs.mb_buf_phys + offs + mb_mod_length, c);
|
||||
|
||||
mb_debug("mod_start: %p\nmod_end: %p\n cmdline: %#x\n",
|
||||
(char *)mbs.mb_buf + offs,
|
||||
(char *)mbs.mb_buf + offs + mb_mod_length, c);
|
||||
initrd_filename = next_initrd+1;
|
||||
} while (next_initrd);
|
||||
}
|
||||
|
||||
/* Commandline support */
|
||||
char kcmdline[strlen(kernel_filename) + strlen(kernel_cmdline) + 2];
|
||||
snprintf(kcmdline, sizeof(kcmdline), "%s %s",
|
||||
kernel_filename, kernel_cmdline);
|
||||
stl_p(bootinfo + MBI_CMDLINE, mb_add_cmdline(&mbs, kcmdline));
|
||||
|
||||
stl_p(bootinfo + MBI_MODS_ADDR, mbs.mb_buf_phys + mbs.offset_mbinfo);
|
||||
stl_p(bootinfo + MBI_MODS_COUNT, mbs.mb_mods_count); /* mods_count */
|
||||
|
||||
/* the kernel is where we want it to be now */
|
||||
stl_p(bootinfo + MBI_FLAGS, MULTIBOOT_FLAGS_MEMORY
|
||||
| MULTIBOOT_FLAGS_BOOT_DEVICE
|
||||
| MULTIBOOT_FLAGS_CMDLINE
|
||||
| MULTIBOOT_FLAGS_MODULES
|
||||
| MULTIBOOT_FLAGS_MMAP);
|
||||
stl_p(bootinfo + MBI_MEM_LOWER, 640);
|
||||
stl_p(bootinfo + MBI_MEM_UPPER, ram_size / 1024);
|
||||
stl_p(bootinfo + MBI_BOOT_DEVICE, 0x8001ffff); /* XXX: use the -boot switch? */
|
||||
stl_p(bootinfo + MBI_MMAP_ADDR, ADDR_E820_MAP);
|
||||
|
||||
mb_debug("multiboot: mh_entry_addr = %#x\n", mh_entry_addr);
|
||||
mb_debug(" mb_buf_phys = %x\n", mbs.mb_buf_phys);
|
||||
mb_debug(" mod_start = %x\n", mbs.mb_buf_phys + mbs.offset_mods);
|
||||
mb_debug(" mb_mods_count = %d\n", mbs.mb_mods_count);
|
||||
|
||||
/* save bootinfo off the stack */
|
||||
mb_bootinfo_data = qemu_malloc(sizeof(bootinfo));
|
||||
memcpy(mb_bootinfo_data, bootinfo, sizeof(bootinfo));
|
||||
|
||||
/* Pass variables to option rom */
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ENTRY, mh_entry_addr);
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, mh_load_addr);
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, mbs.mb_buf_size);
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA,
|
||||
mbs.mb_buf, mbs.mb_buf_size);
|
||||
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, ADDR_MBI);
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, sizeof(bootinfo));
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, mb_bootinfo_data,
|
||||
sizeof(bootinfo));
|
||||
|
||||
option_rom[nb_option_roms] = "multiboot.bin";
|
||||
nb_option_roms++;
|
||||
|
||||
return 1; /* yes, we are multiboot */
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef QEMU_MULTIBOOT_H
|
||||
#define QEMU_MULTIBOOT_H
|
||||
|
||||
int load_multiboot(void *fw_cfg,
|
||||
FILE *f,
|
||||
const char *kernel_filename,
|
||||
const char *initrd_filename,
|
||||
const char *kernel_cmdline,
|
||||
int kernel_file_size,
|
||||
uint8_t *header);
|
||||
|
||||
#endif
|
||||
+4
-5
@@ -67,7 +67,7 @@
|
||||
#define MP_AUDIO_IRQ 30
|
||||
|
||||
/* Wolfson 8750 I2C address */
|
||||
#define MP_WM_ADDR 0x34
|
||||
#define MP_WM_ADDR 0x1A
|
||||
|
||||
/* Ethernet register offsets */
|
||||
#define MP_ETH_SMIR 0x010
|
||||
@@ -238,14 +238,13 @@ static void eth_send(mv88w8618_eth_state *s, int queue_index)
|
||||
{
|
||||
uint32_t desc_addr = s->tx_queue[queue_index];
|
||||
mv88w8618_tx_desc desc;
|
||||
uint32_t next_desc;
|
||||
uint8_t buf[2048];
|
||||
int len;
|
||||
|
||||
if (!desc_addr) {
|
||||
return;
|
||||
}
|
||||
do {
|
||||
eth_tx_desc_get(desc_addr, &desc);
|
||||
next_desc = desc.next;
|
||||
if (desc.cmdstat & MP_ETH_TX_OWN) {
|
||||
len = desc.bytes;
|
||||
if (len < 2048) {
|
||||
@@ -256,7 +255,7 @@ static void eth_send(mv88w8618_eth_state *s, int queue_index)
|
||||
s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
|
||||
eth_tx_desc_put(desc_addr, &desc);
|
||||
}
|
||||
desc_addr = desc.next;
|
||||
desc_addr = next_desc;
|
||||
} while (desc_addr != s->tx_queue[queue_index]);
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -724,8 +724,7 @@ static int pci_ne2000_init(PCIDevice *pci_dev)
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REALTEK_8029);
|
||||
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
|
||||
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
||||
/* TODO: RST# value should be 0. PCI spec 6.2.4 */
|
||||
pci_conf[PCI_INTERRUPT_PIN] = 1; // interrupt pin 0
|
||||
pci_conf[0x3d] = 1; // interrupt pin 0
|
||||
|
||||
pci_register_bar(&d->dev, 0, 0x100,
|
||||
PCI_BASE_ADDRESS_SPACE_IO, ne2000_map);
|
||||
|
||||
+131
-133
@@ -219,20 +219,20 @@ typedef struct openpic_t {
|
||||
int nb_cpus;
|
||||
/* Timer registers */
|
||||
struct {
|
||||
uint32_t ticc; /* Global timer current count register */
|
||||
uint32_t tibc; /* Global timer base count register */
|
||||
uint32_t ticc; /* Global timer current count register */
|
||||
uint32_t tibc; /* Global timer base count register */
|
||||
} timers[MAX_TMR];
|
||||
#if MAX_DBL > 0
|
||||
/* Doorbell registers */
|
||||
uint32_t dar; /* Doorbell activate register */
|
||||
struct {
|
||||
uint32_t dmr; /* Doorbell messaging register */
|
||||
uint32_t dmr; /* Doorbell messaging register */
|
||||
} doorbells[MAX_DBL];
|
||||
#endif
|
||||
#if MAX_MBX > 0
|
||||
/* Mailbox registers */
|
||||
struct {
|
||||
uint32_t mbr; /* Mailbox register */
|
||||
uint32_t mbr; /* Mailbox register */
|
||||
} mailboxes[MAX_MAILBOXES];
|
||||
#endif
|
||||
/* IRQ out is used when in bypass mode (not implemented) */
|
||||
@@ -276,14 +276,14 @@ static void IRQ_check (openpic_t *opp, IRQ_queue_t *q)
|
||||
next = -1;
|
||||
priority = -1;
|
||||
for (i = 0; i < opp->max_irq; i++) {
|
||||
if (IRQ_testbit(q, i)) {
|
||||
if (IRQ_testbit(q, i)) {
|
||||
DPRINTF("IRQ_check: irq %d set ipvp_pr=%d pr=%d\n",
|
||||
i, IPVP_PRIORITY(opp->src[i].ipvp), priority);
|
||||
if (IPVP_PRIORITY(opp->src[i].ipvp) > priority) {
|
||||
next = i;
|
||||
priority = IPVP_PRIORITY(opp->src[i].ipvp);
|
||||
}
|
||||
}
|
||||
if (IPVP_PRIORITY(opp->src[i].ipvp) > priority) {
|
||||
next = i;
|
||||
priority = IPVP_PRIORITY(opp->src[i].ipvp);
|
||||
}
|
||||
}
|
||||
}
|
||||
q->next = next;
|
||||
q->priority = priority;
|
||||
@@ -293,7 +293,7 @@ static int IRQ_get_next (openpic_t *opp, IRQ_queue_t *q)
|
||||
{
|
||||
if (q->next == -1) {
|
||||
/* XXX: optimize */
|
||||
IRQ_check(opp, q);
|
||||
IRQ_check(opp, q);
|
||||
}
|
||||
|
||||
return q->next;
|
||||
@@ -309,16 +309,16 @@ static void IRQ_local_pipe (openpic_t *opp, int n_CPU, int n_IRQ)
|
||||
src = &opp->src[n_IRQ];
|
||||
priority = IPVP_PRIORITY(src->ipvp);
|
||||
if (priority <= dst->pctp) {
|
||||
/* Too low priority */
|
||||
/* Too low priority */
|
||||
DPRINTF("%s: IRQ %d has too low priority on CPU %d\n",
|
||||
__func__, n_IRQ, n_CPU);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
if (IRQ_testbit(&dst->raised, n_IRQ)) {
|
||||
/* Interrupt miss */
|
||||
/* Interrupt miss */
|
||||
DPRINTF("%s: IRQ %d was missed on CPU %d\n",
|
||||
__func__, n_IRQ, n_CPU);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
set_bit(&src->ipvp, IPVP_ACTIVITY);
|
||||
IRQ_setbit(&dst->raised, n_IRQ);
|
||||
@@ -354,14 +354,14 @@ static void openpic_update_irq(openpic_t *opp, int n_IRQ)
|
||||
return;
|
||||
}
|
||||
if (test_bit(&src->ipvp, IPVP_MASK)) {
|
||||
/* Interrupt source is disabled */
|
||||
/* Interrupt source is disabled */
|
||||
DPRINTF("%s: IRQ %d is disabled\n", __func__, n_IRQ);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
if (IPVP_PRIORITY(src->ipvp) == 0) {
|
||||
/* Priority set to zero */
|
||||
/* Priority set to zero */
|
||||
DPRINTF("%s: IRQ %d has 0 priority\n", __func__, n_IRQ);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
if (test_bit(&src->ipvp, IPVP_ACTIVITY)) {
|
||||
/* IRQ already active */
|
||||
@@ -369,9 +369,9 @@ static void openpic_update_irq(openpic_t *opp, int n_IRQ)
|
||||
return;
|
||||
}
|
||||
if (src->ide == 0x00000000) {
|
||||
/* No target */
|
||||
/* No target */
|
||||
DPRINTF("%s: IRQ %d has no target\n", __func__, n_IRQ);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (src->ide == (1 << src->last_cpu)) {
|
||||
@@ -434,34 +434,32 @@ static void openpic_reset (void *opaque)
|
||||
opp->micr = 0x00000000;
|
||||
/* Initialise IRQ sources */
|
||||
for (i = 0; i < opp->max_irq; i++) {
|
||||
opp->src[i].ipvp = 0xA0000000;
|
||||
opp->src[i].ide = 0x00000000;
|
||||
opp->src[i].ipvp = 0xA0000000;
|
||||
opp->src[i].ide = 0x00000000;
|
||||
}
|
||||
/* Initialise IRQ destinations */
|
||||
for (i = 0; i < MAX_CPU; i++) {
|
||||
opp->dst[i].pctp = 0x0000000F;
|
||||
opp->dst[i].pcsr = 0x00000000;
|
||||
memset(&opp->dst[i].raised, 0, sizeof(IRQ_queue_t));
|
||||
opp->dst[i].raised.next = -1;
|
||||
memset(&opp->dst[i].servicing, 0, sizeof(IRQ_queue_t));
|
||||
opp->dst[i].servicing.next = -1;
|
||||
opp->dst[i].pctp = 0x0000000F;
|
||||
opp->dst[i].pcsr = 0x00000000;
|
||||
memset(&opp->dst[i].raised, 0, sizeof(IRQ_queue_t));
|
||||
memset(&opp->dst[i].servicing, 0, sizeof(IRQ_queue_t));
|
||||
}
|
||||
/* Initialise timers */
|
||||
for (i = 0; i < MAX_TMR; i++) {
|
||||
opp->timers[i].ticc = 0x00000000;
|
||||
opp->timers[i].tibc = 0x80000000;
|
||||
opp->timers[i].ticc = 0x00000000;
|
||||
opp->timers[i].tibc = 0x80000000;
|
||||
}
|
||||
/* Initialise doorbells */
|
||||
#if MAX_DBL > 0
|
||||
opp->dar = 0x00000000;
|
||||
for (i = 0; i < MAX_DBL; i++) {
|
||||
opp->doorbells[i].dmr = 0x00000000;
|
||||
opp->doorbells[i].dmr = 0x00000000;
|
||||
}
|
||||
#endif
|
||||
/* Initialise mailboxes */
|
||||
#if MAX_MBX > 0
|
||||
for (i = 0; i < MAX_MBX; i++) { /* ? */
|
||||
opp->mailboxes[i].mbr = 0x00000000;
|
||||
opp->mailboxes[i].mbr = 0x00000000;
|
||||
}
|
||||
#endif
|
||||
/* Go out of RESET state */
|
||||
@@ -474,11 +472,11 @@ static inline uint32_t read_IRQreg (openpic_t *opp, int n_IRQ, uint32_t reg)
|
||||
|
||||
switch (reg) {
|
||||
case IRQ_IPVP:
|
||||
retval = opp->src[n_IRQ].ipvp;
|
||||
break;
|
||||
retval = opp->src[n_IRQ].ipvp;
|
||||
break;
|
||||
case IRQ_IDE:
|
||||
retval = opp->src[n_IRQ].ide;
|
||||
break;
|
||||
retval = opp->src[n_IRQ].ide;
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -494,95 +492,95 @@ static inline void write_IRQreg (openpic_t *opp, int n_IRQ,
|
||||
/* NOTE: not fully accurate for special IRQs, but simple and
|
||||
sufficient */
|
||||
/* ACTIVITY bit is read-only */
|
||||
opp->src[n_IRQ].ipvp =
|
||||
opp->src[n_IRQ].ipvp =
|
||||
(opp->src[n_IRQ].ipvp & 0x40000000) |
|
||||
(val & 0x800F00FF);
|
||||
openpic_update_irq(opp, n_IRQ);
|
||||
DPRINTF("Set IPVP %d to 0x%08x -> 0x%08x\n",
|
||||
n_IRQ, val, opp->src[n_IRQ].ipvp);
|
||||
break;
|
||||
break;
|
||||
case IRQ_IDE:
|
||||
tmp = val & 0xC0000000;
|
||||
tmp = val & 0xC0000000;
|
||||
tmp |= val & ((1 << MAX_CPU) - 1);
|
||||
opp->src[n_IRQ].ide = tmp;
|
||||
opp->src[n_IRQ].ide = tmp;
|
||||
DPRINTF("Set IDE %d to 0x%08x\n", n_IRQ, opp->src[n_IRQ].ide);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 // Code provision for Intel model
|
||||
#if MAX_DBL > 0
|
||||
static uint32_t read_doorbell_register (openpic_t *opp,
|
||||
int n_dbl, uint32_t offset)
|
||||
int n_dbl, uint32_t offset)
|
||||
{
|
||||
uint32_t retval;
|
||||
|
||||
switch (offset) {
|
||||
case DBL_IPVP_OFFSET:
|
||||
retval = read_IRQreg(opp, IRQ_DBL0 + n_dbl, IRQ_IPVP);
|
||||
break;
|
||||
retval = read_IRQreg(opp, IRQ_DBL0 + n_dbl, IRQ_IPVP);
|
||||
break;
|
||||
case DBL_IDE_OFFSET:
|
||||
retval = read_IRQreg(opp, IRQ_DBL0 + n_dbl, IRQ_IDE);
|
||||
break;
|
||||
retval = read_IRQreg(opp, IRQ_DBL0 + n_dbl, IRQ_IDE);
|
||||
break;
|
||||
case DBL_DMR_OFFSET:
|
||||
retval = opp->doorbells[n_dbl].dmr;
|
||||
break;
|
||||
retval = opp->doorbells[n_dbl].dmr;
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void write_doorbell_register (penpic_t *opp, int n_dbl,
|
||||
uint32_t offset, uint32_t value)
|
||||
uint32_t offset, uint32_t value)
|
||||
{
|
||||
switch (offset) {
|
||||
case DBL_IVPR_OFFSET:
|
||||
write_IRQreg(opp, IRQ_DBL0 + n_dbl, IRQ_IPVP, value);
|
||||
break;
|
||||
write_IRQreg(opp, IRQ_DBL0 + n_dbl, IRQ_IPVP, value);
|
||||
break;
|
||||
case DBL_IDE_OFFSET:
|
||||
write_IRQreg(opp, IRQ_DBL0 + n_dbl, IRQ_IDE, value);
|
||||
break;
|
||||
write_IRQreg(opp, IRQ_DBL0 + n_dbl, IRQ_IDE, value);
|
||||
break;
|
||||
case DBL_DMR_OFFSET:
|
||||
opp->doorbells[n_dbl].dmr = value;
|
||||
break;
|
||||
opp->doorbells[n_dbl].dmr = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MAX_MBX > 0
|
||||
static uint32_t read_mailbox_register (openpic_t *opp,
|
||||
int n_mbx, uint32_t offset)
|
||||
int n_mbx, uint32_t offset)
|
||||
{
|
||||
uint32_t retval;
|
||||
|
||||
switch (offset) {
|
||||
case MBX_MBR_OFFSET:
|
||||
retval = opp->mailboxes[n_mbx].mbr;
|
||||
break;
|
||||
retval = opp->mailboxes[n_mbx].mbr;
|
||||
break;
|
||||
case MBX_IVPR_OFFSET:
|
||||
retval = read_IRQreg(opp, IRQ_MBX0 + n_mbx, IRQ_IPVP);
|
||||
break;
|
||||
retval = read_IRQreg(opp, IRQ_MBX0 + n_mbx, IRQ_IPVP);
|
||||
break;
|
||||
case MBX_DMR_OFFSET:
|
||||
retval = read_IRQreg(opp, IRQ_MBX0 + n_mbx, IRQ_IDE);
|
||||
break;
|
||||
retval = read_IRQreg(opp, IRQ_MBX0 + n_mbx, IRQ_IDE);
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void write_mailbox_register (openpic_t *opp, int n_mbx,
|
||||
uint32_t address, uint32_t value)
|
||||
uint32_t address, uint32_t value)
|
||||
{
|
||||
switch (offset) {
|
||||
case MBX_MBR_OFFSET:
|
||||
opp->mailboxes[n_mbx].mbr = value;
|
||||
break;
|
||||
opp->mailboxes[n_mbx].mbr = value;
|
||||
break;
|
||||
case MBX_IVPR_OFFSET:
|
||||
write_IRQreg(opp, IRQ_MBX0 + n_mbx, IRQ_IPVP, value);
|
||||
break;
|
||||
write_IRQreg(opp, IRQ_MBX0 + n_mbx, IRQ_IPVP, value);
|
||||
break;
|
||||
case MBX_DMR_OFFSET:
|
||||
write_IRQreg(opp, IRQ_MBX0 + n_mbx, IRQ_IDE, value);
|
||||
break;
|
||||
write_IRQreg(opp, IRQ_MBX0 + n_mbx, IRQ_IDE, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -608,9 +606,9 @@ static void openpic_gbl_write (void *opaque, target_phys_addr_t addr, uint32_t v
|
||||
if (val & 0x80000000 && opp->reset)
|
||||
opp->reset(opp);
|
||||
opp->glbc = val & ~0x80000000;
|
||||
break;
|
||||
break;
|
||||
case 0x80: /* VENI */
|
||||
break;
|
||||
break;
|
||||
case 0x90: /* PINT */
|
||||
for (idx = 0; idx < opp->nb_cpus; idx++) {
|
||||
if ((val & (1 << idx)) && !(opp->pint & (1 << idx))) {
|
||||
@@ -624,7 +622,7 @@ static void openpic_gbl_write (void *opaque, target_phys_addr_t addr, uint32_t v
|
||||
}
|
||||
}
|
||||
opp->pint = val;
|
||||
break;
|
||||
break;
|
||||
#if MAX_IPI > 0
|
||||
case 0xA0: /* IPI_IPVP */
|
||||
case 0xB0:
|
||||
@@ -642,7 +640,7 @@ static void openpic_gbl_write (void *opaque, target_phys_addr_t addr, uint32_t v
|
||||
break;
|
||||
case 0xF0: /* TIFR */
|
||||
opp->tifr = val;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -664,13 +662,13 @@ static uint32_t openpic_gbl_read (void *opaque, target_phys_addr_t addr)
|
||||
break;
|
||||
case 0x20: /* GLBC */
|
||||
retval = opp->glbc;
|
||||
break;
|
||||
break;
|
||||
case 0x80: /* VENI */
|
||||
retval = opp->veni;
|
||||
break;
|
||||
break;
|
||||
case 0x90: /* PINT */
|
||||
retval = 0x00000000;
|
||||
break;
|
||||
break;
|
||||
#if MAX_IPI > 0
|
||||
case 0xA0: /* IPI_IPVP */
|
||||
case 0xB0:
|
||||
@@ -681,14 +679,14 @@ static uint32_t openpic_gbl_read (void *opaque, target_phys_addr_t addr)
|
||||
idx = (addr - 0xA0) >> 4;
|
||||
retval = read_IRQreg(opp, opp->irq_ipi0 + idx, IRQ_IPVP);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
#endif
|
||||
case 0xE0: /* SPVE */
|
||||
retval = opp->spve;
|
||||
break;
|
||||
case 0xF0: /* TIFR */
|
||||
retval = opp->tifr;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -719,18 +717,18 @@ static void openpic_timer_write (void *opaque, uint32_t addr, uint32_t val)
|
||||
case 0x00: /* TICC */
|
||||
break;
|
||||
case 0x10: /* TIBC */
|
||||
if ((opp->timers[idx].ticc & 0x80000000) != 0 &&
|
||||
(val & 0x80000000) == 0 &&
|
||||
if ((opp->timers[idx].ticc & 0x80000000) != 0 &&
|
||||
(val & 0x80000000) == 0 &&
|
||||
(opp->timers[idx].tibc & 0x80000000) != 0)
|
||||
opp->timers[idx].ticc &= ~0x80000000;
|
||||
opp->timers[idx].tibc = val;
|
||||
break;
|
||||
opp->timers[idx].ticc &= ~0x80000000;
|
||||
opp->timers[idx].tibc = val;
|
||||
break;
|
||||
case 0x20: /* TIVP */
|
||||
write_IRQreg(opp, opp->irq_tim0 + idx, IRQ_IPVP, val);
|
||||
break;
|
||||
break;
|
||||
case 0x30: /* TIDE */
|
||||
write_IRQreg(opp, opp->irq_tim0 + idx, IRQ_IDE, val);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -750,17 +748,17 @@ static uint32_t openpic_timer_read (void *opaque, uint32_t addr)
|
||||
addr = addr & 0x30;
|
||||
switch (addr) {
|
||||
case 0x00: /* TICC */
|
||||
retval = opp->timers[idx].ticc;
|
||||
retval = opp->timers[idx].ticc;
|
||||
break;
|
||||
case 0x10: /* TIBC */
|
||||
retval = opp->timers[idx].tibc;
|
||||
break;
|
||||
retval = opp->timers[idx].tibc;
|
||||
break;
|
||||
case 0x20: /* TIPV */
|
||||
retval = read_IRQreg(opp, opp->irq_tim0 + idx, IRQ_IPVP);
|
||||
break;
|
||||
break;
|
||||
case 0x30: /* TIDE */
|
||||
retval = read_IRQreg(opp, opp->irq_tim0 + idx, IRQ_IDE);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
DPRINTF("%s: => %08x\n", __func__, retval);
|
||||
#if defined TARGET_WORDS_BIGENDIAN
|
||||
@@ -849,21 +847,21 @@ static void openpic_cpu_write (void *opaque, target_phys_addr_t addr, uint32_t v
|
||||
break;
|
||||
#endif
|
||||
case 0x80: /* PCTP */
|
||||
dst->pctp = val & 0x0000000F;
|
||||
break;
|
||||
dst->pctp = val & 0x0000000F;
|
||||
break;
|
||||
case 0x90: /* WHOAMI */
|
||||
/* Read-only register */
|
||||
break;
|
||||
/* Read-only register */
|
||||
break;
|
||||
case 0xA0: /* PIAC */
|
||||
/* Read-only register */
|
||||
break;
|
||||
/* Read-only register */
|
||||
break;
|
||||
case 0xB0: /* PEOI */
|
||||
DPRINTF("PEOI\n");
|
||||
s_IRQ = IRQ_get_next(opp, &dst->servicing);
|
||||
IRQ_resetbit(&dst->servicing, s_IRQ);
|
||||
dst->servicing.next = -1;
|
||||
/* Set up next servicing IRQ */
|
||||
s_IRQ = IRQ_get_next(opp, &dst->servicing);
|
||||
s_IRQ = IRQ_get_next(opp, &dst->servicing);
|
||||
IRQ_resetbit(&dst->servicing, s_IRQ);
|
||||
dst->servicing.next = -1;
|
||||
/* Set up next servicing IRQ */
|
||||
s_IRQ = IRQ_get_next(opp, &dst->servicing);
|
||||
/* Check queued interrupts. */
|
||||
n_IRQ = IRQ_get_next(opp, &dst->raised);
|
||||
src = &opp->src[n_IRQ];
|
||||
@@ -874,7 +872,7 @@ static void openpic_cpu_write (void *opaque, target_phys_addr_t addr, uint32_t v
|
||||
idx, n_IRQ);
|
||||
opp->irq_raise(opp, idx, src);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -898,46 +896,46 @@ static uint32_t openpic_cpu_read (void *opaque, target_phys_addr_t addr)
|
||||
addr &= 0xFF0;
|
||||
switch (addr) {
|
||||
case 0x80: /* PCTP */
|
||||
retval = dst->pctp;
|
||||
break;
|
||||
retval = dst->pctp;
|
||||
break;
|
||||
case 0x90: /* WHOAMI */
|
||||
retval = idx;
|
||||
break;
|
||||
retval = idx;
|
||||
break;
|
||||
case 0xA0: /* PIAC */
|
||||
DPRINTF("Lower OpenPIC INT output\n");
|
||||
qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_INT]);
|
||||
n_IRQ = IRQ_get_next(opp, &dst->raised);
|
||||
n_IRQ = IRQ_get_next(opp, &dst->raised);
|
||||
DPRINTF("PIAC: irq=%d\n", n_IRQ);
|
||||
if (n_IRQ == -1) {
|
||||
/* No more interrupt pending */
|
||||
if (n_IRQ == -1) {
|
||||
/* No more interrupt pending */
|
||||
retval = IPVP_VECTOR(opp->spve);
|
||||
} else {
|
||||
src = &opp->src[n_IRQ];
|
||||
if (!test_bit(&src->ipvp, IPVP_ACTIVITY) ||
|
||||
!(IPVP_PRIORITY(src->ipvp) > dst->pctp)) {
|
||||
/* - Spurious level-sensitive IRQ
|
||||
* - Priorities has been changed
|
||||
* and the pending IRQ isn't allowed anymore
|
||||
*/
|
||||
reset_bit(&src->ipvp, IPVP_ACTIVITY);
|
||||
retval = IPVP_VECTOR(opp->spve);
|
||||
} else {
|
||||
/* IRQ enter servicing state */
|
||||
IRQ_setbit(&dst->servicing, n_IRQ);
|
||||
retval = IPVP_VECTOR(src->ipvp);
|
||||
}
|
||||
IRQ_resetbit(&dst->raised, n_IRQ);
|
||||
dst->raised.next = -1;
|
||||
if (!test_bit(&src->ipvp, IPVP_SENSE)) {
|
||||
} else {
|
||||
src = &opp->src[n_IRQ];
|
||||
if (!test_bit(&src->ipvp, IPVP_ACTIVITY) ||
|
||||
!(IPVP_PRIORITY(src->ipvp) > dst->pctp)) {
|
||||
/* - Spurious level-sensitive IRQ
|
||||
* - Priorities has been changed
|
||||
* and the pending IRQ isn't allowed anymore
|
||||
*/
|
||||
reset_bit(&src->ipvp, IPVP_ACTIVITY);
|
||||
retval = IPVP_VECTOR(opp->spve);
|
||||
} else {
|
||||
/* IRQ enter servicing state */
|
||||
IRQ_setbit(&dst->servicing, n_IRQ);
|
||||
retval = IPVP_VECTOR(src->ipvp);
|
||||
}
|
||||
IRQ_resetbit(&dst->raised, n_IRQ);
|
||||
dst->raised.next = -1;
|
||||
if (!test_bit(&src->ipvp, IPVP_SENSE)) {
|
||||
/* edge-sensitive IRQ */
|
||||
reset_bit(&src->ipvp, IPVP_ACTIVITY);
|
||||
reset_bit(&src->ipvp, IPVP_ACTIVITY);
|
||||
src->pending = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0xB0: /* PEOI */
|
||||
retval = 0;
|
||||
break;
|
||||
retval = 0;
|
||||
break;
|
||||
#if MAX_IPI > 0
|
||||
case 0x40: /* IDE */
|
||||
case 0x50:
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "hw.h"
|
||||
#include "pc.h"
|
||||
#include "fdc.h"
|
||||
#include "ide.h"
|
||||
#include "pci.h"
|
||||
#include "vmware_vga.h"
|
||||
#include "usb-uhci.h"
|
||||
@@ -44,11 +45,13 @@
|
||||
#include "ide.h"
|
||||
#include "loader.h"
|
||||
#include "elf.h"
|
||||
#include "multiboot.h"
|
||||
|
||||
/* output Bochs bios info messages */
|
||||
//#define DEBUG_BIOS
|
||||
|
||||
/* Show multiboot debug output */
|
||||
//#define DEBUG_MULTIBOOT
|
||||
|
||||
#define BIOS_FILENAME "bios.bin"
|
||||
|
||||
#define PC_MAX_BIOS_SIZE (4 * 1024 * 1024)
|
||||
@@ -242,15 +245,66 @@ static int pc_boot_set(void *opaque, const char *boot_device)
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* hd_table must contain 4 block drivers */
|
||||
typedef struct pc_cmos_init_late_arg {
|
||||
BusState *idebus0, *idebus1;
|
||||
} pc_cmos_init_late_arg;
|
||||
|
||||
static void pc_cmos_init_late(void *opaque)
|
||||
{
|
||||
pc_cmos_init_late_arg *arg = opaque;
|
||||
RTCState *s = rtc_state;
|
||||
int val;
|
||||
BlockDriverState *hd_table[4];
|
||||
int i;
|
||||
|
||||
ide_get_bs(hd_table, arg->idebus0);
|
||||
ide_get_bs(hd_table + 2, arg->idebus1);
|
||||
|
||||
rtc_set_memory(s, 0x12, (hd_table[0] ? 0xf0 : 0) | (hd_table[1] ? 0x0f : 0));
|
||||
if (hd_table[0])
|
||||
cmos_init_hd(0x19, 0x1b, hd_table[0]);
|
||||
if (hd_table[1])
|
||||
cmos_init_hd(0x1a, 0x24, hd_table[1]);
|
||||
|
||||
val = 0;
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (hd_table[i]) {
|
||||
int cylinders, heads, sectors, translation;
|
||||
/* NOTE: bdrv_get_geometry_hint() returns the physical
|
||||
geometry. It is always such that: 1 <= sects <= 63, 1
|
||||
<= heads <= 16, 1 <= cylinders <= 16383. The BIOS
|
||||
geometry can be different if a translation is done. */
|
||||
translation = bdrv_get_translation_hint(hd_table[i]);
|
||||
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
|
||||
bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, §ors);
|
||||
if (cylinders <= 1024 && heads <= 16 && sectors <= 63) {
|
||||
/* No translation. */
|
||||
translation = 0;
|
||||
} else {
|
||||
/* LBA translation. */
|
||||
translation = 1;
|
||||
}
|
||||
} else {
|
||||
translation--;
|
||||
}
|
||||
val |= translation << (i * 2);
|
||||
}
|
||||
}
|
||||
rtc_set_memory(s, 0x39, val);
|
||||
|
||||
qemu_unregister_reset(pc_cmos_init_late, opaque);
|
||||
}
|
||||
|
||||
static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
||||
const char *boot_device, DriveInfo **hd_table)
|
||||
const char *boot_device,
|
||||
BusState *idebus0, BusState *idebus1)
|
||||
{
|
||||
RTCState *s = rtc_state;
|
||||
int nbds, bds[3] = { 0, };
|
||||
int val;
|
||||
int fd0, fd1, nb;
|
||||
int i;
|
||||
static pc_cmos_init_late_arg arg;
|
||||
|
||||
/* various important CMOS locations needed by PC/Bochs bios */
|
||||
|
||||
@@ -333,37 +387,9 @@ static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
||||
|
||||
/* hard drives */
|
||||
|
||||
rtc_set_memory(s, 0x12, (hd_table[0] ? 0xf0 : 0) | (hd_table[1] ? 0x0f : 0));
|
||||
if (hd_table[0])
|
||||
cmos_init_hd(0x19, 0x1b, hd_table[0]->bdrv);
|
||||
if (hd_table[1])
|
||||
cmos_init_hd(0x1a, 0x24, hd_table[1]->bdrv);
|
||||
|
||||
val = 0;
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (hd_table[i]) {
|
||||
int cylinders, heads, sectors, translation;
|
||||
/* NOTE: bdrv_get_geometry_hint() returns the physical
|
||||
geometry. It is always such that: 1 <= sects <= 63, 1
|
||||
<= heads <= 16, 1 <= cylinders <= 16383. The BIOS
|
||||
geometry can be different if a translation is done. */
|
||||
translation = bdrv_get_translation_hint(hd_table[i]->bdrv);
|
||||
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
|
||||
bdrv_get_geometry_hint(hd_table[i]->bdrv, &cylinders, &heads, §ors);
|
||||
if (cylinders <= 1024 && heads <= 16 && sectors <= 63) {
|
||||
/* No translation. */
|
||||
translation = 0;
|
||||
} else {
|
||||
/* LBA translation. */
|
||||
translation = 1;
|
||||
}
|
||||
} else {
|
||||
translation--;
|
||||
}
|
||||
val |= translation << (i * 2);
|
||||
}
|
||||
}
|
||||
rtc_set_memory(s, 0x39, val);
|
||||
arg.idebus0 = idebus0;
|
||||
arg.idebus1 = idebus1;
|
||||
qemu_register_reset(pc_cmos_init_late, &arg);
|
||||
}
|
||||
|
||||
void ioport_set_a20(int enable)
|
||||
@@ -504,6 +530,234 @@ static long get_file_size(FILE *f)
|
||||
return size;
|
||||
}
|
||||
|
||||
#define MULTIBOOT_STRUCT_ADDR 0x9000
|
||||
|
||||
#if MULTIBOOT_STRUCT_ADDR > 0xf0000
|
||||
#error multiboot struct needs to fit in 16 bit real mode
|
||||
#endif
|
||||
|
||||
static int load_multiboot(void *fw_cfg,
|
||||
FILE *f,
|
||||
const char *kernel_filename,
|
||||
const char *initrd_filename,
|
||||
const char *kernel_cmdline,
|
||||
uint8_t *header)
|
||||
{
|
||||
int i, is_multiboot = 0;
|
||||
uint32_t flags = 0;
|
||||
uint32_t mh_entry_addr;
|
||||
uint32_t mh_load_addr;
|
||||
uint32_t mb_kernel_size;
|
||||
uint32_t mmap_addr = MULTIBOOT_STRUCT_ADDR;
|
||||
uint32_t mb_bootinfo = MULTIBOOT_STRUCT_ADDR + 0x500;
|
||||
uint32_t mb_mod_end;
|
||||
uint8_t bootinfo[0x500];
|
||||
uint32_t cmdline = 0x200;
|
||||
uint8_t *mb_kernel_data;
|
||||
uint8_t *mb_bootinfo_data;
|
||||
|
||||
/* Ok, let's see if it is a multiboot image.
|
||||
The header is 12x32bit long, so the latest entry may be 8192 - 48. */
|
||||
for (i = 0; i < (8192 - 48); i += 4) {
|
||||
if (ldl_p(header+i) == 0x1BADB002) {
|
||||
uint32_t checksum = ldl_p(header+i+8);
|
||||
flags = ldl_p(header+i+4);
|
||||
checksum += flags;
|
||||
checksum += (uint32_t)0x1BADB002;
|
||||
if (!checksum) {
|
||||
is_multiboot = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_multiboot)
|
||||
return 0; /* no multiboot */
|
||||
|
||||
#ifdef DEBUG_MULTIBOOT
|
||||
fprintf(stderr, "qemu: I believe we found a multiboot image!\n");
|
||||
#endif
|
||||
memset(bootinfo, 0, sizeof(bootinfo));
|
||||
|
||||
if (flags & 0x00000004) { /* MULTIBOOT_HEADER_HAS_VBE */
|
||||
fprintf(stderr, "qemu: multiboot knows VBE. we don't.\n");
|
||||
}
|
||||
if (!(flags & 0x00010000)) { /* MULTIBOOT_HEADER_HAS_ADDR */
|
||||
uint64_t elf_entry;
|
||||
uint64_t elf_low, elf_high;
|
||||
int kernel_size;
|
||||
fclose(f);
|
||||
kernel_size = load_elf(kernel_filename, 0, &elf_entry, &elf_low, &elf_high,
|
||||
0, ELF_MACHINE, 0);
|
||||
if (kernel_size < 0) {
|
||||
fprintf(stderr, "Error while loading elf kernel\n");
|
||||
exit(1);
|
||||
}
|
||||
mh_load_addr = elf_low;
|
||||
mb_kernel_size = elf_high - elf_low;
|
||||
mh_entry_addr = elf_entry;
|
||||
|
||||
mb_kernel_data = qemu_malloc(mb_kernel_size);
|
||||
if (rom_copy(mb_kernel_data, mh_load_addr, mb_kernel_size) != mb_kernel_size) {
|
||||
fprintf(stderr, "Error while fetching elf kernel from rom\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MULTIBOOT
|
||||
fprintf(stderr, "qemu: loading multiboot-elf kernel (%#x bytes) with entry %#zx\n",
|
||||
mb_kernel_size, (size_t)mh_entry_addr);
|
||||
#endif
|
||||
} else {
|
||||
/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */
|
||||
uint32_t mh_header_addr = ldl_p(header+i+12);
|
||||
mh_load_addr = ldl_p(header+i+16);
|
||||
#ifdef DEBUG_MULTIBOOT
|
||||
uint32_t mh_load_end_addr = ldl_p(header+i+20);
|
||||
uint32_t mh_bss_end_addr = ldl_p(header+i+24);
|
||||
#endif
|
||||
uint32_t mb_kernel_text_offset = i - (mh_header_addr - mh_load_addr);
|
||||
|
||||
mh_entry_addr = ldl_p(header+i+28);
|
||||
mb_kernel_size = get_file_size(f) - mb_kernel_text_offset;
|
||||
|
||||
/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE.
|
||||
uint32_t mh_mode_type = ldl_p(header+i+32);
|
||||
uint32_t mh_width = ldl_p(header+i+36);
|
||||
uint32_t mh_height = ldl_p(header+i+40);
|
||||
uint32_t mh_depth = ldl_p(header+i+44); */
|
||||
|
||||
#ifdef DEBUG_MULTIBOOT
|
||||
fprintf(stderr, "multiboot: mh_header_addr = %#x\n", mh_header_addr);
|
||||
fprintf(stderr, "multiboot: mh_load_addr = %#x\n", mh_load_addr);
|
||||
fprintf(stderr, "multiboot: mh_load_end_addr = %#x\n", mh_load_end_addr);
|
||||
fprintf(stderr, "multiboot: mh_bss_end_addr = %#x\n", mh_bss_end_addr);
|
||||
fprintf(stderr, "qemu: loading multiboot kernel (%#x bytes) at %#x\n",
|
||||
mb_kernel_size, mh_load_addr);
|
||||
#endif
|
||||
|
||||
mb_kernel_data = qemu_malloc(mb_kernel_size);
|
||||
fseek(f, mb_kernel_text_offset, SEEK_SET);
|
||||
fread(mb_kernel_data, 1, mb_kernel_size, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
/* blob size is only the kernel for now */
|
||||
mb_mod_end = mh_load_addr + mb_kernel_size;
|
||||
|
||||
/* load modules */
|
||||
stl_p(bootinfo + 20, 0x0); /* mods_count */
|
||||
if (initrd_filename) {
|
||||
uint32_t mb_mod_info = 0x100;
|
||||
uint32_t mb_mod_cmdline = 0x300;
|
||||
uint32_t mb_mod_start = mh_load_addr;
|
||||
uint32_t mb_mod_length = mb_kernel_size;
|
||||
char *next_initrd;
|
||||
char *next_space;
|
||||
int mb_mod_count = 0;
|
||||
|
||||
do {
|
||||
if (mb_mod_info + 16 > mb_mod_cmdline) {
|
||||
printf("WARNING: Too many modules loaded, aborting.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
next_initrd = strchr(initrd_filename, ',');
|
||||
if (next_initrd)
|
||||
*next_initrd = '\0';
|
||||
/* if a space comes after the module filename, treat everything
|
||||
after that as parameters */
|
||||
pstrcpy((char*)bootinfo + mb_mod_cmdline,
|
||||
sizeof(bootinfo) - mb_mod_cmdline,
|
||||
initrd_filename);
|
||||
stl_p(bootinfo + mb_mod_info + 8, mb_bootinfo + mb_mod_cmdline); /* string */
|
||||
mb_mod_cmdline += strlen(initrd_filename) + 1;
|
||||
if (mb_mod_cmdline > sizeof(bootinfo)) {
|
||||
mb_mod_cmdline = sizeof(bootinfo);
|
||||
printf("WARNING: Too many module cmdlines loaded, aborting.\n");
|
||||
break;
|
||||
}
|
||||
if ((next_space = strchr(initrd_filename, ' ')))
|
||||
*next_space = '\0';
|
||||
#ifdef DEBUG_MULTIBOOT
|
||||
printf("multiboot loading module: %s\n", initrd_filename);
|
||||
#endif
|
||||
mb_mod_start = (mb_mod_start + mb_mod_length + (TARGET_PAGE_SIZE - 1))
|
||||
& (TARGET_PAGE_MASK);
|
||||
mb_mod_length = get_image_size(initrd_filename);
|
||||
if (mb_mod_length < 0) {
|
||||
fprintf(stderr, "failed to get %s image size\n", initrd_filename);
|
||||
exit(1);
|
||||
}
|
||||
mb_mod_end = mb_mod_start + mb_mod_length;
|
||||
mb_mod_count++;
|
||||
|
||||
/* append module data at the end of last module */
|
||||
mb_kernel_data = qemu_realloc(mb_kernel_data,
|
||||
mb_mod_end - mh_load_addr);
|
||||
load_image(initrd_filename,
|
||||
mb_kernel_data + mb_mod_start - mh_load_addr);
|
||||
|
||||
stl_p(bootinfo + mb_mod_info + 0, mb_mod_start);
|
||||
stl_p(bootinfo + mb_mod_info + 4, mb_mod_start + mb_mod_length);
|
||||
stl_p(bootinfo + mb_mod_info + 12, 0x0); /* reserved */
|
||||
#ifdef DEBUG_MULTIBOOT
|
||||
printf("mod_start: %#x\nmod_end: %#x\n", mb_mod_start,
|
||||
mb_mod_start + mb_mod_length);
|
||||
#endif
|
||||
initrd_filename = next_initrd+1;
|
||||
mb_mod_info += 16;
|
||||
} while (next_initrd);
|
||||
stl_p(bootinfo + 20, mb_mod_count); /* mods_count */
|
||||
stl_p(bootinfo + 24, mb_bootinfo + 0x100); /* mods_addr */
|
||||
}
|
||||
|
||||
/* Commandline support */
|
||||
stl_p(bootinfo + 16, mb_bootinfo + cmdline);
|
||||
snprintf((char*)bootinfo + cmdline, 0x100, "%s %s",
|
||||
kernel_filename, kernel_cmdline);
|
||||
|
||||
/* the kernel is where we want it to be now */
|
||||
#define MULTIBOOT_FLAGS_MEMORY (1 << 0)
|
||||
#define MULTIBOOT_FLAGS_BOOT_DEVICE (1 << 1)
|
||||
#define MULTIBOOT_FLAGS_CMDLINE (1 << 2)
|
||||
#define MULTIBOOT_FLAGS_MODULES (1 << 3)
|
||||
#define MULTIBOOT_FLAGS_MMAP (1 << 6)
|
||||
stl_p(bootinfo, MULTIBOOT_FLAGS_MEMORY
|
||||
| MULTIBOOT_FLAGS_BOOT_DEVICE
|
||||
| MULTIBOOT_FLAGS_CMDLINE
|
||||
| MULTIBOOT_FLAGS_MODULES
|
||||
| MULTIBOOT_FLAGS_MMAP);
|
||||
stl_p(bootinfo + 4, 640); /* mem_lower */
|
||||
stl_p(bootinfo + 8, ram_size / 1024); /* mem_upper */
|
||||
stl_p(bootinfo + 12, 0x8001ffff); /* XXX: use the -boot switch? */
|
||||
stl_p(bootinfo + 48, mmap_addr); /* mmap_addr */
|
||||
|
||||
#ifdef DEBUG_MULTIBOOT
|
||||
fprintf(stderr, "multiboot: mh_entry_addr = %#x\n", mh_entry_addr);
|
||||
#endif
|
||||
|
||||
/* save bootinfo off the stack */
|
||||
mb_bootinfo_data = qemu_malloc(sizeof(bootinfo));
|
||||
memcpy(mb_bootinfo_data, bootinfo, sizeof(bootinfo));
|
||||
|
||||
/* Pass variables to option rom */
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ENTRY, mh_entry_addr);
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, mh_load_addr);
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, mb_mod_end - mh_load_addr);
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, mb_kernel_data,
|
||||
mb_mod_end - mh_load_addr);
|
||||
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, mb_bootinfo);
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, sizeof(bootinfo));
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, mb_bootinfo_data,
|
||||
sizeof(bootinfo));
|
||||
|
||||
option_rom[nb_option_roms] = "multiboot.bin";
|
||||
nb_option_roms++;
|
||||
|
||||
return 1; /* yes, we are multiboot */
|
||||
}
|
||||
|
||||
static void load_linux(void *fw_cfg,
|
||||
const char *kernel_filename,
|
||||
const char *initrd_filename,
|
||||
@@ -540,8 +794,8 @@ static void load_linux(void *fw_cfg,
|
||||
else {
|
||||
/* This looks like a multiboot kernel. If it is, let's stop
|
||||
treating it like a Linux kernel. */
|
||||
if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
|
||||
kernel_cmdline, kernel_size, header))
|
||||
if (load_multiboot(fw_cfg, f, kernel_filename,
|
||||
initrd_filename, kernel_cmdline, header))
|
||||
return;
|
||||
protocol = 0;
|
||||
}
|
||||
@@ -657,14 +911,8 @@ static void load_linux(void *fw_cfg,
|
||||
setup = qemu_malloc(setup_size);
|
||||
kernel = qemu_malloc(kernel_size);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
if (fread(setup, 1, setup_size, f) != setup_size) {
|
||||
fprintf(stderr, "fread() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
if (fread(kernel, 1, kernel_size, f) != kernel_size) {
|
||||
fprintf(stderr, "fread() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
fread(setup, 1, setup_size, f);
|
||||
fread(kernel, 1, kernel_size, f);
|
||||
fclose(f);
|
||||
memcpy(setup, header, MIN(sizeof(header), setup_size));
|
||||
|
||||
@@ -770,6 +1018,7 @@ static void pc_init1(ram_addr_t ram_size,
|
||||
qemu_irq *i8259;
|
||||
IsaIrqState *isa_irq_state;
|
||||
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
||||
BusState *idebus[MAX_IDE_BUS];
|
||||
DriveInfo *fd[MAX_FD];
|
||||
void *fw_cfg;
|
||||
|
||||
@@ -866,6 +1115,7 @@ static void pc_init1(ram_addr_t ram_size,
|
||||
bios_size, bios_offset | IO_MEM_ROM);
|
||||
|
||||
fw_cfg = bochs_bios_init();
|
||||
rom_set_fw(fw_cfg);
|
||||
|
||||
if (linux_boot) {
|
||||
load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size);
|
||||
@@ -962,11 +1212,16 @@ static void pc_init1(ram_addr_t ram_size,
|
||||
}
|
||||
|
||||
if (pci_enabled) {
|
||||
pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
|
||||
PCIDevice *dev;
|
||||
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
|
||||
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
|
||||
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
|
||||
} else {
|
||||
for(i = 0; i < MAX_IDE_BUS; i++) {
|
||||
isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
|
||||
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
|
||||
ISADevice *dev;
|
||||
dev = isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
|
||||
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
|
||||
idebus[i] = qdev_get_child_bus(&dev->qdev, "ide.0");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -981,7 +1236,8 @@ static void pc_init1(ram_addr_t ram_size,
|
||||
}
|
||||
floppy_controller = fdctrl_init_isa(fd);
|
||||
|
||||
cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd);
|
||||
cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
|
||||
idebus[0], idebus[1]);
|
||||
|
||||
if (pci_enabled && usb_enabled) {
|
||||
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
|
||||
@@ -1026,8 +1282,6 @@ static void pc_init1(ram_addr_t ram_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rom_load_fw(fw_cfg);
|
||||
}
|
||||
|
||||
static void pc_init_pci(ram_addr_t ram_size,
|
||||
@@ -1065,7 +1319,7 @@ void cmos_set_s3_resume(void)
|
||||
}
|
||||
|
||||
static QEMUMachine pc_machine = {
|
||||
.name = "pc-0.11",
|
||||
.name = "pc-0.12",
|
||||
.alias = "pc",
|
||||
.desc = "Standard PC",
|
||||
.init = pc_init_pci,
|
||||
@@ -1073,6 +1327,33 @@ static QEMUMachine pc_machine = {
|
||||
.is_default = 1,
|
||||
};
|
||||
|
||||
static QEMUMachine pc_machine_v0_11 = {
|
||||
.name = "pc-0.11",
|
||||
.desc = "Standard PC, qemu 0.11",
|
||||
.init = pc_init_pci,
|
||||
.max_cpus = 255,
|
||||
.compat_props = (GlobalProperty[]) {
|
||||
{
|
||||
.driver = "virtio-blk-pci",
|
||||
.property = "vectors",
|
||||
.value = stringify(0),
|
||||
},{
|
||||
.driver = "ide-drive",
|
||||
.property = "ver",
|
||||
.value = "0.11",
|
||||
},{
|
||||
.driver = "scsi-disk",
|
||||
.property = "ver",
|
||||
.value = "0.11",
|
||||
},{
|
||||
.driver = "PCI",
|
||||
.property = "rombar",
|
||||
.value = stringify(0),
|
||||
},
|
||||
{ /* end of list */ }
|
||||
}
|
||||
};
|
||||
|
||||
static QEMUMachine pc_machine_v0_10 = {
|
||||
.name = "pc-0.10",
|
||||
.desc = "Standard PC, qemu 0.10",
|
||||
@@ -1095,6 +1376,18 @@ static QEMUMachine pc_machine_v0_10 = {
|
||||
.driver = "virtio-blk-pci",
|
||||
.property = "vectors",
|
||||
.value = stringify(0),
|
||||
},{
|
||||
.driver = "ide-drive",
|
||||
.property = "ver",
|
||||
.value = "0.10",
|
||||
},{
|
||||
.driver = "scsi-disk",
|
||||
.property = "ver",
|
||||
.value = "0.10",
|
||||
},{
|
||||
.driver = "PCI",
|
||||
.property = "rombar",
|
||||
.value = stringify(0),
|
||||
},
|
||||
{ /* end of list */ }
|
||||
},
|
||||
@@ -1110,6 +1403,7 @@ static QEMUMachine isapc_machine = {
|
||||
static void pc_machine_init(void)
|
||||
{
|
||||
qemu_register_machine(&pc_machine);
|
||||
qemu_register_machine(&pc_machine_v0_11);
|
||||
qemu_register_machine(&pc_machine_v0_10);
|
||||
qemu_register_machine(&isapc_machine);
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ struct PCIBus {
|
||||
pci_set_irq_fn set_irq;
|
||||
pci_map_irq_fn map_irq;
|
||||
pci_hotplug_fn hotplug;
|
||||
uint32_t config_reg; /* XXX: suppress */
|
||||
void *irq_opaque;
|
||||
PCIDevice *devices[256];
|
||||
PCIDevice *parent_dev;
|
||||
target_phys_addr_t mem_base;
|
||||
|
||||
QLIST_HEAD(, PCIBus) child; /* this will be replaced by qdev later */
|
||||
QLIST_ENTRY(PCIBus) sibling;/* this will be replaced by qdev later */
|
||||
@@ -64,6 +64,7 @@ static struct BusInfo pci_bus_info = {
|
||||
.props = (Property[]) {
|
||||
DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
|
||||
DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
|
||||
DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1),
|
||||
DEFINE_PROP_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
@@ -72,6 +73,7 @@ static void pci_update_mappings(PCIDevice *d);
|
||||
static void pci_set_irq(void *opaque, int irq_num, int level);
|
||||
static int pci_add_option_rom(PCIDevice *pdev);
|
||||
|
||||
target_phys_addr_t pci_mem_base;
|
||||
static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
|
||||
static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU;
|
||||
|
||||
@@ -237,11 +239,6 @@ void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug)
|
||||
bus->hotplug = hotplug;
|
||||
}
|
||||
|
||||
void pci_bus_set_mem_base(PCIBus *bus, target_phys_addr_t base)
|
||||
{
|
||||
bus->mem_base = base;
|
||||
}
|
||||
|
||||
PCIBus *pci_register_bus(DeviceState *parent, const char *name,
|
||||
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
|
||||
void *irq_opaque, int devfn_min, int nirq)
|
||||
@@ -320,7 +317,7 @@ static VMStateInfo vmstate_info_pci_config = {
|
||||
|
||||
static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
|
||||
{
|
||||
PCIDevice *s = container_of(pv, PCIDevice, config);
|
||||
PCIDevice *s = container_of(pv, PCIDevice, irq_state);
|
||||
uint32_t irq_state[PCI_NUM_PINS];
|
||||
int i;
|
||||
for (i = 0; i < PCI_NUM_PINS; ++i) {
|
||||
@@ -342,7 +339,7 @@ static int get_pci_irq_state(QEMUFile *f, void *pv, size_t size)
|
||||
static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size)
|
||||
{
|
||||
int i;
|
||||
PCIDevice *s = container_of(pv, PCIDevice, config);
|
||||
PCIDevice *s = container_of(pv, PCIDevice, irq_state);
|
||||
|
||||
for (i = 0; i < PCI_NUM_PINS; ++i) {
|
||||
qemu_put_be32(f, pci_irq_state(s, i));
|
||||
@@ -419,7 +416,7 @@ static int pci_set_default_subsystem_id(PCIDevice *pci_dev)
|
||||
{
|
||||
uint16_t *id;
|
||||
|
||||
id = (void*)(&pci_dev->config[PCI_SUBSYSTEM_VENDOR_ID]);
|
||||
id = (void*)(&pci_dev->config[PCI_SUBVENDOR_ID]);
|
||||
id[0] = cpu_to_le16(pci_default_sub_vendor_id);
|
||||
id[1] = cpu_to_le16(pci_default_sub_device_id);
|
||||
return 0;
|
||||
@@ -525,8 +522,7 @@ static void pci_init_wmask(PCIDevice *dev)
|
||||
dev->wmask[PCI_CACHE_LINE_SIZE] = 0xff;
|
||||
dev->wmask[PCI_INTERRUPT_LINE] = 0xff;
|
||||
pci_set_word(dev->wmask + PCI_COMMAND,
|
||||
PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
|
||||
PCI_COMMAND_INTX_DISABLE);
|
||||
PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
|
||||
|
||||
memset(dev->wmask + PCI_CONFIG_HEADER_SIZE, 0xff,
|
||||
config_size - PCI_CONFIG_HEADER_SIZE);
|
||||
@@ -639,11 +635,9 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,
|
||||
}
|
||||
return pci_dev;
|
||||
}
|
||||
|
||||
static target_phys_addr_t pci_to_cpu_addr(PCIBus *bus,
|
||||
target_phys_addr_t addr)
|
||||
static target_phys_addr_t pci_to_cpu_addr(target_phys_addr_t addr)
|
||||
{
|
||||
return addr + bus->mem_base;
|
||||
return addr + pci_mem_base;
|
||||
}
|
||||
|
||||
static void pci_unregister_io_regions(PCIDevice *pci_dev)
|
||||
@@ -658,10 +652,9 @@ static void pci_unregister_io_regions(PCIDevice *pci_dev)
|
||||
if (r->type == PCI_BASE_ADDRESS_SPACE_IO) {
|
||||
isa_unassign_ioport(r->addr, r->filtered_size);
|
||||
} else {
|
||||
cpu_register_physical_memory(pci_to_cpu_addr(pci_dev->bus,
|
||||
r->addr),
|
||||
r->filtered_size,
|
||||
IO_MEM_UNASSIGNED);
|
||||
cpu_register_physical_memory(pci_to_cpu_addr(r->addr),
|
||||
r->filtered_size,
|
||||
IO_MEM_UNASSIGNED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -933,7 +926,7 @@ static void pci_update_mappings(PCIDevice *d)
|
||||
isa_unassign_ioport(r->addr, r->filtered_size);
|
||||
}
|
||||
} else {
|
||||
cpu_register_physical_memory(pci_to_cpu_addr(d->bus, r->addr),
|
||||
cpu_register_physical_memory(pci_to_cpu_addr(r->addr),
|
||||
r->filtered_size,
|
||||
IO_MEM_UNASSIGNED);
|
||||
qemu_unregister_coalesced_mmio(r->addr, r->filtered_size);
|
||||
@@ -949,35 +942,11 @@ static void pci_update_mappings(PCIDevice *d)
|
||||
* Teach them such cases, such that filtered_size < size and
|
||||
* addr & (size - 1) != 0.
|
||||
*/
|
||||
if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
|
||||
r->map_func(d, i, r->addr, r->filtered_size, r->type);
|
||||
} else {
|
||||
r->map_func(d, i, pci_to_cpu_addr(d->bus, r->addr),
|
||||
r->filtered_size, r->type);
|
||||
}
|
||||
r->map_func(d, i, r->addr, r->filtered_size, r->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline int pci_irq_disabled(PCIDevice *d)
|
||||
{
|
||||
return pci_get_word(d->config + PCI_COMMAND) & PCI_COMMAND_INTX_DISABLE;
|
||||
}
|
||||
|
||||
/* Called after interrupt disabled field update in config space,
|
||||
* assert/deassert interrupts if necessary.
|
||||
* Gets original interrupt disable bit value (before update). */
|
||||
static void pci_update_irq_disabled(PCIDevice *d, int was_irq_disabled)
|
||||
{
|
||||
int i, disabled = pci_irq_disabled(d);
|
||||
if (disabled == was_irq_disabled)
|
||||
return;
|
||||
for (i = 0; i < PCI_NUM_PINS; ++i) {
|
||||
int state = pci_irq_state(d, i);
|
||||
pci_change_irq_level(d, i, disabled ? -state : state);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t pci_default_read_config(PCIDevice *d,
|
||||
uint32_t address, int len)
|
||||
{
|
||||
@@ -990,7 +959,7 @@ uint32_t pci_default_read_config(PCIDevice *d,
|
||||
|
||||
void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
|
||||
{
|
||||
int i, was_irq_disabled = pci_irq_disabled(d);
|
||||
int i;
|
||||
uint32_t config_size = pci_config_size(d);
|
||||
|
||||
for (i = 0; i < l && addr + i < config_size; val >>= 8, ++i) {
|
||||
@@ -1002,9 +971,6 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
|
||||
ranges_overlap(addr, l, PCI_ROM_ADDRESS1, 4) ||
|
||||
range_covers_byte(addr, l, PCI_COMMAND))
|
||||
pci_update_mappings(d);
|
||||
|
||||
if (range_covers_byte(addr, l, PCI_COMMAND))
|
||||
pci_update_irq_disabled(d, was_irq_disabled);
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
@@ -1022,8 +988,6 @@ static void pci_set_irq(void *opaque, int irq_num, int level)
|
||||
|
||||
pci_set_irq_state(pci_dev, irq_num, level);
|
||||
pci_update_irq_status(pci_dev);
|
||||
if (pci_irq_disabled(pci_dev))
|
||||
return;
|
||||
pci_change_irq_level(pci_dev, irq_num, change);
|
||||
}
|
||||
|
||||
@@ -1501,6 +1465,20 @@ static int pci_add_option_rom(PCIDevice *pdev)
|
||||
if (strlen(pdev->romfile) == 0)
|
||||
return 0;
|
||||
|
||||
if (!pdev->rom_bar) {
|
||||
/*
|
||||
* Load rom via fw_cfg instead of creating a rom bar,
|
||||
* for 0.11 compatibility.
|
||||
*/
|
||||
int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
|
||||
if (class == 0x0300) {
|
||||
rom_add_vga(pdev->romfile);
|
||||
} else {
|
||||
rom_add_option(pdev->romfile);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
|
||||
if (path == NULL) {
|
||||
path = qemu_strdup(pdev->romfile);
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
/* PCI bus */
|
||||
|
||||
extern target_phys_addr_t pci_mem_base;
|
||||
|
||||
#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
|
||||
#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
|
||||
#define PCI_FUNC(devfn) ((devfn) & 0x07)
|
||||
@@ -92,10 +94,77 @@ typedef struct PCIIORegion {
|
||||
#define PCI_ROM_SLOT 6
|
||||
#define PCI_NUM_REGIONS 7
|
||||
|
||||
#include "pci_regs.h"
|
||||
|
||||
/* PCI HEADER_TYPE */
|
||||
/* Declarations from linux/pci_regs.h */
|
||||
#define PCI_VENDOR_ID 0x00 /* 16 bits */
|
||||
#define PCI_DEVICE_ID 0x02 /* 16 bits */
|
||||
#define PCI_COMMAND 0x04 /* 16 bits */
|
||||
#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
|
||||
#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
|
||||
#define PCI_COMMAND_MASTER 0x4 /* Enable bus master */
|
||||
#define PCI_STATUS 0x06 /* 16 bits */
|
||||
#define PCI_STATUS_INTERRUPT 0x08
|
||||
#define PCI_REVISION_ID 0x08 /* 8 bits */
|
||||
#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */
|
||||
#define PCI_CLASS_DEVICE 0x0a /* Device class */
|
||||
#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */
|
||||
#define PCI_LATENCY_TIMER 0x0d /* 8 bits */
|
||||
#define PCI_HEADER_TYPE 0x0e /* 8 bits */
|
||||
#define PCI_HEADER_TYPE_NORMAL 0
|
||||
#define PCI_HEADER_TYPE_BRIDGE 1
|
||||
#define PCI_HEADER_TYPE_CARDBUS 2
|
||||
#define PCI_HEADER_TYPE_MULTI_FUNCTION 0x80
|
||||
#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_SPACE_IO 0x01
|
||||
#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
|
||||
#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */
|
||||
#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */
|
||||
#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */
|
||||
#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */
|
||||
#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */
|
||||
#define PCI_IO_LIMIT 0x1d
|
||||
#define PCI_IO_RANGE_TYPE_32 0x01
|
||||
#define PCI_IO_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */
|
||||
#define PCI_MEMORY_BASE 0x20 /* Memory range behind */
|
||||
#define PCI_MEMORY_LIMIT 0x22
|
||||
#define PCI_MEMORY_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */
|
||||
#define PCI_PREF_MEMORY_LIMIT 0x26
|
||||
#define PCI_PREF_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_PREF_RANGE_TYPE_64 0x01
|
||||
#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */
|
||||
#define PCI_PREF_LIMIT_UPPER32 0x2c
|
||||
#define PCI_SUBSYSTEM_VENDOR_ID 0x2c /* 16 bits */
|
||||
#define PCI_SUBSYSTEM_ID 0x2e /* 16 bits */
|
||||
#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */
|
||||
#define PCI_ROM_ADDRESS_ENABLE 0x01
|
||||
#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */
|
||||
#define PCI_IO_LIMIT_UPPER16 0x32
|
||||
#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
|
||||
#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */
|
||||
#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
|
||||
#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
|
||||
#define PCI_MIN_GNT 0x3e /* 8 bits */
|
||||
#define PCI_BRIDGE_CONTROL 0x3e
|
||||
#define PCI_MAX_LAT 0x3f /* 8 bits */
|
||||
|
||||
/* Capability lists */
|
||||
#define PCI_CAP_LIST_ID 0 /* Capability ID */
|
||||
#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */
|
||||
|
||||
#define PCI_REVISION 0x08 /* obsolete, use PCI_REVISION_ID */
|
||||
#define PCI_SUBVENDOR_ID 0x2c /* obsolete, use PCI_SUBSYSTEM_VENDOR_ID */
|
||||
#define PCI_SUBDEVICE_ID 0x2e /* obsolete, use PCI_SUBSYSTEM_ID */
|
||||
|
||||
/* Bits in the PCI Status Register (PCI 2.3 spec) */
|
||||
#define PCI_STATUS_RESERVED1 0x007
|
||||
#define PCI_STATUS_INT_STATUS 0x008
|
||||
#define PCI_STATUS_CAP_LIST 0x010
|
||||
#define PCI_STATUS_66MHZ 0x020
|
||||
#define PCI_STATUS_RESERVED2 0x040
|
||||
#define PCI_STATUS_FAST_BACK 0x080
|
||||
#define PCI_STATUS_DEVSEL 0x600
|
||||
|
||||
#define PCI_STATUS_RESERVED_MASK_LO (PCI_STATUS_RESERVED1 | \
|
||||
PCI_STATUS_INT_STATUS | PCI_STATUS_CAPABILITIES | \
|
||||
@@ -177,6 +246,7 @@ struct PCIDevice {
|
||||
/* Location of option rom */
|
||||
char *romfile;
|
||||
ram_addr_t rom_offset;
|
||||
uint32_t rom_bar;
|
||||
};
|
||||
|
||||
PCIDevice *pci_register_device(PCIBus *bus, const char *name,
|
||||
@@ -217,8 +287,6 @@ PCIBus *pci_register_bus(DeviceState *parent, const char *name,
|
||||
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
|
||||
void *irq_opaque, int devfn_min, int nirq);
|
||||
|
||||
void pci_bus_set_mem_base(PCIBus *bus, target_phys_addr_t base);
|
||||
|
||||
PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
|
||||
const char *default_devaddr);
|
||||
PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
|
||||
|
||||
-665
@@ -1,665 +0,0 @@
|
||||
/*
|
||||
* pci_regs.h
|
||||
*
|
||||
* PCI standard defines
|
||||
* Copyright 1994, Drew Eckhardt
|
||||
* Copyright 1997--1999 Martin Mares <mj@ucw.cz>
|
||||
*
|
||||
* For more information, please consult the following manuals (look at
|
||||
* http://www.pcisig.com/ for how to get them):
|
||||
*
|
||||
* PCI BIOS Specification
|
||||
* PCI Local Bus Specification
|
||||
* PCI to PCI Bridge Specification
|
||||
* PCI System Design Guide
|
||||
*
|
||||
* For hypertransport information, please consult the following manuals
|
||||
* from http://www.hypertransport.org
|
||||
*
|
||||
* The Hypertransport I/O Link Specification
|
||||
*/
|
||||
|
||||
#ifndef LINUX_PCI_REGS_H
|
||||
#define LINUX_PCI_REGS_H
|
||||
|
||||
/*
|
||||
* Under PCI, each device has 256 bytes of configuration address space,
|
||||
* of which the first 64 bytes are standardized as follows:
|
||||
*/
|
||||
#define PCI_VENDOR_ID 0x00 /* 16 bits */
|
||||
#define PCI_DEVICE_ID 0x02 /* 16 bits */
|
||||
#define PCI_COMMAND 0x04 /* 16 bits */
|
||||
#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
|
||||
#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
|
||||
#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */
|
||||
#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */
|
||||
#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */
|
||||
#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */
|
||||
#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */
|
||||
#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */
|
||||
#define PCI_COMMAND_SERR 0x100 /* Enable SERR */
|
||||
#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */
|
||||
#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
|
||||
|
||||
#define PCI_STATUS 0x06 /* 16 bits */
|
||||
#define PCI_STATUS_INTERRUPT 0x08 /* Interrupt status */
|
||||
#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
|
||||
#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */
|
||||
#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */
|
||||
#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */
|
||||
#define PCI_STATUS_PARITY 0x100 /* Detected parity error */
|
||||
#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */
|
||||
#define PCI_STATUS_DEVSEL_FAST 0x000
|
||||
#define PCI_STATUS_DEVSEL_MEDIUM 0x200
|
||||
#define PCI_STATUS_DEVSEL_SLOW 0x400
|
||||
#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */
|
||||
#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */
|
||||
#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */
|
||||
#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */
|
||||
#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */
|
||||
|
||||
#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */
|
||||
#define PCI_REVISION_ID 0x08 /* Revision ID */
|
||||
#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */
|
||||
#define PCI_CLASS_DEVICE 0x0a /* Device class */
|
||||
|
||||
#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */
|
||||
#define PCI_LATENCY_TIMER 0x0d /* 8 bits */
|
||||
#define PCI_HEADER_TYPE 0x0e /* 8 bits */
|
||||
#define PCI_HEADER_TYPE_NORMAL 0
|
||||
#define PCI_HEADER_TYPE_BRIDGE 1
|
||||
#define PCI_HEADER_TYPE_CARDBUS 2
|
||||
|
||||
#define PCI_BIST 0x0f /* 8 bits */
|
||||
#define PCI_BIST_CODE_MASK 0x0f /* Return result */
|
||||
#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */
|
||||
#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */
|
||||
|
||||
/*
|
||||
* Base addresses specify locations in memory or I/O space.
|
||||
* Decoded size can be determined by writing a value of
|
||||
* 0xffffffff to the register, and reading it back. Only
|
||||
* 1 bits are decoded.
|
||||
*/
|
||||
#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */
|
||||
#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */
|
||||
#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */
|
||||
#define PCI_BASE_ADDRESS_SPACE_IO 0x01
|
||||
#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
|
||||
#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */
|
||||
#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL)
|
||||
#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL)
|
||||
/* bit 1 is reserved if address_space = 1 */
|
||||
|
||||
/* Header type 0 (normal devices) */
|
||||
#define PCI_CARDBUS_CIS 0x28
|
||||
#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
|
||||
#define PCI_SUBSYSTEM_ID 0x2e
|
||||
#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */
|
||||
#define PCI_ROM_ADDRESS_ENABLE 0x01
|
||||
#define PCI_ROM_ADDRESS_MASK (~0x7ffUL)
|
||||
|
||||
#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
|
||||
|
||||
/* 0x35-0x3b are reserved */
|
||||
#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
|
||||
#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
|
||||
#define PCI_MIN_GNT 0x3e /* 8 bits */
|
||||
#define PCI_MAX_LAT 0x3f /* 8 bits */
|
||||
|
||||
/* Header type 1 (PCI-to-PCI bridges) */
|
||||
#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */
|
||||
#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */
|
||||
#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */
|
||||
#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */
|
||||
#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */
|
||||
#define PCI_IO_LIMIT 0x1d
|
||||
#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */
|
||||
#define PCI_IO_RANGE_TYPE_16 0x00
|
||||
#define PCI_IO_RANGE_TYPE_32 0x01
|
||||
#define PCI_IO_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */
|
||||
#define PCI_MEMORY_BASE 0x20 /* Memory range behind */
|
||||
#define PCI_MEMORY_LIMIT 0x22
|
||||
#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL
|
||||
#define PCI_MEMORY_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */
|
||||
#define PCI_PREF_MEMORY_LIMIT 0x26
|
||||
#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL
|
||||
#define PCI_PREF_RANGE_TYPE_32 0x00
|
||||
#define PCI_PREF_RANGE_TYPE_64 0x01
|
||||
#define PCI_PREF_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */
|
||||
#define PCI_PREF_LIMIT_UPPER32 0x2c
|
||||
#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */
|
||||
#define PCI_IO_LIMIT_UPPER16 0x32
|
||||
/* 0x34 same as for htype 0 */
|
||||
/* 0x35-0x3b is reserved */
|
||||
#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */
|
||||
/* 0x3c-0x3d are same as for htype 0 */
|
||||
#define PCI_BRIDGE_CONTROL 0x3e
|
||||
#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */
|
||||
#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */
|
||||
#define PCI_BRIDGE_CTL_ISA 0x04 /* Enable ISA mode */
|
||||
#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */
|
||||
#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */
|
||||
#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */
|
||||
#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */
|
||||
|
||||
/* Header type 2 (CardBus bridges) */
|
||||
#define PCI_CB_CAPABILITY_LIST 0x14
|
||||
/* 0x15 reserved */
|
||||
#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */
|
||||
#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */
|
||||
#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */
|
||||
#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */
|
||||
#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */
|
||||
#define PCI_CB_MEMORY_BASE_0 0x1c
|
||||
#define PCI_CB_MEMORY_LIMIT_0 0x20
|
||||
#define PCI_CB_MEMORY_BASE_1 0x24
|
||||
#define PCI_CB_MEMORY_LIMIT_1 0x28
|
||||
#define PCI_CB_IO_BASE_0 0x2c
|
||||
#define PCI_CB_IO_BASE_0_HI 0x2e
|
||||
#define PCI_CB_IO_LIMIT_0 0x30
|
||||
#define PCI_CB_IO_LIMIT_0_HI 0x32
|
||||
#define PCI_CB_IO_BASE_1 0x34
|
||||
#define PCI_CB_IO_BASE_1_HI 0x36
|
||||
#define PCI_CB_IO_LIMIT_1 0x38
|
||||
#define PCI_CB_IO_LIMIT_1_HI 0x3a
|
||||
#define PCI_CB_IO_RANGE_MASK (~0x03UL)
|
||||
/* 0x3c-0x3d are same as for htype 0 */
|
||||
#define PCI_CB_BRIDGE_CONTROL 0x3e
|
||||
#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */
|
||||
#define PCI_CB_BRIDGE_CTL_SERR 0x02
|
||||
#define PCI_CB_BRIDGE_CTL_ISA 0x04
|
||||
#define PCI_CB_BRIDGE_CTL_VGA 0x08
|
||||
#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20
|
||||
#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */
|
||||
#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */
|
||||
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */
|
||||
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200
|
||||
#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400
|
||||
#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40
|
||||
#define PCI_CB_SUBSYSTEM_ID 0x42
|
||||
#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */
|
||||
/* 0x48-0x7f reserved */
|
||||
|
||||
/* Capability lists */
|
||||
|
||||
#define PCI_CAP_LIST_ID 0 /* Capability ID */
|
||||
#define PCI_CAP_ID_PM 0x01 /* Power Management */
|
||||
#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */
|
||||
#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */
|
||||
#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */
|
||||
#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */
|
||||
#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */
|
||||
#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */
|
||||
#define PCI_CAP_ID_HT 0x08 /* HyperTransport */
|
||||
#define PCI_CAP_ID_VNDR 0x09 /* Vendor specific */
|
||||
#define PCI_CAP_ID_DBG 0x0A /* Debug port */
|
||||
#define PCI_CAP_ID_CCRC 0x0B /* CompactPCI Central Resource Control */
|
||||
#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */
|
||||
#define PCI_CAP_ID_SSVID 0x0D /* Bridge subsystem vendor/device ID */
|
||||
#define PCI_CAP_ID_AGP3 0x0E /* AGP Target PCI-PCI bridge */
|
||||
#define PCI_CAP_ID_EXP 0x10 /* PCI Express */
|
||||
#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */
|
||||
#define PCI_CAP_ID_AF 0x13 /* PCI Advanced Features */
|
||||
#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */
|
||||
#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */
|
||||
#define PCI_CAP_SIZEOF 4
|
||||
|
||||
/* Power Management Registers */
|
||||
|
||||
#define PCI_PM_PMC 2 /* PM Capabilities Register */
|
||||
#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */
|
||||
#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */
|
||||
#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */
|
||||
#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
|
||||
#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */
|
||||
#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */
|
||||
#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */
|
||||
#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */
|
||||
#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */
|
||||
#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */
|
||||
#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */
|
||||
#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */
|
||||
#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */
|
||||
#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */
|
||||
#define PCI_PM_CAP_PME_SHIFT 11 /* Start of the PME Mask in PMC */
|
||||
#define PCI_PM_CTRL 4 /* PM control and status register */
|
||||
#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
|
||||
#define PCI_PM_CTRL_NO_SOFT_RESET 0x0008 /* No reset for D3hot->D0 */
|
||||
#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
|
||||
#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */
|
||||
#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */
|
||||
#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
|
||||
#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */
|
||||
#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */
|
||||
#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */
|
||||
#define PCI_PM_DATA_REGISTER 7 /* (??) */
|
||||
#define PCI_PM_SIZEOF 8
|
||||
|
||||
/* AGP registers */
|
||||
|
||||
#define PCI_AGP_VERSION 2 /* BCD version number */
|
||||
#define PCI_AGP_RFU 3 /* Rest of capability flags */
|
||||
#define PCI_AGP_STATUS 4 /* Status register */
|
||||
#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */
|
||||
#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */
|
||||
#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */
|
||||
#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */
|
||||
#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */
|
||||
#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */
|
||||
#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */
|
||||
#define PCI_AGP_COMMAND 8 /* Control register */
|
||||
#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */
|
||||
#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */
|
||||
#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */
|
||||
#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */
|
||||
#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */
|
||||
#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */
|
||||
#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */
|
||||
#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */
|
||||
#define PCI_AGP_SIZEOF 12
|
||||
|
||||
/* Vital Product Data */
|
||||
|
||||
#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */
|
||||
#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */
|
||||
#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */
|
||||
#define PCI_VPD_DATA 4 /* 32-bits of data returned here */
|
||||
|
||||
/* Slot Identification */
|
||||
|
||||
#define PCI_SID_ESR 2 /* Expansion Slot Register */
|
||||
#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */
|
||||
#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */
|
||||
#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */
|
||||
|
||||
/* Message Signalled Interrupts registers */
|
||||
|
||||
#define PCI_MSI_FLAGS 2 /* Various flags */
|
||||
#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */
|
||||
#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */
|
||||
#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */
|
||||
#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */
|
||||
#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */
|
||||
#define PCI_MSI_RFU 3 /* Rest of capability flags */
|
||||
#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */
|
||||
#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
|
||||
#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
|
||||
#define PCI_MSI_MASK_32 12 /* Mask bits register for 32-bit devices */
|
||||
#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
|
||||
#define PCI_MSI_MASK_64 16 /* Mask bits register for 64-bit devices */
|
||||
|
||||
/* MSI-X registers (these are at offset PCI_MSIX_FLAGS) */
|
||||
#define PCI_MSIX_FLAGS 2
|
||||
#define PCI_MSIX_FLAGS_QSIZE 0x7FF
|
||||
#define PCI_MSIX_FLAGS_ENABLE (1 << 15)
|
||||
#define PCI_MSIX_FLAGS_MASKALL (1 << 14)
|
||||
#define PCI_MSIX_FLAGS_BIRMASK (7 << 0)
|
||||
|
||||
/* CompactPCI Hotswap Register */
|
||||
|
||||
#define PCI_CHSWP_CSR 2 /* Control and Status Register */
|
||||
#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */
|
||||
#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */
|
||||
#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */
|
||||
#define PCI_CHSWP_LOO 0x08 /* LED On / Off */
|
||||
#define PCI_CHSWP_PI 0x30 /* Programming Interface */
|
||||
#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */
|
||||
#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */
|
||||
|
||||
/* PCI Advanced Feature registers */
|
||||
|
||||
#define PCI_AF_LENGTH 2
|
||||
#define PCI_AF_CAP 3
|
||||
#define PCI_AF_CAP_TP 0x01
|
||||
#define PCI_AF_CAP_FLR 0x02
|
||||
#define PCI_AF_CTRL 4
|
||||
#define PCI_AF_CTRL_FLR 0x01
|
||||
#define PCI_AF_STATUS 5
|
||||
#define PCI_AF_STATUS_TP 0x01
|
||||
|
||||
/* PCI-X registers */
|
||||
|
||||
#define PCI_X_CMD 2 /* Modes & Features */
|
||||
#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */
|
||||
#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */
|
||||
#define PCI_X_CMD_READ_512 0x0000 /* 512 byte maximum read byte count */
|
||||
#define PCI_X_CMD_READ_1K 0x0004 /* 1Kbyte maximum read byte count */
|
||||
#define PCI_X_CMD_READ_2K 0x0008 /* 2Kbyte maximum read byte count */
|
||||
#define PCI_X_CMD_READ_4K 0x000c /* 4Kbyte maximum read byte count */
|
||||
#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */
|
||||
/* Max # of outstanding split transactions */
|
||||
#define PCI_X_CMD_SPLIT_1 0x0000 /* Max 1 */
|
||||
#define PCI_X_CMD_SPLIT_2 0x0010 /* Max 2 */
|
||||
#define PCI_X_CMD_SPLIT_3 0x0020 /* Max 3 */
|
||||
#define PCI_X_CMD_SPLIT_4 0x0030 /* Max 4 */
|
||||
#define PCI_X_CMD_SPLIT_8 0x0040 /* Max 8 */
|
||||
#define PCI_X_CMD_SPLIT_12 0x0050 /* Max 12 */
|
||||
#define PCI_X_CMD_SPLIT_16 0x0060 /* Max 16 */
|
||||
#define PCI_X_CMD_SPLIT_32 0x0070 /* Max 32 */
|
||||
#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */
|
||||
#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */
|
||||
#define PCI_X_STATUS 4 /* PCI-X capabilities */
|
||||
#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */
|
||||
#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */
|
||||
#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */
|
||||
#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */
|
||||
#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */
|
||||
#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */
|
||||
#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */
|
||||
#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */
|
||||
#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */
|
||||
#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */
|
||||
#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */
|
||||
#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */
|
||||
#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */
|
||||
|
||||
/* PCI Express capability registers */
|
||||
|
||||
#define PCI_EXP_FLAGS 2 /* Capabilities register */
|
||||
#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */
|
||||
#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */
|
||||
#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */
|
||||
#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */
|
||||
#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */
|
||||
#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */
|
||||
#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */
|
||||
#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */
|
||||
#define PCI_EXP_TYPE_RC_END 0x9 /* Root Complex Integrated Endpoint */
|
||||
#define PCI_EXP_TYPE_RC_EC 0x10 /* Root Complex Event Collector */
|
||||
#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */
|
||||
#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */
|
||||
#define PCI_EXP_DEVCAP 4 /* Device capabilities */
|
||||
#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */
|
||||
#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */
|
||||
#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */
|
||||
#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */
|
||||
#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */
|
||||
#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */
|
||||
#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */
|
||||
#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */
|
||||
#define PCI_EXP_DEVCAP_RBER 0x8000 /* Role-Based Error Reporting */
|
||||
#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */
|
||||
#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */
|
||||
#define PCI_EXP_DEVCAP_FLR 0x10000000 /* Function Level Reset */
|
||||
#define PCI_EXP_DEVCTL 8 /* Device Control */
|
||||
#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */
|
||||
#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */
|
||||
#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */
|
||||
#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */
|
||||
#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */
|
||||
#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */
|
||||
#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */
|
||||
#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */
|
||||
#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */
|
||||
#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */
|
||||
#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */
|
||||
#define PCI_EXP_DEVCTL_BCR_FLR 0x8000 /* Bridge Configuration Retry / FLR */
|
||||
#define PCI_EXP_DEVSTA 10 /* Device Status */
|
||||
#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */
|
||||
#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */
|
||||
#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */
|
||||
#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */
|
||||
#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */
|
||||
#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */
|
||||
#define PCI_EXP_LNKCAP 12 /* Link Capabilities */
|
||||
#define PCI_EXP_LNKCAP_SLS 0x0000000f /* Supported Link Speeds */
|
||||
#define PCI_EXP_LNKCAP_MLW 0x000003f0 /* Maximum Link Width */
|
||||
#define PCI_EXP_LNKCAP_ASPMS 0x00000c00 /* ASPM Support */
|
||||
#define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */
|
||||
#define PCI_EXP_LNKCAP_L1EL 0x00038000 /* L1 Exit Latency */
|
||||
#define PCI_EXP_LNKCAP_CLKPM 0x00040000 /* L1 Clock Power Management */
|
||||
#define PCI_EXP_LNKCAP_SDERC 0x00080000 /* Suprise Down Error Reporting Capable */
|
||||
#define PCI_EXP_LNKCAP_DLLLARC 0x00100000 /* Data Link Layer Link Active Reporting Capable */
|
||||
#define PCI_EXP_LNKCAP_LBNC 0x00200000 /* Link Bandwidth Notification Capability */
|
||||
#define PCI_EXP_LNKCAP_PN 0xff000000 /* Port Number */
|
||||
#define PCI_EXP_LNKCTL 16 /* Link Control */
|
||||
#define PCI_EXP_LNKCTL_ASPMC 0x0003 /* ASPM Control */
|
||||
#define PCI_EXP_LNKCTL_RCB 0x0008 /* Read Completion Boundary */
|
||||
#define PCI_EXP_LNKCTL_LD 0x0010 /* Link Disable */
|
||||
#define PCI_EXP_LNKCTL_RL 0x0020 /* Retrain Link */
|
||||
#define PCI_EXP_LNKCTL_CCC 0x0040 /* Common Clock Configuration */
|
||||
#define PCI_EXP_LNKCTL_ES 0x0080 /* Extended Synch */
|
||||
#define PCI_EXP_LNKCTL_CLKREQ_EN 0x100 /* Enable clkreq */
|
||||
#define PCI_EXP_LNKCTL_HAWD 0x0200 /* Hardware Autonomous Width Disable */
|
||||
#define PCI_EXP_LNKCTL_LBMIE 0x0400 /* Link Bandwidth Management Interrupt Enable */
|
||||
#define PCI_EXP_LNKCTL_LABIE 0x0800 /* Lnk Autonomous Bandwidth Interrupt Enable */
|
||||
#define PCI_EXP_LNKSTA 18 /* Link Status */
|
||||
#define PCI_EXP_LNKSTA_CLS 0x000f /* Current Link Speed */
|
||||
#define PCI_EXP_LNKSTA_NLW 0x03f0 /* Nogotiated Link Width */
|
||||
#define PCI_EXP_LNKSTA_LT 0x0800 /* Link Training */
|
||||
#define PCI_EXP_LNKSTA_SLC 0x1000 /* Slot Clock Configuration */
|
||||
#define PCI_EXP_LNKSTA_DLLLA 0x2000 /* Data Link Layer Link Active */
|
||||
#define PCI_EXP_LNKSTA_LBMS 0x4000 /* Link Bandwidth Management Status */
|
||||
#define PCI_EXP_LNKSTA_LABS 0x8000 /* Link Autonomous Bandwidth Status */
|
||||
#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */
|
||||
#define PCI_EXP_SLTCAP_ABP 0x00000001 /* Attention Button Present */
|
||||
#define PCI_EXP_SLTCAP_PCP 0x00000002 /* Power Controller Present */
|
||||
#define PCI_EXP_SLTCAP_MRLSP 0x00000004 /* MRL Sensor Present */
|
||||
#define PCI_EXP_SLTCAP_AIP 0x00000008 /* Attention Indicator Present */
|
||||
#define PCI_EXP_SLTCAP_PIP 0x00000010 /* Power Indicator Present */
|
||||
#define PCI_EXP_SLTCAP_HPS 0x00000020 /* Hot-Plug Surprise */
|
||||
#define PCI_EXP_SLTCAP_HPC 0x00000040 /* Hot-Plug Capable */
|
||||
#define PCI_EXP_SLTCAP_SPLV 0x00007f80 /* Slot Power Limit Value */
|
||||
#define PCI_EXP_SLTCAP_SPLS 0x00018000 /* Slot Power Limit Scale */
|
||||
#define PCI_EXP_SLTCAP_EIP 0x00020000 /* Electromechanical Interlock Present */
|
||||
#define PCI_EXP_SLTCAP_NCCS 0x00040000 /* No Command Completed Support */
|
||||
#define PCI_EXP_SLTCAP_PSN 0xfff80000 /* Physical Slot Number */
|
||||
#define PCI_EXP_SLTCTL 24 /* Slot Control */
|
||||
#define PCI_EXP_SLTCTL_ABPE 0x0001 /* Attention Button Pressed Enable */
|
||||
#define PCI_EXP_SLTCTL_PFDE 0x0002 /* Power Fault Detected Enable */
|
||||
#define PCI_EXP_SLTCTL_MRLSCE 0x0004 /* MRL Sensor Changed Enable */
|
||||
#define PCI_EXP_SLTCTL_PDCE 0x0008 /* Presence Detect Changed Enable */
|
||||
#define PCI_EXP_SLTCTL_CCIE 0x0010 /* Command Completed Interrupt Enable */
|
||||
#define PCI_EXP_SLTCTL_HPIE 0x0020 /* Hot-Plug Interrupt Enable */
|
||||
#define PCI_EXP_SLTCTL_AIC 0x00c0 /* Attention Indicator Control */
|
||||
#define PCI_EXP_SLTCTL_PIC 0x0300 /* Power Indicator Control */
|
||||
#define PCI_EXP_SLTCTL_PCC 0x0400 /* Power Controller Control */
|
||||
#define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */
|
||||
#define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */
|
||||
#define PCI_EXP_SLTSTA 26 /* Slot Status */
|
||||
#define PCI_EXP_SLTSTA_ABP 0x0001 /* Attention Button Pressed */
|
||||
#define PCI_EXP_SLTSTA_PFD 0x0002 /* Power Fault Detected */
|
||||
#define PCI_EXP_SLTSTA_MRLSC 0x0004 /* MRL Sensor Changed */
|
||||
#define PCI_EXP_SLTSTA_PDC 0x0008 /* Presence Detect Changed */
|
||||
#define PCI_EXP_SLTSTA_CC 0x0010 /* Command Completed */
|
||||
#define PCI_EXP_SLTSTA_MRLSS 0x0020 /* MRL Sensor State */
|
||||
#define PCI_EXP_SLTSTA_PDS 0x0040 /* Presence Detect State */
|
||||
#define PCI_EXP_SLTSTA_EIS 0x0080 /* Electromechanical Interlock Status */
|
||||
#define PCI_EXP_SLTSTA_DLLSC 0x0100 /* Data Link Layer State Changed */
|
||||
#define PCI_EXP_RTCTL 28 /* Root Control */
|
||||
#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */
|
||||
#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */
|
||||
#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */
|
||||
#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */
|
||||
#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */
|
||||
#define PCI_EXP_RTCAP 30 /* Root Capabilities */
|
||||
#define PCI_EXP_RTSTA 32 /* Root Status */
|
||||
#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */
|
||||
#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */
|
||||
#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
|
||||
#define PCI_EXP_DEVCTL2_ARI 0x20 /* Alternative Routing-ID */
|
||||
#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */
|
||||
#define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */
|
||||
|
||||
/* Extended Capabilities (PCI-X 2.0 and Express) */
|
||||
#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
|
||||
#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf)
|
||||
#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc)
|
||||
|
||||
#define PCI_EXT_CAP_ID_ERR 1
|
||||
#define PCI_EXT_CAP_ID_VC 2
|
||||
#define PCI_EXT_CAP_ID_DSN 3
|
||||
#define PCI_EXT_CAP_ID_PWR 4
|
||||
#define PCI_EXT_CAP_ID_ARI 14
|
||||
#define PCI_EXT_CAP_ID_ATS 15
|
||||
#define PCI_EXT_CAP_ID_SRIOV 16
|
||||
|
||||
/* Advanced Error Reporting */
|
||||
#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */
|
||||
#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */
|
||||
#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */
|
||||
#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */
|
||||
#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */
|
||||
#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */
|
||||
#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */
|
||||
#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */
|
||||
#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */
|
||||
#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */
|
||||
#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */
|
||||
#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */
|
||||
#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */
|
||||
/* Same bits as above */
|
||||
#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */
|
||||
/* Same bits as above */
|
||||
#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */
|
||||
#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */
|
||||
#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */
|
||||
#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */
|
||||
#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */
|
||||
#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */
|
||||
#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */
|
||||
/* Same bits as above */
|
||||
#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */
|
||||
#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */
|
||||
#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */
|
||||
#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */
|
||||
#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */
|
||||
#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */
|
||||
#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */
|
||||
#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */
|
||||
/* Correctable Err Reporting Enable */
|
||||
#define PCI_ERR_ROOT_CMD_COR_EN 0x00000001
|
||||
/* Non-fatal Err Reporting Enable */
|
||||
#define PCI_ERR_ROOT_CMD_NONFATAL_EN 0x00000002
|
||||
/* Fatal Err Reporting Enable */
|
||||
#define PCI_ERR_ROOT_CMD_FATAL_EN 0x00000004
|
||||
#define PCI_ERR_ROOT_STATUS 48
|
||||
#define PCI_ERR_ROOT_COR_RCV 0x00000001 /* ERR_COR Received */
|
||||
/* Multi ERR_COR Received */
|
||||
#define PCI_ERR_ROOT_MULTI_COR_RCV 0x00000002
|
||||
/* ERR_FATAL/NONFATAL Recevied */
|
||||
#define PCI_ERR_ROOT_UNCOR_RCV 0x00000004
|
||||
/* Multi ERR_FATAL/NONFATAL Recevied */
|
||||
#define PCI_ERR_ROOT_MULTI_UNCOR_RCV 0x00000008
|
||||
#define PCI_ERR_ROOT_FIRST_FATAL 0x00000010 /* First Fatal */
|
||||
#define PCI_ERR_ROOT_NONFATAL_RCV 0x00000020 /* Non-Fatal Received */
|
||||
#define PCI_ERR_ROOT_FATAL_RCV 0x00000040 /* Fatal Received */
|
||||
#define PCI_ERR_ROOT_COR_SRC 52
|
||||
#define PCI_ERR_ROOT_SRC 54
|
||||
|
||||
/* Virtual Channel */
|
||||
#define PCI_VC_PORT_REG1 4
|
||||
#define PCI_VC_PORT_REG2 8
|
||||
#define PCI_VC_PORT_CTRL 12
|
||||
#define PCI_VC_PORT_STATUS 14
|
||||
#define PCI_VC_RES_CAP 16
|
||||
#define PCI_VC_RES_CTRL 20
|
||||
#define PCI_VC_RES_STATUS 26
|
||||
|
||||
/* Power Budgeting */
|
||||
#define PCI_PWR_DSR 4 /* Data Select Register */
|
||||
#define PCI_PWR_DATA 8 /* Data Register */
|
||||
#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */
|
||||
#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */
|
||||
#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */
|
||||
#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */
|
||||
#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */
|
||||
#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */
|
||||
#define PCI_PWR_CAP 12 /* Capability */
|
||||
#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */
|
||||
|
||||
/*
|
||||
* Hypertransport sub capability types
|
||||
*
|
||||
* Unfortunately there are both 3 bit and 5 bit capability types defined
|
||||
* in the HT spec, catering for that is a little messy. You probably don't
|
||||
* want to use these directly, just use pci_find_ht_capability() and it
|
||||
* will do the right thing for you.
|
||||
*/
|
||||
#define HT_3BIT_CAP_MASK 0xE0
|
||||
#define HT_CAPTYPE_SLAVE 0x00 /* Slave/Primary link configuration */
|
||||
#define HT_CAPTYPE_HOST 0x20 /* Host/Secondary link configuration */
|
||||
|
||||
#define HT_5BIT_CAP_MASK 0xF8
|
||||
#define HT_CAPTYPE_IRQ 0x80 /* IRQ Configuration */
|
||||
#define HT_CAPTYPE_REMAPPING_40 0xA0 /* 40 bit address remapping */
|
||||
#define HT_CAPTYPE_REMAPPING_64 0xA2 /* 64 bit address remapping */
|
||||
#define HT_CAPTYPE_UNITID_CLUMP 0x90 /* Unit ID clumping */
|
||||
#define HT_CAPTYPE_EXTCONF 0x98 /* Extended Configuration Space Access */
|
||||
#define HT_CAPTYPE_MSI_MAPPING 0xA8 /* MSI Mapping Capability */
|
||||
#define HT_MSI_FLAGS 0x02 /* Offset to flags */
|
||||
#define HT_MSI_FLAGS_ENABLE 0x1 /* Mapping enable */
|
||||
#define HT_MSI_FLAGS_FIXED 0x2 /* Fixed mapping only */
|
||||
#define HT_MSI_FIXED_ADDR 0x00000000FEE00000ULL /* Fixed addr */
|
||||
#define HT_MSI_ADDR_LO 0x04 /* Offset to low addr bits */
|
||||
#define HT_MSI_ADDR_LO_MASK 0xFFF00000 /* Low address bit mask */
|
||||
#define HT_MSI_ADDR_HI 0x08 /* Offset to high addr bits */
|
||||
#define HT_CAPTYPE_DIRECT_ROUTE 0xB0 /* Direct routing configuration */
|
||||
#define HT_CAPTYPE_VCSET 0xB8 /* Virtual Channel configuration */
|
||||
#define HT_CAPTYPE_ERROR_RETRY 0xC0 /* Retry on error configuration */
|
||||
#define HT_CAPTYPE_GEN3 0xD0 /* Generation 3 hypertransport configuration */
|
||||
#define HT_CAPTYPE_PM 0xE0 /* Hypertransport powermanagement configuration */
|
||||
|
||||
/* Alternative Routing-ID Interpretation */
|
||||
#define PCI_ARI_CAP 0x04 /* ARI Capability Register */
|
||||
#define PCI_ARI_CAP_MFVC 0x0001 /* MFVC Function Groups Capability */
|
||||
#define PCI_ARI_CAP_ACS 0x0002 /* ACS Function Groups Capability */
|
||||
#define PCI_ARI_CAP_NFN(x) (((x) >> 8) & 0xff) /* Next Function Number */
|
||||
#define PCI_ARI_CTRL 0x06 /* ARI Control Register */
|
||||
#define PCI_ARI_CTRL_MFVC 0x0001 /* MFVC Function Groups Enable */
|
||||
#define PCI_ARI_CTRL_ACS 0x0002 /* ACS Function Groups Enable */
|
||||
#define PCI_ARI_CTRL_FG(x) (((x) >> 4) & 7) /* Function Group */
|
||||
|
||||
/* Address Translation Service */
|
||||
#define PCI_ATS_CAP 0x04 /* ATS Capability Register */
|
||||
#define PCI_ATS_CAP_QDEP(x) ((x) & 0x1f) /* Invalidate Queue Depth */
|
||||
#define PCI_ATS_MAX_QDEP 32 /* Max Invalidate Queue Depth */
|
||||
#define PCI_ATS_CTRL 0x06 /* ATS Control Register */
|
||||
#define PCI_ATS_CTRL_ENABLE 0x8000 /* ATS Enable */
|
||||
#define PCI_ATS_CTRL_STU(x) ((x) & 0x1f) /* Smallest Translation Unit */
|
||||
#define PCI_ATS_MIN_STU 12 /* shift of minimum STU block */
|
||||
|
||||
/* Single Root I/O Virtualization */
|
||||
#define PCI_SRIOV_CAP 0x04 /* SR-IOV Capabilities */
|
||||
#define PCI_SRIOV_CAP_VFM 0x01 /* VF Migration Capable */
|
||||
#define PCI_SRIOV_CAP_INTR(x) ((x) >> 21) /* Interrupt Message Number */
|
||||
#define PCI_SRIOV_CTRL 0x08 /* SR-IOV Control */
|
||||
#define PCI_SRIOV_CTRL_VFE 0x01 /* VF Enable */
|
||||
#define PCI_SRIOV_CTRL_VFM 0x02 /* VF Migration Enable */
|
||||
#define PCI_SRIOV_CTRL_INTR 0x04 /* VF Migration Interrupt Enable */
|
||||
#define PCI_SRIOV_CTRL_MSE 0x08 /* VF Memory Space Enable */
|
||||
#define PCI_SRIOV_CTRL_ARI 0x10 /* ARI Capable Hierarchy */
|
||||
#define PCI_SRIOV_STATUS 0x0a /* SR-IOV Status */
|
||||
#define PCI_SRIOV_STATUS_VFM 0x01 /* VF Migration Status */
|
||||
#define PCI_SRIOV_INITIAL_VF 0x0c /* Initial VFs */
|
||||
#define PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */
|
||||
#define PCI_SRIOV_NUM_VF 0x10 /* Number of VFs */
|
||||
#define PCI_SRIOV_FUNC_LINK 0x12 /* Function Dependency Link */
|
||||
#define PCI_SRIOV_VF_OFFSET 0x14 /* First VF Offset */
|
||||
#define PCI_SRIOV_VF_STRIDE 0x16 /* Following VF Stride */
|
||||
#define PCI_SRIOV_VF_DID 0x1a /* VF Device ID */
|
||||
#define PCI_SRIOV_SUP_PGSIZE 0x1c /* Supported Page Sizes */
|
||||
#define PCI_SRIOV_SYS_PGSIZE 0x20 /* System Page Size */
|
||||
#define PCI_SRIOV_BAR 0x24 /* VF BAR0 */
|
||||
#define PCI_SRIOV_NUM_BARS 6 /* Number of VF BARs */
|
||||
#define PCI_SRIOV_VFM 0x3c /* VF Migration State Array Offset*/
|
||||
#define PCI_SRIOV_VFM_BIR(x) ((x) & 7) /* State BIR */
|
||||
#define PCI_SRIOV_VFM_OFFSET(x) ((x) & ~7) /* State Offset */
|
||||
#define PCI_SRIOV_VFM_UA 0x0 /* Inactive.Unavailable */
|
||||
#define PCI_SRIOV_VFM_MI 0x1 /* Dormant.MigrateIn */
|
||||
#define PCI_SRIOV_VFM_MO 0x2 /* Active.MigrateOut */
|
||||
#define PCI_SRIOV_VFM_AV 0x3 /* Active.Available */
|
||||
|
||||
#endif /* LINUX_PCI_REGS_H */
|
||||
+9
-17
@@ -1981,32 +1981,24 @@ static int pci_pcnet_init(PCIDevice *pci_dev)
|
||||
|
||||
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_AMD);
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_AMD_LANCE);
|
||||
/* TODO: value should be 0 at RST# */
|
||||
pci_set_word(pci_conf + PCI_COMMAND,
|
||||
PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
|
||||
pci_set_word(pci_conf + PCI_STATUS,
|
||||
PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM);
|
||||
pci_conf[PCI_REVISION_ID] = 0x10;
|
||||
/* TODO: 0 is the default anyway, no need to set it. */
|
||||
pci_conf[PCI_CLASS_PROG] = 0x00;
|
||||
*(uint16_t *)&pci_conf[0x04] = cpu_to_le16(0x0007);
|
||||
*(uint16_t *)&pci_conf[0x06] = cpu_to_le16(0x0280);
|
||||
pci_conf[0x08] = 0x10;
|
||||
pci_conf[0x09] = 0x00;
|
||||
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
|
||||
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
||||
|
||||
/* TODO: not necessary, is set when BAR is registered. */
|
||||
pci_set_long(pci_conf + PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_SPACE_IO);
|
||||
pci_set_long(pci_conf + PCI_BASE_ADDRESS_0 + 4,
|
||||
PCI_BASE_ADDRESS_SPACE_MEMORY);
|
||||
*(uint32_t *)&pci_conf[0x10] = cpu_to_le32(0x00000001);
|
||||
*(uint32_t *)&pci_conf[0x14] = cpu_to_le32(0x00000000);
|
||||
|
||||
/* TODO: value must be 0 at RST# */
|
||||
pci_conf[PCI_INTERRUPT_PIN] = 1; // interrupt pin 0
|
||||
pci_conf[PCI_MIN_GNT] = 0x06;
|
||||
pci_conf[PCI_MAX_LAT] = 0xff;
|
||||
pci_conf[0x3d] = 1; // interrupt pin 0
|
||||
pci_conf[0x3e] = 0x06;
|
||||
pci_conf[0x3f] = 0xff;
|
||||
|
||||
/* Handler for memory-mapped I/O */
|
||||
s->mmio_index =
|
||||
cpu_register_io_memory(pcnet_mmio_read, pcnet_mmio_write, &d->state);
|
||||
|
||||
/* TODO: use pci_dev, avoid cast below. */
|
||||
pci_register_bar((PCIDevice *)d, 0, PCNET_IOPORT_SIZE,
|
||||
PCI_BASE_ADDRESS_SPACE_IO, pcnet_ioport_map);
|
||||
|
||||
|
||||
@@ -38,21 +38,13 @@
|
||||
#define LMB_BRAM_SIZE (128 * 1024)
|
||||
#define FLASH_SIZE (16 * 1024 * 1024)
|
||||
|
||||
static struct
|
||||
{
|
||||
uint32_t bootstrap_pc;
|
||||
uint32_t cmdline;
|
||||
uint32_t fdt;
|
||||
} boot_info;
|
||||
static uint32_t bootstrap_pc;
|
||||
|
||||
static void main_cpu_reset(void *opaque)
|
||||
{
|
||||
CPUState *env = opaque;
|
||||
|
||||
cpu_reset(env);
|
||||
env->regs[5] = boot_info.cmdline;
|
||||
env->regs[7] = boot_info.fdt;
|
||||
env->sregs[SR_PC] = boot_info.bootstrap_pc;
|
||||
env->sregs[SR_PC] = bootstrap_pc;
|
||||
}
|
||||
|
||||
#define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb"
|
||||
@@ -174,24 +166,27 @@ petalogix_s3adsp1800_init(ram_addr_t ram_size,
|
||||
1, ELF_MACHINE, 0);
|
||||
}
|
||||
/* Always boot into physical ram. */
|
||||
boot_info.bootstrap_pc = ddr_base + (entry & 0x0fffffff);
|
||||
bootstrap_pc = ddr_base + (entry & 0x0fffffff);
|
||||
if (kernel_size < 0) {
|
||||
/* If we failed loading ELF's try a raw image. */
|
||||
kernel_size = load_image_targphys(kernel_filename, ddr_base,
|
||||
ram_size);
|
||||
boot_info.bootstrap_pc = ddr_base;
|
||||
bootstrap_pc = ddr_base;
|
||||
}
|
||||
|
||||
boot_info.cmdline = ddr_base + kernel_size + 8192;
|
||||
env->regs[5] = ddr_base + kernel_size + 8192;
|
||||
if (kernel_cmdline && (kcmdline_len = strlen(kernel_cmdline))) {
|
||||
pstrcpy_targphys("cmdline", boot_info.cmdline, 256, kernel_cmdline);
|
||||
pstrcpy_targphys("cmdline", env->regs[5], 256, kernel_cmdline);
|
||||
}
|
||||
env->regs[6] = 0;
|
||||
/* Provide a device-tree. */
|
||||
boot_info.fdt = boot_info.cmdline + 256;
|
||||
petalogix_load_device_tree(boot_info.fdt, ram_size,
|
||||
0, 0,
|
||||
env->regs[7] = ddr_base + kernel_size + 256;
|
||||
petalogix_load_device_tree(env->regs[7], ram_size,
|
||||
env->regs[6], 0,
|
||||
kernel_cmdline);
|
||||
}
|
||||
|
||||
env->sregs[SR_PC] = bootstrap_pc;
|
||||
}
|
||||
|
||||
static QEMUMachine petalogix_s3adsp1800_machine = {
|
||||
|
||||
+5
-17
@@ -29,11 +29,6 @@
|
||||
#include "isa.h"
|
||||
#include "sysbus.h"
|
||||
|
||||
/*
|
||||
* I440FX chipset data sheet.
|
||||
* http://download.intel.com/design/chipsets/datashts/29054901.pdf
|
||||
*/
|
||||
|
||||
typedef PCIHostState I440FXState;
|
||||
|
||||
typedef struct PIIX3State {
|
||||
@@ -49,11 +44,6 @@ struct PCII440FXState {
|
||||
PIIX3State *piix3;
|
||||
};
|
||||
|
||||
|
||||
#define I440FX_PAM 0x59
|
||||
#define I440FX_PAM_SIZE 7
|
||||
#define I440FX_SMRAM 0x72
|
||||
|
||||
static void piix3_set_irq(void *opaque, int irq_num, int level);
|
||||
|
||||
/* return the global irq number corresponding to a given device irq
|
||||
@@ -98,12 +88,12 @@ static void i440fx_update_memory_mappings(PCII440FXState *d)
|
||||
int i, r;
|
||||
uint32_t smram, addr;
|
||||
|
||||
update_pam(d, 0xf0000, 0x100000, (d->dev.config[I440FX_PAM] >> 4) & 3);
|
||||
update_pam(d, 0xf0000, 0x100000, (d->dev.config[0x59] >> 4) & 3);
|
||||
for(i = 0; i < 12; i++) {
|
||||
r = (d->dev.config[(i >> 1) + (I440FX_PAM + 1)] >> ((i & 1) * 4)) & 3;
|
||||
r = (d->dev.config[(i >> 1) + 0x5a] >> ((i & 1) * 4)) & 3;
|
||||
update_pam(d, 0xc0000 + 0x4000 * i, 0xc0000 + 0x4000 * (i + 1), r);
|
||||
}
|
||||
smram = d->dev.config[I440FX_SMRAM];
|
||||
smram = d->dev.config[0x72];
|
||||
if ((d->smm_enabled && (smram & 0x08)) || (smram & 0x40)) {
|
||||
cpu_register_physical_memory(0xa0000, 0x20000, 0xa0000);
|
||||
} else {
|
||||
@@ -142,10 +132,8 @@ static void i440fx_write_config(PCIDevice *dev,
|
||||
|
||||
/* XXX: implement SMRAM.D_LOCK */
|
||||
pci_default_write_config(dev, address, val, len);
|
||||
if (ranges_overlap(address, len, I440FX_PAM, I440FX_PAM_SIZE) ||
|
||||
range_covers_byte(address, len, I440FX_SMRAM)) {
|
||||
if ((address >= 0x59 && address <= 0x5f) || address == 0x72)
|
||||
i440fx_update_memory_mappings(d);
|
||||
}
|
||||
}
|
||||
|
||||
static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id)
|
||||
@@ -208,7 +196,7 @@ static int i440fx_initfn(PCIDevice *dev)
|
||||
pci_config_set_class(d->dev.config, PCI_CLASS_BRIDGE_HOST);
|
||||
d->dev.config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
||||
|
||||
d->dev.config[I440FX_SMRAM] = 0x02;
|
||||
d->dev.config[0x72] = 0x02; /* SMRAM */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ static inline uint64_t cpu_ppc_get_tb(ppc_tb_t *tb_env, uint64_t vmclk,
|
||||
return muldiv64(vmclk, tb_env->tb_freq, get_ticks_per_sec()) + tb_offset;
|
||||
}
|
||||
|
||||
uint64_t cpu_ppc_load_tbl (CPUState *env)
|
||||
uint32_t cpu_ppc_load_tbl (CPUState *env)
|
||||
{
|
||||
ppc_tb_t *tb_env = env->tb_env;
|
||||
uint64_t tb;
|
||||
@@ -409,7 +409,7 @@ uint64_t cpu_ppc_load_tbl (CPUState *env)
|
||||
tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->tb_offset);
|
||||
LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb);
|
||||
|
||||
return tb;
|
||||
return tb & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
static inline uint32_t _cpu_ppc_load_tbu(CPUState *env)
|
||||
@@ -463,7 +463,7 @@ void cpu_ppc_store_tbu (CPUState *env, uint32_t value)
|
||||
_cpu_ppc_store_tbu(env, value);
|
||||
}
|
||||
|
||||
uint64_t cpu_ppc_load_atbl (CPUState *env)
|
||||
uint32_t cpu_ppc_load_atbl (CPUState *env)
|
||||
{
|
||||
ppc_tb_t *tb_env = env->tb_env;
|
||||
uint64_t tb;
|
||||
@@ -471,7 +471,7 @@ uint64_t cpu_ppc_load_atbl (CPUState *env)
|
||||
tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->atb_offset);
|
||||
LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb);
|
||||
|
||||
return tb;
|
||||
return tb & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
uint32_t cpu_ppc_load_atbu (CPUState *env)
|
||||
@@ -1009,7 +1009,7 @@ struct ppc_dcr_t {
|
||||
int (*write_error)(int dcrn);
|
||||
};
|
||||
|
||||
int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp)
|
||||
int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, target_ulong *valp)
|
||||
{
|
||||
ppc_dcrn_t *dcr;
|
||||
|
||||
@@ -1029,7 +1029,7 @@ int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val)
|
||||
int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc_dcrn_t *dcr;
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ static inline void clk_setup (clk_setup_t *clk, uint32_t freq)
|
||||
|
||||
clk_setup_cb cpu_ppc_tb_init (CPUState *env, uint32_t freq);
|
||||
/* Embedded PowerPC DCR management */
|
||||
typedef uint32_t (*dcr_read_cb)(void *opaque, int dcrn);
|
||||
typedef void (*dcr_write_cb)(void *opaque, int dcrn, uint32_t val);
|
||||
typedef target_ulong (*dcr_read_cb)(void *opaque, int dcrn);
|
||||
typedef void (*dcr_write_cb)(void *opaque, int dcrn, target_ulong val);
|
||||
int ppc_dcr_init (CPUState *env, int (*dcr_read_error)(int dcrn),
|
||||
int (*dcr_write_error)(int dcrn));
|
||||
int ppc_dcr_register (CPUState *env, int dcrn, void *opaque,
|
||||
|
||||
+23
-23
@@ -107,10 +107,10 @@ struct ppc4xx_plb_t {
|
||||
uint32_t besr;
|
||||
};
|
||||
|
||||
static uint32_t dcr_read_plb (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_plb (void *opaque, int dcrn)
|
||||
{
|
||||
ppc4xx_plb_t *plb;
|
||||
uint32_t ret;
|
||||
target_ulong ret;
|
||||
|
||||
plb = opaque;
|
||||
switch (dcrn) {
|
||||
@@ -132,7 +132,7 @@ static uint32_t dcr_read_plb (void *opaque, int dcrn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dcr_write_plb (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_plb (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc4xx_plb_t *plb;
|
||||
|
||||
@@ -189,10 +189,10 @@ struct ppc4xx_pob_t {
|
||||
uint32_t besr[2];
|
||||
};
|
||||
|
||||
static uint32_t dcr_read_pob (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_pob (void *opaque, int dcrn)
|
||||
{
|
||||
ppc4xx_pob_t *pob;
|
||||
uint32_t ret;
|
||||
target_ulong ret;
|
||||
|
||||
pob = opaque;
|
||||
switch (dcrn) {
|
||||
@@ -212,7 +212,7 @@ static uint32_t dcr_read_pob (void *opaque, int dcrn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dcr_write_pob (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_pob (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc4xx_pob_t *pob;
|
||||
|
||||
@@ -410,10 +410,10 @@ enum {
|
||||
EBC0_CFGDATA = 0x013,
|
||||
};
|
||||
|
||||
static uint32_t dcr_read_ebc (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_ebc (void *opaque, int dcrn)
|
||||
{
|
||||
ppc4xx_ebc_t *ebc;
|
||||
uint32_t ret;
|
||||
target_ulong ret;
|
||||
|
||||
ebc = opaque;
|
||||
switch (dcrn) {
|
||||
@@ -494,7 +494,7 @@ static uint32_t dcr_read_ebc (void *opaque, int dcrn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dcr_write_ebc (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_ebc (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc4xx_ebc_t *ebc;
|
||||
|
||||
@@ -627,7 +627,7 @@ struct ppc405_dma_t {
|
||||
uint32_t pol;
|
||||
};
|
||||
|
||||
static uint32_t dcr_read_dma (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_dma (void *opaque, int dcrn)
|
||||
{
|
||||
ppc405_dma_t *dma;
|
||||
|
||||
@@ -636,7 +636,7 @@ static uint32_t dcr_read_dma (void *opaque, int dcrn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dcr_write_dma (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_dma (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc405_dma_t *dma;
|
||||
|
||||
@@ -914,10 +914,10 @@ static void ocm_update_mappings (ppc405_ocm_t *ocm,
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t dcr_read_ocm (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_ocm (void *opaque, int dcrn)
|
||||
{
|
||||
ppc405_ocm_t *ocm;
|
||||
uint32_t ret;
|
||||
target_ulong ret;
|
||||
|
||||
ocm = opaque;
|
||||
switch (dcrn) {
|
||||
@@ -941,7 +941,7 @@ static uint32_t dcr_read_ocm (void *opaque, int dcrn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dcr_write_ocm (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_ocm (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc405_ocm_t *ocm;
|
||||
uint32_t isarc, dsarc, isacntl, dsacntl;
|
||||
@@ -1578,10 +1578,10 @@ struct ppc40x_mal_t {
|
||||
|
||||
static void ppc40x_mal_reset (void *opaque);
|
||||
|
||||
static uint32_t dcr_read_mal (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_mal (void *opaque, int dcrn)
|
||||
{
|
||||
ppc40x_mal_t *mal;
|
||||
uint32_t ret;
|
||||
target_ulong ret;
|
||||
|
||||
mal = opaque;
|
||||
switch (dcrn) {
|
||||
@@ -1650,7 +1650,7 @@ static uint32_t dcr_read_mal (void *opaque, int dcrn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dcr_write_mal (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_mal (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc40x_mal_t *mal;
|
||||
int idx;
|
||||
@@ -1951,10 +1951,10 @@ static void ppc405cr_clk_setup (ppc405cr_cpc_t *cpc)
|
||||
clk_setup(&cpc->clk_setup[PPC405CR_UART_CLK], UART_clk);
|
||||
}
|
||||
|
||||
static uint32_t dcr_read_crcpc (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_crcpc (void *opaque, int dcrn)
|
||||
{
|
||||
ppc405cr_cpc_t *cpc;
|
||||
uint32_t ret;
|
||||
target_ulong ret;
|
||||
|
||||
cpc = opaque;
|
||||
switch (dcrn) {
|
||||
@@ -1991,7 +1991,7 @@ static uint32_t dcr_read_crcpc (void *opaque, int dcrn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dcr_write_crcpc (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_crcpc (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc405cr_cpc_t *cpc;
|
||||
|
||||
@@ -2353,10 +2353,10 @@ static void ppc405ep_compute_clocks (ppc405ep_cpc_t *cpc)
|
||||
clk_setup(&cpc->clk_setup[PPC405EP_UART1_CLK], UART1_clk);
|
||||
}
|
||||
|
||||
static uint32_t dcr_read_epcpc (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_epcpc (void *opaque, int dcrn)
|
||||
{
|
||||
ppc405ep_cpc_t *cpc;
|
||||
uint32_t ret;
|
||||
target_ulong ret;
|
||||
|
||||
cpc = opaque;
|
||||
switch (dcrn) {
|
||||
@@ -2393,7 +2393,7 @@ static uint32_t dcr_read_epcpc (void *opaque, int dcrn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dcr_write_epcpc (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_epcpc (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc405ep_cpc_t *cpc;
|
||||
|
||||
|
||||
+7
-7
@@ -183,10 +183,10 @@ static void ppcuic_set_irq (void *opaque, int irq_num, int level)
|
||||
ppcuic_trigger_irq(uic);
|
||||
}
|
||||
|
||||
static uint32_t dcr_read_uic (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_uic (void *opaque, int dcrn)
|
||||
{
|
||||
ppcuic_t *uic;
|
||||
uint32_t ret;
|
||||
target_ulong ret;
|
||||
|
||||
uic = opaque;
|
||||
dcrn -= uic->dcr_base;
|
||||
@@ -229,13 +229,13 @@ static uint32_t dcr_read_uic (void *opaque, int dcrn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dcr_write_uic (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_uic (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppcuic_t *uic;
|
||||
|
||||
uic = opaque;
|
||||
dcrn -= uic->dcr_base;
|
||||
LOG_UIC("%s: dcr %d val 0x%x\n", __func__, dcrn, val);
|
||||
LOG_UIC("%s: dcr %d val " TARGET_FMT_lx "\n", __func__, dcrn, val);
|
||||
switch (dcrn) {
|
||||
case DCR_UICSR:
|
||||
uic->uicsr &= ~val;
|
||||
@@ -448,10 +448,10 @@ static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram)
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t dcr_read_sdram (void *opaque, int dcrn)
|
||||
static target_ulong dcr_read_sdram (void *opaque, int dcrn)
|
||||
{
|
||||
ppc4xx_sdram_t *sdram;
|
||||
uint32_t ret;
|
||||
target_ulong ret;
|
||||
|
||||
sdram = opaque;
|
||||
switch (dcrn) {
|
||||
@@ -516,7 +516,7 @@ static uint32_t dcr_read_sdram (void *opaque, int dcrn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dcr_write_sdram (void *opaque, int dcrn, uint32_t val)
|
||||
static void dcr_write_sdram (void *opaque, int dcrn, target_ulong val)
|
||||
{
|
||||
ppc4xx_sdram_t *sdram;
|
||||
|
||||
|
||||
+5
-8
@@ -108,6 +108,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
|
||||
MacIONVRAMState *nvr;
|
||||
int nvram_mem_index;
|
||||
int vga_bios_size, bios_size;
|
||||
qemu_irq *dummy_irq;
|
||||
int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
|
||||
int ppc_boot_device;
|
||||
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
||||
@@ -119,11 +120,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
|
||||
|
||||
/* init CPUs */
|
||||
if (cpu_model == NULL)
|
||||
#ifdef TARGET_PPC64
|
||||
cpu_model = "970fx";
|
||||
#else
|
||||
cpu_model = "G4";
|
||||
#endif
|
||||
for (i = 0; i < smp_cpus; i++) {
|
||||
env = cpu_init(cpu_model);
|
||||
if (!env) {
|
||||
@@ -321,7 +318,10 @@ static void ppc_core99_init (ram_addr_t ram_size,
|
||||
/* init basic PC hardware */
|
||||
pci_vga_init(pci_bus, vga_bios_offset, vga_bios_size);
|
||||
|
||||
escc_mem_index = escc_init(0x80013000, pic[0x25], pic[0x24],
|
||||
/* XXX: suppress that */
|
||||
dummy_irq = i8259_init(NULL);
|
||||
|
||||
escc_mem_index = escc_init(0x80013000, dummy_irq[4], dummy_irq[5],
|
||||
serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
|
||||
|
||||
for(i = 0; i < nb_nics; i++)
|
||||
@@ -389,9 +389,6 @@ static QEMUMachine core99_machine = {
|
||||
.desc = "Mac99 based PowerMAC",
|
||||
.init = ppc_core99_init,
|
||||
.max_cpus = MAX_CPUS,
|
||||
#ifdef TARGET_PPC64
|
||||
.is_default = 1,
|
||||
#endif
|
||||
};
|
||||
|
||||
static void core99_machine_init(void)
|
||||
|
||||
@@ -409,9 +409,7 @@ static QEMUMachine heathrow_machine = {
|
||||
.desc = "Heathrow based PowerMAC",
|
||||
.init = ppc_heathrow_init,
|
||||
.max_cpus = MAX_CPUS,
|
||||
#ifndef TARGET_PPC64
|
||||
.is_default = 1,
|
||||
#endif
|
||||
};
|
||||
|
||||
static void heathrow_machine_init(void)
|
||||
|
||||
+2
-10
@@ -192,19 +192,11 @@ static void realview_init(ram_addr_t ram_size,
|
||||
proc_id = 0x02000000;
|
||||
}
|
||||
|
||||
if (is_pb && ram_size > 0x20000000) {
|
||||
/* Core tile RAM. */
|
||||
low_ram_size = ram_size - 0x20000000;
|
||||
ram_size = 0x20000000;
|
||||
ram_offset = qemu_ram_alloc(low_ram_size);
|
||||
cpu_register_physical_memory(0x20000000, low_ram_size,
|
||||
ram_offset | IO_MEM_RAM);
|
||||
}
|
||||
|
||||
ram_offset = qemu_ram_alloc(ram_size);
|
||||
low_ram_size = ram_size;
|
||||
if (low_ram_size > 0x10000000)
|
||||
low_ram_size = 0x10000000;
|
||||
/* ??? RAM should repeat to fill physical memory space. */
|
||||
/* SDRAM at address zero. */
|
||||
cpu_register_physical_memory(0, low_ram_size, ram_offset | IO_MEM_RAM);
|
||||
if (is_pb) {
|
||||
@@ -364,7 +356,7 @@ static void realview_init(ram_addr_t ram_size,
|
||||
realview_binfo.initrd_filename = initrd_filename;
|
||||
realview_binfo.nb_cpus = smp_cpus;
|
||||
realview_binfo.board_id = realview_board_id[board_type];
|
||||
realview_binfo.loader_start = (board_type == BOARD_PB_A8 ? 0x70000000 : 0);
|
||||
realview_binfo.loader_start = is_pb ? 0x70000000 : 0;
|
||||
arm_load_kernel(first_cpu, &realview_binfo);
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -3320,20 +3320,16 @@ static int pci_rtl8139_init(PCIDevice *dev)
|
||||
pci_conf = s->dev.config;
|
||||
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REALTEK);
|
||||
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REALTEK_8139);
|
||||
/* TODO: value should be 0 at RST#. */
|
||||
pci_conf[PCI_COMMAND] = PCI_COMMAND_IO | PCI_COMMAND_MASTER;
|
||||
pci_conf[PCI_REVISION_ID] = RTL8139_PCI_REVID; /* >=0x20 is for 8139C+ */
|
||||
pci_conf[0x04] = 0x05; /* command = I/O space, Bus Master */
|
||||
pci_conf[0x08] = RTL8139_PCI_REVID; /* PCI revision ID; >=0x20 is for 8139C+ */
|
||||
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
|
||||
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;
|
||||
/* TODO: value should be 0 at RST# */
|
||||
pci_conf[PCI_INTERRUPT_PIN] = 1; /* interrupt pin 0 */
|
||||
/* TODO: start of capability list, but no capability
|
||||
* list bit in status register, and offset 0xdc seems unused. */
|
||||
pci_conf[PCI_CAPABILITY_LIST] = 0xdc;
|
||||
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; /* header_type */
|
||||
pci_conf[0x3d] = 1; /* interrupt pin 0 */
|
||||
pci_conf[0x34] = 0xdc;
|
||||
|
||||
/* I/O handler for memory-mapped I/O */
|
||||
s->rtl8139_mmio_io_addr =
|
||||
cpu_register_io_memory(rtl8139_mmio_read, rtl8139_mmio_write, s);
|
||||
cpu_register_io_memory(rtl8139_mmio_read, rtl8139_mmio_write, s);
|
||||
|
||||
pci_register_bar(&s->dev, 0, 0x100,
|
||||
PCI_BASE_ADDRESS_SPACE_IO, rtl8139_ioport_map);
|
||||
|
||||
+2
-2
@@ -374,7 +374,6 @@ static const char *scsi_command_name(uint8_t cmd)
|
||||
static const char *names[] = {
|
||||
[ TEST_UNIT_READY ] = "TEST_UNIT_READY",
|
||||
[ REZERO_UNIT ] = "REZERO_UNIT",
|
||||
/* REWIND and REZERO_UNIT use the same operation code */
|
||||
[ REQUEST_SENSE ] = "REQUEST_SENSE",
|
||||
[ FORMAT_UNIT ] = "FORMAT_UNIT",
|
||||
[ READ_BLOCK_LIMITS ] = "READ_BLOCK_LIMITS",
|
||||
@@ -410,7 +409,7 @@ static const char *scsi_command_name(uint8_t cmd)
|
||||
[ SEARCH_LOW ] = "SEARCH_LOW",
|
||||
[ SET_LIMITS ] = "SET_LIMITS",
|
||||
[ PRE_FETCH ] = "PRE_FETCH",
|
||||
/* READ_POSITION and PRE_FETCH use the same operation code */
|
||||
[ READ_POSITION ] = "READ_POSITION",
|
||||
[ SYNCHRONIZE_CACHE ] = "SYNCHRONIZE_CACHE",
|
||||
[ LOCK_UNLOCK_CACHE ] = "LOCK_UNLOCK_CACHE",
|
||||
[ READ_DEFECT_DATA ] = "READ_DEFECT_DATA",
|
||||
@@ -444,6 +443,7 @@ static const char *scsi_command_name(uint8_t cmd)
|
||||
[ SEND_VOLUME_TAG ] = "SEND_VOLUME_TAG",
|
||||
[ WRITE_LONG_2 ] = "WRITE_LONG_2",
|
||||
|
||||
[ REWIND ] = "REWIND",
|
||||
[ REPORT_DENSITY_SUPPORT ] = "REPORT_DENSITY_SUPPORT",
|
||||
[ GET_CONFIGURATION ] = "GET_CONFIGURATION",
|
||||
[ READ_16 ] = "READ_16",
|
||||
|
||||
+7
-2
@@ -65,6 +65,7 @@ struct SCSIDiskState
|
||||
int cluster_size;
|
||||
uint64_t max_lba;
|
||||
QEMUBH *bh;
|
||||
char *version;
|
||||
};
|
||||
|
||||
static SCSIDiskReq *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun)
|
||||
@@ -80,7 +81,7 @@ static SCSIDiskReq *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun)
|
||||
|
||||
static void scsi_remove_request(SCSIDiskReq *r)
|
||||
{
|
||||
qemu_free(r->iov.iov_base);
|
||||
qemu_vfree(r->iov.iov_base);
|
||||
scsi_req_free(&r->req);
|
||||
}
|
||||
|
||||
@@ -315,6 +316,7 @@ static uint8_t *scsi_get_buf(SCSIDevice *d, uint32_t tag)
|
||||
static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
|
||||
{
|
||||
BlockDriverState *bdrv = req->dev->dinfo->bdrv;
|
||||
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
|
||||
int buflen = 0;
|
||||
|
||||
if (req->cmd.buf[1] & 0x2) {
|
||||
@@ -432,7 +434,9 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
|
||||
memcpy(&outbuf[16], "QEMU HARDDISK ", 16);
|
||||
}
|
||||
memcpy(&outbuf[8], "QEMU ", 8);
|
||||
memcpy(&outbuf[32], QEMU_VERSION, 4);
|
||||
memset(&outbuf[32], 0, 4);
|
||||
memcpy(&outbuf[32], s->version ? s->version : QEMU_VERSION,
|
||||
MIN(4, strlen(s->version ? s->version : QEMU_VERSION)));
|
||||
/* Identify device as SCSI-3 rev 1.
|
||||
Some later commands are also implemented. */
|
||||
outbuf[2] = 3;
|
||||
@@ -1029,6 +1033,7 @@ static SCSIDeviceInfo scsi_disk_info = {
|
||||
.get_buf = scsi_get_buf,
|
||||
.qdev.props = (Property[]) {
|
||||
DEFINE_PROP_DRIVE("drive", SCSIDiskState, qdev.dinfo),
|
||||
DEFINE_PROP_STRING("ver", SCSIDiskState, version),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -669,10 +669,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
|
||||
}
|
||||
break;
|
||||
|
||||
case 5: /* CMD5: reserved for SDIO cards */
|
||||
sd->card_status |= ILLEGAL_COMMAND;
|
||||
return sd_r0;
|
||||
|
||||
case 6: /* CMD6: SWITCH_FUNCTION */
|
||||
if (sd->spi)
|
||||
goto bad_cmd;
|
||||
|
||||
+5
-2
@@ -396,8 +396,11 @@ static void sh7750_mem_writel(void *opaque, target_phys_addr_t addr,
|
||||
portb_changed(s, temp);
|
||||
return;
|
||||
case SH7750_MMUCR_A7:
|
||||
s->cpu->mmucr = mem_value;
|
||||
return;
|
||||
if (mem_value & MMUCR_TI) {
|
||||
cpu_sh4_invalidate_tlb(s->cpu);
|
||||
}
|
||||
s->cpu->mmucr = mem_value & ~MMUCR_TI;
|
||||
return;
|
||||
case SH7750_PTEH_A7:
|
||||
/* If asid changes, clear all registered tlb entries. */
|
||||
if ((s->cpu->pteh & 0xff) != (mem_value & 0xff))
|
||||
|
||||
+15
-96
@@ -47,10 +47,15 @@ static void sh_pci_reg_write (void *p, target_phys_addr_t addr, uint32_t val)
|
||||
pcic->par = val;
|
||||
break;
|
||||
case 0x1c4:
|
||||
pcic->mbr = val;
|
||||
pcic->mbr = val & 0xff000001;
|
||||
break;
|
||||
case 0x1c8:
|
||||
pcic->iobr = val;
|
||||
if ((val & 0xfffc0000) != (pcic->iobr & 0xfffc0000)) {
|
||||
cpu_register_physical_memory(pcic->iobr & 0xfffc0000, 0x40000,
|
||||
IO_MEM_UNASSIGNED);
|
||||
pcic->iobr = val & 0xfffc0001;
|
||||
isa_mmio_init(pcic->iobr & 0xfffc0000, 0x40000);
|
||||
}
|
||||
break;
|
||||
case 0x220:
|
||||
pci_data_write(pcic->bus, pcic->par, val, 4);
|
||||
@@ -66,89 +71,16 @@ static uint32_t sh_pci_reg_read (void *p, target_phys_addr_t addr)
|
||||
return le32_to_cpup((uint32_t*)(pcic->dev->config + addr));
|
||||
case 0x1c0:
|
||||
return pcic->par;
|
||||
case 0x1c4:
|
||||
return pcic->mbr;
|
||||
case 0x1c8:
|
||||
return pcic->iobr;
|
||||
case 0x220:
|
||||
return pci_data_read(pcic->bus, pcic->par, 4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sh_pci_data_write (SHPCIC *pcic, target_phys_addr_t addr,
|
||||
uint32_t val, int size)
|
||||
{
|
||||
pci_data_write(pcic->bus, addr + pcic->mbr, val, size);
|
||||
}
|
||||
|
||||
static uint32_t sh_pci_mem_read (SHPCIC *pcic, target_phys_addr_t addr,
|
||||
int size)
|
||||
{
|
||||
return pci_data_read(pcic->bus, addr + pcic->mbr, size);
|
||||
}
|
||||
|
||||
static void sh_pci_writeb (void *p, target_phys_addr_t addr, uint32_t val)
|
||||
{
|
||||
sh_pci_data_write(p, addr, val, 1);
|
||||
}
|
||||
|
||||
static void sh_pci_writew (void *p, target_phys_addr_t addr, uint32_t val)
|
||||
{
|
||||
sh_pci_data_write(p, addr, val, 2);
|
||||
}
|
||||
|
||||
static void sh_pci_writel (void *p, target_phys_addr_t addr, uint32_t val)
|
||||
{
|
||||
sh_pci_data_write(p, addr, val, 4);
|
||||
}
|
||||
|
||||
static uint32_t sh_pci_readb (void *p, target_phys_addr_t addr)
|
||||
{
|
||||
return sh_pci_mem_read(p, addr, 1);
|
||||
}
|
||||
|
||||
static uint32_t sh_pci_readw (void *p, target_phys_addr_t addr)
|
||||
{
|
||||
return sh_pci_mem_read(p, addr, 2);
|
||||
}
|
||||
|
||||
static uint32_t sh_pci_readl (void *p, target_phys_addr_t addr)
|
||||
{
|
||||
return sh_pci_mem_read(p, addr, 4);
|
||||
}
|
||||
|
||||
static int sh_pci_addr2port(SHPCIC *pcic, target_phys_addr_t addr)
|
||||
{
|
||||
return addr + pcic->iobr;
|
||||
}
|
||||
|
||||
static void sh_pci_outb (void *p, target_phys_addr_t addr, uint32_t val)
|
||||
{
|
||||
cpu_outb(sh_pci_addr2port(p, addr), val);
|
||||
}
|
||||
|
||||
static void sh_pci_outw (void *p, target_phys_addr_t addr, uint32_t val)
|
||||
{
|
||||
cpu_outw(sh_pci_addr2port(p, addr), val);
|
||||
}
|
||||
|
||||
static void sh_pci_outl (void *p, target_phys_addr_t addr, uint32_t val)
|
||||
{
|
||||
cpu_outl(sh_pci_addr2port(p, addr), val);
|
||||
}
|
||||
|
||||
static uint32_t sh_pci_inb (void *p, target_phys_addr_t addr)
|
||||
{
|
||||
return cpu_inb(sh_pci_addr2port(p, addr));
|
||||
}
|
||||
|
||||
static uint32_t sh_pci_inw (void *p, target_phys_addr_t addr)
|
||||
{
|
||||
return cpu_inw(sh_pci_addr2port(p, addr));
|
||||
}
|
||||
|
||||
static uint32_t sh_pci_inl (void *p, target_phys_addr_t addr)
|
||||
{
|
||||
return cpu_inl(sh_pci_addr2port(p, addr));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
CPUReadMemoryFunc * const r[3];
|
||||
CPUWriteMemoryFunc * const w[3];
|
||||
@@ -159,21 +91,11 @@ static MemOp sh_pci_reg = {
|
||||
{ NULL, NULL, sh_pci_reg_write },
|
||||
};
|
||||
|
||||
static MemOp sh_pci_mem = {
|
||||
{ sh_pci_readb, sh_pci_readw, sh_pci_readl },
|
||||
{ sh_pci_writeb, sh_pci_writew, sh_pci_writel },
|
||||
};
|
||||
|
||||
static MemOp sh_pci_iop = {
|
||||
{ sh_pci_inb, sh_pci_inw, sh_pci_inl },
|
||||
{ sh_pci_outb, sh_pci_outw, sh_pci_outl },
|
||||
};
|
||||
|
||||
PCIBus *sh_pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
|
||||
void *opaque, int devfn_min, int nirq)
|
||||
{
|
||||
SHPCIC *p;
|
||||
int mem, reg, iop;
|
||||
int reg;
|
||||
|
||||
p = qemu_mallocz(sizeof(SHPCIC));
|
||||
p->bus = pci_register_bus(NULL, "pci",
|
||||
@@ -182,14 +104,11 @@ PCIBus *sh_pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
|
||||
p->dev = pci_register_device(p->bus, "SH PCIC", sizeof(PCIDevice),
|
||||
-1, NULL, NULL);
|
||||
reg = cpu_register_io_memory(sh_pci_reg.r, sh_pci_reg.w, p);
|
||||
iop = cpu_register_io_memory(sh_pci_iop.r, sh_pci_iop.w, p);
|
||||
mem = cpu_register_io_memory(sh_pci_mem.r, sh_pci_mem.w, p);
|
||||
cpu_register_physical_memory(0x1e200000, 0x224, reg);
|
||||
cpu_register_physical_memory(0x1e240000, 0x40000, iop);
|
||||
cpu_register_physical_memory(0x1d000000, 0x1000000, mem);
|
||||
cpu_register_physical_memory(0xfe200000, 0x224, reg);
|
||||
cpu_register_physical_memory(0xfe240000, 0x40000, iop);
|
||||
cpu_register_physical_memory(0xfd000000, 0x1000000, mem);
|
||||
|
||||
p->iobr = 0xfe240000;
|
||||
isa_mmio_init(p->iobr, 0x40000);
|
||||
|
||||
pci_config_set_vendor_id(p->dev->config, PCI_VENDOR_ID_HITACHI);
|
||||
pci_config_set_device_id(p->dev->config, PCI_DEVICE_ID_HITACHI_SH7751R);
|
||||
|
||||
+1
-50
@@ -95,7 +95,7 @@ struct sun4m_hwdef {
|
||||
target_phys_addr_t iommu_base, slavio_base;
|
||||
target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;
|
||||
target_phys_addr_t serial_base, fd_base;
|
||||
target_phys_addr_t afx_base, idreg_base, dma_base, esp_base, le_base;
|
||||
target_phys_addr_t idreg_base, dma_base, esp_base, le_base;
|
||||
target_phys_addr_t tcx_base, cs_base, apc_base, aux1_base, aux2_base;
|
||||
target_phys_addr_t ecc_base;
|
||||
uint32_t ecc_version;
|
||||
@@ -600,41 +600,6 @@ static void idreg_register_devices(void)
|
||||
|
||||
device_init(idreg_register_devices);
|
||||
|
||||
/* SS-5 TCX AFX register */
|
||||
static void afx_init(target_phys_addr_t addr)
|
||||
{
|
||||
DeviceState *dev;
|
||||
SysBusDevice *s;
|
||||
|
||||
dev = qdev_create(NULL, "tcx_afx");
|
||||
qdev_init_nofail(dev);
|
||||
s = sysbus_from_qdev(dev);
|
||||
|
||||
sysbus_mmio_map(s, 0, addr);
|
||||
}
|
||||
|
||||
static int afx_init1(SysBusDevice *dev)
|
||||
{
|
||||
ram_addr_t afx_offset;
|
||||
|
||||
afx_offset = qemu_ram_alloc(4);
|
||||
sysbus_init_mmio(dev, 4, afx_offset | IO_MEM_RAM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SysBusDeviceInfo afx_info = {
|
||||
.init = afx_init1,
|
||||
.qdev.name = "tcx_afx",
|
||||
.qdev.size = sizeof(SysBusDevice),
|
||||
};
|
||||
|
||||
static void afx_register_devices(void)
|
||||
{
|
||||
sysbus_register_withprop(&afx_info);
|
||||
}
|
||||
|
||||
device_init(afx_register_devices);
|
||||
|
||||
/* Boot PROM (OpenBIOS) */
|
||||
static void prom_init(target_phys_addr_t addr, const char *bios_name)
|
||||
{
|
||||
@@ -830,10 +795,6 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
idreg_init(hwdef->idreg_base);
|
||||
}
|
||||
|
||||
if (hwdef->afx_base) {
|
||||
afx_init(hwdef->afx_base);
|
||||
}
|
||||
|
||||
iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
|
||||
slavio_irq[30]);
|
||||
|
||||
@@ -917,9 +878,6 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
if (kernel_cmdline) {
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
|
||||
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA,
|
||||
(uint8_t*)strdup(kernel_cmdline),
|
||||
strlen(kernel_cmdline) + 1);
|
||||
} else {
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
|
||||
}
|
||||
@@ -962,7 +920,6 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
|
||||
.esp_base = 0x78800000,
|
||||
.le_base = 0x78c00000,
|
||||
.apc_base = 0x6a000000,
|
||||
.afx_base = 0x6e000000,
|
||||
.aux1_base = 0x71900000,
|
||||
.aux2_base = 0x71910000,
|
||||
.nvram_machine_id = 0x80,
|
||||
@@ -1503,9 +1460,6 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
if (kernel_cmdline) {
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
|
||||
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA,
|
||||
(uint8_t*)strdup(kernel_cmdline),
|
||||
strlen(kernel_cmdline) + 1);
|
||||
} else {
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
|
||||
}
|
||||
@@ -1694,9 +1648,6 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
|
||||
if (kernel_cmdline) {
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
|
||||
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA,
|
||||
(uint8_t*)strdup(kernel_cmdline),
|
||||
strlen(kernel_cmdline) + 1);
|
||||
} else {
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
|
||||
}
|
||||
|
||||
+7
-19
@@ -39,20 +39,12 @@
|
||||
#include "elf.h"
|
||||
|
||||
//#define DEBUG_IRQ
|
||||
//#define DEBUG_EBUS
|
||||
|
||||
#ifdef DEBUG_IRQ
|
||||
#define CPUIRQ_DPRINTF(fmt, ...) \
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { printf("CPUIRQ: " fmt , ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define CPUIRQ_DPRINTF(fmt, ...)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_EBUS
|
||||
#define EBUS_DPRINTF(fmt, ...) \
|
||||
do { printf("EBUS: " fmt , ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define EBUS_DPRINTF(fmt, ...)
|
||||
#define DPRINTF(fmt, ...)
|
||||
#endif
|
||||
|
||||
#define KERNEL_LOAD_ADDR 0x00404000
|
||||
@@ -246,14 +238,14 @@ void cpu_check_irqs(CPUState *env)
|
||||
|
||||
env->interrupt_index = TT_EXTINT | i;
|
||||
if (old_interrupt != env->interrupt_index) {
|
||||
CPUIRQ_DPRINTF("Set CPU IRQ %d\n", i);
|
||||
DPRINTF("Set CPU IRQ %d\n", i);
|
||||
cpu_interrupt(env, CPU_INTERRUPT_HARD);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (!pil && (env->interrupt_index & ~15) == TT_EXTINT) {
|
||||
CPUIRQ_DPRINTF("Reset CPU IRQ %d\n", env->interrupt_index & 15);
|
||||
DPRINTF("Reset CPU IRQ %d\n", env->interrupt_index & 15);
|
||||
env->interrupt_index = 0;
|
||||
cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
|
||||
}
|
||||
@@ -264,12 +256,12 @@ static void cpu_set_irq(void *opaque, int irq, int level)
|
||||
CPUState *env = opaque;
|
||||
|
||||
if (level) {
|
||||
CPUIRQ_DPRINTF("Raise CPU IRQ %d\n", irq);
|
||||
DPRINTF("Raise CPU IRQ %d\n", irq);
|
||||
env->halted = 0;
|
||||
env->pil_in |= 1 << irq;
|
||||
cpu_check_irqs(env);
|
||||
} else {
|
||||
CPUIRQ_DPRINTF("Lower CPU IRQ %d\n", irq);
|
||||
DPRINTF("Lower CPU IRQ %d\n", irq);
|
||||
env->pil_in &= ~(1 << irq);
|
||||
cpu_check_irqs(env);
|
||||
}
|
||||
@@ -355,8 +347,7 @@ void cpu_tick_set_limit(void *opaque, uint64_t limit)
|
||||
static void ebus_mmio_mapfunc(PCIDevice *pci_dev, int region_num,
|
||||
pcibus_t addr, pcibus_t size, int type)
|
||||
{
|
||||
EBUS_DPRINTF("Mapping region %d registers at %" FMT_PCIBUS "\n",
|
||||
region_num, addr);
|
||||
DPRINTF("Mapping region %d registers at %08x\n", region_num, addr);
|
||||
switch (region_num) {
|
||||
case 0:
|
||||
isa_mmio_init(addr, 0x1000000);
|
||||
@@ -661,9 +652,6 @@ static void sun4uv_init(ram_addr_t RAM_size,
|
||||
if (kernel_cmdline) {
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
|
||||
pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
|
||||
fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA,
|
||||
(uint8_t*)strdup(kernel_cmdline),
|
||||
strlen(kernel_cmdline) + 1);
|
||||
} else {
|
||||
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
|
||||
}
|
||||
|
||||
+7
-2
@@ -102,6 +102,9 @@ USBDevice *usb_create(USBBus *bus, const char *name)
|
||||
USBDevice *usb_create_simple(USBBus *bus, const char *name)
|
||||
{
|
||||
USBDevice *dev = usb_create(bus, name);
|
||||
if (!dev) {
|
||||
hw_error("Failed to create USB device '%s'\n", name);
|
||||
}
|
||||
qdev_init_nofail(&dev->qdev);
|
||||
return dev;
|
||||
}
|
||||
@@ -261,7 +264,8 @@ USBDevice *usbdevice_create(const char *cmdline)
|
||||
USBBus *bus = usb_bus_find(-1 /* any */);
|
||||
DeviceInfo *info;
|
||||
USBDeviceInfo *usb;
|
||||
char driver[32], *params;
|
||||
char driver[32];
|
||||
const char *params;
|
||||
int len;
|
||||
|
||||
params = strchr(cmdline,':');
|
||||
@@ -272,6 +276,7 @@ USBDevice *usbdevice_create(const char *cmdline)
|
||||
len = sizeof(driver);
|
||||
pstrcpy(driver, len, cmdline);
|
||||
} else {
|
||||
params = "";
|
||||
pstrcpy(driver, sizeof(driver), cmdline);
|
||||
}
|
||||
|
||||
@@ -294,7 +299,7 @@ USBDevice *usbdevice_create(const char *cmdline)
|
||||
}
|
||||
|
||||
if (!usb->usbdevice_init) {
|
||||
if (params) {
|
||||
if (*params) {
|
||||
qemu_error("usbdevice %s accepts no params\n", driver);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ static const uint8_t qemu_mouse_config_descriptor[] = {
|
||||
0x01, /* u8 bNumInterfaces; (1) */
|
||||
0x01, /* u8 bConfigurationValue; */
|
||||
0x04, /* u8 iConfiguration; */
|
||||
0xe0, /* u8 bmAttributes;
|
||||
0xa0, /* u8 bmAttributes;
|
||||
Bit 7: must be set,
|
||||
6: Self-powered,
|
||||
5: Remote wakeup,
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ static const uint8_t qemu_hub_config_descriptor[] = {
|
||||
0x01, /* u8 bNumInterfaces; (1) */
|
||||
0x01, /* u8 bConfigurationValue; */
|
||||
0x00, /* u8 iConfiguration; */
|
||||
0xe0, /* u8 bmAttributes;
|
||||
0xc0, /* u8 bmAttributes;
|
||||
Bit 7: must be set,
|
||||
6: Self-powered,
|
||||
5: Remote wakeup,
|
||||
|
||||
Loaded 100 of 195 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user