Commit graph

5915 commits

Author SHA1 Message Date
Peter Maydell 7196345549 hw/omap_gpmc: Add comment about FIFOTHRESHOLDSTATUS bit
Promote the remark about why we handle FIFOTHRESHOLDSTATUS the
way we do from the commit message of de8af7fe0 to a comment in
the code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
2011-09-23 08:36:36 +02:00
Aneesh Kumar K.V 5f5422258e hw/9pfs: Add handle based fs driver
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22 21:38:53 +05:30
Aneesh Kumar K.V bccacf6c79 hw/9pfs: Implement TFLUSH operation
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22 21:38:52 +05:30
Aneesh Kumar K.V ce421a1961 hw/9pfs: Avoid unnecessary get_fid in v9fs_clunk
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22 21:38:52 +05:30
Aneesh Kumar K.V 532decb715 hw/9pfs: Add fs driver specific details to fscontext
Add a new context flag PATHNAME_FSCONTEXT and indicate whether
the fs driver track fid using path names. Also add a private
pointer that help us to track fs driver specific values in there

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22 21:38:52 +05:30
Aneesh Kumar K.V 0174fe73e6 hw/9pfs: Add init callback to fs driver
This call back can be used to do fs driver specific initialization.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22 21:38:52 +05:30
Aneesh Kumar K.V 2289be19ae hw/9pfs: Move fid pathname tracking to seperate data type.
This enables us to add handles to track fids later. The
V9fsPath added is similar to V9fsString except that the
size include the NULL byte also.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22 21:38:52 +05:30
Aneesh Kumar K.V 02cb7f3a25 hw/9pfs: Use read-write lock for protecting fid path.
On rename we take the write lock and this ensure path
doesn't change as we operate on them.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22 21:38:52 +05:30
Aneesh Kumar K.V 70c18fc08b hw/9pfs: Make v9fs_string* functions non-static
We will use them later in other files

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-22 21:38:52 +05:30
Anthony Liguori d85a1302a9 Merge remote-tracking branch 'kwolf/for-anthony' into staging 2011-09-22 10:31:26 -05:00
Anthony Liguori 9ba2a054db Merge remote-tracking branch 'stefanha/trivial-patches' into staging 2011-09-22 10:29:42 -05:00
Anthony Liguori bdd2672109 Merge remote-tracking branch 'qemu-kvm-tmp/memory/batch' into staging 2011-09-22 10:27:14 -05:00
Daniel Verkamp 465f1ab161 ahci: add port I/O index-data pair
Implement an I/O space index-data register pair as defined by the AHCI
spec, including the corresponding SATA PCI capability and BAR.

This allows real-mode code to access the AHCI registers; real-mode
code cannot address the memory-mapped register space because it is
beyond the first megabyte.

Signed-off-by: Daniel Verkamp <daniel@drv.nu>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-21 14:32:20 +02:00
Jan Kiszka 43b26fc851 Drop unneeded pthread.h inclusions
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-09-21 10:49:16 +01:00
Avi Kivity 2654c962b8 omap1: convert to memory API (part VI)
Easy RAM stuff.

Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-21 11:14:42 +03:00
Avi Kivity 90aeba9dac soc_dma: drop soc_dma_port_add_mem_ram()
It's a trivial wrapper for soc_dma_port_add_mem(), which makes
the memory API conversion more difficult because it takes a ram
addr_t.  Drop.

Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-21 11:14:38 +03:00
Avi Kivity 9898b79abe omap_lcdc: remove imif, emiff from structure
Not used.

Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-21 11:14:35 +03:00
Avi Kivity 763b946c28 omap1: convert to memory API (part V)
Tricky aliases.

Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-21 11:14:32 +03:00
Avi Kivity 60fe76e3ad omap1: convert to memory API (part IV)
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-21 11:14:30 +03:00
Avi Kivity a4ebbd18b1 omap1: convert to memory API (part III)
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-21 11:14:27 +03:00
Avi Kivity e7aa0ae034 omap1: convert to memory API (part II)
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-21 11:14:25 +03:00
Avi Kivity 4b3fedf3a5 omap1: convert to memory API (part I)
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-21 11:14:10 +03:00
Anthony Liguori 03c39eb558 Merge remote-tracking branch 'mst-tmp/for_anthony' into staging 2011-09-20 15:22:10 -05:00
Anthony Liguori c8af89af96 Merge remote-tracking branch 'kwolf/for-anthony' into staging 2011-09-20 15:21:03 -05:00
Anthony Liguori 7f67d8922e Merge remote-tracking branch 'qmp/queue/qmp' into staging 2011-09-20 15:16:00 -05:00
Michael S. Tsirkin 336411cafd pci_bridge: simplify memory regions some more
replace alloc/free with struct members.
todo: smash with initial implementation after
testing.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-09-20 17:46:12 +03:00
Paolo Bonzini bd5da23265 scsi: fix sign extension problems
When assigning a 32-bit value to cmd->xfer (which is 64-bits)
it can be erroneously sign extended because the intermediate
32-bit computation is signed.  Fix this by standardizing on
the ld*_be_p functions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-20 12:27:44 +02:00
Alexander Motin a26a13da68 AHCI Port Interrupt Enable register cleaning on soft reset
I've found that FreeBSD AHCI driver doesn't work with AHCI hardware
emulation of QEMU 0.15.0. I believe the problem is on QEMU's side. As I
see, it clears port's Interrupt Enable register each time when reset of
any level happens. Is is reasonable for the global controller reset. It
is probably not good, but acceptable for FreeBSD driver for the port
hard reset. But it is IMO wrong for the device soft reset. None of real
hardware I know behaves that way.

Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-20 12:27:44 +02:00
Paolo Bonzini 7285477ab1 scsi-disk: lazily allocate bounce buffer
It will not be needed for reads and writes if the HBA provides a sglist.
In addition, this lets scsi-disk refuse commands with an excessive
allocation length, as well as limit memory on usual well-behaved guests.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-20 12:27:43 +02:00
Paolo Bonzini 103b40f51e scsi-disk: commonize iovec creation between reads and writes
Also, consistently use qiov.size instead of iov.iov_len.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-20 12:27:43 +02:00
Michael S. Tsirkin 7df32ca08a pci: implement bridge filtering
Support bridge filtering on top of the memory
API as suggested by Avi Kivity:

Create a memory region for the bridge's address space.  This region is
not directly added to system_memory or its descendants.  Devices under
the bridge see this region as its pci_address_space().  The region is
as large as the entire address space - it does not take into account
any windows.

For each of the three windows (pref, non-pref, vga), create an alias
with the appropriate start and size.  Map the alias into the bridge's
parent's pci_address_space(), as subregions.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-09-19 21:22:30 +03:00
Wen Congyang 778d179939 pci_bridge: use parent bus's address space
The switch to the new memory API caused the following problem:

The pci device may call pci_register_bar() to use PCI bus's address
space.  But we don't init PCI bus's address space if it is not bus
0.  A crash was reported:
http://lists.gnu.org/archive/html/qemu-devel/2011-08/msg02243.html

More work will be needed to make bridge filtering work correctly
with the memory API.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-09-19 21:22:30 +03:00
Jan Kiszka a92eb87a44 pci: Remove unused mem_base from PCIBus
Obsoleted by f64e02b6cc.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-09-19 21:22:29 +03:00
Michael S. Tsirkin 817e0b6fe8 pci: interrupt pin documentation update
Fix up some erroneous comments in code:
interrupt pins are named A-D, the
interrupt pin register is always readonly
and isn't zeroed out on reset.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-09-19 21:22:29 +03:00
Jan Kiszka ab346bb23f pci: Remove unused pci_reserve_capability
eepro100 was the last user. Now pci_add_capability is powerful enough.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-09-19 21:22:29 +03:00
Paolo Bonzini bbca72c621 dma-helpers: rename is_write to to_dev
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-19 11:35:33 +02:00
Paolo Bonzini 1b8f8a6f91 scsi-generic: do not disable FUA
I found no rationale for this in the logs, and it is quite bad because
it will make scsi-generic unsafe WRT power failures.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-19 11:34:34 +02:00
Avi Kivity 19b4a424d8 musicpal: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-18 17:06:53 +03:00
Avi Kivity 0ae164504e mips_r4k: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-18 17:06:53 +03:00
Avi Kivity 23ebf23dd1 mips_mipssim: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-18 17:06:53 +03:00
Avi Kivity ea85df72b6 mips_malta: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-18 17:06:53 +03:00
Avi Kivity 60581b3777 mips_jazz: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-18 17:06:53 +03:00
Blue Swirl 530889ff95 sun4u: don't set up isa_mem_base
Since we use memory API in sun4u.c, after
71579cae30, setting up isa_mem_base
puts vga.chain4 outside of the physical address space.

Fix by removing obsolete isa_mem_base set up.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-18 12:00:19 +00:00
Stefan Hajnoczi 4e1837f855 trace: add virtio_set_status() trace event
The virtio device lifecycle can be observed by looking at the sequence
of set status operations.  This is especially important for catching the
reset operation (status value 0), which resets the device and all
virtqueues.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-17 15:14:24 +00:00
Gerd Hoffmann a8467c7a0e qdev: print bus properties too
Make qdev_device_help print both device and bus properties.
Helps libvirt to figure whenever bus properties such as
PCI.multifunction are supported present or not.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-16 09:06:28 -05:00
Jan Kiszka 71579cae30 vga: Respect isa_mem_base when registering chain4 alias
This does not yet unbreak PPC (which has its own problems) but
potentially other non-x86 systems where isa_mem_base is != 0.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-16 09:06:28 -05:00
Peter Maydell df3f457b4b hw/integratorcp: Fix bugs in writes to CM_CTRL system register
Fix a number of bugs in the implementation of writes to the CM_CTRL
system register:
 * write to cm_ctrl, not cm_init !
 * an '&' vs '^' typo meant we would write the inverse of the bits
 * handling the LED via printf() meant we spew lots of output
   to stdout when Linux uses the LED as a heartbeat indicator
 * we would hw_error() if a reset was requested rather than
   actually resetting

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-16 08:28:46 -05:00
Jan Kiszka 2313e998d7 vga: Fix text mode screendumps
In text mode, even a full refresh of the screen takes multiple updates.
As we reset the dump file pointer after the first call, we only wrote
the first line.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-16 08:25:57 -05:00
Stefan Weil b2bedb2144 Remove blanks before \n in output strings
Those blanks violate the coding conventions, see
scripts/checkpatch.pl.

Blanks missing after colons in the changed lines were added.

This patch does not try to fix tabs, long lines and other
problems in the changed lines, therefore checkpatch.pl reports
many violations.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-16 08:25:56 -05:00
Luiz Capitulino 1354869c38 Drop the vm_running global variable
Use runstate_is_running() instead, which is introduced by this commit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15 16:39:32 -03:00
Luiz Capitulino 1dfb4dd993 Replace the VMSTOP macros with a proper state type
Today, when notifying a VM state change with vm_state_notify(),
we pass a VMSTOP macro as the 'reason' argument. This is not ideal
because the VMSTOP macros tell why qemu stopped and not exactly
what the current VM state is.

One example to demonstrate this problem is that vm_start() calls
vm_state_notify() with reason=0, which turns out to be VMSTOP_USER.

This commit fixes that by replacing the VMSTOP macros with a proper
state type called RunState.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15 16:39:32 -03:00
Anthony Liguori c7fbbdf9c8 Merge remote-tracking branch 'aneesh/for-upstream-4' into staging 2011-09-15 13:28:28 -05:00
Stefan Weil 847f171e6a ahci: Remove unused struct member
Member variable is_read is written, but never read
(contrary to its name). Remove it.

Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:22 +02:00
Markus Armbruster 25ad22bc4e ide/atapi scsi-disk: Make monitor eject -f, then change work
change fails while the tray is locked by the guest.  eject -f forces
it open and removes any media.  Unfortunately, the tray closes again
instantly.  Since the lock remains as it is, there is no way to insert
another medium unless the guest voluntarily unlocks.

Fix by leaving the tray open after monitor eject.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:22 +02:00
Markus Armbruster 7d4b4ba5c2 block: New change_media_cb() parameter load
To let device models distinguish between eject and load.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:22 +02:00
Markus Armbruster 7b6f9300d5 block: New bdrv_set_buffer_alignment()
Device models should be able to set it without an unclean include of
block_int.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:22 +02:00
Markus Armbruster fb0c61a5a5 hw: Trim superfluous #include "block_int.h"
Including it in device models is unclean, including it without a
reason adds insult to injury.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:21 +02:00
Markus Armbruster d1a0739de5 block: Move BlockConf & friends from block_int.h to block.h
It's convenience stuff for block device models, so block.h isn't the
ideal home either, but better than block_int.h.

Permits moving some #include "block_int.h" from device model .h into
.c.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:21 +02:00
Markus Armbruster e4def80b36 block: Show whether the virtual tray is open in info block
Need to ask the device, so this requires new BlockDevOps member
is_tray_open().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:21 +02:00
Markus Armbruster 9e6a4c9177 block: Drop BlockDriverState member removable
It's a confused mess (see previous commit).  No users remain.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:21 +02:00
Markus Armbruster 2c6942fa7b block: Clean up remaining users of "removable"
BlockDriverState member removable is a confused mess.  It is true when
an ide-cd, scsi-cd or floppy qdev is attached, or when the
BlockDriverState was created with -drive if={floppy,sd} or -drive
if={ide,scsi,xen,none},media=cdrom ("created removable"), except when
an ide-hd, scsi-hd, scsi-generic or virtio-blk qdev is attached.

Three users remain:

1. eject_device(), via bdrv_is_removable() uses it to determine
   whether a block device can eject media.

2. bdrv_info() is monitor command "info block".  QMP documentation
   says "true if the device is removable, false otherwise".  From the
   monitor user's point of view, the only sensible interpretation of
   "is removable" is "can eject media with monitor commands eject and
   change".

A block device can eject media unless a device is attached that
doesn't support it.  Switch the two users over to new
bdrv_dev_has_removable_media() that returns exactly that.

3. bdrv_getlength() uses to suppress its length cache when media can
   change (see commit 46a4e4e6).  Media change is either monitor
   command change (updates the length cache), monitor command eject
   (doesn't update the length cache, easily fixable), or physical
   media change (invalidates length cache, not so easily fixable).

I'm refraining from improving anything here, because this series is
long enough already.  Instead, I simply switch it over to
bdrv_dev_has_removable_media() as well.

This changes the behavior of the length cache and of monitor commands
eject and change in two cases:

a. drive not created removable, no device attached

   The commit makes the drive removable, and defeats the length cache.

   Example: -drive if=none

b. drive created removable, but the attached drive is non-removable,
   and doesn't call bdrv_set_removable(..., 0) (most devices don't)

   The commit makes the drive non-removable, and enables the length
   cache.

   Example: -drive if=xen,media=cdrom -M xenpv

   The other non-removable devices that don't call
   bdrv_set_removable() can't currently use a drive created removable,
   either because they aren't qdevified, or because they lack a drive
   property.  Won't stay that way.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:21 +02:00
Markus Armbruster db118fe725 ide/atapi: Preserve tray state on migration
Use a subsection, so that migration to older version still works,
provided the tray is closed and unlocked.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:21 +02:00
Markus Armbruster 68bb01f398 scsi-disk: Fix START_STOP to fail when it can't eject
Don't fail when tray is already open.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:21 +02:00
Markus Armbruster 48f65b3f52 ide/atapi: Don't fail eject when tray is already open
MMC-5 6.40.2.6 specifies that START STOP UNIT succeeds when the drive
already has the requested state.  cmd_start_stop_unit() fails when
asked to eject while the tray is open and locked.  Fix that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:21 +02:00
Markus Armbruster 025e849a50 block: Rename bdrv_set_locked() to bdrv_lock_medium()
While there, make the locked parameter bool.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:20 +02:00
Markus Armbruster f107639a6f block: Drop medium lock tracking, ask device models instead
Requires new BlockDevOps member is_medium_locked().  Implement for IDE
and SCSI CD-ROMs.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:20 +02:00
Markus Armbruster fdec4404dd block: Leave enforcing tray lock to device models
The device model knows best when to accept the guest's eject command.
No need to detour through the block layer.

bdrv_eject() can't fail anymore.  Make it void.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:20 +02:00
Markus Armbruster 81b1008d50 scsi-disk: Track tray locked state
We already track it in BlockDriverState.  Just like tray open/close
state, we should track it in the device models instead, because it's
device state.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:20 +02:00
Markus Armbruster a0a7573b84 ide/atapi: Track tray locked state
We already track it in BlockDriverState.  Just like tray open/close
state, we should track it in the device models instead, because it's
device state.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:20 +02:00
Markus Armbruster a1aff5bf67 block: Revert entanglement of bdrv_is_inserted() with tray status
Commit 4be9762a changed bdrv_is_inserted() to fail when the tray is
open.  Unfortunately, there are two different kinds of users, with
conflicting needs.

1. Device models using bdrv_eject(), currently ide-cd and scsi-cd.
They expect bdrv_is_inserted() to reflect the tray status.  Commit
4be9762a makes them happy.

2. Code that wants to know whether a BlockDriverState has media, such
as find_image_format(), bdrv_flush_all().  Commit 4be9762a makes them
unhappy.  In particular, it breaks flush on VM stop for media ejected
by the guest.

Revert the change to bdrv_is_inserted().  Check the tray status in the
device models instead.

Note on IDE: Since only ATAPI devices have a tray, and they don't
accept ATA commands since the recent commit "ide: Reject ATA commands
specific to drive kinds", checking in atapi.c suffices.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:20 +02:00
Markus Armbruster ece0d5e9a7 scsi-disk: Track tray open/close state
We already track it in BlockDriverState since commit 4be9762a.  As
discussed in that commit's message, we should track it in the device
device models instead, because it's device state.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:20 +02:00
Markus Armbruster bfd52647ad scsi-disk: Factor out scsi_disk_emulate_start_stop()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:20 +02:00
Markus Armbruster dd06333392 ide/atapi: Track tray open/close state
We already track it in BlockDriverState since commit 4be9762a.  As
discussed in that commit's message, we should track it in the device
device models instead, because it's device state.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:20 +02:00
Markus Armbruster f077656418 ide/atapi: Clean up misleading name in cmd_start_stop_unit()
"eject" is misleading; it means "eject" when start is clear, but
"load" when start is set.  Rename to loej, because that's how MMC-5
calls it, in section 6.40.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:19 +02:00
Markus Armbruster 3cfc22692e ide: Reject ATA commands specific to drive kinds
ACS-2 Table B.2 explicitly prohibits ATAPI devices from implementing
WIN_RECAL, WIN_READ_EXT, WIN_READDMA_EXT, WIN_READ_NATIVE_MAX,
WIN_MULTREAD_EXT, WIN_WRITE, WIN_WRITE_ONCE, WIN_WRITE_EXT,
WIN_WRITEDMA_EXT, WIN_MULTWRITE_EXT, WIN_WRITE_VERIFY, WIN_VERIFY,
WIN_VERIFY_ONCE, WIN_VERIFY_EXT, WIN_SPECIFY, WIN_MULTREAD,
WIN_MULTWRITE, WIN_SETMULT, WIN_READDMA, WIN_READDMA_ONCE,
WIN_WRITEDMA, WIN_WRITEDMA_ONCE, WIN_FLUSH_CACHE_EXT.  Restrict them
to IDE_HD and IDE_CFATA.

Same for CFA_WRITE_SECT_WO_ERASE, CFA_WRITE_MULTI_WO_ERASE.  Restrict
them to IDE_CFATA, like the other CFA_ commands.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:19 +02:00
Markus Armbruster 844505b12e ide: Use a table to declare which drive kinds accept each command
No functional change.

It would be nice to have handler functions in the table, like commit
e1a064f9 did for ATAPI.  Left for another day.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:19 +02:00
Markus Armbruster 3f76a7c381 ide: Fix ATA command READ to set ATAPI signature for CD-ROM
Must set the ATAPI device signature, see ATA4 8.27.5.2 Outputs for
PACKET Command feature set devices, and ACS-2 7.36.6 Outputs for
PACKET feature set devices.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12 15:17:18 +02:00
Max Filippov 47d05a8629 target-xtensa: add dc232b core and board
This is Diamond 232L Standard Core Rev.B (LE).

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 16:57:40 +00:00
Max Filippov f3df4c04d8 target-xtensa: implement CPENABLE and PRID SRs
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 16:57:39 +00:00
Max Filippov b994e91b00 target-xtensa: implement interrupt option
See ISA, 4.4.6 (interrupt option), 4.4.7 (high priority interrupt
option) and 4.4.8 (timer interrupt option) for details.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 16:57:39 +00:00
Max Filippov 7b039f741c target-xtensa: add sample board
Sample board and sample CPU core are used for debug and may be used for
development of custom SoC emulators.

This board has two fixed size memory regions for DTCM and ITCM and
variable length SRAM region.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 16:57:36 +00:00
Max Filippov 2328826b1d target-xtensa: add target stubs
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 16:57:36 +00:00
Hervé Poussineau 83818f7cdd mipsnet: use trace framework
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 16:50:46 +00:00
Hervé Poussineau d118d64a92 mipsnet: convert to qdev
Move mipsnet_init() function to mipssim machine

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 16:50:46 +00:00
Blue Swirl f64e02b6cc PCI: delete unused mem_base and pci_to_cpu_addr
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 14:56:04 +00:00
Blue Swirl a6c6f44ae4 lsi53c895a: avoid a warning from clang analyzer
Avoid this warning from clang analyzer by deleting the variable:
/src/qemu/hw/lsi53c895a.c:895:5: warning: Value stored to 'id' is never read
    id = (current_tag >> 8) & 0xf;

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 14:52:33 +00:00
Blue Swirl 18f88f1195 hid: fix misassignment
The code does not have any effect as is, fix it.

Spotted by clang analyzer:
/src/qemu/hw/hid.c:99:13: warning: Value stored to 'x1' is never read
            x1 = 1;

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 14:49:51 +00:00
Blue Swirl 48bb9f53f4 scsi-bus: remove duplicate table entries
Remove duplicate entries from SCSI command table, spotted by
clang analyzer:
/src/qemu/hw/scsi-bus.c:979:40: warning: initializer overrides prior initialization of this subobject
        [ ERASE_16                 ] = "ERASE_16",
/src/qemu/hw/scsi-bus.c:978:40: note: previous initialization is here
        [ WRITE_SAME_16            ] = "WRITE_SAME_16",
/src/qemu/hw/scsi-bus.c:984:40: warning: initializer overrides prior initialization of this subobject
        [ MAINTENANCE_IN           ] = "MAINTENANCE_IN",
/src/qemu/hw/scsi-bus.c:917:40: note: previous initialization is here
        [ MAINTENANCE_IN           ] = "MAINTENANCE_IN",
/src/qemu/hw/scsi-bus.c:985:40: warning: initializer overrides prior initialization of this subobject
        [ MAINTENANCE_OUT          ] = "MAINTENANCE_OUT",
/src/qemu/hw/scsi-bus.c:918:40: note: previous initialization is here
        [ MAINTENANCE_OUT          ] = "MAINTENANCE_OUT",

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 14:48:08 +00:00
Blue Swirl 1213406bf8 g364fb: compile in hwlib
Compile g364fb in hwlib. Two compilations less for the full build.

Acked-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10 14:46:12 +00:00
Anthony Liguori 282c355b17 Merge remote-tracking branch 'sstabellini/xen-next' into staging 2011-09-09 13:13:27 -05:00
Anthony Liguori da5391edd1 Merge remote-tracking branch 'stefanha/trivial-patches' into staging 2011-09-09 13:09:57 -05:00
Gerd Hoffmann ad8b818686 Don't use g_thread_get_initialized.
Initialize glib threads unconditionally in main() instead
of using g_thread_get_initialized in the 9p code.

Fixes a build failure on RHEL-5, which ships glib 2.12.
g_thread_get_initialized was added in 2.20.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-09 12:58:16 -05:00
Amit Shah 3b86b13ab0 virtio-balloon: Disassociate from the balloon handlers on unplug
Adding a 2nd balloon device after unplugging the first one doesn't work.
Also, the 'info balloon' command should indicate an error mentioning no
balloon device is registered after unplug.

Reproduction steps given by Shaolong Hu:

(qemu) info balloon
Device 'balloon' has not been activated by the guest
(qemu) device_add virtio-balloon-pci,id=balloon1
(qemu) info balloon
balloon: actual=4096
(qemu) balloon 2048
(qemu) info balloon
balloon: actual=2048
(qemu) device_del balloon1
(qemu) info balloon
balloon: actual=4096
(qemu) balloon 2048
(qemu) info balloon
balloon: actual=4096
(qemu) device_del balloon1
Device 'balloon1' not found
(qemu) device_add virtio-balloon-pci,id=balloon1
Another balloon device already registered
Device 'virtio-balloon-pci' could not be initialized
(qemu) device_add virtio-balloon-pci,id=balloon2
Another balloon device already registered
Device 'virtio-balloon-pci' could not be initialized

Reported-by: Shaolong Hu <shu@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-09 12:58:16 -05:00
John Haxby 6d6467305a Move the xenfb pointer handler to the connected method
Ensure that we read "request-abs-pointer" after the frontend has written
it.  This means that we will correctly set up an ansolute or relative
pointer handler correctly.

Signed-off-by: John Haxby <john.haxby@oracle.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2011-09-09 13:13:16 +00:00
John Haxby 384087b2fe Introduce a new 'connected' xendev op called when Connected.
Rename the existing xendev 'connect' op to 'initialised' and introduce
a new 'connected' op.  This new op, if defined, is called when the
backend is connected.  Note that since there is no state transition this
may be called more than once.

Signed-off-by: John Haxby <john.haxby@oracle.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2011-09-09 13:13:16 +00:00
Aneesh Kumar K.V 7834cf77be hw/9pfs: add 9P2000.L unlinkat operation
unlinkat - Remove a directory entry

size[4] Tunlinkat tag[2] dirfid[4] name[s] flag[4]
size[4] Runlinkat tag[2]

older Tremove have the below request format

size[4] Tremove tag[2] fid[4]

The remove message is used to remove a directory entry either file or directory
The remove opreation is actually a directory opertation and should ideally have
dirfid, if not we cannot represent the fid on server with anything other than
name. We will have to derive the directory name from fid in the Tremove request.

NOTE: The operation doesn't clunk the unlink fid.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09 15:07:01 +05:30
Aneesh Kumar K.V 89bf65938a hw/9pfs: add 9P2000.L renameat operation
rename - change name of file or directory

size[4] Trenameat tag[2] olddirfid[4] oldname[s] newdirfid[4] newname[s]
size[4] Rrenameat tag[2]

older Trename have the below request format

size[4] Trename tag[2] fid[4] newdirfid[4] name[s]

The rename message is used to change the name of a file, possibly moving it
to a new directory. The rename opreation is actually a directory opertation
and should ideally have olddirfid, if not we cannot represent the fid on server
with anything other than name. We will have to derive the old directory name
from fid in the Trename request.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09 14:46:03 +05:30
Aneesh Kumar K.V 10e72295bd hw/9pfs: Fix memleaks in some 9p operation
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09 14:46:00 +05:30
Aneesh Kumar K.V 25427ec143 hw/9pfs: Initialize rest of qid field to zero.
Since qid is allocated out of stack we need to intialize
the field to zero. Otherwise we will send wrong qid value
to client.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09 14:45:55 +05:30
Aneesh Kumar K.V 407fee0f02 hw/9pfs: Update the fidp path before opendir
We need to update the fidp path before opendir. Since we don't
use the fid returned by mkdir, earlier code should not have
much issue. We do a double v9fs_string_copy here. The later patch
cleanup the entire function.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-09-09 14:45:53 +05:30
Stefan Weil 5a61cb60d6 Fix include statements for qemu-common.h
* qemu-common.h is not a system include file, so it should be included
  with "" instead of <>. Otherwise incremental builds might fail
  because only local include files are checked for changes.

* linux-user/syscall.c included the file twice.

Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-09-09 09:56:12 +01:00
Stefan Weil 069d89b8a8 virtio-9p: Fix syntax error in debug code
This error was reported by cppcheck:

qemu/hw/9pfs/virtio-9p-debug.c:342:
error: Invalid number of character ({) when these macros are defined:
'DEBUG_DATA'.

Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-09-09 09:51:07 +01:00
Anthony Liguori 573da34a41 Merge remote-tracking branch 'spice/spice.v42' into staging 2011-09-08 09:07:57 -05:00
Anthony Liguori 220724ca4a Merge remote-tracking branch 'kwolf/for-anthony' into staging 2011-09-08 09:05:14 -05:00
Anthony Liguori d8ac46d950 Merge remote-tracking branch 'qemu-kvm-tmp/memory/batch' into staging 2011-09-08 09:03:57 -05:00
Anthony Liguori 9d0baba110 Merge remote-tracking branch 'stefanha/trivial-patches' into staging 2011-09-08 08:59:32 -05:00
Anthony Liguori a60fce0bcc Merge remote-tracking branch 'kraxel/usb.26' into staging 2011-09-08 08:57:33 -05:00
Anthony Liguori 63236c15e9 Merge remote-tracking branch 'aneesh/for-upstream-3' into staging 2011-09-08 08:52:59 -05:00
Juha Riihimäki 5b1cdb4ead usb-musb: Add reset function
Add a separate reset function musb_reset() to the usb-musb interface,
so that users who implement a reset function can also reset usb-musb.
Use this in tusb6010.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:27 +02:00
Peter Maydell 406c20754a usb-musb: Take a DeviceState* in init function
Initialise usb-musb by passing it a DeviceState* and the offset of the
IRQs in its gpio array, rather than a plain pointer to an irq array.
This is simpler for callers and also allows us to pass in a valid parent
to usb_bus_new(), so the USB bus actually appears in the qdev tree.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:27 +02:00
Peter Maydell 9147b75288 usb: Remove leading underscores from __musb_irq_max
Identifiers with double leading underscore are reserved, so rename
__musb_irq_max so we don't encroach on reserved namespace.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:27 +02:00
Gerd Hoffmann 891fb2cd45 usb: claim port at device initialization time.
This patch makes qemu assign a port when creating the device, not when
attaching it.  For most usb devices this isn't a noticable difference
because they are in attached state all the time.

The change affects usb-host devices which live in detached state while
the real device is unplugged from the host.  They have a fixed port
assigned all the time now instead of getting grabbing one on attach and
releasing it at detach, i.e. they stop floating around at the usb bus.

The change also allows to simplify usb-hub.  It doesn't need the
handle_attach() callback any more to configure the downstream ports.
This can be done at device initialitation time now.  The changed
initialization order (first grab upstream port, then register downstream
ports) also fixes some icky corner cases.  For example it is not possible
any more to plug the hub into one of its own downstream ports.

The usb host adapters must care too.  USBPort->dev being non-NULL
doesn't imply any more the device is in attached state.  The host
adapters must additionally check the USBPort->dev->attached flag.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:26 +02:00
Gerd Hoffmann 7755260f01 usb-ccid: remote wakeup support
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:26 +02:00
Gerd Hoffmann 97237e0a5a usb-ccid: switch to USBDesc*
Switch the smard card emulation to use the USBDesc*
structs for the usb descriptors.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:26 +02:00
Gerd Hoffmann 4d8debba76 usb: fix use after free
The ->complete() callback might have released the USBPacket (uhci
actually does), so we must not touch it after the callback returns.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:26 +02:00
Gerd Hoffmann 2fe80192ba usb-ehci: handle siTDs
This patch adds code to do minimal siTD handling, which is basically
just following the next pointer.  This is good enougth to handle the
inactive siTDs used by FreeBSD.  Active siTDs are skipped too as we
don't have split transfer support in qemu, additionally a warning is
printed.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:58:16 +02:00
Yonit Halperin 40010aea63 qxl: s/qxl_set_irq/qxl_update_irq/
Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:20:09 +02:00
Yonit Halperin efbf2950f5 qxl: send interrupt after migration in case ram->int_pending != 0, RHBZ #732949
if qxl_send_events was called from spice server context, and then
migration had completed before a call to pipe_read, the target
guest qxl driver didn't get the interrupt. In addition,
qxl_send_events ignored further interrupts of the same kind, since
ram->int_pending was set. As a result, the guest driver was stacked
or very slow (when the waiting for the interrupt was with timeout).

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:20:09 +02:00
Peter Maydell a680f7e7cb hw/qxl: Fix format string errors
Fix format string errors causing compile failure on 32 bit hosts
when spice is enabled.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-09-07 09:20:09 +02:00
Paolo Bonzini cfc606da0d scsi: improve MODE SENSE emulation
- do not return extra pages when requesting all pages (PAGE CODE = 0x3f)

- return correct sense code for PC = 3 (saved parameters not supported)

- do not return geometry pages for CD devices

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 15:45:20 +02:00
Paolo Bonzini eae31cb998 scsi: fill in additional sense length correctly
Even though we do not use them, we should include the last three
bytes of sense data in the additional sense length.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 15:28:37 +02:00
Paolo Bonzini f651526271 scsi: refine constants for READ CAPACITY 16
Rename SERVICE_ACTION_IN to SERVICE_ACTION_IN_16 to distinguish
from the 12-byte CDB variant, and add a constant for the subcommand.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 15:14:41 +02:00
Paolo Bonzini 8e321cc622 scsi: fix accounting of writes
Writes go through scsi_write_complete at least twice, the first time
to get some data without having actually written anything.  Because
of this, the first time scsi_write_complete is called it will call
bdrv_acct_done and account a read incorrectly.  Fix this by looking
at the aiocb.  I am doing the same in scsi_read_complete for symmetry,
but it is only needed in the (bogus) case of bdrv_aio_readv returning
NULL.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 13:15:25 +02:00
Paolo Bonzini 0a4ac106f7 scsi: execute SYNCHRONIZE_CACHE asynchronously
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 13:02:16 +02:00
Markus Armbruster ba5b7ad449 block: Declare qemu_blockalign() in block.h, not block_int.h
Device models should be able to use it without an unclean include of
block_int.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:24:07 +02:00
Markus Armbruster 124386cc75 spitz tosa: Simplify "drive is suitable for microdrive" test
We try the drive defined with -drive if=ide,index=0 (or equivalent
sugar).  We use it only if (dinfo && bdrv_is_inserted(dinfo->bdrv) &&
!bdrv_is_removable(dinfo->bdrv)).  This is a convoluted way to test
for "drive media can't be removed".

The only way to create such a drive with -drive if=ide is media=cdrom.
And that sets dinfo->media_cd, so just test that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:24:07 +02:00
Markus Armbruster f9e8fda479 xen: Clean up pci_piix3_xen_ide_unplug()'s test for "not a CD"
pci_piix3_xen_ide_unplug() unplugs only disks, not CD-ROMs.  It peeks
into the DriveInfo's BlockDriverState to distinguish between the two.
Unclean; use DriveInfo member media_cd, like xen_config_dev_blk().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:24:07 +02:00
Markus Armbruster 18d9005529 fdc: Make media change detection more robust
fdctrl_change_cb() gets called on a virtual media change via monitor.
It would be nice if host device block drivers called it on physical
media change, but they don't.

bdrv_media_changed() lets you poll for media change, but it returns
"don't know" except with block driver "host_floppy".

FDrive member media_changed gets set on device initialization and by
fdctrl_change_cb(), and cleared by fdctrl_media_changed().  Thus, it's
set on first entry to fdctrl_media_changed() since device
initialization or virtual media change.

fdctrl_media_changed() ignores media_changed unless
bdrv_media_changed() returns "don't know".  If we change media via
monitor (setting media_changed), and the new media's block driver
returns 0, we lose.  Fortunately, "host_floppy" always returns 1 on
first call.  Brittle.  Clean it up not to rely on it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:24:06 +02:00
Markus Armbruster 8e49ca4624 block: Leave tracking media change to device models
hw/fdc.c is the only one that cares.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:24:06 +02:00
Markus Armbruster 656fbeff92 ide: Give vmstate structs internal linkage where possible
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:24:06 +02:00
Markus Armbruster 814839c00b ide: Clean up case label indentation in ide_exec_cmd()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:23:51 +02:00
Markus Armbruster 1d4316d385 ide: Update command code definitions as per ACS-2 Table B.2
Drop WIN_SRST, it has the same value as WIN_DEVICE_RESET.

Drop unused WIN_RESTORE, it has the same value as WIN_RECAL.

Drop codes that are not implemented and long obsolete: WIN_READ_LONG,
WIN_READ_LONG_ONCE, WIN_WRITE_LONG, WIN_WRITE_LONG_ONCE, WIN_FORMAT
(all obsolete since ATA4), WIN_ACKMEDIACHANGE, WIN_POSTBOOT,
WIN_PREBOOT (obsolete since ATA3), WIN_WRITE_SAME (obsolete since
ATA3, code reused for something else in ACS2), WIN_IDENTIFY_DMA
(obsolete since ATA4).

Drop codes that are not implemented and vendor-specific:
EXABYTE_ENABLE_NEST, DISABLE_SEAGATE.

Drop WIN_INIT, it isn't implemented, its value used to be reserved,
and is used for something else since ATA8.

CFA_IDLEIMMEDIATE isn't specific to CFATA.  ACS-2 shows it as a
defined command in ATA-1, -2 and -3.  Rename to WIN_IDLEIMMEDIATE2.

Mark vendor specific, retired, and obsolete codes.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:23:51 +02:00
Markus Armbruster 145feb176f block: Split change_cb() into change_media_cb(), resize_cb()
Multiplexing callbacks complicates matters needlessly.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:23:51 +02:00
Markus Armbruster 0e49de5232 block: Generalize change_cb() to BlockDevOps
So we can more easily add device model callbacks.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:23:51 +02:00
Markus Armbruster fa879d62eb block: Attach non-qdev devices as well
For now, this just protects against programming errors like having the
same drive back multiple non-qdev devices, or untimely bdrv_delete().
Later commits will add other interesting uses.

While there, rename BlockDriverState member peer to dev, bdrv_attach()
to bdrv_attach_dev(), bdrv_detach() to bdrv_detach_dev(), and
bdrv_get_attached() to bdrv_get_attached_dev().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06 11:23:51 +02:00
Edgar E. Iglesias c4cb2578b5 mips: Add SMP support to the Malta board
No change to the CPU kinds, so SMP will only work if
manually changing the cpu to 34Kf:

-cpu 34Kf -smp 2

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-09-06 11:09:39 +02:00
Avi Kivity c50a6def96 milkymist: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:52 +03:00
Avi Kivity 5105ed3b19 milkymist-softusb: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:52 +03:00
Avi Kivity 8a53d56fdc milkymist-minimac2: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:52 +03:00
Avi Kivity c378b364ee mcf5208: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:51 +03:00
Avi Kivity 02e5c16757 mainstone: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:51 +03:00
Avi Kivity 88fa8031bd lm32_boards: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:51 +03:00
Avi Kivity cbdea0ca89 dummy_m68k: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:51 +03:00
Avi Kivity cfe5f01104 pflash_cfi01/pflash_cfi02: convert to memory API
cfi02 is annoying in that is ignores some address bits; we probably
want explicit support in the memory API for that.

In order to get the correct opaque into the MemoryRegion object, the
allocation scheme is changed so that the flash emulation code allocates
memory, instead of the caller.  This clears a FIXME in the flash code.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:51 +03:00
Avi Kivity 72124c01c6 piix_pci: wrap memory update in a transaction
The code will remap all PAMs, even if just one is updated, resulting
in reduced performance.  Wrap in a transaction to detect that those
other PAMs have not changed.

Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:51 +03:00
Avi Kivity 64c048f4a8 cirrus: wrap memory update in a transaction
This prevents spurious unmapping and remapping of the vga windows,
which reduces performance.

Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:51 +03:00
Avi Kivity a4911d6425 leon3: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:51 +03:00
Avi Kivity 211adf4d51 integratorcp: convert to memory API (RAM/flash only)
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:51 +03:00
Avi Kivity d40b2af8ba sysbus: add sysbus_add_memory_overlap()
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:50 +03:00
Avi Kivity b0e3d5ac2f axis_dev88: convert to memory API (RAM only)
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:50 +03:00
Avi Kivity 7d6f78cfac armv7m: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:50 +03:00
Avi Kivity 72e4d2554d an5206: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:50 +03:00
Avi Kivity d0ed8076cb pci_host: convert conf index and data ports to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:50 +03:00
Avi Kivity 2b985d9c29 sysbus: add helpers to add and delete memory regions to the system bus
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:50 +03:00
Avi Kivity f070e1e227 stellaris_enet: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:50 +03:00
Avi Kivity 13faf2a71f mips_fulong2e: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-04 17:46:50 +03:00
Blue Swirl f69539b14b apb_pci: convert PCI space to memory API
Add a new memory space for PCI instead of using system memory.

This also fixes a bug where VGA region vga.chain4 is
accidentally mapped to 0xa0000 instead of 0x1ff000a0000.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-04 09:28:04 +00:00
Blue Swirl 962d4b2834 fw_cfg: fix crash if FW_CFG_WRITE_CHANNEL is used incorrectly
Avoid a crash if the guest combines FW_CFG_WRITE_CHANNEL with
a wrong value.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-04 06:38:24 +00:00
Stefan Weil 541dc0d47f Use new macro QEMU_PACKED for packed structures
Most changes were made using these commands:

git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'
git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'
git grep -la '__attribute__((__packed__))'|xargs perl -pi -e 's/__attribute__\(\(__packed__\)\)/QEMU_PACKED/'
git grep -la '__attribute__ ((__packed__))'|xargs perl -pi -e 's/__attribute__ \(\(__packed__\)\)/QEMU_PACKED/'
git grep -la '__attribute((packed))'|xargs perl -pi -e 's/__attribute\(\(packed\)\)/QEMU_PACKED/'

Whitespace in linux-user/syscall_defs.h was fixed manually
to avoid warnings from scripts/checkpatch.pl.

Manual changes were also applied to hw/pc.c.

I did not fix indentation with tabs in block/vvfat.c.
The patch will show 4 errors with scripts/checkpatch.pl.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-03 10:45:59 +00:00
Anthony Liguori 12d4536f7d main: force enabling of I/O thread
Enabling the I/O thread by default seems like an important part of declaring
1.0.  Besides allowing true SMP support with KVM, the I/O thread means that the
TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which
currently requires a (racey) signal based alarm system.

I know there have been concerns about performance.  I think so far the ones that
have come up (virtio-net) are most likely due to secondary reasons like
decreased batching.

I think we ought to force enabling I/O thread early in 1.0 development and
commit to resolving any lingering issues.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-09-02 10:34:55 -05:00
Stefan Weil 6f9faa91f5 sh4: Fix potential crash in debug code
cppcheck reports this error:

qemu/hw/sh_intc.c:390: error: Possible null pointer dereference:
 s - otherwise it is redundant to check if s is null at line 385

If s were NULL, the printf() statement would crash.
Setting braces fixes this bug.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Reviewed-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-09-02 10:49:12 +01:00
Anthony Liguori 625f9e1f54 Merge remote-tracking branch 'stefanha/trivial-patches' into staging 2011-09-01 13:57:19 -05:00
Peter Maydell bdc76462ac tusb6010: Convert to qdev
Convert the tusb6010 to qdev.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-08-31 21:48:10 +02:00
Edgar E. Iglesias f0fb8b7180 Merge branch 'omap-for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm into pm 2011-08-29 23:59:06 +02:00
Anthony Liguori 9f4bd6baf6 Merge remote-tracking branch 'kwolf/for-anthony' into staging 2011-08-29 09:57:06 -05:00
Anthony Liguori 751d63c371 Merge remote-tracking branch 'qemu-kvm/memory/urgent' into staging 2011-08-29 08:48:28 -05:00
Anthony Liguori c783924136 Merge remote-tracking branch 'mst/for_anthony' into staging 2011-08-29 08:48:15 -05:00
Alon Levy 11d6dded8e hw/pci-stub: fix comment typo
[Stefan fixed "doesn't" -> "don't"]

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-08-29 10:35:05 +01:00
Peter Maydell d5c8cf993a omap_gpmc: Implement prefetch engine
This commit implements the prefetch engine feature of the GPMC
which can be used for NAND devices. This includes both interrupt
driven and DMA-filling modes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:13 +00:00
Peter Maydell eee0a1c67e omap: Wire up the DMA request line to the GPMC
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:13 +00:00
Peter Maydell ef20677ca6 omap_gpmc: Pull prefetch engine data into sub-struct
Refactor the gpmc state structure so items relating to
the prefetch engine are in their own sub-struct and have
more useful names.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:13 +00:00
Juha Riihimäki 856f2df771 omap_gpmc: Accept a zero mask field on omap3630
OMAP3630 adds an extra bit of address masking, so a mask of
0xb1111 is valid. Unfortunately the GPMC_REVISION is the same as
on the OMAP3430 which only has three bits of address masking, so
we have to derive this feature directly from the OMAP revision
rather than from the GPMC revision.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:13 +00:00
Peter Maydell f13e656e7e hw/omap.h: Add OMAP 3630 to omap_mpu_model enumeration
Add the OMAP 3630 to the omap_mpu_model enumeration, and add the
corresponding cpu_is_omap3630() function.

(OMAP3 isn't supported yet but this is useful in upgrading common
components to be "OMAP3 ready". We already have this for OMAP3430.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Peter Maydell 2a952feb83 omap_gpmc: Support NAND devices
Support accesses to NAND devices, both by mapping them into
the GPMC address space, and via the NAND_COMMAND, NAND_ADDRESS
and NAND_DATA GPMC registers.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Peter Maydell 9ed3e1b183 omap_gpmc: Reindent misindented switch statements
Whitespace-only change fixing indentation.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Juha Riihimäki 7c470ff1eb omap_gpmc: Calculate revision from OMAP model
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Juha Riihimäki b5325c2739 omap_gpmc: Take omap_mpu_state* in omap_gpmc_init
Take a pointer to the omap mpu state struct in omap_gpmc_init.
Some details of GPMC behaviour depend on the OMAP version we
are a part of.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Peter Maydell de8af7fe01 omap_gpmc: Fix handling of FIFOTHRESHOLDSTATUS bit
The OMAP3 TRM is inconsistent about whether the GPMC FIFOTHRESHOLDSTATUS
bit should be set when FIFOPOINTER > FIFOTHRESHOLD or when it is >=
FIFOTHRESHOLD. Apparently the underlying functional spec from which
the TRM was created states that the behaviour is ">=", and this also
makes more conceptual sense.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Peter Maydell 77c6c73690 omap_gpmc: Wire up the GPMC IRQ correctly
The omap_gpmc wasn't actually wiring up its IRQ, so
anything that provoked an interrupt would be using
uninitialised data for its IRQ number.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Peter Maydell 9c8255e124 omap_gpmc: GPMC_IRQSTATUS is write-one-to-clear
Fix a bug in the handling of writes to GPMC_IRQSTATUS:
it behaves as "write one to clear, writing zero is ignored".

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Peter Maydell 3387bf5581 omap_gpmc: Refactor omap_gpmc_cs_map and omap_gpmc_cs_unmap
Refactor the omap_gpmc_cs_map/unmap functions:
 * take the omap_gpmc_s* and a chipselect id rather than the
   omap_gpmc_cs_file_s*, so they have access to the general gpmc
   member fields
 * extract the base and mask from the config registers in the functions
   rather than at every callsite
 * check for CSVALID in the functions rather than at every callsite

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Peter Maydell 07bc2f8077 omap_gpmc: Clean up omap_gpmc_attach MemoryRegion conversion
Now that all callers of omap_gpmc_attach pass in a MemoryRegion*,
we can remove the base_update and unmap function pointer arguments,
and the opaque pointer that was passed into these callbacks.

We can also remove the base and size fields from omap_gpmc_cs_file_s
as these are no longer necessary (you don't need the base/size
to unmap a MemoryRegion the way you did to undo a mapping made
with cpu_register_physical_memory()).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Juha Riihimäki 7c00b9de8b hw/onenand: Minor spacing fixes
Minor whitespace-only cleanup (separated out from the qdevifying
patch for clarity).

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:37:12 +00:00
Juha Riihimäki 500954e35c hw/onenand: Qdevify
Qdevify the ONENAND device.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:36:58 +00:00
Juha Riihimäki 82866965e9 hw/onenand: Remove unnecessary argument from onenand_command()
Refactor onenand_command() -- since it is essentially a method of
the device object, it doesn't make sense to pass in something as
an argument which is one of the object's own member fields.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by:  Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:33:02 +00:00
Peter Maydell 46c305ef6b hw/sysbus: Add sysbus_mmio_get_region()
Add a sysbus_mmio_get_region() which allows users of sysbus
devices to turn a (SysBusDevice*, mmioidx) tuple into a
MemoryRegion*. This enables some useful simplifications of
devices which pass through another device's mmio region
(either directly or by implementing some kind of memory
controller device).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-28 16:22:17 +00:00
Avi Kivity 73c92f9aec sh_pci: Fix sh_pci memory alias confusion
The a7 area was set up as an alias of itself, rather than the p4 area.  This
sent the memory core into infinite recursion.

Fix by aliasing the a7 area to the p4 area.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-28 18:34:39 +03:00
Artyom Tarasenko 9f94778c16 Fix disabling interrupts in sun4u
clear interrupt request if the interrupt priority < CPU pil
clear hardware interrupt request if interrupts are disabled

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
[blauwirbel@gmail.com: added a comment about magic 2]
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-28 11:38:13 +00:00
Edgar E. Iglesias 010f3f5fbd xilinx: Convert most xilinx devices to MemoryRegion
This converts ethlite, intc, timer and uartlite to use
MemoryRegions.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-08-28 09:56:49 +02:00
Hervé Poussineau 97a3f6ffbb g364fb: convert to qdev
Extract G364 ROM contents from device emulation to machine emulation,
so device emulation can be reused in other machines (Commodore Amiga)

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-27 17:03:30 +00:00
Hervé Poussineau b213b37072 g364fb: use trace framework
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-27 17:03:23 +00:00
Michael S. Tsirkin b0b3db7955 vhost-net: cleanup host notifiers at last step
When the vhost notifier is disabled, the userspace handler runs
immediately: virtio_pci_set_host_notifier_internal might
call virtio_queue_notify_vq.
Since the VQ state and the tap backend state aren't
recovered yet, this causes
"Guest moved used index from XXX to YYY" assertions.

The solution is to split out host notifier handling
from vhost VQ setup and disable notifiers as our last step
when we stop vhost-net. For symmetry enable them first thing
on start.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-08-26 11:25:25 +03:00
Anthony Liguori 01e0451a08 Revert "Merge remote-tracking branch 'qemu-kvm/memory/batch' into staging"
This reverts commit 8ef9ea85a2, reversing
changes made to 444dc48298.

From Avi:

  Please revert the entire pull (git revert 8ef9ea85a2) while I work this
  out - it isn't trivial.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-25 14:39:18 -05:00
Jan Kiszka f065aa0a00 vga: Silence bogus gcc warning about uninitialized variables
Some gcc versions do not properly detect that all possible cases are
covered and base and size are always initialized. Please gcc by defining
a pseudo default case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-25 13:56:54 -05:00
Christoph Hellwig a597e79ce1 block: explicit I/O accounting
Decouple the I/O accounting from bdrv_aio_readv/writev/flush and
make the hardware models call directly into the accounting helpers.

This means:
 - we do not count internal requests from image formats in addition
   to guest originating I/O
 - we do not double count I/O ops if the device model handles it
   chunk wise
 - we only account I/O once it actuall is done
 - can extent I/O accounting to synchronous or coroutine I/O easily
 - implement I/O latency tracking easily (see the next patch)

I've conveted the existing device model callers to the new model,
device models that are using synchronous I/O and weren't accounted
before haven't been updated yet.  Also scsi hasn't been converted
to the end-to-end accounting as I want to defer that after the pending
scsi layer overhaul.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-25 18:18:42 +02:00
Aneesh Kumar K.V b9cb88b056 hw/9pfs: mark directories also as un-reclaimable on unlink
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25 20:16:42 +05:30
Aneesh Kumar K.V 95f65511c3 hw/9pfs: Add directory reclaim support
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25 20:16:42 +05:30
Aneesh Kumar K.V 9b54ffaab2 hw/9pfs: Use v9fs_do_close instead of close
we should use the local abstraction instead of
directly calling close.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25 20:16:42 +05:30
Aneesh Kumar K.V 9e5b2247ea hw/9pfs: init fid list properly
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25 20:16:41 +05:30
Aneesh Kumar K.V 7a46274529 hw/9pfs: Add file descriptor reclaim support
[M. Mohan Kumar <mohan@in.ibm.com> removed some unused variables]

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25 20:16:41 +05:30
Aneesh Kumar K.V 84dfb926e5 hw/9pfs: Add reference counting for fid
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-25 20:16:41 +05:30
Anthony Liguori 8ef9ea85a2 Merge remote-tracking branch 'qemu-kvm/memory/batch' into staging 2011-08-25 07:48:24 -05:00
Anthony Liguori 444dc48298 Merge remote-tracking branch 'aneesh/for-upstream-2' into staging 2011-08-25 07:48:15 -05:00
Avi Kivity 2b90ca040c milkymist: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:34 +03:00
Avi Kivity fcb9fc24c4 milkymist-softusb: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:34 +03:00
Avi Kivity 906d23eb0d milkymist-minimac2: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:34 +03:00
Avi Kivity e33df454e5 mcf5208: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:34 +03:00
Avi Kivity 09730e296b mainstone: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:34 +03:00
Avi Kivity 4c9e975d64 lm32_boards: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:33 +03:00
Avi Kivity 82afb3a707 g364fb: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:33 +03:00
Avi Kivity 9eadff4a94 dummy_m68k: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:33 +03:00
Avi Kivity c8a50e596c pflash_cfi01/pflash_cfi02: convert to memory API
cfi02 is annoying in that is ignores some address bits; we probably
want explicit support in the memory API for that.

Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:33 +03:00
Avi Kivity c2c1b0f84b piix_pci: wrap memory update in a transaction
The code will remap all PAMs, even if just one is updated, resulting
in reduced performance.  Wrap in a transaction to detect that those
other PAMs have not changed.

Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:33 +03:00
Avi Kivity cf9182e229 cirrus: wrap memory update in a transaction
This prevents spurious unmapping and remapping of the vga windows,
which reduces performance.

Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:33 +03:00
Avi Kivity 20e5758b08 leon3: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:33 +03:00
Avi Kivity b3cc496255 integratorcp: convert to memory API (RAM/flash only)
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:33 +03:00
Avi Kivity 28e7796459 sysbus: add sysbus_add_memory_overlap()
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:33 +03:00
Avi Kivity 5461eb2111 axis_dev88: convert to memory API (RAM only)
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:56:12 +03:00
Avi Kivity 5b15f27516 ppc_oldworld, ppc_newworld: fix escc BAR related crash
ppc maps the escc mmio region both at a fixed offset (as a sysbus area) and as part of a PCI BAR.
This crashes, since a MemoryRegion may have only one parent.  Use an alias so we have a separate
MemoryRegion for the BAR.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-25 10:49:46 +03:00
Avi Kivity 89da90b1b4 gt64xxx: fix crash in gt64120_pci_mapping()
The map/unmap code was assymetric - unmap used the local MemoryRegion while
map used isa_mmio_init(), which cannot handle dynamic mappings.

Fix by using isa_mmio_setup() and the local MemoryRegion.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-08-24 21:11:21 +02:00
Avi Kivity fbe15adf8e armv7m: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-24 20:17:51 +03:00
Avi Kivity 4c390a1d32 an5206: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-24 20:17:47 +03:00
Avi Kivity d2c33733c8 pci_host: convert conf index and data ports to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-24 20:17:39 +03:00
Avi Kivity be35694da9 sysbus: add helpers to add and delete memory regions to the system bus
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-24 20:17:35 +03:00
Avi Kivity 58160bafa2 stellaris_enet: convert to memory API
Reviewed-by: Richard Henderson  <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-08-24 20:17:20 +03:00
Jan Kiszka c9abe11120 pci: Error on PCI capability collisions
Nothing good can happen when we overlap capabilities. This may happen
when plugging in assigned devices or when devices models contain bugs.
Detect the overlap and report it.

Based on qemu-kvm commit by Alex Williamson.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Don Dutile <ddutile@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-08-24 15:52:54 +03:00
Isaku Yamahata 74d63b6547 pcie/aer: fix inject aer error command
various fixes to make aer inject error command work.
- wrong assert
- command line parser
- err.status needs initialization

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-08-24 15:52:54 +03:00
Isaku Yamahata 1553d4f1fc pcie/slot: fix hotplug event
When slot status register is cleared, PCIDevice::exp.hpev_notify
needs to be cleared.
Otherwise, PCIDevice::exp.hpev_notify is never set to false resulting
in no more hot plug event once it's raised.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-08-24 15:52:54 +03:00
Peter Maydell 710ffe6048 hw/omap_gpmc: Don't try to map CS0 twice on reset
Remove a spurious second map of the OMAP GPMC CS0 region on reset.
This fixes an assertion failure when we try to add the region to
its container when it was already added. (The old code did not
complain about mismatched map/unmap calls, but the new MemoryRegion
implementation does.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-08-23 21:51:47 +02:00
Peter A. G. Crosthwaite b861b7419c xilinx: removed microbalze_pic_init from xilinx.h
This is a microblaze target specific function that belongs outside
of xilinx.h (which is a collection of target independent device model
instantiator functions)

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-08-22 23:29:37 +02:00
Peter A. G. Crosthwaite 0d877c66b6 xilinx.h: Added missing includes
Added some missing #includes for this file. Previously this file
relied on its clients to pre-include its dependencies.

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-08-22 23:29:37 +02:00
Jan Kiszka 78dd9ff632 vga: Drop some unused fields
Memory region refactorings obsoleted them.

CC: Avi Kivity <avi@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 14:37:03 -05:00
Jan Kiszka 80763888bf vga: Use linear mapping + dirty logging in chain 4 memory access mode
Most VGA memory access modes require MMIO handling as they demand weird
logic to get a byte from or into the video RAM. However, there is one
exception: chain 4 mode with all memory planes enabled for writing. This
mode actually allows lineary mapping, which can then be combined with
dirty logging to accelerate KVM.

This patch accelerates specifically VBE accesses like they are used by
grub in graphical mode. Not only the standard VGA adapter benefits from
this, also vmware and spice in VGA mode.

CC: Gerd Hoffmann <kraxel@redhat.com>
CC: Avi Kivity <avi@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 14:37:03 -05:00
Jan Kiszka fe55ff6e61 vmware-vga: Eliminate vga_dirty_log_restart
After the conversion to the new Memory API, vga_dirty_log_restart became
seriously pointless. Remove it from vmware-vga and and then finally drop
the service.

CC: Andrzej Zaborowski <balrogg@gmail.com>
CC: Avi Kivity <avi@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 14:37:03 -05:00
Jan Kiszka 8d121d4960 vmware-vga: Remove dead DIRECT_VRAM mode
The code was disabled since day 1 of vmware-vga, and now it does not
even build anymore. Time for a cleanup.

CC: Andrzej Zaborowski <balrogg@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 14:37:03 -05:00
Jan Kiszka ca0508df2e vmware-vga: Disable verbose mode
Elimiates 'vmsvga_value_write: guest runs Linux.' messages from the
console.

CC: Andrzej Zaborowski <balrogg@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 14:37:03 -05:00
Jan Kiszka 8a9501bae2 vmware-vga: Register reset service
Fixes cold reset in vmware graphic modes. We need to split up the reset
function for this purpose, breaking out init-once bits.

Cc: Andrzej Zaborowski <balrogg@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 14:37:03 -05:00
Jan Kiszka 0035e5094c ioapic: Implement polarity
If the polarity bit is set in the redirection table, the input level
simply has to inverted as it is low active in this case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 14:37:03 -05:00
Jan Kiszka 1f6f408c8c target-i386: Remove unused polarity arguments from APIC API
Polarity of external interrupts needs to be handled in the IOAPIC.
Passing it to the APIC is pointless. So remove all these arguments.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 14:37:03 -05:00
Avi Kivity ae0a54664c 440fx: fix PAM, PCI holes
The current implementation of PAM and the PCI holes is broken in several
ways:

  - PCI BARs are not restricted to the PCI hole (a BAR may hide memory)
  - PCI devices do not respect PAM (if a PCI device maps a region while
    PAM maps the region to RAM, the request will be honored)

This patch fixes things by introducing a pci address space, and using
memory region aliases to represent PAM regions, SMRAM, and PCI holes.

The memory hierarchy looks something like

system_memory
 |
 +--- low memory alias (0-0xe0000000)
 |      |
 |      +-- ram@0
 |
 +--- high memory alias (0x100000000-EOM)
 |      |
 |      +-- ram@0xe0000000
 |
 +--- pci hole alias (end of low memory-0x100000000)
 |      |
 |      +-- pci@end-of-low-memory
 |
 |
 +--- pam[n] (0xc0000-0xc3fff etc) (when set to pci, priority 1)
 |      |
 |      +-- pci@0xc4000 etc
 |
 +--- smram (0xa0000-0xbffff) (when set to pci/vga, priority 1)
        |
        +-- pci@0xa0000 etc

ram (simple ram region)

pci
 |
 +--- BARn
 |
 +--- VGA 0xa0000-0xbffff
 |
 +--- ROMs

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:49 -05:00
Avi Kivity be20f9e902 vga: drop get_system_memory() from vga devices and derivatives
Instead, use the bus accessors, or get the address space directly
from the board constructor.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:49 -05:00
Avi Kivity f5e6fed879 pci: add pci_address_space()
Returns the PCI address space.  Useful for bridges that can obscure
part of the PCI address space.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:49 -05:00
Avi Kivity c839adec88 isa: add isa_address_space()
A helper that returns the address space used by ISA devices.  Useful
for getting rid of isa_mem_base, multiple ISA buses, or ISA buses behind
bridges.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:49 -05:00
Avi Kivity c5b3572fc6 sysbus: remove sysbus_init_mmio_cb()
This problem with this function is that it is not reversible - it is
impossible to know where things are registered and unregister them
exactly.  As there are no more users, we can remove it.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:48 -05:00
Avi Kivity cd0fa1e6d3 ppce500_pci: convert to sysbus_init_mmio_cb2()
Not a huge step forward, but at least we now have a 1:1 relationship
between registration and unregistration.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:48 -05:00
Avi Kivity 45de094eb8 versatile_pci: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:48 -05:00
Avi Kivity 1635bdfa78 arm11mpcore: use sysbus_init_mmio_cb2
This tells the sysbus code it need not use IO_MEM_UNASSIGNED.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:48 -05:00
Avi Kivity fb57117a19 sh_pci: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:48 -05:00
Avi Kivity d76120135b sysbus: add a variant of sysbus_init_mmio_cb with an unmap callback
sysbus_init_mmio_cb() uses the destructive IO_MEM_UNASSIGNED to remove a
region.  Provide an alternative that calls an unmap callback, so the removal
may be done non-destructively.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:47 -05:00
Avi Kivity b6dcbe086c ppc4xx_sdram: convert to memory API
Clumsy due to the lack of clipping support, needed for
changing exposed ram size.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:47:42 -05:00
Avi Kivity 9074e0e3e8 ppc405_uc: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:23:20 -05:00
Avi Kivity c76f990e8d pcie_host: convert to memory API
Assuming that mmcfg size cannot change at runtime.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:22:03 -05:00
Avi Kivity 689a1921ae onenand: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:22:03 -05:00
Avi Kivity 64066a8fb6 omap_gpmc/nseries/tusb6010: convert to memory API
Somewhat clumsy since it needs a variable sized region.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:21:57 -05:00
Avi Kivity d09871f69c tusb6010: move declarations to new file tusb6010.h
Avoid #include hell.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:20:40 -05:00
Avi Kivity fc2bf44972 gt64xxx.c: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:20:40 -05:00
Avi Kivity f69bf9d41c armv7m: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:20:40 -05:00
Avi Kivity e219dea2f3 arm_timer: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:20:40 -05:00
Avi Kivity 460d7c53cd arm_sysctl: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:20:39 -05:00
Avi Kivity 755c080225 arm_gic: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:20:10 -05:00
Avi Kivity 312b4234c6 apic: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:20:10 -05:00
Avi Kivity 3812ed0baa apb_pci: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:20:10 -05:00
Hervé Poussineau 145aebeca4 pcnet: fix wrong opaque (broken by bd8d6f7cad)
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:20:10 -05:00
Bjørn Mork d4044c2a6b e1000: use MII status register for link up/down
Some guests will use the standard MII status register
to verify link state.  They will not notice link changes
unless this register is updated.

Verified with Linux 3.0 and Windows XP guests.

Without this patch, ethtool will report speed and duplex as
unknown when the link is down, but still report the link as
up.  This is because the Linux e1000 driver checks the
mac_reg[STATUS] register link state before it checks speed
and duplex, but uses the phy_reg[PHY_STATUS] register for
the actual link state check.  Fix by updating both registers
on link state changes.

Linux guest before:

 (qemu) set_link e1000.0 off

 kvm-sid:~# ethtool eth0
 Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: Unknown!
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes

 (qemu) set_link e1000.0 on

Linux guest after:

 (qemu) set_link e1000.0 off
 [   63.384221] e1000: eth0 NIC Link is Down

 kvm-sid:~# ethtool eth0
 Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: Unknown!
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: no

 (qemu) set_link e1000.0 on
 [   84.304582] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:51 -05:00
Anthony Liguori 903396ad3e char: remove qemu_chr_send_event()
It's dead code.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:44 -05:00
Anthony Liguori 74c0d6f020 char: rename qemu_chr_get_msgfd() -> qemu_chr_fe_get_msgfd()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:44 -05:00
Anthony Liguori 70f24fb6c6 char: rename qemu_chr_close() -> qemu_chr_delete()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:43 -05:00
Anthony Liguori 27143a445b char: rename qemu_chr_open() -> qemu_chr_new()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:43 -05:00
Anthony Liguori 41084f1bad char: qemu_chr_ioctl() -> qemu_chr_fe_ioctl()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:37 -05:00
Anthony Liguori 2817822dce char: rename qemu_chr_guest_close() -> qemu_chr_fe_close()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:16 -05:00
Anthony Liguori c9d830eddc char: rename qemu_chr_guest_open() -> qemu_chr_fe_open()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:16 -05:00
Anthony Liguori 909cda12b5 char: rename qemu_chr_can_read() -> qemu_chr_be_can_read()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:16 -05:00
Anthony Liguori fa5efccb2a char: rename qemu_chr_read() -> qemu_chr_be_write()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:16 -05:00
Anthony Liguori e7e71b0ec6 char: rename qemu_chr_printf() -> qemu_chr_fe_printf()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:15 -05:00
Anthony Liguori 2cc6e0a142 char: rename qemu_chr_write() -> qemu_chr_fe_write()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:15 -05:00
Harsh Prateek Bora 5f524c1ebc use readdir_r instead of readdir for reentrancy
Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:52 +05:30
Aneesh Kumar K.V d208a0e005 hw/9pfs: Update v9fs_read to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:50 +05:30
Aneesh Kumar K.V 7eafdcc96c hw/9pfs: Add yield support for preadv coroutine
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:47 +05:30
Aneesh Kumar K.V 8c158561a0 hw/9pfs: Update v9fs_attach to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:46 +05:30
Aneesh Kumar K.V b81d685e21 hw/9pfs: Update v9fs_wstat to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:42 +05:30
Aneesh Kumar K.V d7a9049119 hw/9pfs: Update v9fs_write to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:40 +05:30
Aneesh Kumar K.V f6b3c976c6 hw/9pfs: Add yield support for pwritev coroutine
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:37 +05:30
Venkateswararao Jujjuri (JV) ffd668764c hw/9pfs: Update v9fs_link to use coroutines
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:35 +05:30
Venkateswararao Jujjuri c6c069b0c5 hw/9pfs: Add yield support for link coroutine
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:33 +05:30
Venkateswararao Jujjuri 3fa2a8d1cd hw/9pfs: Update v9fs_symlink to use coroutines
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:29 +05:30
Venkateswararao Jujjuri 02ac7a34ff hw/9pfs: Add yield support for symlin coroutine
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:26 +05:30
Venkateswararao Jujjuri baaa86d9f5 hw/9pfs: Update v9fs_create to use coroutines
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:22 +05:30
Aneesh Kumar K.V 4e9ad44498 hw/9pfs: Update v9fs_fsync to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:21 +05:30
Aneesh Kumar K.V 4743d1f5d3 hw/9pfs: Add yield support for fsync coroutine
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:18 +05:30
Aneesh Kumar K.V c540ee5187 hw/9pfs: Update v9fs_clunk to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:16 +05:30
Aneesh Kumar K.V bed4352c4f hw/9pfs: Add yeild support for clunk related coroutine
This include lsetxattr, lremovexattr, closedir and close.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:44:13 +05:30
Aneesh Kumar K.V 3cc19c0c60 hw/9pfs: Update v9fs_walk to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:23:22 +05:30
Aneesh Kumar K.V d8e0c29e40 hw/9pfs: Update v9fs_stat to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:22:37 +05:30
Venkateswararao Jujjuri 36f8981f01 hw/9pfs: Update v9fs_lcreate to use coroutines
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:21:42 +05:30
Venkateswararao Jujjuri e4de423214 hw/9pfs: Add yield support for open2 coroutine
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:21:42 +05:30
Aneesh Kumar K.V 857bc158d4 hw/9pfs: Update v9fs_open to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:19:53 +05:30
Aneesh Kumar K.V f6b7f0ab5c hw/9pfs: Add yield support for open and opendir coroutine
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:19:53 +05:30
Aneesh Kumar K.V e4e414a427 hw/9pfs: Update v9fs_getlock to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:18:58 +05:30
Aneesh Kumar K.V 0c27bf2a45 hw/9pfs: Update v9fs_lock to use coroutines
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:14:04 +05:30
Aneesh Kumar K.V 03feb1e172 hw/9pfs: Add yeild support for fstat coroutine
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2011-08-22 09:14:04 +05:30
Anthony Liguori f1a7104a5f Merge remote-tracking branch 'pmaydell/armhw-for-upstream' into staging 2011-08-21 18:34:33 -05:00
Blue Swirl 30c2f2388a escc: replace DPRINTFs with tracepoints
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 20:02:02 +00:00
Blue Swirl 42c812b98b m48t59: avoid structure holes spotted by pahole
Report from pahole on amd64 host:
struct M48t59State {
	uint32_t                   type;                 /*     0     4 */

	/* XXX 4 bytes hole, try to pack */

	qemu_irq                   IRQ;                  /*     8     8 */
	uint32_t                   io_base;              /*    16     4 */
	uint32_t                   size;                 /*    20     4 */
	time_t                     time_offset;          /*    24     8 */
	time_t                     stop_time;            /*    32     8 */
	struct tm                  alarm;                /*    40    56 */
	/* --- cacheline 1 boundary (64 bytes) was 32 bytes ago --- */
	struct QEMUTimer *         alrm_timer;           /*    96     8 */
	struct QEMUTimer *         wd_timer;             /*   104     8 */
	uint8_t                    lock;                 /*   112     1 */

	/* XXX 1 byte hole, try to pack */

	uint16_t                   addr;                 /*   114     2 */

	/* XXX 4 bytes hole, try to pack */

	uint8_t *                  buffer;               /*   120     8 */
	/* --- cacheline 2 boundary (128 bytes) --- */

	/* size: 128, cachelines: 2 */
	/* sum members: 119, holes: 3, sum holes: 9 */
};	/* definitions: 1 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 20:02:01 +00:00
Blue Swirl d7b9553489 escc: avoid structure holes spotted by pahole
Edited report from pahole on amd64 host:
struct ChannelState {
...
	ChnType                    type;                 /*    32     4 */

	/* XXX 4 bytes hole, try to pack */
...
	uint8_t                    rregs[16];            /*    66    16 */

	/* XXX 2 bytes hole, try to pack */
...
	/* size: 392, cachelines: 7 */
	/* sum members: 382, holes: 2, sum holes: 6 */
	/* padding: 4 */
	/* last cacheline: 8 bytes */
};	/* definitions: 1 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 20:01:59 +00:00
Blue Swirl 242cca4fdf fdc: avoid structure holes spotted by pahole
Edited report from pahole on amd64 host:
struct FDCtrl {
	uint8_t                    version;              /*     0     1 */

	/* XXX 7 bytes hole, try to pack */

	qemu_irq                   irq;                  /*     8     8 */
	int                        dma_chann;            /*    16     4 */

	/* XXX 4 bytes hole, try to pack */
...
	uint8_t                    status2;              /*    42     1 */

	/* XXX 5 bytes hole, try to pack */

	uint8_t *                  fifo;                 /*    48     8 */
...
	uint8_t                    pwrd;                 /*    76     1 */

	/* XXX 3 bytes hole, try to pack */

	int                        sun4m;                /*    80     4 */
	uint8_t                    num_floppies;         /*    84     1 */

	/* XXX 3 bytes hole, try to pack */

	FDrive                     drives[2];            /*    88    64 */
	/* --- cacheline 2 boundary (128 bytes) was 24 bytes ago --- */
	int                        reset_sensei;         /*   152     4 */

	/* size: 160, cachelines: 3 */
	/* sum members: 134, holes: 5, sum holes: 22 */
	/* padding: 4 */
	/* last cacheline: 32 bytes */
};	/* definitions: 1 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 20:01:57 +00:00
Blue Swirl fe87aa83c6 pcnet: avoid structure holes spotted by pahole
Edited report from pahole on amd64 host:
struct PCNetState_st {
...
	uint16_t                   bcr[32];              /*   340    64 */

	/* XXX 4 bytes hole, try to pack */
...
	int                        tx_busy;              /*  4520     4 */

	/* XXX 4 bytes hole, try to pack */

	qemu_irq                   irq;                  /*  4528     8 */
	void                       (*phys_mem_read)(void *, target_phys_addr_t, uint8_t *, int, int); /*  4536     8 */
	/* --- cacheline 71 boundary (4544 bytes) --- */
	void                       (*phys_mem_write)(void *, target_phys_addr_t, uint8_t *, int, int); /*  4544     8 */
	void *                     dma_opaque;           /*  4552     8 */
	int                        looptest;             /*  4560     4 */

	/* size: 4568, cachelines: 72 */
	/* sum members: 4556, holes: 2, sum holes: 8 */
	/* padding: 4 */
	/* last cacheline: 24 bytes */
};	/* definitions: 2 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 19:52:38 +00:00
Blue Swirl 9a975d6356 esp: avoid structure holes spotted by pahole
Report from pahole on amd64 host:
struct ESPState {
	SysBusDevice               busdev;               /*     0  5648 */
	/* --- cacheline 88 boundary (5632 bytes) was 16 bytes ago --- */
	uint32_t                   it_shift;             /*  5648     4 */

	/* XXX 4 bytes hole, try to pack */

	qemu_irq                   irq;                  /*  5656     8 */
	uint8_t                    rregs[16];            /*  5664    16 */
	uint8_t                    wregs[16];            /*  5680    16 */
	/* --- cacheline 89 boundary (5696 bytes) --- */
	int32_t                    ti_size;              /*  5696     4 */
	uint32_t                   ti_rptr;              /*  5700     4 */
	uint32_t                   ti_wptr;              /*  5704     4 */
	uint8_t                    ti_buf[16];           /*  5708    16 */
	uint32_t                   status;               /*  5724     4 */
	uint32_t                   dma;                  /*  5728     4 */

	/* XXX 4 bytes hole, try to pack */

	SCSIBus                    bus;                  /*  5736  2120 */
	/* --- cacheline 122 boundary (7808 bytes) was 48 bytes ago --- */
	SCSIDevice *               current_dev;          /*  7856     8 */
	SCSIRequest *              current_req;          /*  7864     8 */
	/* --- cacheline 123 boundary (7872 bytes) --- */
	uint8_t                    cmdbuf[16];           /*  7872    16 */
	uint32_t                   cmdlen;               /*  7888     4 */
	uint32_t                   do_cmd;               /*  7892     4 */
	uint32_t                   dma_left;             /*  7896     4 */
	uint32_t                   dma_counter;          /*  7900     4 */
	uint8_t *                  async_buf;            /*  7904     8 */
	uint32_t                   async_len;            /*  7912     4 */

	/* XXX 4 bytes hole, try to pack */

	ESPDMAMemoryReadWriteFunc  dma_memory_read;      /*  7920     8 */
	ESPDMAMemoryReadWriteFunc  dma_memory_write;     /*  7928     8 */
	/* --- cacheline 124 boundary (7936 bytes) --- */
	void *                     dma_opaque;           /*  7936     8 */
	int                        dma_enabled;          /*  7944     4 */

	/* XXX 4 bytes hole, try to pack */

	void                       (*dma_cb)(ESPState *); /*  7952     8 */

	/* size: 7960, cachelines: 125 */
	/* sum members: 7944, holes: 4, sum holes: 16 */
	/* last cacheline: 24 bytes */
};	/* definitions: 1 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 19:52:36 +00:00
Blue Swirl 61999750d3 sun4m: avoid structure holes spotted by pahole
Edited report from pahole on amd64 host:
struct sun4c_hwdef {
...
	uint8_t                    nvram_machine_id;     /*   112     1 */

	/* XXX 1 byte hole, try to pack */
...
	/* size: 136, cachelines: 3 */
	/* sum members: 135, holes: 1, sum holes: 1 */
	/* last cacheline: 8 bytes */
};	/* definitions: 1 */

struct sun4d_hwdef {
...
	uint8_t                    nvram_machine_id;     /*   128     1 */

	/* XXX 1 byte hole, try to pack */
...
	/* size: 152, cachelines: 3 */
	/* sum members: 151, holes: 1, sum holes: 1 */
	/* last cacheline: 24 bytes */
};	/* definitions: 1 */

struct sun4m_hwdef {
...
	uint8_t                    nvram_machine_id;     /*   260     1 */

	/* XXX 1 byte hole, try to pack */

	uint16_t                   machine_id;           /*   262     2 */
	uint32_t                   iommu_version;        /*   264     4 */

	/* XXX 4 bytes hole, try to pack */
...
	/* size: 288, cachelines: 5 */
	/* sum members: 283, holes: 2, sum holes: 5 */
	/* last cacheline: 32 bytes */
};	/* definitions: 1 */

Fix by rearranging the structures to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 19:52:35 +00:00
Blue Swirl 427a66c3a5 tcx: avoid structure holes spotted by pahole
Report from pahole on amd64 host:
struct TCXState {
	SysBusDevice               busdev;               /*     0  5648 */
	/* --- cacheline 88 boundary (5632 bytes) was 16 bytes ago --- */
	target_phys_addr_t         addr;                 /*  5648     8 */
	DisplayState *             ds;                   /*  5656     8 */
	uint8_t *                  vram;                 /*  5664     8 */
	uint32_t *                 vram24;               /*  5672     8 */
	uint32_t *                 cplane;               /*  5680     8 */
	ram_addr_t                 vram_offset;          /*  5688     8 */
	/* --- cacheline 89 boundary (5696 bytes) --- */
	ram_addr_t                 vram24_offset;        /*  5696     8 */
	ram_addr_t                 cplane_offset;        /*  5704     8 */
	uint32_t                   vram_size;            /*  5712     4 */
	uint16_t                   width;                /*  5716     2 */
	uint16_t                   height;               /*  5718     2 */
	uint16_t                   depth;                /*  5720     2 */
	uint8_t                    r[256];               /*  5722   256 */
	/* --- cacheline 93 boundary (5952 bytes) was 26 bytes ago --- */
	uint8_t                    g[256];               /*  5978   256 */
	/* --- cacheline 97 boundary (6208 bytes) was 26 bytes ago --- */
	uint8_t                    b[256];               /*  6234   256 */

	/* XXX 2 bytes hole, try to pack */

	/* --- cacheline 101 boundary (6464 bytes) was 28 bytes ago --- */
	uint32_t                   palette[256];         /*  6492  1024 */
	/* --- cacheline 117 boundary (7488 bytes) was 28 bytes ago --- */
	uint8_t                    dac_index;            /*  7516     1 */
	uint8_t                    dac_state;            /*  7517     1 */

	/* size: 7520, cachelines: 118 */
	/* sum members: 7516, holes: 1, sum holes: 2 */
	/* padding: 2 */
	/* last cacheline: 32 bytes */
};	/* definitions: 1 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 19:52:33 +00:00
Blue Swirl 149e1ea154 sun4m_iommu: avoid structure holes spotted by pahole
Report from pahole on amd64 host:
struct IOMMUState {
	SysBusDevice               busdev;               /*     0  5648 */
	/* --- cacheline 88 boundary (5632 bytes) was 16 bytes ago --- */
	uint32_t                   regs[4096];           /*  5648 16384 */
	/* --- cacheline 344 boundary (22016 bytes) was 16 bytes ago --- */
	target_phys_addr_t         iostart;              /* 22032     8 */
	uint32_t                   version;              /* 22040     4 */

	/* XXX 4 bytes hole, try to pack */

	qemu_irq                   irq;                  /* 22048     8 */

	/* size: 22056, cachelines: 345 */
	/* sum members: 22052, holes: 1, sum holes: 4 */
	/* last cacheline: 40 bytes */
};	/* definitions: 1 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 19:52:32 +00:00
Blue Swirl 07dd0035d8 slavio_intctl: avoid structure holes spotted by pahole
Report from pahole on amd64 host:
struct SLAVIO_INTCTLState {
	SysBusDevice               busdev;               /*     0  5648 */
	/* --- cacheline 88 boundary (5632 bytes) was 16 bytes ago --- */
	uint32_t                   intregm_pending;      /*  5648     4 */
	uint32_t                   intregm_disabled;     /*  5652     4 */
	uint32_t                   target_cpu;           /*  5656     4 */

	/* XXX 4 bytes hole, try to pack */

	qemu_irq                   cpu_irqs[16][16];     /*  5664  2048 */
	/* --- cacheline 120 boundary (7680 bytes) was 32 bytes ago --- */
	SLAVIO_CPUINTCTLState      slaves[16];           /*  7712   384 */
	/* --- cacheline 126 boundary (8064 bytes) was 32 bytes ago --- */

	/* size: 8096, cachelines: 127 */
	/* sum members: 8092, holes: 1, sum holes: 4 */
	/* last cacheline: 32 bytes */
};	/* definitions: 1 */

struct SLAVIO_CPUINTCTLState {
	uint32_t                   intreg_pending;       /*     0     4 */

	/* XXX 4 bytes hole, try to pack */

	struct SLAVIO_INTCTLState * master;              /*     8     8 */
	uint32_t                   cpu;                  /*    16     4 */
	uint32_t                   irl_out;              /*    20     4 */

	/* size: 24, cachelines: 1 */
	/* sum members: 20, holes: 1, sum holes: 4 */
	/* last cacheline: 24 bytes */
};	/* definitions: 1 */

Fix by rearranging the structures to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 19:52:31 +00:00
Blue Swirl 97bbb109b1 slavio_misc: avoid structure holes spotted by pahole
Report from pahole on amd64 host:
struct MiscState {
	SysBusDevice               busdev;               /*     0  5648 */
	/* --- cacheline 88 boundary (5632 bytes) was 16 bytes ago --- */
	qemu_irq                   irq;                  /*  5648     8 */
	uint32_t                   dummy;                /*  5656     4 */
	uint8_t                    config;               /*  5660     1 */
	uint8_t                    aux1;                 /*  5661     1 */
	uint8_t                    aux2;                 /*  5662     1 */
	uint8_t                    diag;                 /*  5663     1 */
	uint8_t                    mctrl;                /*  5664     1 */
	uint8_t                    sysctrl;              /*  5665     1 */
	uint16_t                   leds;                 /*  5666     2 */

	/* XXX 4 bytes hole, try to pack */

	qemu_irq                   fdc_tc;               /*  5672     8 */

	/* size: 5680, cachelines: 89 */
	/* sum members: 5676, holes: 1, sum holes: 4 */
	/* last cacheline: 48 bytes */
};	/* definitions: 1 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 19:52:29 +00:00
Blue Swirl f90074f493 slavio_timer: avoid structure holes spotted by pahole
Report from pahole on amd64 host:
struct SLAVIO_TIMERState {
	SysBusDevice               busdev;               /*     0  5648 */
	/* --- cacheline 88 boundary (5632 bytes) was 16 bytes ago --- */
	uint32_t                   num_cpus;             /*  5648     4 */

	/* XXX 4 bytes hole, try to pack */

	CPUTimerState              cputimer[17];         /*  5656   816 */
	/* --- cacheline 101 boundary (6464 bytes) was 8 bytes ago --- */
	uint32_t                   cputimer_mode;        /*  6472     4 */

	/* size: 6480, cachelines: 102 */
	/* sum members: 6472, holes: 1, sum holes: 4 */
	/* padding: 4 */
	/* last cacheline: 16 bytes */
};	/* definitions: 1 */

struct CPUTimerState {
	qemu_irq                   irq;                  /*     0     8 */
	ptimer_state *             timer;                /*     8     8 */
	uint32_t                   count;                /*    16     4 */
	uint32_t                   counthigh;            /*    20     4 */
	uint32_t                   reached;              /*    24     4 */

	/* XXX 4 bytes hole, try to pack */

	uint64_t                   limit;                /*    32     8 */
	uint32_t                   running;              /*    40     4 */

	/* size: 48, cachelines: 1 */
	/* sum members: 40, holes: 1, sum holes: 4 */
	/* padding: 4 */
	/* last cacheline: 48 bytes */
};	/* definitions: 1 */

Fix by rearranging the structures to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 19:52:27 +00:00
Anthony Liguori 7267c0947d Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20 23:01:08 -05:00
Blue Swirl 02fa69b6e8 scsi-disk: fix DPRINTF
The variable 'status' does not exist anymore, adjust DPRINTF
accordingly.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-20 09:22:52 +00:00
Engin AYDOGAN dc804ab776 hw/stellaris: Add support for RCC2 register
Add support for the RCC2 register on Fury class devices.
Based on a patch by Vijay Kumar.

Signed-off-by: Engin AYDOGAN <engin@bzzzt.biz>
[Peter Maydell: fixed comment typos, minor cleanup of unreachable code]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-17 23:02:15 +00:00
Peter Maydell b3aaff11ec hw/pl061.c: Support GPIOAMSEL register
Support the GPIOAMSEL register found on some Stellaris boards.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-17 23:01:47 +00:00
Peter Maydell a35faa94c8 hw/pl061: Convert to VMState
Convert the PL061 to VMState. We choose to widen the struct members
to uint32_t rather than the other two options of breaking migration
compatibility or using vmstate hacks to read/write a 32 bit value
into an 8 bit struct field.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-17 23:01:41 +00:00
Peter Maydell acb9b72240 vexpress, realview: Use pl111, not pl110
The Versatile Express, Realview EB, PBX A9 and PB A8 boards all
use a PL111 for their graphics, not a PL110. Now we model the
PL111, use it on these board models.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-17 23:01:27 +00:00
Peter Maydell 242ea2c6bc versatilepb: Implement SYS_CLCD mux control register bits
On the Versatile PB, PL110 graphics adaptor only natively supports
5551 pixel format; an external mux swaps bits around to allow
RGB565 and BGR565, under the control of bits [1:0] in the SYS_CLCD
system register.

Implement these SYS_CLCD register bits, and use a gpio line to
feed them out of the system register model, across the versatilepb
board and into the pl110 so we can select the right format.

This is necessary as recent Linux versatile kernels default to
programming the CLCD and mux for 16 bit BGR rather than 16 bit RGB.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-17 23:01:21 +00:00
Peter Maydell 4fbf55568b hw/pl110: Model the PL111 CLCD controller
Model the PL111 CLCD controller. This is a minor variation
on the PL110; the major programmer visible differences are
support for hardware cursor (unimplemented) and two new
pixel formats.

Since syborg_fb.c borrows the pl11x pixel drawing routines,
we also update it to cope with the new slightly larger array
of function pointers.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-08-17 23:01:11 +00:00
Paolo Bonzini 8b2a04eeb9 scsi: do not overwrite memory on REQUEST SENSE commands with a large buffer
Other scsi_target_reqops commands were careful about not using r->cmd.xfer
directly, and instead always cap it to a fixed length.  This was not done
for REQUEST SENSE, and this patch fixes it.

Reported-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-16 19:11:51 +00:00
Peter Maydell 3b6ffe5030 hw/scsi-bus.c: Fix use of uninitialised variable
Don't use req before it has been initialised in scsi_req_new().
This fixes a compile failure due to gcc complaining about this.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-14 19:34:25 +00:00
Paolo Bonzini 98254542f9 scsi: add special traces for common commands
Can be useful when debugging the device scan phase.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:31:28 -05:00
Paolo Bonzini c7b488721d scsi: report unit attention on reset
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:31:28 -05:00
Paolo Bonzini 6dc06f08b3 scsi: add support for unit attention conditions
Unit attention conditions override any sense data the device already
has.  Their signaling and clearing is handled entirely by the SCSIBus
code, and they are completely transparent to the SCSIDevices.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:31:28 -05:00
Paolo Bonzini a872a3049a scsi: add a bunch more common sense codes
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:31:05 -05:00
Paolo Bonzini 739df2150d scsi: move handling of REQUEST SENSE to common code
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:31:05 -05:00
Paolo Bonzini fdaef06917 scsi: move handling of REPORT LUNS and invalid LUNs to common code
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:30:20 -05:00
Paolo Bonzini afa46c468a scsi: move request parsing to common code
Also introduce the first occurrence of "independent" SCSIReqOps,
to handle invalid commands in common code.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:29:01 -05:00
Paolo Bonzini 87dcd1b2c2 scsi: push lun field to SCSIDevice
This will let SCSIBus detect requests sent to an invalid LUN, and
handle them itself.  However, there will be still support for only one
LUN per target

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:29:01 -05:00
Paolo Bonzini 2599aece1b scsi: introduce SCSICommand
This struct is currently unnamed.  Give it a name and use it
explicitly to decouple (some parts of) CDB parsing from
SCSIRequest.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:29:01 -05:00
Paolo Bonzini c39ce112b6 scsi: pass cdb already to scsi_req_new
Right now the CDB is not passed to the SCSIBus until scsi_req_enqueue.
Passing it to scsi_req_new will let scsi_req_new dispatch common requests
through different reqops.

Moving the memcpy to scsi_req_new is a hack that will go away as
soon as scsi_req_new will also take care of the parsing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:27:37 -05:00
Paolo Bonzini 12010e7b29 scsi: move request-related callbacks from SCSIDeviceInfo to SCSIReqOps
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:27:37 -05:00
Paolo Bonzini 8dbd457488 scsi: introduce SCSIReqOps
This will let allow requests to be dispatched through different callbacks,
either common or per-device.

This patch adjusts the API, the next one will move members to SCSIReqOps.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:27:36 -05:00
Paolo Bonzini b45ef674f4 scsi: move sense handling to generic code
With this patch, sense data is stored in the generic data structures
for SCSI devices and requests.  The SCSI layer takes care of storing
sense data in the SCSIDevice for the subsequent REQUEST SENSE command.

At the same time, get_sense is removed and scsi_req_get_sense can use
an entirely generic implementation.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:27:30 -05:00
Paolo Bonzini 682a9b213c scsi: pass status when completing
A small improvement in the SCSI request API.  Pass the status
at the time the request is completed, so that we can assert that
no request is completed twice.  This would have detected the
problem fixed in the previous patch.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:27:00 -05:00
Paolo Bonzini 05751d3ff7 vscsi: always use get_sense
vscsi supports autosensing by providing sense data directly in the
response.  When get_sense was added, the older state machine approach
that sent REQUEST SENSE commands separately was left in place.  Remove
it, all existing SCSIDevices do support autosensing and the next patches
will make the support come for free from the SCSIBus.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:27:00 -05:00
Paolo Bonzini e44089c79d scsi-disk: no need to call scsi_req_data on a short read
In fact, if the HBA's transfer_data callback goes on with scsi_req_continue
the request will be completed successfully instead of showing a failure.
It can even cause a segmentation fault.

An easy way to trigger it is "eject -f cd" during installation (during media
test if the installer does something like that).

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:27:00 -05:00
Anthony Liguori 4333979e3d pc: make vgabios exit port more useful
We've always listened on port 501 for vgabios panic messages.  In the entire
time I've worked on QEMU, I've never actually seen a vgabios panic message :-)

If we change the semantics of this port a little bit, it makes it possible to
use it for more interesting use-cases.  I chose this approach instead of adding
a new I/O port because it avoids having a guest visible change.

This change allows single-byte access to port 501 and also uses the value
written to construct an exit code.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-12 08:27:00 -05:00
Anthony Liguori 9b024b5f96 Merge remote-tracking branch 'stefanha/trivial-patches' into staging 2011-08-12 08:06:02 -05:00
Anthony Liguori eecaecedec Merge remote-tracking branch 'aneesh/for-upstream-1' into staging 2011-08-12 07:52:53 -05:00
Anthony Liguori 25a263cdec Merge remote-tracking branch 'spice/spice.v41' into staging 2011-08-12 07:51:09 -05:00
Anthony Liguori 7cb78eec5c Merge remote-tracking branch 'kraxel/usb.23' into staging 2011-08-12 07:50:35 -05:00
Peter Maydell e92714c71a hw/qdev: Don't crash if qdev_create(NULL, ...) fails
If an attempt to create a qdev device on the default sysbus (by passing
NULL as the bus to qdev_create) fails, print a useful error message
rather than crashing trying to dereference a NULL pointer.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-08-11 14:37:03 +01:00
Zhi Yong Wu 645a8ad6e1 scsi-bus: use DO_UPCAST
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-08-11 14:37:03 +01:00
Edgar E. Iglesias 8cc7c3952d etrax-ser: printf -> qemu_log.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-08-11 12:02:30 +02:00
Edgar E. Iglesias d949396e53 etrax: QDevify the Ethernet MAC.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-08-11 11:12:16 +02:00
Alon Levy c5f3dabba9 qxl: unbreak after memory API conversion
Break is only noticable with newer spice-server library (0.8.2 release
or 0.9.0 and newer on master branch).

ioport_write's val was changed from uint32_t to uint64_t, this
broke two printfs. Use PRId64 instead of %d.

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-10 17:27:21 +02:00
Yonit Halperin be48e99512 qxl: allowing the command rings to be not empty when spice worker is stopped RHBZ #728984
same as 8927cfbba2, but for qxl_check_state, that was
triggered by qxl_pre_load (which calls qxl_hard_reset, which calls qxl_soft_reset),
and caused the migration target to crash.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-10 17:27:13 +02:00