Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LThxY-0003Kh-QP for qemu-devel@nongnu.org; Sun, 01 Feb 2009 14:26:24 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LThxW-0003Jx-U9 for qemu-devel@nongnu.org; Sun, 01 Feb 2009 14:26:24 -0500 Received: from [199.232.76.173] (port=41833 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LThxW-0003Js-QB for qemu-devel@nongnu.org; Sun, 01 Feb 2009 14:26:22 -0500 Received: from savannah.gnu.org ([199.232.41.3]:55386 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LThxW-00087m-3N for qemu-devel@nongnu.org; Sun, 01 Feb 2009 14:26:22 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LThxV-00034R-F5 for qemu-devel@nongnu.org; Sun, 01 Feb 2009 19:26:21 +0000 Received: from blueswir1 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LThxU-00033q-T0 for qemu-devel@nongnu.org; Sun, 01 Feb 2009 19:26:21 +0000 MIME-Version: 1.0 Errors-To: blueswir1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Blue Swirl Message-Id: Date: Sun, 01 Feb 2009 19:26:20 +0000 Subject: [Qemu-devel] [6491] Add and use #defines for PCI device classes 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 Revision: 6491 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6491 Author: blueswir1 Date: 2009-02-01 19:26:20 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Add and use #defines for PCI device classes This patch adds and uses #defines for PCI device classes and subclases, using a new pci_config_set_class() function, similar to the recently added pci_config_set_vendor_id() and pci_config_set_device_id(). Change since v1: fixed compilation of hw/sun4u.c Signed-off-by: Stuart Brady Modified Paths: -------------- trunk/hw/ac97.c trunk/hw/acpi.c trunk/hw/apb_pci.c trunk/hw/cirrus_vga.c trunk/hw/e1000.c trunk/hw/eepro100.c trunk/hw/es1370.c trunk/hw/grackle_pci.c trunk/hw/gt64xxx.c trunk/hw/ide.c trunk/hw/lsi53c895a.c trunk/hw/macio.c trunk/hw/ne2000.c trunk/hw/openpic.c trunk/hw/pci.c trunk/hw/pci.h trunk/hw/pcnet.c trunk/hw/piix_pci.c trunk/hw/ppc4xx_pci.c trunk/hw/prep_pci.c trunk/hw/rtl8139.c trunk/hw/sun4u.c trunk/hw/unin_pci.c trunk/hw/usb-ohci.c trunk/hw/usb-uhci.c trunk/hw/versatile_pci.c trunk/hw/vga.c trunk/hw/virtio-balloon.c trunk/hw/virtio-blk.c trunk/hw/virtio-console.c trunk/hw/virtio-net.c trunk/hw/virtio.c trunk/hw/virtio.h trunk/hw/vmware_vga.c Modified: trunk/hw/ac97.c =================================================================== --- trunk/hw/ac97.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/ac97.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -1347,8 +1347,7 @@ c[0x08] = 0x01; /* rid revision ro */ c[0x09] = 0x00; /* pi programming interface ro */ - c[0x0a] = 0x01; /* scc sub class code ro */ - c[0x0b] = 0x04; /* bcc base class code ro */ + pci_config_set_class(c, PCI_CLASS_MULTIMEDIA_AUDIO); /* ro */ c[0x0e] = 0x00; /* headtyp header type ro */ c[0x10] = 0x01; /* nabmar native audio mixer base Modified: trunk/hw/acpi.c =================================================================== --- trunk/hw/acpi.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/acpi.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -509,8 +509,7 @@ pci_conf[0x07] = 0x02; pci_conf[0x08] = 0x03; // revision number pci_conf[0x09] = 0x00; - pci_conf[0x0a] = 0x80; // other bridge device - pci_conf[0x0b] = 0x06; // bridge device + pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_OTHER); pci_conf[0x0e] = 0x00; // header_type pci_conf[0x3d] = 0x01; // interrupt pin 1 Modified: trunk/hw/apb_pci.c =================================================================== --- trunk/hw/apb_pci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/apb_pci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -260,8 +260,7 @@ d->config[0x07] = 0x03; // status = medium devsel d->config[0x08] = 0x00; // revision d->config[0x09] = 0x00; // programming i/f - d->config[0x0A] = 0x00; // class_sub = pci host - d->config[0x0B] = 0x06; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0D] = 0x10; // latency_timer d->config[0x0E] = 0x00; // header_type Modified: trunk/hw/cirrus_vga.c =================================================================== --- trunk/hw/cirrus_vga.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/cirrus_vga.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -3378,8 +3378,7 @@ pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_CIRRUS); pci_config_set_device_id(pci_conf, device_id); pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS; - pci_conf[0x0a] = PCI_CLASS_SUB_VGA; - pci_conf[0x0b] = PCI_CLASS_BASE_DISPLAY; + pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA); pci_conf[0x0e] = PCI_CLASS_HEADERTYPE_00h; /* setup VGA */ Modified: trunk/hw/e1000.c =================================================================== --- trunk/hw/e1000.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/e1000.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -1054,8 +1054,7 @@ *(uint16_t *)(pci_conf+0x04) = cpu_to_le16(0x0407); *(uint16_t *)(pci_conf+0x06) = cpu_to_le16(0x0010); pci_conf[0x08] = 0x03; - pci_conf[0x0a] = 0x00; // ethernet network controller - pci_conf[0x0b] = 0x02; + pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET); pci_conf[0x0c] = 0x10; pci_conf[0x3d] = 1; // interrupt pin 0 Modified: trunk/hw/eepro100.c =================================================================== --- trunk/hw/eepro100.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/eepro100.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -433,8 +433,7 @@ PCI_CONFIG_8(PCI_REVISION_ID, 0x08); /* PCI Class Code */ PCI_CONFIG_8(0x09, 0x00); - PCI_CONFIG_8(PCI_SUBCLASS_CODE, 0x00); // ethernet network controller - PCI_CONFIG_8(PCI_CLASS_CODE, 0x02); // network controller + pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET); /* PCI Cache Line Size */ /* check cache line size!!! */ //~ PCI_CONFIG_8(0x0c, 0x00); Modified: trunk/hw/es1370.c =================================================================== --- trunk/hw/es1370.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/es1370.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -1034,8 +1034,7 @@ pci_config_set_vendor_id(c, PCI_VENDOR_ID_ENSONIQ); pci_config_set_device_id(c, PCI_DEVICE_ID_ENSONIQ_ES1370); c[0x07] = 2 << 1; - c[0x0a] = 0x01; - c[0x0b] = 0x04; + pci_config_set_class(c, PCI_CLASS_MULTIMEDIA_AUDIO); #if 1 c[0x2c] = 0x42; Modified: trunk/hw/grackle_pci.c =================================================================== --- trunk/hw/grackle_pci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/grackle_pci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -148,8 +148,7 @@ pci_config_set_device_id(d->config, PCI_DEVICE_ID_MOTOROLA_MPC106); d->config[0x08] = 0x00; // revision d->config[0x09] = 0x01; - d->config[0x0a] = 0x00; // class_sub = host - d->config[0x0b] = 0x06; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0e] = 0x00; // header_type #if 0 @@ -157,8 +156,7 @@ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_DEC); pci_config_set_device_id(d->config, PCI_DEVICE_ID_DEC_21154); d->config[0x08] = 0x02; // revision - d->config[0x0a] = 0x04; // class_sub = pci2pci - d->config[0x0b] = 0x06; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI); d->config[0x0e] = 0x01; // header_type d->config[0x18] = 0x0; // primary_bus Modified: trunk/hw/gt64xxx.c =================================================================== --- trunk/hw/gt64xxx.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/gt64xxx.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -1146,8 +1146,7 @@ d->config[0x08] = 0x10; d->config[0x09] = 0x00; - d->config[0x0A] = 0x00; - d->config[0x0B] = 0x06; + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x10] = 0x08; d->config[0x14] = 0x08; Modified: trunk/hw/ide.c =================================================================== --- trunk/hw/ide.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/ide.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -3353,8 +3353,7 @@ pci_conf[0x08] = 0x07; // IDE controller revision pci_conf[0x09] = 0x8f; - pci_conf[0x0a] = 0x01; // class_sub = PCI_IDE - pci_conf[0x0b] = 0x01; // class_base = PCI_mass_storage + pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE); pci_conf[0x0e] = 0x00; // header_type pci_conf[0x51] = 0x04; // enable IDE0 @@ -3423,8 +3422,7 @@ pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_1); pci_conf[0x09] = 0x80; // legacy ATA mode - pci_conf[0x0a] = 0x01; // class_sub = PCI_IDE - pci_conf[0x0b] = 0x01; // class_base = PCI_mass_storage + pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE); pci_conf[0x0e] = 0x00; // header_type qemu_register_reset(piix3_reset, d); @@ -3460,8 +3458,7 @@ pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB); pci_conf[0x09] = 0x80; // legacy ATA mode - pci_conf[0x0a] = 0x01; // class_sub = PCI_IDE - pci_conf[0x0b] = 0x01; // class_base = PCI_mass_storage + pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_IDE); pci_conf[0x0e] = 0x00; // header_type qemu_register_reset(piix3_reset, d); Modified: trunk/hw/lsi53c895a.c =================================================================== --- trunk/hw/lsi53c895a.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/lsi53c895a.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -1979,7 +1979,7 @@ /* PCI device ID (word) */ pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_LSI_53C895A); /* PCI base class code */ - pci_conf[0x0b] = 0x01; + pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_SCSI); /* PCI subsystem ID */ pci_conf[0x2e] = 0x00; pci_conf[0x2f] = 0x10; Modified: trunk/hw/macio.c =================================================================== --- trunk/hw/macio.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/macio.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -109,9 +109,7 @@ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, device_id); - - d->config[0x0a] = 0x00; // class_sub = pci2pci - d->config[0x0b] = 0xff; // class_base = bridge + pci_config_set_class(d->config, PCI_CLASS_OTHERS << 8); d->config[0x0e] = 0x00; // header_type d->config[0x3d] = 0x01; // interrupt on pin 1 Modified: trunk/hw/ne2000.c =================================================================== --- trunk/hw/ne2000.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/ne2000.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -792,8 +792,7 @@ pci_conf = d->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REALTEK); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REALTEK_RTL8029); - pci_conf[0x0a] = 0x00; // ethernet network controller - pci_conf[0x0b] = 0x02; + pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET); pci_conf[0x0e] = 0x00; // header_type pci_conf[0x3d] = 1; // interrupt pin 0 Modified: trunk/hw/openpic.c =================================================================== --- trunk/hw/openpic.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/openpic.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -1019,8 +1019,7 @@ pci_conf = opp->pci_dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_IBM); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_IBM_OPENPIC2); - pci_conf[0x0a] = 0x80; // PIC - pci_conf[0x0b] = 0x08; + pci_config_set_class(pci_conf, PCI_CLASS_SYSTEM_OTHER); // FIXME? pci_conf[0x0e] = 0x00; // header_type pci_conf[0x3d] = 0x00; // no interrupt pin Modified: trunk/hw/pci.c =================================================================== --- trunk/hw/pci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/pci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -729,8 +729,7 @@ s->dev.config[0x07] = 0x00; // status = fast devsel s->dev.config[0x08] = 0x00; // revision s->dev.config[0x09] = 0x00; // programming i/f - s->dev.config[0x0A] = 0x04; // class_sub = PCI to PCI bridge - s->dev.config[0x0B] = 0x06; // class_base = PCI_bridge + pci_config_set_class(s->dev.config, PCI_CLASS_BRIDGE_PCI); s->dev.config[0x0D] = 0x10; // latency_timer s->dev.config[0x0E] = 0x81; // header_type s->dev.config[0x1E] = 0xa0; // secondary status Modified: trunk/hw/pci.h =================================================================== --- trunk/hw/pci.h 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/pci.h 2009-02-01 19:26:20 UTC (rev 6491) @@ -8,6 +8,36 @@ extern target_phys_addr_t pci_mem_base; +/* Device classes and subclasses */ + +#define PCI_CLASS_STORAGE_SCSI 0x0100 +#define PCI_CLASS_STORAGE_IDE 0x0101 +#define PCI_CLASS_STORAGE_OTHER 0x0180 + +#define PCI_CLASS_NETWORK_ETHERNET 0x0200 + +#define PCI_CLASS_DISPLAY_VGA 0x0300 +#define PCI_CLASS_DISPLAY_OTHER 0x0380 + +#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401 + +#define PCI_CLASS_MEMORY_RAM 0x0500 + +#define PCI_CLASS_SYSTEM_OTHER 0x0880 + +#define PCI_CLASS_SERIAL_USB 0x0c03 + +#define PCI_CLASS_BRIDGE_HOST 0x0600 +#define PCI_CLASS_BRIDGE_ISA 0x0601 +#define PCI_CLASS_BRIDGE_PCI 0x0604 +#define PCI_CLASS_BRIDGE_OTHER 0x0680 + +#define PCI_CLASS_PROCESSOR_CO 0x0b40 + +#define PCI_CLASS_OTHERS 0xff + +/* Vendors and devices. */ + #define PCI_VENDOR_ID_LSI_LOGIC 0x1000 #define PCI_DEVICE_ID_LSI_53C895A 0x0012 @@ -209,6 +239,12 @@ cpu_to_le16wu((uint16_t *)&pci_config[PCI_DEVICE_ID], val); } +static inline void +pci_config_set_class(uint8_t *pci_config, uint16_t val) +{ + cpu_to_le16wu((uint16_t *)&pci_config[PCI_CLASS_DEVICE], val); +} + /* lsi53c895a.c */ #define LSI_MAX_DEVS 7 void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id); Modified: trunk/hw/pcnet.c =================================================================== --- trunk/hw/pcnet.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/pcnet.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -2006,8 +2006,7 @@ *(uint16_t *)&pci_conf[0x06] = cpu_to_le16(0x0280); pci_conf[0x08] = 0x10; pci_conf[0x09] = 0x00; - pci_conf[0x0a] = 0x00; // ethernet network controller - pci_conf[0x0b] = 0x02; + pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET); pci_conf[0x0e] = 0x00; // header_type *(uint32_t *)&pci_conf[0x10] = cpu_to_le32(0x00000001); Modified: trunk/hw/piix_pci.c =================================================================== --- trunk/hw/piix_pci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/piix_pci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -195,8 +195,7 @@ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(d->config, PCI_DEVICE_ID_INTEL_82441); d->config[0x08] = 0x02; // revision - d->config[0x0a] = 0x00; // class_sub = host2pci - d->config[0x0b] = 0x06; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0e] = 0x00; // header_type d->config[0x72] = 0x02; /* SMRAM */ @@ -337,8 +336,7 @@ pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_0); // 82371SB PIIX3 PCI-to-ISA bridge (Step A1) - pci_conf[0x0a] = 0x01; // class_sub = PCI_ISA - pci_conf[0x0b] = 0x06; // class_base = PCI_bridge + pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA); pci_conf[0x0e] = 0x80; // header_type = PCI_multifunction, generic piix3_reset(d); @@ -359,8 +357,7 @@ pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_0); // 82371AB/EB/MB PIIX4 PCI-to-ISA bridge - pci_conf[0x0a] = 0x01; // class_sub = PCI_ISA - pci_conf[0x0b] = 0x06; // class_base = PCI_bridge + pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA); pci_conf[0x0e] = 0x80; // header_type = PCI_multifunction, generic piix4_reset(d); Modified: trunk/hw/ppc4xx_pci.c =================================================================== --- trunk/hw/ppc4xx_pci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/ppc4xx_pci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -382,8 +382,7 @@ pci_conf = controller->pci_dev->config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_IBM); pci_config_set_device_id(pci_conf, 0x027f); // device_id - pci_conf[0x0a] = 0x80; // class_sub = other bridge type - pci_conf[0x0b] = 0x06; // class_base = PCI_bridge + pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_OTHER); /* CFGADDR */ index = cpu_register_io_memory(0, pci4xx_cfgaddr_read, Modified: trunk/hw/prep_pci.c =================================================================== --- trunk/hw/prep_pci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/prep_pci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -158,8 +158,7 @@ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MOTOROLA); pci_config_set_device_id(d->config, PCI_DEVICE_ID_MOTOROLA_RAVEN); d->config[0x08] = 0x00; // revision - d->config[0x0A] = 0x00; // class_sub = pci host - d->config[0x0B] = 0x06; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; // cache_line_size d->config[0x0D] = 0x10; // latency_timer d->config[0x0E] = 0x00; // header_type Modified: trunk/hw/rtl8139.c =================================================================== --- trunk/hw/rtl8139.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/rtl8139.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -3429,8 +3429,7 @@ pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REALTEK_8139); pci_conf[0x04] = 0x05; /* command = I/O space, Bus Master */ pci_conf[0x08] = RTL8139_PCI_REVID; /* PCI revision ID; >=0x20 is for 8139C+ */ - pci_conf[0x0a] = 0x00; /* ethernet network controller */ - pci_conf[0x0b] = 0x02; + pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET); pci_conf[0x0e] = 0x00; /* header_type */ pci_conf[0x3d] = 1; /* interrupt pin 0 */ pci_conf[0x34] = 0xdc; Modified: trunk/hw/sun4u.c =================================================================== --- trunk/hw/sun4u.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/sun4u.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -373,8 +373,7 @@ s->config[0x07] = 0x03; // status = medium devsel s->config[0x08] = 0x01; // revision s->config[0x09] = 0x00; // programming i/f - s->config[0x0A] = 0x80; // class_sub = misc bridge - s->config[0x0B] = 0x06; // class_base = PCI_bridge + pci_config_set_class(s->config, PCI_CLASS_BRIDGE_OTHER); s->config[0x0D] = 0x0a; // latency_timer s->config[0x0E] = 0x00; // header_type Modified: trunk/hw/unin_pci.c =================================================================== --- trunk/hw/unin_pci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/unin_pci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -177,8 +177,7 @@ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_PCI); d->config[0x08] = 0x00; // revision - d->config[0x0A] = 0x00; // class_sub = pci host - d->config[0x0B] = 0x06; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; // cache_line_size d->config[0x0D] = 0x10; // latency_timer d->config[0x0E] = 0x00; // header_type @@ -191,8 +190,7 @@ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_DEC); pci_config_set_device_id(d->config, PCI_DEVICE_ID_DEC_21154); d->config[0x08] = 0x05; // revision - d->config[0x0A] = 0x04; // class_sub = pci2pci - d->config[0x0B] = 0x06; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI); d->config[0x0C] = 0x08; // cache_line_size d->config[0x0D] = 0x20; // latency_timer d->config[0x0E] = 0x01; // header_type @@ -228,8 +226,7 @@ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_AGP); d->config[0x08] = 0x00; // revision - d->config[0x0A] = 0x00; // class_sub = pci host - d->config[0x0B] = 0x06; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; // cache_line_size d->config[0x0D] = 0x10; // latency_timer d->config[0x0E] = 0x00; // header_type @@ -251,8 +248,7 @@ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_I_PCI); d->config[0x08] = 0x00; // revision - d->config[0x0A] = 0x00; // class_sub = pci host - d->config[0x0B] = 0x06; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; // cache_line_size d->config[0x0D] = 0x10; // latency_timer d->config[0x0E] = 0x00; // header_type Modified: trunk/hw/usb-ohci.c =================================================================== --- trunk/hw/usb-ohci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/usb-ohci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -1682,8 +1682,7 @@ pci_config_set_vendor_id(ohci->pci_dev.config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(ohci->pci_dev.config, 0x003f); // device_id ohci->pci_dev.config[0x09] = 0x10; /* OHCI */ - ohci->pci_dev.config[0x0a] = 0x3; - ohci->pci_dev.config[0x0b] = 0xc; + pci_config_set_class(ohci->pci_dev.config, PCI_CLASS_SERIAL_USB); ohci->pci_dev.config[0x3d] = 0x01; /* interrupt pin 1 */ usb_ohci_init(&ohci->state, num_ports, devfn, ohci->pci_dev.irq[0], Modified: trunk/hw/usb-uhci.c =================================================================== --- trunk/hw/usb-uhci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/usb-uhci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -1084,8 +1084,7 @@ pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_2); pci_conf[0x08] = 0x01; // revision number pci_conf[0x09] = 0x00; - pci_conf[0x0a] = 0x03; - pci_conf[0x0b] = 0x0c; + pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB); pci_conf[0x0e] = 0x00; // header_type pci_conf[0x3d] = 4; // interrupt pin 3 pci_conf[0x60] = 0x10; // release number @@ -1119,8 +1118,7 @@ pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_2); pci_conf[0x08] = 0x01; // revision number pci_conf[0x09] = 0x00; - pci_conf[0x0a] = 0x03; - pci_conf[0x0b] = 0x0c; + pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB); pci_conf[0x0e] = 0x00; // header_type pci_conf[0x3d] = 4; // interrupt pin 3 pci_conf[0x60] = 0x10; // release number Modified: trunk/hw/versatile_pci.c =================================================================== --- trunk/hw/versatile_pci.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/versatile_pci.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -133,8 +133,7 @@ d->config[0x07] = 0x02; d->config[0x08] = 0x00; // revision d->config[0x09] = 0x00; // programming i/f - d->config[0x0A] = 0x40; // class_sub = pci host - d->config[0x0B] = 0x0b; // class_base = PCI_bridge + pci_config_set_class(d->config, PCI_CLASS_PROCESSOR_CO); d->config[0x0D] = 0x10; // latency_timer return s; Modified: trunk/hw/vga.c =================================================================== --- trunk/hw/vga.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/vga.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -2513,8 +2513,7 @@ // dummy VGA (same as Bochs ID) pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_QEMU); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_QEMU_VGA); - pci_conf[0x0a] = 0x00; // VGA controller - pci_conf[0x0b] = 0x03; + pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA); pci_conf[0x0e] = 0x00; // header_type /* XXX: vga_ram_size must be a power of two */ Modified: trunk/hw/virtio-balloon.c =================================================================== --- trunk/hw/virtio-balloon.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/virtio-balloon.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -176,7 +176,7 @@ PCI_DEVICE_ID_VIRTIO_BALLOON, PCI_VENDOR_ID_REDHAT_QUMRANET, VIRTIO_ID_BALLOON, - 0x05, 0x00, 0x00, + PCI_CLASS_MEMORY_RAM, 0x00, 8, sizeof(VirtIOBalloon)); if (s == NULL) return NULL; Modified: trunk/hw/virtio-blk.c =================================================================== --- trunk/hw/virtio-blk.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/virtio-blk.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -305,7 +305,7 @@ PCI_DEVICE_ID_VIRTIO_BLOCK, PCI_VENDOR_ID_REDHAT_QUMRANET, VIRTIO_ID_BLOCK, - 0x01, 0x80, 0x00, + PCI_CLASS_STORAGE_OTHER, 0x00, sizeof(struct virtio_blk_config), sizeof(VirtIOBlock)); if (!s) return NULL; Modified: trunk/hw/virtio-console.c =================================================================== --- trunk/hw/virtio-console.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/virtio-console.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -130,7 +130,7 @@ PCI_DEVICE_ID_VIRTIO_CONSOLE, PCI_VENDOR_ID_REDHAT_QUMRANET, VIRTIO_ID_CONSOLE, - 0x03, 0x80, 0x00, + PCI_CLASS_DISPLAY_OTHER, 0x00, 0, sizeof(VirtIOConsole)); if (s == NULL) return NULL; Modified: trunk/hw/virtio-net.c =================================================================== --- trunk/hw/virtio-net.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/virtio-net.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -325,7 +325,7 @@ PCI_DEVICE_ID_VIRTIO_NET, PCI_VENDOR_ID_REDHAT_QUMRANET, VIRTIO_ID_NET, - 0x02, 0x00, 0x00, + PCI_CLASS_NETWORK_ETHERNET, 0x00, sizeof(struct virtio_net_config), sizeof(VirtIONet)); if (!n) Modified: trunk/hw/virtio.c =================================================================== --- trunk/hw/virtio.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/virtio.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -811,9 +811,8 @@ VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name, uint16_t vendor, uint16_t device, uint16_t subvendor, uint16_t subdevice, - uint8_t class_code, uint8_t subclass_code, - uint8_t pif, size_t config_size, - size_t struct_size) + uint16_t class_code, uint8_t pif, + size_t config_size, size_t struct_size) { VirtIODevice *vdev; PCIDevice *pci_dev; @@ -839,8 +838,7 @@ config[0x08] = VIRTIO_PCI_ABI_VERSION; config[0x09] = pif; - config[0x0a] = subclass_code; - config[0x0b] = class_code; + pci_config_set_class(config, class_code); config[0x0e] = 0x00; config[0x2c] = subvendor & 0xFF; Modified: trunk/hw/virtio.h =================================================================== --- trunk/hw/virtio.h 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/virtio.h 2009-02-01 19:26:20 UTC (rev 6491) @@ -92,9 +92,8 @@ VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name, uint16_t vendor, uint16_t device, uint16_t subvendor, uint16_t subdevice, - uint8_t class_code, uint8_t subclass_code, - uint8_t pif, size_t config_size, - size_t struct_size); + uint16_t class_code, uint8_t pif, + size_t config_size, size_t struct_size); VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, void (*handle_output)(VirtIODevice *, Modified: trunk/hw/vmware_vga.c =================================================================== --- trunk/hw/vmware_vga.c 2009-02-01 12:01:04 UTC (rev 6490) +++ trunk/hw/vmware_vga.c 2009-02-01 19:26:20 UTC (rev 6491) @@ -1204,8 +1204,6 @@ iomemtype); } -#define PCI_CLASS_BASE_DISPLAY 0x03 -#define PCI_CLASS_SUB_VGA 0x00 #define PCI_CLASS_HEADERTYPE_00h 0x00 void pci_vmsvga_init(PCIBus *bus, uint8_t *vga_ram_base, @@ -1220,8 +1218,7 @@ pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE); pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID); s->card.config[PCI_COMMAND] = 0x07; /* I/O + Memory */ - s->card.config[PCI_CLASS_DEVICE] = PCI_CLASS_SUB_VGA; - s->card.config[0x0b] = PCI_CLASS_BASE_DISPLAY; + pci_config_set_class(s->card.config, PCI_CLASS_DISPLAY_VGA); s->card.config[0x0c] = 0x08; /* Cache line size */ s->card.config[0x0d] = 0x40; /* Latency timer */ s->card.config[0x0e] = PCI_CLASS_HEADERTYPE_00h;