From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KXw15-0002Im-5k for qemu-devel@nongnu.org; Tue, 26 Aug 2008 06:43:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KXw13-0002IO-TG for qemu-devel@nongnu.org; Tue, 26 Aug 2008 06:43:14 -0400 Received: from [199.232.76.173] (port=35313 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KXw12-0002IA-DY for qemu-devel@nongnu.org; Tue, 26 Aug 2008 06:43:12 -0400 Received: from mx2.redhat.com ([66.187.237.31]:45040) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KXw0y-0001DI-UZ for qemu-devel@nongnu.org; Tue, 26 Aug 2008 06:43:12 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id m7QAgVST013822 for ; Tue, 26 Aug 2008 06:42:51 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m7QAgJsK029026 for ; Tue, 26 Aug 2008 06:42:20 -0400 Received: from zweiblum.travel.kraxel.org (vpn-4-42.str.redhat.com [10.32.4.42]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id m7QAgDcP014593 for ; Tue, 26 Aug 2008 06:42:14 -0400 Message-ID: <48B3DE05.3000009@redhat.com> Date: Tue, 26 Aug 2008 12:42:13 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040406000103050301040505" Subject: [Qemu-devel] [patch 2/2] 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 This is a multi-part message in MIME format. --------------040406000103050301040505 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, This sets a default pci subsystem id for all emulated pci devices. I'm using fffa:0001 for now, we should probably get something assigned instead ... cheers, Gerd --------------040406000103050301040505 Content-Type: text/plain; name="0019-pci-add-default-pci-subsystem-id-for-all-devices.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0019-pci-add-default-pci-subsystem-id-for-all-devices.patch" >>From 1acb8825f1537b55659498fb61d543ef5d015550 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 26 Aug 2008 12:34:42 +0200 Subject: [PATCH] pci: add default pci subsystem id for all devices. This sets a default PCI subsystem ID for all emulated PCI devices. PCI specs require this, so do it. Individual devices can overwrite it of course. 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. 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 | 2 ++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index bc55989..ffc90d7 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 = 0xfffa; /* FIXME: get one assigned */ +uint16_t pci_default_sub_device_id = 0x0001; 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 2b1ebba..6e0d7ed 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -33,6 +33,8 @@ 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; typedef void PCIConfigWriteFunc(PCIDevice *pci_dev, uint32_t address, uint32_t data, int len); -- 1.5.5.1 --------------040406000103050301040505--