root / hw / dec_pci.c @ a0f42610
History | View | Annotate | Download (3.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 | 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 | |
84 | e1c6bbab | Blue Swirl | s = FROM_SYSBUS(DECState, dev); |
85 | e1c6bbab | Blue Swirl | |
86 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
87 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-idx", 0x1000); |
88 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops, |
89 | d0ed8076 | Avi Kivity | &s->host_state, "pci-data-idx", 0x1000); |
90 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->host_state.conf_mem); |
91 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->host_state.data_mem); |
92 | e1c6bbab | Blue Swirl | return 0; |
93 | e1c6bbab | Blue Swirl | } |
94 | e1c6bbab | Blue Swirl | |
95 | e1c6bbab | Blue Swirl | static int dec_21154_pci_host_init(PCIDevice *d) |
96 | e1c6bbab | Blue Swirl | { |
97 | e1c6bbab | Blue Swirl | /* PCI2PCI bridge same values as PearPC - check this */
|
98 | e1c6bbab | Blue Swirl | return 0; |
99 | e1c6bbab | Blue Swirl | } |
100 | e1c6bbab | Blue Swirl | |
101 | e1c6bbab | Blue Swirl | static PCIDeviceInfo dec_21154_pci_host_info = {
|
102 | e1c6bbab | Blue Swirl | .qdev.name = "dec-21154",
|
103 | e1c6bbab | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
104 | e1c6bbab | Blue Swirl | .init = dec_21154_pci_host_init, |
105 | e7b9bc3e | Isaku Yamahata | .vendor_id = PCI_VENDOR_ID_DEC, |
106 | e7b9bc3e | Isaku Yamahata | .device_id = PCI_DEVICE_ID_DEC_21154, |
107 | e7b9bc3e | Isaku Yamahata | .revision = 0x02,
|
108 | e7b9bc3e | Isaku Yamahata | .class_id = PCI_CLASS_BRIDGE_PCI, |
109 | e327e323 | Isaku Yamahata | .is_bridge = 1,
|
110 | e1c6bbab | Blue Swirl | }; |
111 | e1c6bbab | Blue Swirl | |
112 | e1c6bbab | Blue Swirl | static void dec_register_devices(void) |
113 | e1c6bbab | Blue Swirl | { |
114 | e1c6bbab | Blue Swirl | sysbus_register_dev("dec-21154", sizeof(DECState), |
115 | e1c6bbab | Blue Swirl | pci_dec_21154_init_device); |
116 | e1c6bbab | Blue Swirl | pci_qdev_register(&dec_21154_pci_host_info); |
117 | 68f79994 | Isaku Yamahata | pci_qdev_register(&dec_21154_pci_bridge_info); |
118 | e1c6bbab | Blue Swirl | } |
119 | e1c6bbab | Blue Swirl | |
120 | e1c6bbab | Blue Swirl | device_init(dec_register_devices) |