* [Qemu-devel] [PATCH 1/7] pci: move ids of config space into PCIDeviceInfo
2011-04-08 12:52 [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Isaku Yamahata
@ 2011-04-08 12:53 ` Isaku Yamahata
2011-05-05 12:48 ` Michael S. Tsirkin
2011-04-08 12:53 ` [Qemu-devel] [PATCH 2/7] usb-uhci: convert to PCIDEviceInfo to initialize ids Isaku Yamahata
` (6 subsequent siblings)
7 siblings, 1 reply; 11+ messages in thread
From: Isaku Yamahata @ 2011-04-08 12:53 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, mst
vender id/device id... in configuration space are read-only registers
which are commonly defined for all pci devices.
So move those initialization into common place.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
hw/pci.c | 46 ++++++++++++++++++++++++++++++++--------------
hw/pci.h | 9 +++++++++
2 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 410b67b..a3fd391 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -726,10 +726,12 @@ static void pci_config_free(PCIDevice *pci_dev)
/* -1 for devfn means auto assign */
static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
const char *name, int devfn,
- PCIConfigReadFunc *config_read,
- PCIConfigWriteFunc *config_write,
- bool is_bridge)
+ const PCIDeviceInfo *info)
{
+ PCIConfigReadFunc *config_read = info->config_read;
+ PCIConfigWriteFunc *config_write = info->config_write;
+ uint8_t header_type = info->header_type & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
+
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
devfn += PCI_FUNC_MAX) {
@@ -750,13 +752,27 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
pci_dev->irq_state = 0;
pci_config_alloc(pci_dev);
- if (!is_bridge) {
- pci_set_default_subsystem_id(pci_dev);
+ pci_config_set_vendor_id(pci_dev->config, info->vendor_id);
+ pci_config_set_device_id(pci_dev->config, info->device_id);
+ pci_config_set_revision(pci_dev->config, info->revision);
+ pci_config_set_prog_interface(pci_dev->config, info->prog_interface);
+ pci_config_set_class(pci_dev->config, info->class_id);
+ pci_dev->config[PCI_HEADER_TYPE] = header_type;
+
+ if (!info->is_bridge) {
+ if (info->subsystem_vendor_id) {
+ pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID,
+ info->subsystem_vendor_id);
+ pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID,
+ info->subsystem_id);
+ } else {
+ pci_set_default_subsystem_id(pci_dev);
+ }
}
pci_init_cmask(pci_dev);
pci_init_wmask(pci_dev);
pci_init_w1cmask(pci_dev);
- if (is_bridge) {
+ if (info->is_bridge) {
pci_init_wmask_bridge(pci_dev);
}
if (pci_init_multifunction(bus, pci_dev)) {
@@ -783,17 +799,21 @@ static void do_pci_unregister_device(PCIDevice *pci_dev)
pci_config_free(pci_dev);
}
+/* TODO: obsolete. eliminate this once all pci devices are qdevifed. */
PCIDevice *pci_register_device(PCIBus *bus, const char *name,
int instance_size, int devfn,
PCIConfigReadFunc *config_read,
PCIConfigWriteFunc *config_write)
{
PCIDevice *pci_dev;
+ PCIDeviceInfo info = {
+ .config_read = config_read,
+ .config_write = config_write,
+ .header_type = PCI_HEADER_TYPE_NORMAL
+ };
pci_dev = qemu_mallocz(instance_size);
- pci_dev = do_pci_register_device(pci_dev, bus, name, devfn,
- config_read, config_write,
- PCI_HEADER_TYPE_NORMAL);
+ pci_dev = do_pci_register_device(pci_dev, bus, name, devfn, &info);
if (pci_dev == NULL) {
hw_error("PCI: can't register device\n");
}
@@ -1642,7 +1662,7 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
PCIDevice *pci_dev = (PCIDevice *)qdev;
PCIDeviceInfo *info = container_of(base, PCIDeviceInfo, qdev);
PCIBus *bus;
- int devfn, rc;
+ int rc;
bool is_default_rom;
/* initialize cap_present for pci_is_express() and pci_config_size() */
@@ -1651,10 +1671,8 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
}
bus = FROM_QBUS(PCIBus, qdev_get_parent_bus(qdev));
- devfn = pci_dev->devfn;
- pci_dev = do_pci_register_device(pci_dev, bus, base->name, devfn,
- info->config_read, info->config_write,
- info->is_bridge);
+ pci_dev = do_pci_register_device(pci_dev, bus, base->name,
+ pci_dev->devfn, info);
if (pci_dev == NULL)
return -1;
if (qdev->hotplugged && info->no_hotplug) {
diff --git a/hw/pci.h b/hw/pci.h
index c6a6eb6..f945798 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -433,6 +433,15 @@ typedef struct {
PCIConfigReadFunc *config_read;
PCIConfigWriteFunc *config_write;
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint8_t revision;
+ uint8_t prog_interface;
+ uint16_t class_id;
+ uint8_t header_type;
+ uint16_t subsystem_vendor_id; /* only for header type = 0 */
+ uint16_t subsystem_id; /* only for header type = 0 */
+
/*
* pci-to-pci bridge or normal device.
* This doesn't mean pci host switch.
--
1.7.1.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 1/7] pci: move ids of config space into PCIDeviceInfo
2011-04-08 12:53 ` [Qemu-devel] [PATCH 1/7] pci: move ids of config space into PCIDeviceInfo Isaku Yamahata
@ 2011-05-05 12:48 ` Michael S. Tsirkin
0 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2011-05-05 12:48 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: qemu-devel
So the benefit as I see it would be that qemu will be able to list
supported devices by vendor id etc.
lspci has a database of readable vendor/device strings,
maybe we can import that.
And we could sort by device type, that's also helpful.
header type/prog interface - not so sure.
On Fri, Apr 08, 2011 at 09:53:00PM +0900, Isaku Yamahata wrote:
> diff --git a/hw/pci.h b/hw/pci.h
> index c6a6eb6..f945798 100644
> --- a/hw/pci.h
> +++ b/hw/pci.h
> @@ -433,6 +433,15 @@ typedef struct {
> PCIConfigReadFunc *config_read;
> PCIConfigWriteFunc *config_write;
>
> + uint16_t vendor_id;
> + uint16_t device_id;
> + uint8_t revision;
This is good.
> + uint8_t prog_interface;
Not sure about this one. What is wrong
> + uint16_t class_id;
This is good.
> + uint8_t header_type;
We have a flag for bridge already, right?
Let's fill this in automatically then.
> + uint16_t subsystem_vendor_id; /* only for header type = 0 */
> + uint16_t subsystem_id; /* only for header type = 0 */
add an assert then?
> +
> /*
> * pci-to-pci bridge or normal device.
> * This doesn't mean pci host switch.
> --
> 1.7.1.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 2/7] usb-uhci: convert to PCIDEviceInfo to initialize ids
2011-04-08 12:52 [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Isaku Yamahata
2011-04-08 12:53 ` [Qemu-devel] [PATCH 1/7] pci: move ids of config space into PCIDeviceInfo Isaku Yamahata
@ 2011-04-08 12:53 ` Isaku Yamahata
2011-04-08 12:53 ` [Qemu-devel] [PATCH 3/7] eepro100: convert to PCIDeviceInfo " Isaku Yamahata
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Isaku Yamahata @ 2011-04-08 12:53 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, mst
use PCIDeviceInfo to initialize ids.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
hw/usb-uhci.c | 38 +++++++++++---------------------------
1 files changed, 11 insertions(+), 27 deletions(-)
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 346db3e..16c4f3f 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -1115,8 +1115,9 @@ static USBPortOps uhci_port_ops = {
.wakeup = uhci_wakeup,
};
-static int usb_uhci_common_initfn(UHCIState *s)
+static int usb_uhci_common_initfn(PCIDevice *dev)
{
+ UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
uint8_t *pci_conf = s->dev.config;
int i;
@@ -1148,34 +1149,11 @@ static int usb_uhci_common_initfn(UHCIState *s)
return 0;
}
-static int usb_uhci_piix3_initfn(PCIDevice *dev)
-{
- UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
- uint8_t *pci_conf = s->dev.config;
-
- pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
- pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_2);
- return usb_uhci_common_initfn(s);
-}
-
-static int usb_uhci_piix4_initfn(PCIDevice *dev)
-{
- UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
- uint8_t *pci_conf = s->dev.config;
-
- pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
- pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_2);
- return usb_uhci_common_initfn(s);
-}
-
static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
{
UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
uint8_t *pci_conf = s->dev.config;
- pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA);
- pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_UHCI);
-
/* USB misc control 1/2 */
pci_set_long(pci_conf + 0x40,0x00001000);
/* PM capability */
@@ -1183,7 +1161,7 @@ static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
/* USB legacy support */
pci_set_long(pci_conf + 0xc0,0x00002000);
- return usb_uhci_common_initfn(s);
+ return usb_uhci_common_initfn(dev);
}
static PCIDeviceInfo uhci_info[] = {
@@ -1191,17 +1169,23 @@ static PCIDeviceInfo uhci_info[] = {
.qdev.name = "piix3-usb-uhci",
.qdev.size = sizeof(UHCIState),
.qdev.vmsd = &vmstate_uhci,
- .init = usb_uhci_piix3_initfn,
+ .init = usb_uhci_common_initfn,
+ .vendor_id = PCI_VENDOR_ID_INTEL,
+ .device_id = PCI_DEVICE_ID_INTEL_82371SB_2,
},{
.qdev.name = "piix4-usb-uhci",
.qdev.size = sizeof(UHCIState),
.qdev.vmsd = &vmstate_uhci,
- .init = usb_uhci_piix4_initfn,
+ .init = usb_uhci_common_initfn,
+ .vendor_id = PCI_VENDOR_ID_INTEL,
+ .device_id = PCI_DEVICE_ID_INTEL_82371AB_2,
},{
.qdev.name = "vt82c686b-usb-uhci",
.qdev.size = sizeof(UHCIState),
.qdev.vmsd = &vmstate_uhci,
.init = usb_uhci_vt82c686b_initfn,
+ .vendor_id = PCI_VENDOR_ID_VIA,
+ .device_id = PCI_DEVICE_ID_VIA_UHCI,
},{
/* end of list */
}
--
1.7.1.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 3/7] eepro100: convert to PCIDeviceInfo to initialize ids
2011-04-08 12:52 [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Isaku Yamahata
2011-04-08 12:53 ` [Qemu-devel] [PATCH 1/7] pci: move ids of config space into PCIDeviceInfo Isaku Yamahata
2011-04-08 12:53 ` [Qemu-devel] [PATCH 2/7] usb-uhci: convert to PCIDEviceInfo to initialize ids Isaku Yamahata
@ 2011-04-08 12:53 ` Isaku Yamahata
2011-04-08 12:53 ` [Qemu-devel] [PATCH 4/7] dec_pci: " Isaku Yamahata
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Isaku Yamahata @ 2011-04-08 12:53 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, mst
use PCIDeviceInfo to initialize ids.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
hw/eepro100.c | 60 +++++++++++++++++++++++++-------------------------------
1 files changed, 27 insertions(+), 33 deletions(-)
diff --git a/hw/eepro100.c b/hw/eepro100.c
index f2505e4..8f82bfd 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -121,8 +121,6 @@
typedef struct {
PCIDeviceInfo pci;
uint32_t device;
- uint16_t device_id;
- uint8_t revision;
uint8_t stats_size;
bool has_extended_tcb_support;
bool power_management;
@@ -464,13 +462,9 @@ static void e100_pci_reset(EEPRO100State * s, E100PCIDeviceInfo *e100_device)
/* PCI Vendor ID */
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
- /* PCI Device ID */
- pci_config_set_device_id(pci_conf, e100_device->device_id);
/* PCI Status */
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
PCI_STATUS_FAST_BACK);
- /* PCI Revision ID */
- pci_config_set_revision(pci_conf, e100_device->revision);
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
/* PCI Latency Timer */
pci_set_byte(pci_conf + PCI_LATENCY_TIMER, 0x20); /* latency timer = 32 clocks */
@@ -1903,9 +1897,9 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.desc = "Intel i82550 Ethernet",
.device = i82550,
/* TODO: check device id. */
- .device_id = PCI_DEVICE_ID_INTEL_82551IT,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82551IT,
/* Revision ID: 0x0c, 0x0d, 0x0e. */
- .revision = 0x0e,
+ .pci.revision = 0x0e,
/* TODO: check size of statistical counters. */
.stats_size = 80,
/* TODO: check extended tcb support. */
@@ -1915,9 +1909,9 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.name = "i82551",
.pci.qdev.desc = "Intel i82551 Ethernet",
.device = i82551,
- .device_id = PCI_DEVICE_ID_INTEL_82551IT,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82551IT,
/* Revision ID: 0x0f, 0x10. */
- .revision = 0x0f,
+ .pci.revision = 0x0f,
/* TODO: check size of statistical counters. */
.stats_size = 80,
.has_extended_tcb_support = true,
@@ -1926,29 +1920,29 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.name = "i82557a",
.pci.qdev.desc = "Intel i82557A Ethernet",
.device = i82557A,
- .device_id = PCI_DEVICE_ID_INTEL_82557,
- .revision = 0x01,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82557,
+ .pci.revision = 0x01,
.power_management = false,
},{
.pci.qdev.name = "i82557b",
.pci.qdev.desc = "Intel i82557B Ethernet",
.device = i82557B,
- .device_id = PCI_DEVICE_ID_INTEL_82557,
- .revision = 0x02,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82557,
+ .pci.revision = 0x02,
.power_management = false,
},{
.pci.qdev.name = "i82557c",
.pci.qdev.desc = "Intel i82557C Ethernet",
.device = i82557C,
- .device_id = PCI_DEVICE_ID_INTEL_82557,
- .revision = 0x03,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82557,
+ .pci.revision = 0x03,
.power_management = false,
},{
.pci.qdev.name = "i82558a",
.pci.qdev.desc = "Intel i82558A Ethernet",
.device = i82558A,
- .device_id = PCI_DEVICE_ID_INTEL_82557,
- .revision = 0x04,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82557,
+ .pci.revision = 0x04,
.stats_size = 76,
.has_extended_tcb_support = true,
.power_management = true,
@@ -1956,8 +1950,8 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.name = "i82558b",
.pci.qdev.desc = "Intel i82558B Ethernet",
.device = i82558B,
- .device_id = PCI_DEVICE_ID_INTEL_82557,
- .revision = 0x05,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82557,
+ .pci.revision = 0x05,
.stats_size = 76,
.has_extended_tcb_support = true,
.power_management = true,
@@ -1965,8 +1959,8 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.name = "i82559a",
.pci.qdev.desc = "Intel i82559A Ethernet",
.device = i82559A,
- .device_id = PCI_DEVICE_ID_INTEL_82557,
- .revision = 0x06,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82557,
+ .pci.revision = 0x06,
.stats_size = 80,
.has_extended_tcb_support = true,
.power_management = true,
@@ -1974,8 +1968,8 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.name = "i82559b",
.pci.qdev.desc = "Intel i82559B Ethernet",
.device = i82559B,
- .device_id = PCI_DEVICE_ID_INTEL_82557,
- .revision = 0x07,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82557,
+ .pci.revision = 0x07,
.stats_size = 80,
.has_extended_tcb_support = true,
.power_management = true,
@@ -1983,12 +1977,12 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.name = "i82559c",
.pci.qdev.desc = "Intel i82559C Ethernet",
.device = i82559C,
- .device_id = PCI_DEVICE_ID_INTEL_82557,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82557,
#if 0
- .revision = 0x08,
+ .pci.revision = 0x08,
#endif
/* TODO: Windows wants revision id 0x0c. */
- .revision = 0x0c,
+ .pci.revision = 0x0c,
.stats_size = 80,
.has_extended_tcb_support = true,
.power_management = true,
@@ -1996,8 +1990,8 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.name = "i82559er",
.pci.qdev.desc = "Intel i82559ER Ethernet",
.device = i82559ER,
- .device_id = PCI_DEVICE_ID_INTEL_82551IT,
- .revision = 0x09,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82551IT,
+ .pci.revision = 0x09,
.stats_size = 80,
.has_extended_tcb_support = true,
.power_management = true,
@@ -2006,9 +2000,9 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.desc = "Intel i82562 Ethernet",
.device = i82562,
/* TODO: check device id. */
- .device_id = PCI_DEVICE_ID_INTEL_82551IT,
+ .pci.device_id = PCI_DEVICE_ID_INTEL_82551IT,
/* TODO: wrong revision id. */
- .revision = 0x0e,
+ .pci.revision = 0x0e,
.stats_size = 80,
.has_extended_tcb_support = true,
.power_management = true,
@@ -2017,8 +2011,8 @@ static E100PCIDeviceInfo e100_devices[] = {
.pci.qdev.name = "i82801",
.pci.qdev.desc = "Intel i82801 Ethernet",
.device = i82801,
- .device_id = 0x2449,
- .revision = 0x03,
+ .pci.device_id = 0x2449,
+ .pci.revision = 0x03,
.stats_size = 80,
.has_extended_tcb_support = true,
.power_management = true,
--
1.7.1.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 4/7] dec_pci: convert to PCIDeviceInfo to initialize ids
2011-04-08 12:52 [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Isaku Yamahata
` (2 preceding siblings ...)
2011-04-08 12:53 ` [Qemu-devel] [PATCH 3/7] eepro100: convert to PCIDeviceInfo " Isaku Yamahata
@ 2011-04-08 12:53 ` Isaku Yamahata
2011-04-08 12:53 ` [Qemu-devel] [PATCH 5/7] apb_pci: " Isaku Yamahata
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Isaku Yamahata @ 2011-04-08 12:53 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, mst
use PCIDeviceInfo to initialize ids.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
hw/dec_pci.c | 27 ++++++++-------------------
1 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/hw/dec_pci.c b/hw/dec_pci.c
index bf88f2a..0468aab 100644
--- a/hw/dec_pci.c
+++ b/hw/dec_pci.c
@@ -50,28 +50,17 @@ static int dec_map_irq(PCIDevice *pci_dev, int irq_num)
return irq_num;
}
-static int dec_21154_initfn(PCIDevice *dev)
-{
- int rc;
-
- rc = pci_bridge_initfn(dev);
- if (rc < 0) {
- return rc;
- }
-
- pci_config_set_vendor_id(dev->config, PCI_VENDOR_ID_DEC);
- pci_config_set_device_id(dev->config, PCI_DEVICE_ID_DEC_21154);
- return 0;
-}
-
static PCIDeviceInfo dec_21154_pci_bridge_info = {
.qdev.name = "dec-21154-p2p-bridge",
.qdev.desc = "DEC 21154 PCI-PCI bridge",
.qdev.size = sizeof(PCIBridge),
.qdev.vmsd = &vmstate_pci_device,
.qdev.reset = pci_bridge_reset,
- .init = dec_21154_initfn,
+ .init = pci_bridge_initfn,
.exit = pci_bridge_exitfn,
+ .vendor_id = PCI_VENDOR_ID_DEC,
+ .device_id = PCI_DEVICE_ID_DEC_21154,
+ .header_type = PCI_HEADER_TYPE_BRIDGE,
.config_write = pci_bridge_write_config,
.is_bridge = 1,
};
@@ -108,10 +97,6 @@ static int pci_dec_21154_init_device(SysBusDevice *dev)
static int dec_21154_pci_host_init(PCIDevice *d)
{
/* PCI2PCI bridge same values as PearPC - check this */
- pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_DEC);
- pci_config_set_device_id(d->config, PCI_DEVICE_ID_DEC_21154);
- pci_set_byte(d->config + PCI_REVISION_ID, 0x02);
- pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI);
return 0;
}
@@ -119,6 +104,10 @@ static PCIDeviceInfo dec_21154_pci_host_info = {
.qdev.name = "dec-21154",
.qdev.size = sizeof(PCIDevice),
.init = dec_21154_pci_host_init,
+ .vendor_id = PCI_VENDOR_ID_DEC,
+ .device_id = PCI_DEVICE_ID_DEC_21154,
+ .revision = 0x02,
+ .class_id = PCI_CLASS_BRIDGE_PCI,
.is_bridge = 1,
};
--
1.7.1.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 5/7] apb_pci: convert to PCIDeviceInfo to initialize ids
2011-04-08 12:52 [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Isaku Yamahata
` (3 preceding siblings ...)
2011-04-08 12:53 ` [Qemu-devel] [PATCH 4/7] dec_pci: " Isaku Yamahata
@ 2011-04-08 12:53 ` Isaku Yamahata
2011-04-08 12:53 ` [Qemu-devel] [PATCH 6/7] ide/piix: " Isaku Yamahata
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Isaku Yamahata @ 2011-04-08 12:53 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, mst
Use PCIDeviceInfo to initialize ids.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
hw/apb_pci.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/hw/apb_pci.c b/hw/apb_pci.c
index 84e9af7..974c87a 100644
--- a/hw/apb_pci.c
+++ b/hw/apb_pci.c
@@ -304,9 +304,6 @@ static int apb_pci_bridge_initfn(PCIDevice *dev)
return rc;
}
- pci_config_set_vendor_id(dev->config, PCI_VENDOR_ID_SUN);
- pci_config_set_device_id(dev->config, PCI_DEVICE_ID_SUN_SIMBA);
-
/*
* command register:
* According to PCI bridge spec, after reset
@@ -321,7 +318,6 @@ static int apb_pci_bridge_initfn(PCIDevice *dev)
pci_set_word(dev->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
PCI_STATUS_DEVSEL_MEDIUM);
- pci_set_byte(dev->config + PCI_REVISION_ID, 0x11);
return 0;
}
@@ -436,14 +432,11 @@ static int pci_pbm_init_device(SysBusDevice *dev)
static int pbm_pci_host_init(PCIDevice *d)
{
- pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_SUN);
- pci_config_set_device_id(d->config, PCI_DEVICE_ID_SUN_SABRE);
pci_set_word(d->config + PCI_COMMAND,
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
pci_set_word(d->config + PCI_STATUS,
PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
PCI_STATUS_DEVSEL_MEDIUM);
- pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
return 0;
}
@@ -451,6 +444,9 @@ static PCIDeviceInfo pbm_pci_host_info = {
.qdev.name = "pbm",
.qdev.size = sizeof(PCIDevice),
.init = pbm_pci_host_init,
+ .vendor_id = PCI_VENDOR_ID_SUN,
+ .device_id = PCI_DEVICE_ID_SUN_SABRE,
+ .class_id = PCI_CLASS_BRIDGE_HOST,
.is_bridge = 1,
};
@@ -468,6 +464,9 @@ static PCIDeviceInfo pbm_pci_bridge_info = {
.qdev.reset = pci_bridge_reset,
.init = apb_pci_bridge_initfn,
.exit = pci_bridge_exitfn,
+ .vendor_id = PCI_VENDOR_ID_SUN,
+ .device_id = PCI_DEVICE_ID_SUN_SIMBA,
+ .revision = 0x11,
.config_write = pci_bridge_write_config,
.is_bridge = 1,
};
--
1.7.1.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 6/7] ide/piix: convert to PCIDeviceInfo to initialize ids
2011-04-08 12:52 [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Isaku Yamahata
` (4 preceding siblings ...)
2011-04-08 12:53 ` [Qemu-devel] [PATCH 5/7] apb_pci: " Isaku Yamahata
@ 2011-04-08 12:53 ` Isaku Yamahata
2011-04-08 12:53 ` [Qemu-devel] [PATCH 7/7] vmware_vga.c: " Isaku Yamahata
2011-05-05 12:41 ` [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Michael S. Tsirkin
7 siblings, 0 replies; 11+ messages in thread
From: Isaku Yamahata @ 2011-04-08 12:53 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, mst
use PCIDeviceInfo to initialize ids.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
hw/ide/piix.c | 29 ++++++++---------------------
1 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index c349644..2736b48 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -131,8 +131,9 @@ static void pci_piix_init_ports(PCIIDEState *d) {
}
}
-static int pci_piix_ide_initfn(PCIIDEState *d)
+static int pci_piix_ide_initfn(PCIDevice *dev)
{
+ PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
uint8_t *pci_conf = d->dev.config;
pci_conf[PCI_CLASS_PROG] = 0x80; // legacy ATA mode
@@ -149,24 +150,6 @@ static int pci_piix_ide_initfn(PCIIDEState *d)
return 0;
}
-static int pci_piix3_ide_initfn(PCIDevice *dev)
-{
- PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
-
- pci_config_set_vendor_id(d->dev.config, PCI_VENDOR_ID_INTEL);
- pci_config_set_device_id(d->dev.config, PCI_DEVICE_ID_INTEL_82371SB_1);
- return pci_piix_ide_initfn(d);
-}
-
-static int pci_piix4_ide_initfn(PCIDevice *dev)
-{
- PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
-
- pci_config_set_vendor_id(d->dev.config, PCI_VENDOR_ID_INTEL);
- pci_config_set_device_id(d->dev.config, PCI_DEVICE_ID_INTEL_82371AB);
- return pci_piix_ide_initfn(d);
-}
-
/* hd_table must contain 4 block drivers */
/* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
@@ -195,13 +178,17 @@ static PCIDeviceInfo piix_ide_info[] = {
.qdev.size = sizeof(PCIIDEState),
.qdev.no_user = 1,
.no_hotplug = 1,
- .init = pci_piix3_ide_initfn,
+ .init = pci_piix_ide_initfn,
+ .vendor_id = PCI_VENDOR_ID_INTEL,
+ .device_id = PCI_DEVICE_ID_INTEL_82371SB_1,
},{
.qdev.name = "piix4-ide",
.qdev.size = sizeof(PCIIDEState),
.qdev.no_user = 1,
.no_hotplug = 1,
- .init = pci_piix4_ide_initfn,
+ .init = pci_piix_ide_initfn,
+ .vendor_id = PCI_VENDOR_ID_INTEL,
+ .device_id = PCI_DEVICE_ID_INTEL_82371AB,
},{
/* end of list */
}
--
1.7.1.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 7/7] vmware_vga.c: convert to PCIDeviceInfo to initialize ids
2011-04-08 12:52 [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Isaku Yamahata
` (5 preceding siblings ...)
2011-04-08 12:53 ` [Qemu-devel] [PATCH 6/7] ide/piix: " Isaku Yamahata
@ 2011-04-08 12:53 ` Isaku Yamahata
2011-05-05 12:41 ` [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Michael S. Tsirkin
7 siblings, 0 replies; 11+ messages in thread
From: Isaku Yamahata @ 2011-04-08 12:53 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, mst
use PCIDeviceInfo to initialize ids.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
hw/vmware_vga.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 4656767..354c221 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1280,15 +1280,8 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
struct pci_vmsvga_state_s *s =
DO_UPCAST(struct pci_vmsvga_state_s, card, dev);
- pci_config_set_vendor_id(s->card.config, PCI_VENDOR_ID_VMWARE);
- pci_config_set_device_id(s->card.config, SVGA_PCI_DEVICE_ID);
- pci_config_set_class(s->card.config, PCI_CLASS_DISPLAY_VGA);
s->card.config[PCI_CACHE_LINE_SIZE] = 0x08; /* Cache line size */
s->card.config[PCI_LATENCY_TIMER] = 0x40; /* Latency timer */
- s->card.config[PCI_SUBSYSTEM_VENDOR_ID] = PCI_VENDOR_ID_VMWARE & 0xff;
- s->card.config[PCI_SUBSYSTEM_VENDOR_ID + 1] = PCI_VENDOR_ID_VMWARE >> 8;
- s->card.config[PCI_SUBSYSTEM_ID] = SVGA_PCI_DEVICE_ID & 0xff;
- s->card.config[PCI_SUBSYSTEM_ID + 1] = SVGA_PCI_DEVICE_ID >> 8;
s->card.config[PCI_INTERRUPT_LINE] = 0xff; /* End */
pci_register_bar(&s->card, 0, 0x10,
@@ -1316,6 +1309,12 @@ static PCIDeviceInfo vmsvga_info = {
.no_hotplug = 1,
.init = pci_vmsvga_initfn,
.romfile = "vgabios-vmware.bin",
+
+ .vendor_id = PCI_VENDOR_ID_VMWARE,
+ .device_id = SVGA_PCI_DEVICE_ID,
+ .class_id = PCI_CLASS_DISPLAY_VGA,
+ .subsystem_vendor_id = PCI_VENDOR_ID_VMWARE,
+ .subsystem_id = SVGA_PCI_DEVICE_ID,
};
static void vmsvga_register(void)
--
1.7.1.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code
2011-04-08 12:52 [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Isaku Yamahata
` (6 preceding siblings ...)
2011-04-08 12:53 ` [Qemu-devel] [PATCH 7/7] vmware_vga.c: " Isaku Yamahata
@ 2011-05-05 12:41 ` Michael S. Tsirkin
2011-05-05 15:52 ` Isaku Yamahata
7 siblings, 1 reply; 11+ messages in thread
From: Michael S. Tsirkin @ 2011-05-05 12:41 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: qemu-devel
On Fri, Apr 08, 2011 at 09:52:59PM +0900, Isaku Yamahata wrote:
> vender id/device id... in configuration space are read-only registers
> which are commonly defined for all pci devices.
> So initialize them in common code and it simplifies the initialization a bit.
> I converted some of them.
>
> If this is the right direction, I'll convert the remaining devices.
So I agree about device vendor id and revision but not header type:
devices ideally should supply device type (bridge or not)
and we will fill it in correctly.
> Isaku Yamahata (7):
> pci: move ids of config space into PCIDeviceInfo
> usb-uhci: convert to PCIDEviceInfo to initialize ids
> eepro100: convert to PCIDeviceInfo to initialize ids
> dec_pci: convert to PCIDeviceInfo to initialize ids
> apb_pci: convert to PCIDeviceInfo to initialize ids
> ide/piix: convert to PCIDeviceInfo to initialize ids
> vmware_vga.c: convert to PCIDeviceInfo to initialize ids
>
> hw/apb_pci.c | 13 +++++------
> hw/dec_pci.c | 27 +++++++-----------------
> hw/eepro100.c | 60 ++++++++++++++++++++++++------------------------------
> hw/ide/piix.c | 29 +++++++-------------------
> hw/pci.c | 46 +++++++++++++++++++++++++++++------------
> hw/pci.h | 9 ++++++++
> hw/usb-uhci.c | 38 ++++++++++------------------------
> hw/vmware_vga.c | 13 +++++------
> 8 files changed, 107 insertions(+), 128 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code
2011-05-05 12:41 ` [Qemu-devel] [PATCH 0/7] pci: initialize ids in pci common code Michael S. Tsirkin
@ 2011-05-05 15:52 ` Isaku Yamahata
0 siblings, 0 replies; 11+ messages in thread
From: Isaku Yamahata @ 2011-05-05 15:52 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
On Thu, May 05, 2011 at 03:41:57PM +0300, Michael S. Tsirkin wrote:
> On Fri, Apr 08, 2011 at 09:52:59PM +0900, Isaku Yamahata wrote:
> > vender id/device id... in configuration space are read-only registers
> > which are commonly defined for all pci devices.
> > So initialize them in common code and it simplifies the initialization a bit.
> > I converted some of them.
> >
> > If this is the right direction, I'll convert the remaining devices.
>
> So I agree about device vendor id and revision but not header type:
> devices ideally should supply device type (bridge or not)
> and we will fill it in correctly.
Okay, with the nextspin, I'll drop program interface and header type
and add assert for subsystem id/vendor id.
--
yamahata
^ permalink raw reply [flat|nested] 11+ messages in thread