From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KdO8b-0000jy-3L for qemu-devel@nongnu.org; Wed, 10 Sep 2008 07:45:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KdO8Z-0000ga-7Q for qemu-devel@nongnu.org; Wed, 10 Sep 2008 07:45:32 -0400 Received: from [199.232.76.173] (port=36311 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KdO8Y-0000fU-KH for qemu-devel@nongnu.org; Wed, 10 Sep 2008 07:45:30 -0400 Received: from mx1.redhat.com ([66.187.233.31]:57340) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KdO8Y-0003z5-F3 for qemu-devel@nongnu.org; Wed, 10 Sep 2008 07:45:30 -0400 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m8ABjTNp001182 for ; Wed, 10 Sep 2008 07:45:29 -0400 From: Gerd Hoffmann Date: Wed, 10 Sep 2008 13:45:24 +0200 Message-Id: <1221047125-12949-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1221047125-12949-1-git-send-email-kraxel@redhat.com> References: <1221047125-12949-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 3/4] pci: add default pci subsystem id for all devices. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann This sets a default PCI subsystem ID for all emulated PCI devices. PCI specs require this, so do it. The defaults are global variables so they can easily be changed (before device creation) as Xen probably wants to use the XenSource vendor ID instead of the qemu default. The defaults are pre-filled by pci_register_device(). Individual drivers can overwrite it of course when setting up the config space for the emulated device. TODO: get an official vendor ID assigned, or borrow one (maybe Qumranet which already sponsors the virtio IDs ???). Signed-off-by: Gerd Hoffmann --- hw/pci.c | 11 +++++++++++ hw/pci.h | 5 +++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index bc55989..1304dae 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -50,6 +50,8 @@ static void pci_update_mappings(PCIDevice *d); static void pci_set_irq(void *opaque, int irq_num, int level); target_phys_addr_t pci_mem_base; +uint16_t pci_default_sub_vendor_id = PCI_VENDOR_ID_QEMU; +uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU_DEFAULT; static int pci_irq_index; static PCIBus *first_bus; @@ -145,6 +147,14 @@ int pci_device_load(PCIDevice *s, QEMUFile *f) return 0; } +static int pci_set_default_subsystem_id(PCIDevice *pci_dev) +{ + struct pci_config_header *conf = (void*)pci_dev->config; + + conf->sub_vendor_id = cpu_to_le16(pci_default_sub_vendor_id); + conf->sub_device_id = cpu_to_le16(pci_default_sub_device_id); +} + /* -1 for devfn means auto assign */ PCIDevice *pci_register_device(PCIBus *bus, const char *name, int instance_size, int devfn, @@ -171,6 +181,7 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name, pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); memset(pci_dev->irq_state, 0, sizeof(pci_dev->irq_state)); + pci_set_default_subsystem_id(pci_dev); if (!config_read) config_read = pci_default_read_config; diff --git a/hw/pci.h b/hw/pci.h index f518e5e..3c6976a 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -33,6 +33,11 @@ struct pci_config_header { }; extern target_phys_addr_t pci_mem_base; +extern uint16_t pci_default_sub_vendor_id; +extern uint16_t pci_default_sub_device_id; + +#define PCI_VENDOR_ID_QEMU 0xfffa /* FIXME: get one assigned */ +#define PCI_SUBDEVICE_ID_QEMU_DEFAULT 0x0001 typedef void PCIConfigWriteFunc(PCIDevice *pci_dev, uint32_t address, uint32_t data, int len); -- 1.5.5.1