diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2010-07-13 13:01:42 +0900 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2010-09-07 20:01:27 +0300 |
commit | 68f799944b72387c0ef9535612a212a5ea492059 (patch) | |
tree | 06be7d56583e07a9b7a3cc3db0d0f54b4332a142 /hw/dec_pci.c | |
parent | 51a92333f8eb6d0fe685544f20ad56fc9af702f5 (diff) |
pci_bridge: introduce pci bridge library.
introduce pci bridge library.
convert apb bridge and dec p2p bridge to use new pci bridge library.
save/restore is supported as a side effect.
This is also preparation for pci express root/upstream/downstream port.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/dec_pci.c')
-rw-r--r-- | hw/dec_pci.c | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/hw/dec_pci.c b/hw/dec_pci.c index f7a9cdcfc3..aa07ab7d84 100644 --- a/hw/dec_pci.c +++ b/hw/dec_pci.c @@ -28,6 +28,7 @@ #include "pci.h" #include "pci_host.h" #include "pci_bridge.h" +#include "pci_internals.h" /* debug DEC */ //#define DEBUG_DEC @@ -49,18 +50,43 @@ static int dec_map_irq(PCIDevice *pci_dev, int irq_num) return irq_num; } -PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn) +static int dec_21154_initfn(PCIDevice *dev) { - DeviceState *dev; - PCIBus *ret; + 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; +} - dev = qdev_create(NULL, "dec-21154"); - qdev_init_nofail(dev); - ret = pci_bridge_init(parent_bus, devfn, false, - PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21154, - dec_map_irq, "DEC 21154 PCI-PCI bridge"); +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, + .exit = pci_bridge_exitfn, + .config_write = pci_bridge_write_config, + .is_bridge = 1, +}; + +PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn) +{ + PCIDevice *dev; + PCIBridge *br; - return ret; + dev = pci_create_multifunction(parent_bus, devfn, false, + "dec-21154-p2p-bridge"); + br = DO_UPCAST(PCIBridge, dev, dev); + pci_bridge_map_irq(br, "DEC 21154 PCI-PCI bridge", dec_map_irq); + qdev_init_nofail(&dev->qdev); + return pci_bridge_get_sec_bus(br); } static int pci_dec_21154_init_device(SysBusDevice *dev) @@ -99,6 +125,7 @@ static void dec_register_devices(void) sysbus_register_dev("dec-21154", sizeof(DECState), pci_dec_21154_init_device); pci_qdev_register(&dec_21154_pci_host_info); + pci_qdev_register(&dec_21154_pci_bridge_info); } device_init(dec_register_devices) |