root / hw / pci-bridge / dec.c @ 6327c221
History | View | Annotate | Download (4.7 kB)
1 | e1c6bbab | Blue Swirl | /*
|
---|---|---|---|
2 | e1c6bbab | Blue Swirl | * QEMU DEC 21154 PCI bridge
|
3 | e1c6bbab | Blue Swirl | *
|
4 | e1c6bbab | Blue Swirl | * Copyright (c) 2006-2007 Fabrice Bellard
|
5 | e1c6bbab | Blue Swirl | * Copyright (c) 2007 Jocelyn Mayer
|
6 | e1c6bbab | Blue Swirl | *
|
7 | e1c6bbab | Blue Swirl | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 | e1c6bbab | Blue Swirl | * of this software and associated documentation files (the "Software"), to deal
|
9 | e1c6bbab | Blue Swirl | * in the Software without restriction, including without limitation the rights
|
10 | e1c6bbab | Blue Swirl | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 | e1c6bbab | Blue Swirl | * copies of the Software, and to permit persons to whom the Software is
|
12 | e1c6bbab | Blue Swirl | * furnished to do so, subject to the following conditions:
|
13 | e1c6bbab | Blue Swirl | *
|
14 | e1c6bbab | Blue Swirl | * The above copyright notice and this permission notice shall be included in
|
15 | e1c6bbab | Blue Swirl | * all copies or substantial portions of the Software.
|
16 | e1c6bbab | Blue Swirl | *
|
17 | e1c6bbab | Blue Swirl | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 | e1c6bbab | Blue Swirl | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 | e1c6bbab | Blue Swirl | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
20 | e1c6bbab | Blue Swirl | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 | e1c6bbab | Blue Swirl | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 | e1c6bbab | Blue Swirl | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23 | e1c6bbab | Blue Swirl | * THE SOFTWARE.
|
24 | e1c6bbab | Blue Swirl | */
|
25 | e1c6bbab | Blue Swirl | |
26 | 47b43a1f | Paolo Bonzini | #include "dec.h" |
27 | 83c9f4ca | Paolo Bonzini | #include "hw/sysbus.h" |
28 | 83c9f4ca | Paolo Bonzini | #include "hw/pci/pci.h" |
29 | 83c9f4ca | Paolo Bonzini | #include "hw/pci/pci_host.h" |
30 | 83c9f4ca | Paolo Bonzini | #include "hw/pci/pci_bridge.h" |
31 | 83c9f4ca | Paolo Bonzini | #include "hw/pci/pci_bus.h" |
32 | e1c6bbab | Blue Swirl | |
33 | e1c6bbab | Blue Swirl | /* debug DEC */
|
34 | e1c6bbab | Blue Swirl | //#define DEBUG_DEC
|
35 | e1c6bbab | Blue Swirl | |
36 | e1c6bbab | Blue Swirl | #ifdef DEBUG_DEC
|
37 | e1c6bbab | Blue Swirl | #define DEC_DPRINTF(fmt, ...) \
|
38 | e1c6bbab | Blue Swirl | do { printf("DEC: " fmt , ## __VA_ARGS__); } while (0) |
39 | e1c6bbab | Blue Swirl | #else
|
40 | e1c6bbab | Blue Swirl | #define DEC_DPRINTF(fmt, ...)
|
41 | e1c6bbab | Blue Swirl | #endif
|
42 | e1c6bbab | Blue Swirl | |
43 | ab615367 | Andreas Färber | #define DEC_21154(obj) OBJECT_CHECK(DECState, (obj), TYPE_DEC_21154)
|
44 | ab615367 | Andreas Färber | |
45 | e1c6bbab | Blue Swirl | typedef struct DECState { |
46 | 67c332fd | Andreas Färber | PCIHostState parent_obj; |
47 | e1c6bbab | Blue Swirl | } DECState; |
48 | e1c6bbab | Blue Swirl | |
49 | d55380bb | Blue Swirl | static int dec_map_irq(PCIDevice *pci_dev, int irq_num) |
50 | d55380bb | Blue Swirl | { |
51 | d55380bb | Blue Swirl | return irq_num;
|
52 | d55380bb | Blue Swirl | } |
53 | d55380bb | Blue Swirl | |
54 | 60a0e443 | Alex Williamson | static int dec_pci_bridge_initfn(PCIDevice *pci_dev) |
55 | 60a0e443 | Alex Williamson | { |
56 | 60a0e443 | Alex Williamson | return pci_bridge_initfn(pci_dev, TYPE_PCI_BUS);
|
57 | 60a0e443 | Alex Williamson | } |
58 | 60a0e443 | Alex Williamson | |
59 | 40021f08 | Anthony Liguori | static void dec_21154_pci_bridge_class_init(ObjectClass *klass, void *data) |
60 | 40021f08 | Anthony Liguori | { |
61 | 39bffca2 | Anthony Liguori | DeviceClass *dc = DEVICE_CLASS(klass); |
62 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
63 | 40021f08 | Anthony Liguori | |
64 | 60a0e443 | Alex Williamson | k->init = dec_pci_bridge_initfn; |
65 | 40021f08 | Anthony Liguori | k->exit = pci_bridge_exitfn; |
66 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_DEC; |
67 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_DEC_21154; |
68 | 40021f08 | Anthony Liguori | k->config_write = pci_bridge_write_config; |
69 | 40021f08 | Anthony Liguori | k->is_bridge = 1;
|
70 | 39bffca2 | Anthony Liguori | dc->desc = "DEC 21154 PCI-PCI bridge";
|
71 | 39bffca2 | Anthony Liguori | dc->reset = pci_bridge_reset; |
72 | 39bffca2 | Anthony Liguori | dc->vmsd = &vmstate_pci_device; |
73 | 40021f08 | Anthony Liguori | } |
74 | 40021f08 | Anthony Liguori | |
75 | 4240abff | Andreas Färber | static const TypeInfo dec_21154_pci_bridge_info = { |
76 | 39bffca2 | Anthony Liguori | .name = "dec-21154-p2p-bridge",
|
77 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
78 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIBridge),
|
79 | 39bffca2 | Anthony Liguori | .class_init = dec_21154_pci_bridge_class_init, |
80 | 68f79994 | Isaku Yamahata | }; |
81 | 68f79994 | Isaku Yamahata | |
82 | 68f79994 | Isaku Yamahata | PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn)
|
83 | 68f79994 | Isaku Yamahata | { |
84 | 68f79994 | Isaku Yamahata | PCIDevice *dev; |
85 | 68f79994 | Isaku Yamahata | PCIBridge *br; |
86 | d55380bb | Blue Swirl | |
87 | 68f79994 | Isaku Yamahata | dev = pci_create_multifunction(parent_bus, devfn, false,
|
88 | 68f79994 | Isaku Yamahata | "dec-21154-p2p-bridge");
|
89 | 68f79994 | Isaku Yamahata | br = DO_UPCAST(PCIBridge, dev, dev); |
90 | 68f79994 | Isaku Yamahata | pci_bridge_map_irq(br, "DEC 21154 PCI-PCI bridge", dec_map_irq);
|
91 | 68f79994 | Isaku Yamahata | qdev_init_nofail(&dev->qdev); |
92 | 68f79994 | Isaku Yamahata | return pci_bridge_get_sec_bus(br);
|
93 | d55380bb | Blue Swirl | } |
94 | d55380bb | Blue Swirl | |
95 | 999e12bb | Anthony Liguori | static int pci_dec_21154_device_init(SysBusDevice *dev) |
96 | e1c6bbab | Blue Swirl | { |
97 | ab615367 | Andreas Färber | PCIHostState *phb; |
98 | e1c6bbab | Blue Swirl | |
99 | 8558d942 | Andreas Färber | phb = PCI_HOST_BRIDGE(dev); |
100 | e1c6bbab | Blue Swirl | |
101 | ab615367 | Andreas Färber | memory_region_init_io(&phb->conf_mem, &pci_host_conf_le_ops, |
102 | ab615367 | Andreas Färber | dev, "pci-conf-idx", 0x1000); |
103 | ab615367 | Andreas Färber | memory_region_init_io(&phb->data_mem, &pci_host_data_le_ops, |
104 | ab615367 | Andreas Färber | dev, "pci-data-idx", 0x1000); |
105 | ab615367 | Andreas Färber | sysbus_init_mmio(dev, &phb->conf_mem); |
106 | ab615367 | Andreas Färber | sysbus_init_mmio(dev, &phb->data_mem); |
107 | e1c6bbab | Blue Swirl | return 0; |
108 | e1c6bbab | Blue Swirl | } |
109 | e1c6bbab | Blue Swirl | |
110 | e1c6bbab | Blue Swirl | static int dec_21154_pci_host_init(PCIDevice *d) |
111 | e1c6bbab | Blue Swirl | { |
112 | e1c6bbab | Blue Swirl | /* PCI2PCI bridge same values as PearPC - check this */
|
113 | e1c6bbab | Blue Swirl | return 0; |
114 | e1c6bbab | Blue Swirl | } |
115 | e1c6bbab | Blue Swirl | |
116 | 40021f08 | Anthony Liguori | static void dec_21154_pci_host_class_init(ObjectClass *klass, void *data) |
117 | 40021f08 | Anthony Liguori | { |
118 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
119 | 40021f08 | Anthony Liguori | |
120 | 40021f08 | Anthony Liguori | k->init = dec_21154_pci_host_init; |
121 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_DEC; |
122 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_DEC_21154; |
123 | 40021f08 | Anthony Liguori | k->revision = 0x02;
|
124 | 40021f08 | Anthony Liguori | k->class_id = PCI_CLASS_BRIDGE_PCI; |
125 | 40021f08 | Anthony Liguori | k->is_bridge = 1;
|
126 | 40021f08 | Anthony Liguori | } |
127 | 40021f08 | Anthony Liguori | |
128 | 4240abff | Andreas Färber | static const TypeInfo dec_21154_pci_host_info = { |
129 | 39bffca2 | Anthony Liguori | .name = "dec-21154",
|
130 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
131 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIDevice),
|
132 | 39bffca2 | Anthony Liguori | .class_init = dec_21154_pci_host_class_init, |
133 | e1c6bbab | Blue Swirl | }; |
134 | e1c6bbab | Blue Swirl | |
135 | 999e12bb | Anthony Liguori | static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data) |
136 | e1c6bbab | Blue Swirl | { |
137 | 999e12bb | Anthony Liguori | SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); |
138 | 999e12bb | Anthony Liguori | |
139 | 999e12bb | Anthony Liguori | sdc->init = pci_dec_21154_device_init; |
140 | 999e12bb | Anthony Liguori | } |
141 | 999e12bb | Anthony Liguori | |
142 | 4240abff | Andreas Färber | static const TypeInfo pci_dec_21154_device_info = { |
143 | ab615367 | Andreas Färber | .name = TYPE_DEC_21154, |
144 | 8558d942 | Andreas Färber | .parent = TYPE_PCI_HOST_BRIDGE, |
145 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(DECState),
|
146 | 39bffca2 | Anthony Liguori | .class_init = pci_dec_21154_device_class_init, |
147 | 999e12bb | Anthony Liguori | }; |
148 | 40021f08 | Anthony Liguori | |
149 | 83f7d43a | Andreas Färber | static void dec_register_types(void) |
150 | 999e12bb | Anthony Liguori | { |
151 | 39bffca2 | Anthony Liguori | type_register_static(&pci_dec_21154_device_info); |
152 | 39bffca2 | Anthony Liguori | type_register_static(&dec_21154_pci_host_info); |
153 | 39bffca2 | Anthony Liguori | type_register_static(&dec_21154_pci_bridge_info); |
154 | e1c6bbab | Blue Swirl | } |
155 | e1c6bbab | Blue Swirl | |
156 | 83f7d43a | Andreas Färber | type_init(dec_register_types) |