summaryrefslogtreecommitdiff
path: root/hw/pci.c
AgeCommit message (Collapse)AuthorFilesLines
2009-11-15PCI: make duplicate devfn allocation fatalBlue Swirl1-3/+3
Only two callers of pci_create_simple/pci_register_device bothered to check the return value. Other cases were prone to crashing with spurious NULL pointer dereferences. Make QEMU exit with an error message when devfn is attempted to be duplicated, also applies to case when the bus is full. Remove checks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-14pci: Fix function pci_default_write_configStefan Weil1-3/+3
Change 260c0cd3d985e51b15870ff47e17b7b930efbda1 (pci: use range helper functions) introduced a bug which made pci cirrus vga on mips malta (and maybe other pci devices) fail. Don't change addr - its original value is needed by ranges_overlap() and range_covers(). Signed-off-by: Stefan Weil <weil@mail.berlios.de> Acked-by: Ryan Harper <ryanh@us.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-11-12pci: fix the conversion of config field from array to pointerJuan Quintela1-2/+2
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: initialize pci config headers depending it pci header type.Isaku Yamahata1-4/+38
- Only sets default subsystem id for header type 00.(normal header type) because header type 01 doesn't have subsystem id, and uses the register for other purpose. So setting default subsystem id doesn't make sense. - initialize wmask more for header type 01.(bridge header type) Without those wmasks, linux was confused not boot, and lspci was confused not to print out expected IO/memory range. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: use range helper functions.Isaku Yamahata1-6/+2
clean up pci_default_write_config() by the range helper functions. Suggested by Michael S. Tsirkin <mst@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci/monitor: print out bridge's filtering values and so on.Isaku Yamahata1-0/+25
make pci_info_device() print out bridge's filtering value like io base/limit, subbus and subordinate bus. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: teach pci_default_config_write() ROM bar for normal/bridge device .Isaku Yamahata1-0/+2
When updated ROM expantion address of header type 0, it missed to update mappings. Add PCI_ROM_ADDRESS check whether to call pci_update_mappings() Also update pci mapping when PCI_ROM_ADDRESS1 is written for header type 1. pci_update_mapping() path isn't performance critical, so call it even independent of header type. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: implement pci bridge filtering.Isaku Yamahata1-7/+148
This patch implements pci bridge filtering. TODO: currently almost all the map funcions assumes filtered_size == size and addr & ~(size - 1) == addr. However with bridge filtering, they aren't always true. Teach them such cases, such that filtered_size < size and addr & (size - 1) != 0. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: factor out pci_for_each_device().Isaku Yamahata1-7/+14
split out device iteration logic from pci_for_each_device(). factored out function, pci_for_each_device_under_bus() will be used later. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: cosmetic on pci_upadte_mappings()Isaku Yamahata1-70/+76
Remove one indentation of pci_update_mappings. Just for cosmetics, no logic change. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: pcie host and mmcfg support.Isaku Yamahata1-14/+72
This patch adds common routines for pcie host bridge and pcie mmcfg. This will be used by q35 based chipset emulation. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: move pci host stuff from pci.c to pci_host.cIsaku Yamahata1-67/+0
Move pci host stuff from pci.c to pci_host.c. And add some comments. Later pcie host bridge functions will be defined in pcie_host.c not to bloat pci.c. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: factor out the conversion logic from io port address into pci device.Isaku Yamahata1-14/+18
factor out the logic which converts io port address into pci device and offset in PCI configuration space. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: make pci configuration transaction more accurate.Isaku Yamahata1-31/+101
This patch sorts out/enhances pci code to track pci bus topology more accurately. - Track host bus bridge with pci domain number. Although the current qemu implementation supports only pci domian 0 yet. - Track pci bridge parent-child relationship. When looking down from pci host bus for pci sub bus, be aware of secondary bus/subordinate bus. Thus pci configuration transaction is more accurately emulated. This patch adds new member to PCIBus to track pci bus topology. Since qdev already tracks down bus relationship, those new member wouldn't be necessary. However it would be addressed later because not all the pci device isn't converted to qdev yet. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: remove bus_num member from struct PCIBus.Isaku Yamahata1-11/+10
Since It can be retrieved from pci configuration space, the member is unnecessary. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: 64bit bar support.Isaku Yamahata1-5/+30
implemented pci 64bit bar support. The tricky bit is pci_update_mapping(). An OS is allowed to set the BAR such that OS can't address the area pointed by BAR. It doesn't make sense, though. In that case, don't map the BAR. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: typedef pcibus_t as uint64_t instead of uint32_t.Isaku Yamahata1-1/+8
This patch is preliminary for 64bit bar. For 64bit bar support, change pcibus_t which represents pci bus addr/size from uint32_t to uint64_t. And also change FMT_pcibus for printf. In pci_update_mapping() checks 32bit overflow. So the check must be updated too. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: introduce FMT_PCIBUS for printf format for pcibus_t.Isaku Yamahata1-5/+9
This patch is preliminary for 64bit BAR. Later pcibus_t will be changed from uint32_t to uint64_t. Introduce FMT_PCIBUS for printf format for pcibus_t. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: introduce pcibus_t to represent pci bus address/size instead of uint32_tIsaku Yamahata1-3/+3
This patch is preliminary for 64 bit BAR support. Introduce dedicated type, pcibus_t, to represent pci bus address/size instead of uint32_t. Later this type will be changed to uint64_t. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: make pci_bar() aware of header type 1.Isaku Yamahata1-6/+12
make pci_bar() aware of header type 1. When PCI_ROM_SLOT it should return PCI_ROM_ADDRESS1 (!= PCI_ROM_ADDRESS) Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: s/PCI_ADDRESS_SPACE_/PCI_BASE_ADDRESS_SPACE_/ to match pci_regs.hIsaku Yamahata1-5/+5
make constants for pci base address match pci_regs.h by renaming PCI_ADDRESS_SPACE_xxx to PCI_BASE_ADDRESS_SPACE_xxx. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: clean up of pci_default_read_config.Isaku Yamahata1-21/+5
This patch cleans up pci_default_read_config() removing ugly length and range check. Suggested by "Michael S. Tsirkin" <mst@redhat.com> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: clean up pci_init_wmask()Isaku Yamahata1-2/+2
use pci_set_word() for pci command register. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci/bridge: clean up of pci_bridge_initfn()Isaku Yamahata1-11/+25
- use symbolic constant - use helper function pci_set_xxx() - removed lines which initializes to 0. It is unnecessary because it is already zeroed. - add some comments on command registers. Some initial values are suspicious because they seems to be specific to apb_pci.c which is the only user of pci bridge right now. For now don't touch those values to avoid breakage. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: use helper functions to access pci config space.Isaku Yamahata1-15/+15
use pci_[gs]et_{byte, word, long}() to access pci configuration space. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: define a constant to represent a unmapped bar and use it.Isaku Yamahata1-9/+9
define a constant to represent a unmapped bar instead of -1 and use it. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: use PCI_SLOT() and PCI_FUNC().Isaku Yamahata1-2/+2
use PCI_SLOT() and PCI_FUNC() where appropriate instead of direct use of bit operation. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: introduce constant PCI_NUM_PINS for the number of interrupt pins, 4.Isaku Yamahata1-2/+2
introduce constant PCI_NUM_PINS for the number of interrupt pins, 4. and use it. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09pci: fix PCI_DPRINTF() wrt variadic macro.Isaku Yamahata1-1/+1
add missing ## in PCI_DPRINTF() to compile. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-28Merge commit '59c7b155aa6e1cbfe8a92e2322ea59ab31965c10' into upstream-mergeMark McLoughlin1-1/+1
* commit '59c7b155aa6e1cbfe8a92e2322ea59ab31965c10': (81 commits) posix-aio-compat: Split out posix_aio_process_queue monitor: Convert do_closefd() to QObject monitor: Convert do_getfd() to QObject monitor: Convert do_eject() to QObject monitor: Convert do_pci_device_hot_remove() to QObject monitor: Convert do_migrate_cancel() to QObject monitor: Convert do_migrate_set_speed() to QObject monitor: Convert do_migrate() to QObject monitor: Convert do_physical_memory_save() to QObject monitor: Convert do_memory_save() to QObject lsi_scsi: port to vmstate vmstate: Add VMSTATE_BUFFER_UNSAFE vmware_vga: port to vmstate vmware_vga: the support to change dinamically depth is not there vmware_vga: scratch is really an array of uint32_t vmware_vga: remove !EMBED_STDVGA code vmware_vga: qemu_malloc() returns void * vmware_vga: Remove uselss casts from void * vmware_vga: Pass pci_vmsga_state_t arg no VGACommonState vga: remove unused vga_common_save/load ... Conflicts: posix-aio-compat.c Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-10-28Merge commit '9ad4531e1e00b996ba55de04d6ecfb4d02a9fd7c' into upstream-mergeMark McLoughlin1-8/+1
* commit '9ad4531e1e00b996ba55de04d6ecfb4d02a9fd7c': kill dead nic unplug code. zap DeviceState->nd Conflicts: hw/pci-hotplug.c Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-10-28Merge commit 'a783cc3e551158854c15c6d121f29433a2810e85' into upstream-mergeMark McLoughlin1-2/+8
* commit 'a783cc3e551158854c15c6d121f29433a2810e85': ne2k_pci: use qdev properties for configuration. prepare pci nic init path for qdev property configuration. qdev: add qdev_prop_exists() Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-10-27vmstate: Unfold VMSTATE_INT32_VARRAY() only use and remove itJuan Quintela1-1/+1
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27zap DeviceState->ndGerd Hoffmann1-8/+1
No users left. Also cleanup obsolete helper functions. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27prepare pci nic init path for qdev property configuration.Gerd Hoffmann1-2/+8
Initialization path will work with both converted and not-converted drivers, so we can convert drivers one by one. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15Merge commit 'dea7b3b95a0e6b88e0647e7afc8b6a7b5675fbb1' into upstream-mergeMark McLoughlin1-2/+2
* commit 'dea7b3b95a0e6b88e0647e7afc8b6a7b5675fbb1': net: remove id field from NICInfo net: handle id= parameter for -net net: remove unused qemu_handler_true() net: pass monitor handle to client init functions hotplug: safely iterate bus's sibling list while removing a device eepro100: Remove unused device status entries winwave: ADC support audio: remove last remnants of _t winwave: make error logging more consistent winwave: follow the rules when closing the output device configure: clean temporary executable files even on Windows Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-10-15net: remove id field from NICInfoMark McLoughlin1-2/+2
Just use the name field instead since we now use the id paramater as the name, if supplied. Only implication with this change is that if id is not supplied, the value of the name paramater is used as an id. Patchworks-ID: 35512 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-14Merge commit '1215c6e7615897e4a0bfd6867b762a47fc34f37f' into upstream-mergeMarcelo Tosatti1-2/+3
* commit '1215c6e7615897e4a0bfd6867b762a47fc34f37f': Move generation of config-host.h to Makefile from configure Don't include config-host.mak from inside config.mak CRIS: Update PR_EDA on TLB faults. Clean up test for qdev_init() failure Warn if value of qdev_init() isn't checked Make isa_create() terminate program on failure New qdev_init_nofail() Check return value of qdev_init() Make qdev_init() destroy the device on failure Unbreak USB autoconnect filters tcg: improve output log target-i386: fix ARPL configure and Makefile are not generated in qemu Don't use implicit rules for Makefile optionrom: create .PHONY variable add build-all to .PHONY rules optionrom: remove use of implicit RM variable AIOLIBS is not used anywhere qdev: move comment Conflicts: Makefile Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2009-10-14Merge commit '0f457d91c41047f0f22c2e6965fbd154c5cd07d9' into upstream-mergeMarcelo Tosatti1-6/+5
* commit '0f457d91c41047f0f22c2e6965fbd154c5cd07d9': qemu/pci: make pci not depend on msix qemu/pci: clarify pci config load routine Conflicts: hw/pci.c Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2009-10-13use a more upstream friendly version of irqchip-in-kernel testGlauber Costa1-1/+1
Upstream now has tests for irqchip_in_kernel. It differs from our signature, as it does not take any parameter. For consistency, convert our usage. Also, use a field in KVMState to store it, so we can have the exact same function as qemu upstream does. Signed-off-by: Glauber Costa <glommer@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2009-10-08Merge commit '8a1c5235510da01a200693fe3cfd87acd2dc1fca'Mark McLoughlin1-11/+0
Conflicts: net.c Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-10-07New qdev_init_nofail()Markus Armbruster1-2/+2
Like qdev_init(), but terminate program via hw_error() instead of returning an error value. Use it instead of qdev_init() where terminating the program on failure is okay, either because it's during machine construction, or because we know that failure can't happen. Because relying in the latter is somewhat unclean, and the former is not always obvious, it would be nice to go back to qdev_init() in the not-so-obvious cases, only with proper error handling. I'm leaving that for another day, because it involves making sure that error values are properly checked by all callers. Patchworks-ID: 35168 Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-07Check return value of qdev_init()Markus Armbruster1-0/+1
But do so only where it may actually fail. Leave the rest for the next commit. Patchworks-ID: 35167 Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06qemu/pci: make pci not depend on msixMichael S. Tsirkin1-2/+0
Making pci device cleanup msix automatically makes pci.c depend on msix.c, which is IMO messy. Since devices do msix_init it's easy and natural for them to also do msix_uninit. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06qemu/pci: clarify pci config load routineMichael S. Tsirkin1-4/+5
PCI load routine has to be called with size equal to 256 (otherwise it will crash in weird ways). So assert this, making code clearer. Also avoid dynamically sized array on stack - good for portability. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Cc: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Revert "Fix exit on 'pci_add' Monitor command"Anthony Liguori1-11/+0
This reverts commit 0148fde54c2478ea8a47c8dbfe4c0fb8bda4d996. As requested by Luiz. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Revert "qemu/pci: reset device registers on bus reset"Avi Kivity1-13/+0
This reverts commit c0b1905b285800cfd1a797347efeac8338bfa655. It breaks Windows XP install autotest - Windows seems to drop to lose hibernate support with this patch. Signed-off-by: Avi Kivity <avi@redhat.com>
2009-10-06Merge commit '499cf1027f9387081f73767c7872c9123896817c' into upstream-mergeAvi Kivity1-22/+4
* commit '499cf1027f9387081f73767c7872c9123896817c': Rename pci_create_noinit() to pci_create() pci_create() is now unused, remove it Signed-off-by: Avi Kivity <avi@redhat.com>
2009-10-06Merge commit '07caea315a85ebfe90851f9c2e4ef3fdd24117b5' into upstream-mergeAvi Kivity1-14/+34
* commit '07caea315a85ebfe90851f9c2e4ef3fdd24117b5': Fix pci_add nic not to exit on bad model Make it obvious that pci_nic_init() can't fail Fix pci_add storage not to exit on bad first argument Fix pci_vga_init() not to ignore bus argument set correct CS seg limit and flags on sipi Set revision in eeprom correctly for 82557 versions. restore CFLAGS check for conflict and fix recursive CFLAGS issue virtio-pci: return error if virtio_console_init fails qdev: show name of device that fails init vnc: Set invalid buffer pointers to NULL eepro100: Don't allow guests to fail assertions qcow2: Increase maximum cluster size to 2 MB qemu/virtio-pci: remove unnecessary check Conflicts: hw/pc.c Signed-off-by: Avi Kivity <avi@redhat.com>
2009-10-06Merge commit '5a1fc5e8529afb6041a3dfa406a94c187d2afc1d' into upstream-mergeAvi Kivity1-20/+34
* commit '5a1fc5e8529afb6041a3dfa406a94c187d2afc1d': qemu: clean up target page usage in msix fix comment on cpu_register_physical_memory_offset qemu/pci: reset device registers on bus reset qemu/pci: refactor code/symbolic constants qemu/virtio: fix reset with device removal qemu/qdev: type safety in reset handler serial: convert isa to qdev qdev: don't crash on unset drive properties. floppy: move dma setup + drive connect to fdctrl_init_common() floppy: add drive properties. store a pointer to QemuOpts in DeviceState, release it when zapping a device. allow if=none for drive_add refactor drive_hot_add drive cleanup fixes. Conflicts: hw/msix.c hw/pci.h Signed-off-by: Avi Kivity <avi@redhat.com>