Define PCI vendor and device ID in pci.h
PATCH 1/1 Define PCI vendor and device ID in pci.h
This patch defines PPC vendor and device IDs in pci.h, and uses those definitions where appropriate.
cirrus_vga.c +3 -6
@@ -173,8 +173,7 @@#define CIRRUS_MMIO_LINEDRAW_MODE 0x39 // byte#define CIRRUS_MMIO_BLTSTATUS 0x40 // byte -// PCI 0x00: vendor, 0x02: device -#define PCI_VENDOR_CIRRUS 0x1013 +// PCI 0x02: device #define PCI_DEVICE_CLGD5462 0x00d0#define PCI_DEVICE_CLGD5465 0x00d6
@@ -3354,10 +3353,8 @@sizeof (PCICirrusVGAState), -1, NULL, NULL); pci_conf = d->dev.config; - pci_conf[0x00 ] = (uint8_t ) (PCI_VENDOR_CIRRUS &0xff ); - pci_conf[0x01 ] = (uint8_t ) (PCI_VENDOR_CIRRUS >>8 ); - pci_conf[0x02 ] = (uint8_t ) (device_id &0xff ); - pci_conf[0x03 ] = (uint8_t ) (device_id >>8 ); + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_CIRRUS ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (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 ;
usb-uhci.c +4 -8
@@ -1080,10 +1080,8 @@"USB-UHCI" ,sizeof (UHCIState), devfn, NULL, NULL); pci_conf = s->dev.config; - pci_conf[0x00 ] =0x86 ; - pci_conf[0x01 ] =0x80 ; - pci_conf[0x02 ] =0x20 ; - pci_conf[0x03 ] =0x70 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_INTEL_82371SB_2 ); pci_conf[0x08 ] =0x01 ;// revision number pci_conf[0x09 ] =0x00 ; pci_conf[0x0a ] =0x03 ;
@@ -1117,10 +1115,8 @@"USB-UHCI" ,sizeof (UHCIState), devfn, NULL, NULL); pci_conf = s->dev.config; - pci_conf[0x00 ] =0x86 ; - pci_conf[0x01 ] =0x80 ; - pci_conf[0x02 ] =0x12 ; - pci_conf[0x03 ] =0x71 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_INTEL_82371AB_2 ); pci_conf[0x08 ] =0x01 ;// revision number pci_conf[0x09 ] =0x00 ; pci_conf[0x0a ] =0x03 ;
sh_pci.c +2 -4
@@ -191,10 +191,8 @@cpu_register_physical_memory (p->iopbase,0x40000 , iop);cpu_register_physical_memory (p->membase,0x1000000 , mem); - p->dev->config[0x00 ] =0x54 ;// HITACHI - p->dev->config[0x01 ] =0x10 ;// - p->dev->config[0x02 ] =0x0e ;// SH7751R - p->dev->config[0x03 ] =0x35 ;// + *(uint16_t *)&p->dev->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_HITACHI ); + *(uint16_t *)&p->dev->config[0x02 ] =cpu_to_le16 (0x350e );// SH7751R p->dev->config[0x04 ] =0x80 ; p->dev->config[0x05 ] =0x00 ; p->dev->config[0x06 ] =0x90 ;
pcnet.c +2 -2
@@ -2000,8 +2000,8 @@ pci_conf = d->dev.config; - *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (0x1022 ); - *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (0x2000 ); + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_AMD ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_AMD_LANCE ); *(uint16_t *)&pci_conf[0x04 ] =cpu_to_le16 (0x0007 ); *(uint16_t *)&pci_conf[0x06 ] =cpu_to_le16 (0x0280 ); pci_conf[0x08 ] =0x10 ;
usb-ohci.c +2 -6
@@ -1639,8 +1639,6 @@void usb_ohci_init_pci (struct PCIBus *bus,int num_ports,int devfn) {OHCIPCIState *ohci; -int vid =0x106b ; -int did =0x003f ; ohci = (OHCIPCIState *)pci_register_device (bus,"OHCI USB" ,sizeof (*ohci), devfn,NULL ,NULL );
@@ -1649,10 +1647,8 @@return ; } - ohci->pci_dev.config[0x00 ] = vid &0xff ; - ohci->pci_dev.config[0x01 ] = (vid >>8 ) &0xff ; - ohci->pci_dev.config[0x02 ] = did &0xff ; - ohci->pci_dev.config[0x03 ] = (did >>8 ) &0xff ; + *(uint16_t *)&ohci->pci_dev.config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_APPLE ); + *(uint16_t *)&ohci->pci_dev.config[0x02 ] =cpu_to_le16 (0x003f );// device_id ohci->pci_dev.config[0x09 ] =0x10 ;/* OHCI */ ohci->pci_dev.config[0x0a ] =0x3 ; ohci->pci_dev.config[0x0b ] =0xc ;
acpi.c +2 -4
@@ -503,10 +503,8 @@ devfn, NULL, pm_write_config); pm_state = s; pci_conf = s->dev.config; - pci_conf[0x00 ] =0x86 ; - pci_conf[0x01 ] =0x80 ; - pci_conf[0x02 ] =0x13 ; - pci_conf[0x03 ] =0x71 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_INTEL_82371AB_3 ); pci_conf[0x06 ] =0x80 ; pci_conf[0x07 ] =0x02 ; pci_conf[0x08 ] =0x03 ;// revision number
apb_pci.c +2 -4
@@ -252,10 +252,8 @@ d =pci_register_device (s->bus,"Advanced PCI Bus" ,sizeof (PCIDevice),0 ,NULL ,NULL ); - d->config[0x00 ] =0x8e ;// vendor_id : Sun - d->config[0x01 ] =0x10 ; - d->config[0x02 ] =0x00 ;// device_id - d->config[0x03 ] =0xa0 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_SUN ); + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_SUN_SABRE ); d->config[0x04 ] =0x06 ;// command = bus master, pci mem d->config[0x05 ] =0x00 ; d->config[0x06 ] =0xa0 ;// status = fast back-to-back, 66MHz, no error
unin_pci.c +8 -16
@@ -174,10 +174,8 @@cpu_register_physical_memory (0xf2c00000 ,0x1000 , pci_mem_data); d =pci_register_device (s->bus,"Uni-north main" ,sizeof (PCIDevice),11 <<3 ,NULL ,NULL ); - d->config[0x00 ] =0x6b ;// vendor_id : Apple - d->config[0x01 ] =0x10 ; - d->config[0x02 ] =0x1F ;// device_id - d->config[0x03 ] =0x00 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_APPLE ); + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (0x001f );// device_id d->config[0x08 ] =0x00 ;// revision d->config[0x0A ] =0x00 ;// class_sub = pci host d->config[0x0B ] =0x06 ;// class_base = PCI_bridge
@@ -190,10 +188,8 @@/* pci-to-pci bridge */ d =pci_register_device ("Uni-north bridge" ,sizeof (PCIDevice),0 ,13 <<3 ,NULL ,NULL ); - d->config[0x00 ] =0x11 ;// vendor_id : TI - d->config[0x01 ] =0x10 ; - d->config[0x02 ] =0x26 ;// device_id - d->config[0x03 ] =0x00 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (0x1011 );// vendor_id : TI + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (0x0026 );// device_id d->config[0x08 ] =0x05 ;// revision d->config[0x0A ] =0x04 ;// class_sub = pci2pci d->config[0x0B ] =0x06 ;// class_base = PCI_bridge
@@ -229,10 +225,8 @@ d =pci_register_device ("Uni-north AGP" ,sizeof (PCIDevice),0 ,11 <<3 ,NULL ,NULL ); - d->config[0x00 ] =0x6b ;// vendor_id : Apple - d->config[0x01 ] =0x10 ; - d->config[0x02 ] =0x20 ;// device_id - d->config[0x03 ] =0x00 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_APPLE ); + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (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
@@ -254,10 +248,8 @@ d =pci_register_device ("Uni-north internal" ,sizeof (PCIDevice),3 ,11 <<3 ,NULL ,NULL ); - d->config[0x00 ] =0x6b ;// vendor_id : Apple - d->config[0x01 ] =0x10 ; - d->config[0x02 ] =0x1E ;// device_id - d->config[0x03 ] =0x00 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_APPLE ); + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (0x001E );// device_id d->config[0x08 ] =0x00 ;// revision d->config[0x0A ] =0x00 ;// class_sub = pci host d->config[0x0B ] =0x06 ;// class_base = PCI_bridge
vmware_vga.c +13 -21
@@ -1204,12 +1204,6 @@ iomemtype); } -#define PCI_VENDOR_ID_VMWARE 0x15ad -#define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405 -#define PCI_DEVICE_ID_VMWARE_SVGA 0x0710 -#define PCI_DEVICE_ID_VMWARE_NET 0x0720 -#define PCI_DEVICE_ID_VMWARE_SCSI 0x0730 -#define PCI_DEVICE_ID_VMWARE_IDE 0x1729#define PCI_CLASS_BASE_DISPLAY 0x03#define PCI_CLASS_SUB_VGA 0x00#define PCI_CLASS_HEADERTYPE_00h 0x00
@@ -1218,26 +1212,24 @@ unsigned long vga_ram_offset, int vga_ram_size) {struct pci_vmsvga_state_s *s; +uint8_t *pci_conf;/* Setup PCI configuration */ s = (struct pci_vmsvga_state_s *)pci_register_device (bus,"QEMUware SVGA" ,sizeof (struct pci_vmsvga_state_s ),-1 ,0 ,0 ); - s->card.config[PCI_VENDOR_ID ] =PCI_VENDOR_ID_VMWARE &0xff ; - s->card.config[PCI_VENDOR_ID +1 ] =PCI_VENDOR_ID_VMWARE >>8 ; - s->card.config[PCI_DEVICE_ID ] =SVGA_PCI_DEVICE_ID &0xff ; - s->card.config[PCI_DEVICE_ID +1 ] =SVGA_PCI_DEVICE_ID >>8 ; - 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 ; - s->card.config[0x0c ] =0x08 ;/* Cache line size */ - s->card.config[0x0d ] =0x40 ;/* Latency timer */ - s->card.config[0x0e ] = PCI_CLASS_HEADERTYPE_00h; - s->card.config[0x2c ] =PCI_VENDOR_ID_VMWARE &0xff ; - s->card.config[0x2d ] =PCI_VENDOR_ID_VMWARE >>8 ; - s->card.config[0x2e ] =SVGA_PCI_DEVICE_ID &0xff ; - s->card.config[0x2f ] =SVGA_PCI_DEVICE_ID >>8 ; - s->card.config[0x3c ] =0xff ;/* End */ + pci_conf = s->card.config; + *(uint16_t *)&pci_conf[PCI_VENDOR_ID ] =cpu_to_le16 (PCI_VENDOR_ID_VMWARE ); + *(uint16_t *)&pci_conf[PCI_DEVICE_ID ] =cpu_to_le16 (SVGA_PCI_DEVICE_ID ); + pci_conf[PCI_COMMAND ] =0x07 ;/* I/O + Memory */ + pci_conf[PCI_CLASS_DEVICE ] =PCI_CLASS_SUB_VGA ; + pci_conf[0x0b ] =PCI_CLASS_BASE_DISPLAY ; + pci_conf[0x0c ] =0x08 ;/* Cache line size */ + pci_conf[0x0d ] =0x40 ;/* Latency timer */ + pci_conf[0x0e ] = PCI_CLASS_HEADERTYPE_00h; + *(uint16_t *)&pci_conf[0x2c ] =cpu_to_le16 (PCI_VENDOR_ID_VMWARE ); + *(uint16_t *)&pci_conf[0x2e ] =cpu_to_le16 (SVGA_PCI_DEVICE_ID ); + pci_conf[0x3c ] =0xff ;/* End */ pci_register_io_region (&s->card,0 ,0x10 ,PCI_ADDRESS_SPACE_IO , pci_vmsvga_map_ioport);
grackle_pci.c +2 -4
@@ -144,10 +144,8 @@cpu_register_physical_memory (base +0x00200000 ,0x1000 , pci_mem_data); d =pci_register_device (s->bus,"Grackle host bridge" ,sizeof (PCIDevice),0 ,NULL ,NULL ); - d->config[0x00 ] =0x57 ;// vendor_id - d->config[0x01 ] =0x10 ; - d->config[0x02 ] =0x02 ;// device_id - d->config[0x03 ] =0x00 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_MOTOROLA ); + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_MOTOROLA_MPC106 ); d->config[0x08 ] =0x00 ;// revision d->config[0x09 ] =0x01 ; d->config[0x0a ] =0x00 ;// class_sub = host
prep_pci.c +2 -4
@@ -155,10 +155,8 @@/* PCI host bridge */ d =pci_register_device (s->bus,"PREP Host Bridge - Motorola Raven" ,sizeof (PCIDevice),0 ,NULL ,NULL ); - d->config[0x00 ] =0x57 ;// vendor_id : Motorola - d->config[0x01 ] =0x10 ; - d->config[0x02 ] =0x01 ;// device_id : Raven - d->config[0x03 ] =0x48 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_MOTOROLA ); + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (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
ide.c +6 -12
@@ -3174,10 +3174,8 @@ NULL, NULL); d->type =IDE_TYPE_CMD646 ; pci_conf = d->dev.config; - pci_conf[0x00 ] =0x95 ;// CMD646 - pci_conf[0x01 ] =0x10 ; - pci_conf[0x02 ] =0x46 ; - pci_conf[0x03 ] =0x06 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_CMD ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_CMD_646 ); pci_conf[0x08 ] =0x07 ;// IDE controller revision pci_conf[0x09 ] =0x8f ;
@@ -3249,10 +3247,8 @@ d->type =IDE_TYPE_PIIX3 ; pci_conf = d->dev.config; - pci_conf[0x00 ] =0x86 ;// Intel - pci_conf[0x01 ] =0x80 ; - pci_conf[0x02 ] =0x10 ; - pci_conf[0x03 ] =0x70 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (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
@@ -3288,10 +3284,8 @@ d->type =IDE_TYPE_PIIX4 ; pci_conf = d->dev.config; - pci_conf[0x00 ] =0x86 ;// Intel - pci_conf[0x01 ] =0x80 ; - pci_conf[0x02 ] =0x11 ; - pci_conf[0x03 ] =0x71 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (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
ac97.c +2 -5
@@ -1336,12 +1336,9 @@ s = &d->ac97; s->pci_dev = &d->dev; c = d->dev.config; - c[0x00 ] =0x86 ;/* vid vendor id intel ro */ - c[0x01 ] =0x80 ;/* intel */ + *(uint16_t *)&c[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL );/* ro */ + *(uint16_t *)&c[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_INTEL_82801AA_5 );/* ro */ - c[0x02 ] =0x15 ;/* did device id 82801 ro */ - c[0x03 ] =0x24 ;/* 82801aa */ - c[0x04 ] =0x00 ;/* pcicmd pci command rw, ro */ c[0x05 ] =0x00 ;
openpic.c +2 -4
@@ -1017,10 +1017,8 @@if (opp ==NULL )return NULL ; pci_conf = opp->pci_dev.config; - pci_conf[0x00 ] =0x14 ;// IBM MPIC2 - pci_conf[0x01 ] =0x10 ; - pci_conf[0x02 ] =0xFF ; - pci_conf[0x03 ] =0xFF ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_IBM ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (0xffff );// MPIC2 pci_conf[0x0a ] =0x80 ;// PIC pci_conf[0x0b ] =0x08 ; pci_conf[0x0e ] =0x00 ;// header_type
pci.h +57 -1
64 lines not on this page · raw message
eepro100.c +1 -1
@@ -422,7 +422,7 @@logout ("%p\n" , s);/* PCI Vendor ID */ -PCI_CONFIG_16 (PCI_VENDOR_ID ,0x8086 ); +PCI_CONFIG_16 (PCI_VENDOR_ID ,PCI_VENDOR_ID_INTEL );/* PCI Device ID */ PCI_CONFIG_16 (PCI_DEVICE_ID ,0x1209 );/* PCI Command */
ne2000.c +2 -4
@@ -790,10 +790,8 @@ devfn, NULL, NULL); pci_conf = d->dev.config; - pci_conf[0x00 ] =0xec ;// Realtek 8029 - pci_conf[0x01 ] =0x10 ; - pci_conf[0x02 ] =0x29 ; - pci_conf[0x03 ] =0x80 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_REALTEK ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (0x8029 );// Realtek 8029 pci_conf[0x0a ] =0x00 ;// ethernet network controller pci_conf[0x0b ] =0x02 ; pci_conf[0x0e ] =0x00 ;// header_type
versatile_pci.c +2 -4
@@ -124,11 +124,9 @@isa_mmio_init (base +0x03000000 ,0x00100000 ); } - d->config[0x00 ] =0xee ;// vendor_id - d->config[0x01 ] =0x10 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_XILINX );/* Both boards have the same device ID. Oh well. */ - d->config[0x02 ] =0x00 ;// device_id - d->config[0x03 ] =0x03 ; + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (0x0300 );// device_id d->config[0x04 ] =0x00 ; d->config[0x05 ] =0x00 ; d->config[0x06 ] =0x20 ;
piix_pci.c +6 -12
@@ -192,10 +192,8 @@ d =pci_register_device (b,"i440FX" ,sizeof (PCIDevice),0 ,NULL , i440fx_write_config); - d->config[0x00 ] =0x86 ;// vendor_id - d->config[0x01 ] =0x80 ; - d->config[0x02 ] =0x37 ;// device_id - d->config[0x03 ] =0x12 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (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
@@ -337,10 +335,8 @@ piix3_dev = d; pci_conf = d->config; - pci_conf[0x00 ] =0x86 ;// Intel - pci_conf[0x01 ] =0x80 ; - pci_conf[0x02 ] =0x00 ;// 82371SB PIIX3 PCI-to-ISA bridge (Step A1) - pci_conf[0x03 ] =0x70 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (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_conf[0x0e ] =0x80 ;// header_type = PCI_multifunction, generic
@@ -361,10 +357,8 @@ piix4_dev = d; pci_conf = d->config; - pci_conf[0x00 ] =0x86 ;// Intel - pci_conf[0x01 ] =0x80 ; - pci_conf[0x02 ] =0x10 ;// 82371AB/EB/MB PIIX4 PCI-to-ISA bridge - pci_conf[0x03 ] =0x71 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (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_conf[0x0e ] =0x80 ;// header_type = PCI_multifunction, generic
lsi53c895a.c +10 -9
@@ -1963,6 +1963,7 @@void *lsi_scsi_init (PCIBus *bus,int devfn) {LSIState *s; +uint8_t *pci_conf; s = (LSIState *)pci_register_device (bus,"LSI53C895A SCSI HBA" ,sizeof (*s), devfn,NULL ,NULL );
@@ -1971,21 +1972,21 @@return NULL ; } + pci_conf = s->pci_dev.config; +/* PCI Vendor ID (word) */ - s->pci_dev.config[0x00 ] =0x00 ; - s->pci_dev.config[0x01 ] =0x10 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_LSI_LOGIC );/* PCI device ID (word) */ - s->pci_dev.config[0x02 ] =0x12 ; - s->pci_dev.config[0x03 ] =0x00 ; + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_LSI_53C895A );/* PCI base class code */ - s->pci_dev.config[0x0b ] =0x01 ; + pci_conf[0x0b ] =0x01 ;/* PCI subsystem ID */ - s->pci_dev.config[0x2e ] =0x00 ; - s->pci_dev.config[0x2f ] =0x10 ; + pci_conf[0x2e ] =0x00 ; + pci_conf[0x2f ] =0x10 ;/* PCI latency timer = 255 */ - s->pci_dev.config[0x0d ] =0xff ; + pci_conf[0x0d ] =0xff ;/* Interrupt pin 1 */ - s->pci_dev.config[0x3d ] =0x01 ; + pci_conf[0x3d ] =0x01 ; s->mmio_io_addr =cpu_register_io_memory (0 , lsi_mmio_readfn, lsi_mmio_writefn, s);
virtio.c +2 -4
@@ -830,10 +830,8 @@ vdev->vq =qemu_mallocz (sizeof (VirtQueue) *VIRTIO_PCI_QUEUE_MAX ); config = pci_dev->config; - config[0x00 ] = vendor &0xFF ; - config[0x01 ] = (vendor >>8 ) &0xFF ; - config[0x02 ] = device &0xFF ; - config[0x03 ] = (device >>8 ) &0xFF ; + *(uint16_t *)&config[0x00 ] =cpu_to_le16 (vendor); + *(uint16_t *)&config[0x02 ] =cpu_to_le16 (device); config[0x08 ] =VIRTIO_PCI_ABI_VERSION ;
es1370.c +2 -4
@@ -1031,10 +1031,8 @@ } c = d->dev.config; - c[0x00 ] =0x74 ; - c[0x01 ] =0x12 ; - c[0x02 ] =0x00 ; - c[0x03 ] =0x50 ; + *(uint16_t *)&c[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_ENSONIQ ); + *(uint16_t *)&c[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_ENSONIQ_ES1370 ); c[0x07 ] =2 <<1 ; c[0x0a ] =0x01 ; c[0x0b ] =0x04 ;
macio.c +3 -4
@@ -106,11 +106,10 @@ macio_state->ide_mem_index[i] =-1 ;/* Note: this code is strongly inspirated from the corresponding code in PearPC */ - d->config[0x00 ] =0x6b ;// vendor_id - d->config[0x01 ] =0x10 ; - d->config[0x02 ] = device_id; - d->config[0x03 ] = device_id >>8 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_APPLE ); + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (device_id); + d->config[0x0a ] =0x00 ;// class_sub = pci2pci d->config[0x0b ] =0xff ;// class_base = bridge d->config[0x0e ] =0x00 ;// header_type
vga.c +2 -4
@@ -2505,10 +2505,8 @@ s->pci_dev = &d->dev; pci_conf = d->dev.config; - pci_conf[0x00 ] =0x34 ;// dummy VGA (same as Bochs ID) - pci_conf[0x01 ] =0x12 ; - pci_conf[0x02 ] =0x11 ; - pci_conf[0x03 ] =0x11 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (0x1234 );// dummy VGA (same as Bochs ID) + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (0x1111 ); pci_conf[0x0a ] =0x00 ;// VGA controller pci_conf[0x0b ] =0x03 ; pci_conf[0x0e ] =0x00 ;// header_type
sun4u.c +2 -4
@@ -365,10 +365,8 @@PCIDevice *s; s =pci_register_device (bus,"EBUS" ,sizeof (*s), devfn,NULL ,NULL ); - s->config[0x00 ] =0x8e ;// vendor_id : Sun - s->config[0x01 ] =0x10 ; - s->config[0x02 ] =0x00 ;// device_id - s->config[0x03 ] =0x10 ; + *(uint16_t *)&s->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_SUN ); + *(uint16_t *)&s->config[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_SUN_EBUS ); s->config[0x04 ] =0x06 ;// command = bus master, pci mem s->config[0x05 ] =0x00 ; s->config[0x06 ] =0xa0 ;// status = fast back-to-back, 66MHz, no error
ppc4xx_pci.c +6 -6
@@ -366,6 +366,7 @@PPC4xxPCIState *controller;int index;static int ppc4xx_pci_id; +uint8_t *pci_conf; controller =qemu_mallocz (sizeof (PPC4xxPCIState));if (!controller)
@@ -378,12 +379,11 @@ controller->pci_dev =pci_register_device (controller->pci_state.bus,"host bridge" ,sizeof (PCIDevice),0 ,NULL ,NULL ); - controller->pci_dev->config[0x00 ] =0x14 ;// vendor_id - controller->pci_dev->config[0x01 ] =0x10 ; - controller->pci_dev->config[0x02 ] =0x7f ;// device_id - controller->pci_dev->config[0x03 ] =0x02 ; - controller->pci_dev->config[0x0a ] =0x80 ;// class_sub = other bridge type - controller->pci_dev->config[0x0b ] =0x06 ;// class_base = PCI_bridge + pci_conf = controller->pci_dev->config; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_IBM ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (0x027f );// device_id + pci_conf[0x0a ] =0x80 ;// class_sub = other bridge type + pci_conf[0x0b ] =0x06 ;// class_base = PCI_bridge /* CFGADDR */ index = cpu_register_io_memory(0, pci4xx_cfgaddr_read,
gt64xxx.c +2 -4
@@ -1136,10 +1136,8 @@/* FIXME: Malta specific hw assumptions ahead */ - d->config[0x00 ] =0xab ;/* vendor_id */ - d->config[0x01 ] =0x11 ; - d->config[0x02 ] =0x20 ;/* device_id */ - d->config[0x03 ] =0x46 ; + *(uint16_t *)&d->config[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_MARVELL ); + *(uint16_t *)&d->config[0x02 ] =cpu_to_le16 (0x4620 );/* device_id */ d->config[0x04 ] =0x00 ; d->config[0x05 ] =0x00 ;
e1000.c +4 -4
@@ -1049,10 +1049,10 @@ pci_conf = d->dev.config;memset (pci_conf,0 ,256 ); - *(uint16_t *)(pci_conf+0x00 ) =cpu_to_le16 (0x8086 ); - *(uint16_t *)(pci_conf+0x02 ) =cpu_to_le16 (E1000_DEVID ); - *(uint16_t *)(pci_conf+0x04 ) =cpu_to_le16 (0x0407 ); - *(uint16_t *)(pci_conf+0x06 ) =cpu_to_le16 (0x0010 ); + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (E1000_DEVID ); + *(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 ;
rtl8139.c +4 -6
@@ -1187,8 +1187,8 @@ s->eeprom.contents[0 ] =0x8129 ;#if 1 // PCI vendor and device ID should be mirrored here - s->eeprom.contents[1 ] =0x10ec ; - s->eeprom.contents[2 ] =0x8139 ; + s->eeprom.contents[1 ] =PCI_VENDOR_ID_REALTEK ; + s->eeprom.contents[2 ] =PCI_DEVICE_ID_REALTEK_8139 ;#endif s->eeprom.contents[7 ] = s->macaddr[0 ] | s->macaddr[1 ] <<8 ;
@@ -3425,10 +3425,8 @@ devfn, NULL, NULL); pci_conf = d->dev.config; - pci_conf[0x00 ] =0xec ;/* Realtek 8139 */ - pci_conf[0x01 ] =0x10 ; - pci_conf[0x02 ] =0x39 ; - pci_conf[0x03 ] =0x81 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_REALTEK ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (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 */
Signature · 1 line
Stuart Brady
Quoted 37 lines · Stuart Brady
This patch defines PPC vendor and device IDs in
pci.h, and uses those definitions where appropriate.Signed-off-by Stuart Brady <[email protected]>Index:
hw/cirrus_vga.c
===================================================================cirrus_vga.c +3
-6@@ -173,8 +173,7 @@#define CIRRUS_MMIO_LINEDRAW_MODE 0x39 // byte#define CIRRUS_MMIO_BLTSTATUS 0x40 // byte -// PCI 0x00: vendor, 0x02: device -#define PCI_VENDOR_CIRRUS 0x1013 +// PCI 0x02: device #define PCI_DEVICE_CLGD5462 0x00d0#define PCI_DEVICE_CLGD5465 0x00d6@@ -3354,10 +3353,8 @@sizeof (PCICirrusVGAState), -1, NULL, NULL); pci_conf = d->dev.config; - pci_conf[0x00 ] = (uint8_t ) (PCI_VENDOR_CIRRUS &0xff ); - pci_conf[0x01 ] = (uint8_t ) (PCI_VENDOR_CIRRUS >>8 ); - pci_conf[0x02 ] = (uint8_t ) (device_id &0xff ); - pci_conf[0x03 ] = (uint8_t ) (device_id >>8 ); + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_CIRRUS ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (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 ;Index:
hw/usb-uhci.c
===================================================================
usb-uhci.c line 1085
Quoted 10 lines
usb-uhci.c +2
-4@@ -1080,10 +1080,8 @@"USB-UHCI" ,sizeof (UHCIState), devfn, NULL, NULL); pci_conf = s->dev.config; - pci_conf[0x00 ] =0x86 ; - pci_conf[0x01 ] =0x80 ; - pci_conf[0x02 ] =0x20 ; - pci_conf[0x03 ] =0x70 ; + *(uint16_t *)&pci_conf[0x00 ] =cpu_to_le16 (PCI_VENDOR_ID_INTEL ); + *(uint16_t *)&pci_conf[0x02 ] =cpu_to_le16 (PCI_DEVICE_ID_INTEL_82371SB_2 );
You should use cpu_to_le16uw here. Even better yet, you should introduce some PCI space accessors to remove all of the open coded offset access.
You could start with just pci_config_set_vendor_id()/pci_config_set_device_id().
Regards,
Anthony Liguori
Quoted 5 lines · Anthony Liguori
Quoted 4 lines
(quoted diff) +2
-0+ *(uint16_t *)&pci_conf[0x00] = cpu_to_le16(PCI_VENDOR_ID_INTEL); + *(uint16_t *)&pci_conf[0x02] =
cpu_to_le16(PCI_DEVICE_ID_INTEL_82371SB_2);You should use
cpu_to_le16uwhere.
That was my initial thought -- only cpu_to_le16uw() still requires the cast. The EEPro100 emulation uses its own style:
PCI_CONFIG_16(PCI_VENDOR_ID, 0x8086);
PCI_CONFIG_16(PCI_DEVICE_ID, 0x1209);... but I didn't like this, because the name of 'pci_conf' is not specified explicitly, and PCI_CONFIG_* are just little-endian writes, and not anything particularly special.
Quoted 5 lines
Even better yet, you should introduce some PCI space accessors to remove all of the open coded offset access.
You could start with just pci_config_set_vendor_id()/pci_config_set_device_id().
That sounds much better! Will do! :)
Cheers,
Signature · 1 line
Stuart Brady