23 |
23 |
* THE SOFTWARE.
|
24 |
24 |
*/
|
25 |
25 |
|
26 |
|
#include "sysbus.h"
|
|
26 |
#include "pci_host.h"
|
27 |
27 |
#include "ppc_mac.h"
|
28 |
28 |
#include "pci.h"
|
29 |
|
#include "pci_host.h"
|
30 |
29 |
|
31 |
30 |
/* debug Grackle */
|
32 |
31 |
//#define DEBUG_GRACKLE
|
... | ... | |
38 |
37 |
#define GRACKLE_DPRINTF(fmt, ...)
|
39 |
38 |
#endif
|
40 |
39 |
|
|
40 |
#define GRACKLE_PCI_HOST_BRIDGE(obj) \
|
|
41 |
OBJECT_CHECK(GrackleState, (obj), TYPE_GRACKLE_PCI_HOST_BRIDGE)
|
|
42 |
|
41 |
43 |
typedef struct GrackleState {
|
42 |
|
SysBusDevice busdev;
|
43 |
44 |
PCIHostState host_state;
|
|
45 |
|
44 |
46 |
MemoryRegion pci_mmio;
|
45 |
47 |
MemoryRegion pci_hole;
|
46 |
48 |
} GrackleState;
|
... | ... | |
59 |
61 |
qemu_set_irq(pic[irq_num + 0x15], level);
|
60 |
62 |
}
|
61 |
63 |
|
62 |
|
static void pci_grackle_reset(void *opaque)
|
63 |
|
{
|
64 |
|
}
|
65 |
|
|
66 |
64 |
PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic,
|
67 |
65 |
MemoryRegion *address_space_mem,
|
68 |
66 |
MemoryRegion *address_space_io)
|
69 |
67 |
{
|
70 |
68 |
DeviceState *dev;
|
71 |
69 |
SysBusDevice *s;
|
|
70 |
PCIHostState *phb;
|
72 |
71 |
GrackleState *d;
|
73 |
72 |
|
74 |
|
dev = qdev_create(NULL, "grackle-pcihost");
|
|
73 |
dev = qdev_create(NULL, TYPE_GRACKLE_PCI_HOST_BRIDGE);
|
75 |
74 |
qdev_init_nofail(dev);
|
76 |
|
s = sysbus_from_qdev(dev);
|
77 |
|
d = FROM_SYSBUS(GrackleState, s);
|
|
75 |
s = SYS_BUS_DEVICE(dev);
|
|
76 |
phb = FROM_SYSBUS(PCIHostState, s);
|
|
77 |
d = GRACKLE_PCI_HOST_BRIDGE(dev);
|
78 |
78 |
|
79 |
79 |
memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL);
|
80 |
80 |
memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
|
... | ... | |
82 |
82 |
memory_region_add_subregion(address_space_mem, 0x80000000ULL,
|
83 |
83 |
&d->pci_hole);
|
84 |
84 |
|
85 |
|
d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
|
86 |
|
pci_grackle_set_irq,
|
87 |
|
pci_grackle_map_irq,
|
88 |
|
pic,
|
89 |
|
&d->pci_mmio,
|
90 |
|
address_space_io,
|
91 |
|
0, 4);
|
|
85 |
phb->bus = pci_register_bus(dev, "pci",
|
|
86 |
pci_grackle_set_irq,
|
|
87 |
pci_grackle_map_irq,
|
|
88 |
pic,
|
|
89 |
&d->pci_mmio,
|
|
90 |
address_space_io,
|
|
91 |
0, 4);
|
92 |
92 |
|
93 |
|
pci_create_simple(d->host_state.bus, 0, "grackle");
|
|
93 |
pci_create_simple(phb->bus, 0, "grackle");
|
94 |
94 |
|
95 |
95 |
sysbus_mmio_map(s, 0, base);
|
96 |
96 |
sysbus_mmio_map(s, 1, base + 0x00200000);
|
97 |
97 |
|
98 |
|
return d->host_state.bus;
|
|
98 |
return phb->bus;
|
99 |
99 |
}
|
100 |
100 |
|
101 |
101 |
static int pci_grackle_init_device(SysBusDevice *dev)
|
102 |
102 |
{
|
103 |
|
GrackleState *s;
|
|
103 |
PCIHostState *phb;
|
104 |
104 |
|
105 |
|
s = FROM_SYSBUS(GrackleState, dev);
|
|
105 |
phb = FROM_SYSBUS(PCIHostState, dev);
|
106 |
106 |
|
107 |
|
memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops,
|
108 |
|
&s->host_state, "pci-conf-idx", 0x1000);
|
109 |
|
memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops,
|
110 |
|
&s->host_state, "pci-data-idx", 0x1000);
|
111 |
|
sysbus_init_mmio(dev, &s->host_state.conf_mem);
|
112 |
|
sysbus_init_mmio(dev, &s->host_state.data_mem);
|
|
107 |
memory_region_init_io(&phb->conf_mem, &pci_host_conf_le_ops,
|
|
108 |
dev, "pci-conf-idx", 0x1000);
|
|
109 |
memory_region_init_io(&phb->data_mem, &pci_host_data_le_ops,
|
|
110 |
dev, "pci-data-idx", 0x1000);
|
|
111 |
sysbus_init_mmio(dev, &phb->conf_mem);
|
|
112 |
sysbus_init_mmio(dev, &phb->data_mem);
|
113 |
113 |
|
114 |
|
qemu_register_reset(pci_grackle_reset, &s->host_state);
|
115 |
114 |
return 0;
|
116 |
115 |
}
|
117 |
116 |
|
... | ... | |
151 |
150 |
}
|
152 |
151 |
|
153 |
152 |
static const TypeInfo grackle_pci_host_info = {
|
154 |
|
.name = "grackle-pcihost",
|
|
153 |
.name = TYPE_GRACKLE_PCI_HOST_BRIDGE,
|
155 |
154 |
.parent = TYPE_SYS_BUS_DEVICE,
|
156 |
155 |
.instance_size = sizeof(GrackleState),
|
157 |
156 |
.class_init = pci_grackle_class_init,
|