root / hw / dec_pci.c @ 7cef3f4f
History | View | Annotate | Download (3.8 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 | d55380bb | Blue Swirl | #include "dec_pci.h" |
27 | e1c6bbab | Blue Swirl | #include "sysbus.h" |
28 | e1c6bbab | Blue Swirl | #include "pci.h" |
29 | e1c6bbab | Blue Swirl | #include "pci_host.h" |
30 | 783753fd | Isaku Yamahata | #include "pci_bridge.h" |
31 | 68f79994 | Isaku Yamahata | #include "pci_internals.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 | e1c6bbab | Blue Swirl | typedef struct DECState { |
44 | e1c6bbab | Blue Swirl | SysBusDevice busdev; |
45 | e1c6bbab | Blue Swirl | PCIHostState host_state; |
46 | e1c6bbab | Blue Swirl | } DECState; |
47 | e1c6bbab | Blue Swirl | |
48 | d55380bb | Blue Swirl | static int dec_map_irq(PCIDevice *pci_dev, int irq_num) |
49 | d55380bb | Blue Swirl | { |
50 | d55380bb | Blue Swirl | return irq_num;
|
51 | d55380bb | Blue Swirl | } |
52 | d55380bb | Blue Swirl | |
53 | 68f79994 | Isaku Yamahata | static PCIDeviceInfo dec_21154_pci_bridge_info = {
|
54 | 68f79994 | Isaku Yamahata | .qdev.name = "dec-21154-p2p-bridge",
|
55 | 68f79994 | Isaku Yamahata | .qdev.desc = "DEC 21154 PCI-PCI bridge",
|
56 | 68f79994 | Isaku Yamahata | .qdev.size = sizeof(PCIBridge),
|
57 | 68f79994 | Isaku Yamahata | .qdev.vmsd = &vmstate_pci_device, |
58 | 68f79994 | Isaku Yamahata | .qdev.reset = pci_bridge_reset, |
59 | e7b9bc3e | Isaku Yamahata | .init = pci_bridge_initfn, |
60 | 68f79994 | Isaku Yamahata | .exit = pci_bridge_exitfn, |
61 | e7b9bc3e | Isaku Yamahata | .vendor_id = PCI_VENDOR_ID_DEC, |
62 | e7b9bc3e | Isaku Yamahata | .device_id = PCI_DEVICE_ID_DEC_21154, |
63 | 68f79994 | Isaku Yamahata | .config_write = pci_bridge_write_config, |
64 | 68f79994 | Isaku Yamahata | .is_bridge = 1,
|
65 | 68f79994 | Isaku Yamahata | }; |
66 | 68f79994 | Isaku Yamahata | |
67 | 68f79994 | Isaku Yamahata | PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn)
|
68 | 68f79994 | Isaku Yamahata | { |
69 | 68f79994 | Isaku Yamahata | PCIDevice *dev; |
70 | 68f79994 | Isaku Yamahata | PCIBridge *br; |
71 | d55380bb | Blue Swirl | |
72 | 68f79994 | Isaku Yamahata | dev = pci_create_multifunction(parent_bus, devfn, false,
|
73 | 68f79994 | Isaku Yamahata | "dec-21154-p2p-bridge");
|
74 | 68f79994 | Isaku Yamahata | br = DO_UPCAST(PCIBridge, dev, dev); |
75 | 68f79994 | Isaku Yamahata | pci_bridge_map_irq(br, "DEC 21154 PCI-PCI bridge", dec_map_irq);
|
76 | 68f79994 | Isaku Yamahata | qdev_init_nofail(&dev->qdev); |
77 | 68f79994 | Isaku Yamahata | return pci_bridge_get_sec_bus(br);
|
78 | d55380bb | Blue Swirl | } |
79 | d55380bb | Blue Swirl | |
80 | e1c6bbab | Blue Swirl | static int pci_dec_21154_init_device(SysBusDevice *dev) |
81 | e1c6bbab | Blue Swirl | { |
82 | e1c6bbab | Blue Swirl | DECState *s; |
83 | e1c6bbab | Blue Swirl | int pci_mem_config, pci_mem_data;
|
84 | e1c6bbab | Blue Swirl | |
85 | e1c6bbab | Blue Swirl | s = FROM_SYSBUS(DECState, dev); |
86 | e1c6bbab | Blue Swirl | |
87 | 6ebf5905 | Alexander Graf | pci_mem_config = pci_host_conf_register_mmio(&s->host_state, |
88 | 6ebf5905 | Alexander Graf | DEVICE_LITTLE_ENDIAN); |
89 | 6ebf5905 | Alexander Graf | pci_mem_data = pci_host_data_register_mmio(&s->host_state, |
90 | 6ebf5905 | Alexander Graf | DEVICE_LITTLE_ENDIAN); |
91 | e1c6bbab | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_config);
|
92 | e1c6bbab | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_data);
|
93 | e1c6bbab | Blue Swirl | return 0; |
94 | e1c6bbab | Blue Swirl | } |
95 | e1c6bbab | Blue Swirl | |
96 | e1c6bbab | Blue Swirl | static int dec_21154_pci_host_init(PCIDevice *d) |
97 | e1c6bbab | Blue Swirl | { |
98 | e1c6bbab | Blue Swirl | /* PCI2PCI bridge same values as PearPC - check this */
|
99 | e1c6bbab | Blue Swirl | return 0; |
100 | e1c6bbab | Blue Swirl | } |
101 | e1c6bbab | Blue Swirl | |
102 | e1c6bbab | Blue Swirl | static PCIDeviceInfo dec_21154_pci_host_info = {
|
103 | e1c6bbab | Blue Swirl | .qdev.name = "dec-21154",
|
104 | e1c6bbab | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
105 | e1c6bbab | Blue Swirl | .init = dec_21154_pci_host_init, |
106 | e7b9bc3e | Isaku Yamahata | .vendor_id = PCI_VENDOR_ID_DEC, |
107 | e7b9bc3e | Isaku Yamahata | .device_id = PCI_DEVICE_ID_DEC_21154, |
108 | e7b9bc3e | Isaku Yamahata | .revision = 0x02,
|
109 | e7b9bc3e | Isaku Yamahata | .class_id = PCI_CLASS_BRIDGE_PCI, |
110 | e327e323 | Isaku Yamahata | .is_bridge = 1,
|
111 | e1c6bbab | Blue Swirl | }; |
112 | e1c6bbab | Blue Swirl | |
113 | e1c6bbab | Blue Swirl | static void dec_register_devices(void) |
114 | e1c6bbab | Blue Swirl | { |
115 | e1c6bbab | Blue Swirl | sysbus_register_dev("dec-21154", sizeof(DECState), |
116 | e1c6bbab | Blue Swirl | pci_dec_21154_init_device); |
117 | e1c6bbab | Blue Swirl | pci_qdev_register(&dec_21154_pci_host_info); |
118 | 68f79994 | Isaku Yamahata | pci_qdev_register(&dec_21154_pci_bridge_info); |
119 | e1c6bbab | Blue Swirl | } |
120 | e1c6bbab | Blue Swirl | |
121 | e1c6bbab | Blue Swirl | device_init(dec_register_devices) |