1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include "qemu/osdep.h"
28#include "hw/pci/pci.h"
29#include "hw/pci/pci_bridge.h"
30#include "hw/pci/pci_bus.h"
31#include "qemu/module.h"
32#include "hw/pci-bridge/simba.h"
33
34
35
36
37
38
39
40static void simba_pci_bridge_realize(PCIDevice *dev, Error **errp)
41{
42
43
44
45
46
47
48
49
50
51 SimbaPCIBridge *br = SIMBA_PCI_BRIDGE(dev);
52
53 pci_bridge_initfn(dev, TYPE_PCI_BUS);
54
55 pci_set_word(dev->config + PCI_COMMAND, PCI_COMMAND_MEMORY);
56 pci_set_word(dev->config + PCI_STATUS,
57 PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
58 PCI_STATUS_DEVSEL_MEDIUM);
59
60
61 pci_set_word(dev->config + PCI_IO_BASE, PCI_IO_RANGE_TYPE_32);
62 pci_set_word(dev->config + PCI_IO_LIMIT, PCI_IO_RANGE_TYPE_32);
63 pci_set_word(dev->wmask + PCI_IO_BASE_UPPER16, 0xffff);
64 pci_set_word(dev->wmask + PCI_IO_LIMIT_UPPER16, 0xffff);
65
66 pci_bridge_update_mappings(PCI_BRIDGE(br));
67}
68
69static void simba_pci_bridge_class_init(ObjectClass *klass, void *data)
70{
71 DeviceClass *dc = DEVICE_CLASS(klass);
72 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
73
74 k->realize = simba_pci_bridge_realize;
75 k->exit = pci_bridge_exitfn;
76 k->vendor_id = PCI_VENDOR_ID_SUN;
77 k->device_id = PCI_DEVICE_ID_SUN_SIMBA;
78 k->revision = 0x11;
79 k->config_write = pci_bridge_write_config;
80 k->is_bridge = true;
81 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
82 dc->reset = pci_bridge_reset;
83 dc->vmsd = &vmstate_pci_device;
84}
85
86static const TypeInfo simba_pci_bridge_info = {
87 .name = TYPE_SIMBA_PCI_BRIDGE,
88 .parent = TYPE_PCI_BRIDGE,
89 .class_init = simba_pci_bridge_class_init,
90 .instance_size = sizeof(SimbaPCIBridge),
91 .interfaces = (InterfaceInfo[]) {
92 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
93 { },
94 },
95};
96
97static void simba_register_types(void)
98{
99 type_register_static(&simba_pci_bridge_info);
100}
101
102type_init(simba_register_types)
103