root / hw / ppce500_pci.c @ 1673ad51
History | View | Annotate | Download (9.5 kB)
1 | 74c62ba8 | aurel32 | /*
|
---|---|---|---|
2 | 74c62ba8 | aurel32 | * QEMU PowerPC E500 embedded processors pci controller emulation
|
3 | 74c62ba8 | aurel32 | *
|
4 | 74c62ba8 | aurel32 | * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
|
5 | 74c62ba8 | aurel32 | *
|
6 | 74c62ba8 | aurel32 | * Author: Yu Liu, <yu.liu@freescale.com>
|
7 | 74c62ba8 | aurel32 | *
|
8 | 74c62ba8 | aurel32 | * This file is derived from hw/ppc4xx_pci.c,
|
9 | 74c62ba8 | aurel32 | * the copyright for that material belongs to the original owners.
|
10 | 74c62ba8 | aurel32 | *
|
11 | 74c62ba8 | aurel32 | * This is free software; you can redistribute it and/or modify
|
12 | 74c62ba8 | aurel32 | * it under the terms of the GNU General Public License as published by
|
13 | 74c62ba8 | aurel32 | * the Free Software Foundation; either version 2 of the License, or
|
14 | 74c62ba8 | aurel32 | * (at your option) any later version.
|
15 | 74c62ba8 | aurel32 | */
|
16 | 74c62ba8 | aurel32 | |
17 | 74c62ba8 | aurel32 | #include "hw.h" |
18 | 74c62ba8 | aurel32 | #include "ppc.h" |
19 | 74c62ba8 | aurel32 | #include "ppce500.h" |
20 | 74c62ba8 | aurel32 | #include "pci.h" |
21 | 74c62ba8 | aurel32 | #include "pci_host.h" |
22 | 74c62ba8 | aurel32 | #include "bswap.h" |
23 | 74c62ba8 | aurel32 | #include "qemu-log.h" |
24 | 74c62ba8 | aurel32 | |
25 | 74c62ba8 | aurel32 | #ifdef DEBUG_PCI
|
26 | 001faf32 | Blue Swirl | #define pci_debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__) |
27 | 74c62ba8 | aurel32 | #else
|
28 | 001faf32 | Blue Swirl | #define pci_debug(fmt, ...)
|
29 | 74c62ba8 | aurel32 | #endif
|
30 | 74c62ba8 | aurel32 | |
31 | 74c62ba8 | aurel32 | #define PCIE500_CFGADDR 0x0 |
32 | 74c62ba8 | aurel32 | #define PCIE500_CFGDATA 0x4 |
33 | 74c62ba8 | aurel32 | #define PCIE500_REG_BASE 0xC00 |
34 | 74c62ba8 | aurel32 | #define PCIE500_REG_SIZE (0x1000 - PCIE500_REG_BASE) |
35 | 74c62ba8 | aurel32 | |
36 | 74c62ba8 | aurel32 | #define PPCE500_PCI_CONFIG_ADDR 0x0 |
37 | 74c62ba8 | aurel32 | #define PPCE500_PCI_CONFIG_DATA 0x4 |
38 | 74c62ba8 | aurel32 | #define PPCE500_PCI_INTACK 0x8 |
39 | 74c62ba8 | aurel32 | |
40 | 74c62ba8 | aurel32 | #define PPCE500_PCI_OW1 (0xC20 - PCIE500_REG_BASE) |
41 | 74c62ba8 | aurel32 | #define PPCE500_PCI_OW2 (0xC40 - PCIE500_REG_BASE) |
42 | 74c62ba8 | aurel32 | #define PPCE500_PCI_OW3 (0xC60 - PCIE500_REG_BASE) |
43 | 74c62ba8 | aurel32 | #define PPCE500_PCI_OW4 (0xC80 - PCIE500_REG_BASE) |
44 | 74c62ba8 | aurel32 | #define PPCE500_PCI_IW3 (0xDA0 - PCIE500_REG_BASE) |
45 | 74c62ba8 | aurel32 | #define PPCE500_PCI_IW2 (0xDC0 - PCIE500_REG_BASE) |
46 | 74c62ba8 | aurel32 | #define PPCE500_PCI_IW1 (0xDE0 - PCIE500_REG_BASE) |
47 | 74c62ba8 | aurel32 | |
48 | 74c62ba8 | aurel32 | #define PPCE500_PCI_GASKET_TIMR (0xE20 - PCIE500_REG_BASE) |
49 | 74c62ba8 | aurel32 | |
50 | 74c62ba8 | aurel32 | #define PCI_POTAR 0x0 |
51 | 74c62ba8 | aurel32 | #define PCI_POTEAR 0x4 |
52 | 74c62ba8 | aurel32 | #define PCI_POWBAR 0x8 |
53 | 74c62ba8 | aurel32 | #define PCI_POWAR 0x10 |
54 | 74c62ba8 | aurel32 | |
55 | 74c62ba8 | aurel32 | #define PCI_PITAR 0x0 |
56 | 74c62ba8 | aurel32 | #define PCI_PIWBAR 0x8 |
57 | 74c62ba8 | aurel32 | #define PCI_PIWBEAR 0xC |
58 | 74c62ba8 | aurel32 | #define PCI_PIWAR 0x10 |
59 | 74c62ba8 | aurel32 | |
60 | 74c62ba8 | aurel32 | #define PPCE500_PCI_NR_POBS 5 |
61 | 74c62ba8 | aurel32 | #define PPCE500_PCI_NR_PIBS 3 |
62 | 74c62ba8 | aurel32 | |
63 | 74c62ba8 | aurel32 | struct pci_outbound {
|
64 | 74c62ba8 | aurel32 | uint32_t potar; |
65 | 74c62ba8 | aurel32 | uint32_t potear; |
66 | 74c62ba8 | aurel32 | uint32_t powbar; |
67 | 74c62ba8 | aurel32 | uint32_t powar; |
68 | 74c62ba8 | aurel32 | }; |
69 | 74c62ba8 | aurel32 | |
70 | 74c62ba8 | aurel32 | struct pci_inbound {
|
71 | 74c62ba8 | aurel32 | uint32_t pitar; |
72 | 74c62ba8 | aurel32 | uint32_t piwbar; |
73 | 74c62ba8 | aurel32 | uint32_t piwbear; |
74 | 74c62ba8 | aurel32 | uint32_t piwar; |
75 | 74c62ba8 | aurel32 | }; |
76 | 74c62ba8 | aurel32 | |
77 | 74c62ba8 | aurel32 | struct PPCE500PCIState {
|
78 | 74c62ba8 | aurel32 | struct pci_outbound pob[PPCE500_PCI_NR_POBS];
|
79 | 74c62ba8 | aurel32 | struct pci_inbound pib[PPCE500_PCI_NR_PIBS];
|
80 | 74c62ba8 | aurel32 | uint32_t gasket_time; |
81 | 74c62ba8 | aurel32 | PCIHostState pci_state; |
82 | 74c62ba8 | aurel32 | PCIDevice *pci_dev; |
83 | 74c62ba8 | aurel32 | }; |
84 | 74c62ba8 | aurel32 | |
85 | 74c62ba8 | aurel32 | typedef struct PPCE500PCIState PPCE500PCIState; |
86 | 74c62ba8 | aurel32 | |
87 | c227f099 | Anthony Liguori | static uint32_t pci_reg_read4(void *opaque, target_phys_addr_t addr) |
88 | 74c62ba8 | aurel32 | { |
89 | 74c62ba8 | aurel32 | PPCE500PCIState *pci = opaque; |
90 | 74c62ba8 | aurel32 | unsigned long win; |
91 | 74c62ba8 | aurel32 | uint32_t value = 0;
|
92 | 74c62ba8 | aurel32 | |
93 | 74c62ba8 | aurel32 | win = addr & 0xfe0;
|
94 | 74c62ba8 | aurel32 | |
95 | 74c62ba8 | aurel32 | switch (win) {
|
96 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW1:
|
97 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW2:
|
98 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW3:
|
99 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW4:
|
100 | 74c62ba8 | aurel32 | switch (addr & 0xC) { |
101 | 74c62ba8 | aurel32 | case PCI_POTAR: value = pci->pob[(addr >> 5) & 0x7].potar; break; |
102 | 74c62ba8 | aurel32 | case PCI_POTEAR: value = pci->pob[(addr >> 5) & 0x7].potear; break; |
103 | 74c62ba8 | aurel32 | case PCI_POWBAR: value = pci->pob[(addr >> 5) & 0x7].powbar; break; |
104 | 74c62ba8 | aurel32 | case PCI_POWAR: value = pci->pob[(addr >> 5) & 0x7].powar; break; |
105 | 74c62ba8 | aurel32 | default: break; |
106 | 74c62ba8 | aurel32 | } |
107 | 74c62ba8 | aurel32 | break;
|
108 | 74c62ba8 | aurel32 | |
109 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW3:
|
110 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW2:
|
111 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW1:
|
112 | 74c62ba8 | aurel32 | switch (addr & 0xC) { |
113 | 74c62ba8 | aurel32 | case PCI_PITAR: value = pci->pib[(addr >> 5) & 0x3].pitar; break; |
114 | 74c62ba8 | aurel32 | case PCI_PIWBAR: value = pci->pib[(addr >> 5) & 0x3].piwbar; break; |
115 | 74c62ba8 | aurel32 | case PCI_PIWBEAR: value = pci->pib[(addr >> 5) & 0x3].piwbear; break; |
116 | 74c62ba8 | aurel32 | case PCI_PIWAR: value = pci->pib[(addr >> 5) & 0x3].piwar; break; |
117 | 74c62ba8 | aurel32 | default: break; |
118 | 74c62ba8 | aurel32 | }; |
119 | 74c62ba8 | aurel32 | break;
|
120 | 74c62ba8 | aurel32 | |
121 | 74c62ba8 | aurel32 | case PPCE500_PCI_GASKET_TIMR:
|
122 | 74c62ba8 | aurel32 | value = pci->gasket_time; |
123 | 74c62ba8 | aurel32 | break;
|
124 | 74c62ba8 | aurel32 | |
125 | 74c62ba8 | aurel32 | default:
|
126 | 74c62ba8 | aurel32 | break;
|
127 | 74c62ba8 | aurel32 | } |
128 | 74c62ba8 | aurel32 | |
129 | c0a2a096 | Blue Swirl | pci_debug("%s: win:%lx(addr:" TARGET_FMT_plx ") -> value:%x\n", __func__, |
130 | c0a2a096 | Blue Swirl | win, addr, value); |
131 | 74c62ba8 | aurel32 | return value;
|
132 | 74c62ba8 | aurel32 | } |
133 | 74c62ba8 | aurel32 | |
134 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const e500_pci_reg_read[] = { |
135 | 74c62ba8 | aurel32 | &pci_reg_read4, |
136 | 74c62ba8 | aurel32 | &pci_reg_read4, |
137 | 74c62ba8 | aurel32 | &pci_reg_read4, |
138 | 74c62ba8 | aurel32 | }; |
139 | 74c62ba8 | aurel32 | |
140 | c227f099 | Anthony Liguori | static void pci_reg_write4(void *opaque, target_phys_addr_t addr, |
141 | 74c62ba8 | aurel32 | uint32_t value) |
142 | 74c62ba8 | aurel32 | { |
143 | 74c62ba8 | aurel32 | PPCE500PCIState *pci = opaque; |
144 | 74c62ba8 | aurel32 | unsigned long win; |
145 | 74c62ba8 | aurel32 | |
146 | 74c62ba8 | aurel32 | win = addr & 0xfe0;
|
147 | 74c62ba8 | aurel32 | |
148 | c0a2a096 | Blue Swirl | pci_debug("%s: value:%x -> win:%lx(addr:" TARGET_FMT_plx ")\n", |
149 | c0a2a096 | Blue Swirl | __func__, value, win, addr); |
150 | 74c62ba8 | aurel32 | |
151 | 74c62ba8 | aurel32 | switch (win) {
|
152 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW1:
|
153 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW2:
|
154 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW3:
|
155 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW4:
|
156 | 74c62ba8 | aurel32 | switch (addr & 0xC) { |
157 | 74c62ba8 | aurel32 | case PCI_POTAR: pci->pob[(addr >> 5) & 0x7].potar = value; break; |
158 | 74c62ba8 | aurel32 | case PCI_POTEAR: pci->pob[(addr >> 5) & 0x7].potear = value; break; |
159 | 74c62ba8 | aurel32 | case PCI_POWBAR: pci->pob[(addr >> 5) & 0x7].powbar = value; break; |
160 | 74c62ba8 | aurel32 | case PCI_POWAR: pci->pob[(addr >> 5) & 0x7].powar = value; break; |
161 | 74c62ba8 | aurel32 | default: break; |
162 | 74c62ba8 | aurel32 | }; |
163 | 74c62ba8 | aurel32 | break;
|
164 | 74c62ba8 | aurel32 | |
165 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW3:
|
166 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW2:
|
167 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW1:
|
168 | 74c62ba8 | aurel32 | switch (addr & 0xC) { |
169 | 74c62ba8 | aurel32 | case PCI_PITAR: pci->pib[(addr >> 5) & 0x3].pitar = value; break; |
170 | 74c62ba8 | aurel32 | case PCI_PIWBAR: pci->pib[(addr >> 5) & 0x3].piwbar = value; break; |
171 | 74c62ba8 | aurel32 | case PCI_PIWBEAR: pci->pib[(addr >> 5) & 0x3].piwbear = value; break; |
172 | 74c62ba8 | aurel32 | case PCI_PIWAR: pci->pib[(addr >> 5) & 0x3].piwar = value; break; |
173 | 74c62ba8 | aurel32 | default: break; |
174 | 74c62ba8 | aurel32 | }; |
175 | 74c62ba8 | aurel32 | break;
|
176 | 74c62ba8 | aurel32 | |
177 | 74c62ba8 | aurel32 | case PPCE500_PCI_GASKET_TIMR:
|
178 | 74c62ba8 | aurel32 | pci->gasket_time = value; |
179 | 74c62ba8 | aurel32 | break;
|
180 | 74c62ba8 | aurel32 | |
181 | 74c62ba8 | aurel32 | default:
|
182 | 74c62ba8 | aurel32 | break;
|
183 | 74c62ba8 | aurel32 | }; |
184 | 74c62ba8 | aurel32 | } |
185 | 74c62ba8 | aurel32 | |
186 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const e500_pci_reg_write[] = { |
187 | 74c62ba8 | aurel32 | &pci_reg_write4, |
188 | 74c62ba8 | aurel32 | &pci_reg_write4, |
189 | 74c62ba8 | aurel32 | &pci_reg_write4, |
190 | 74c62ba8 | aurel32 | }; |
191 | 74c62ba8 | aurel32 | |
192 | 74c62ba8 | aurel32 | static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int irq_num) |
193 | 74c62ba8 | aurel32 | { |
194 | 74c62ba8 | aurel32 | int devno = pci_dev->devfn >> 3, ret = 0; |
195 | 74c62ba8 | aurel32 | |
196 | 74c62ba8 | aurel32 | switch (devno) {
|
197 | 74c62ba8 | aurel32 | /* Two PCI slot */
|
198 | 74c62ba8 | aurel32 | case 0x11: |
199 | 74c62ba8 | aurel32 | case 0x12: |
200 | 74c62ba8 | aurel32 | ret = (irq_num + devno - 0x10) % 4; |
201 | 74c62ba8 | aurel32 | break;
|
202 | 74c62ba8 | aurel32 | default:
|
203 | 74c62ba8 | aurel32 | printf("Error:%s:unknow dev number\n", __func__);
|
204 | 74c62ba8 | aurel32 | } |
205 | 74c62ba8 | aurel32 | |
206 | 74c62ba8 | aurel32 | pci_debug("%s: devfn %x irq %d -> %d devno:%x\n", __func__,
|
207 | 74c62ba8 | aurel32 | pci_dev->devfn, irq_num, ret, devno); |
208 | 74c62ba8 | aurel32 | |
209 | 74c62ba8 | aurel32 | return ret;
|
210 | 74c62ba8 | aurel32 | } |
211 | 74c62ba8 | aurel32 | |
212 | 5d4e84c8 | Juan Quintela | static void mpc85xx_pci_set_irq(void *opaque, int irq_num, int level) |
213 | 74c62ba8 | aurel32 | { |
214 | 5d4e84c8 | Juan Quintela | qemu_irq *pic = opaque; |
215 | 5d4e84c8 | Juan Quintela | |
216 | 74c62ba8 | aurel32 | pci_debug("%s: PCI irq %d, level:%d\n", __func__, irq_num, level);
|
217 | 74c62ba8 | aurel32 | |
218 | 74c62ba8 | aurel32 | qemu_set_irq(pic[irq_num], level); |
219 | 74c62ba8 | aurel32 | } |
220 | 74c62ba8 | aurel32 | |
221 | 74c62ba8 | aurel32 | static void ppce500_pci_save(QEMUFile *f, void *opaque) |
222 | 74c62ba8 | aurel32 | { |
223 | 74c62ba8 | aurel32 | PPCE500PCIState *controller = opaque; |
224 | 74c62ba8 | aurel32 | int i;
|
225 | 74c62ba8 | aurel32 | |
226 | 74c62ba8 | aurel32 | pci_device_save(controller->pci_dev, f); |
227 | 74c62ba8 | aurel32 | |
228 | 74c62ba8 | aurel32 | for (i = 0; i < PPCE500_PCI_NR_POBS; i++) { |
229 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pob[i].potar); |
230 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pob[i].potear); |
231 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pob[i].powbar); |
232 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pob[i].powar); |
233 | 74c62ba8 | aurel32 | } |
234 | 74c62ba8 | aurel32 | |
235 | 74c62ba8 | aurel32 | for (i = 0; i < PPCE500_PCI_NR_PIBS; i++) { |
236 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pib[i].pitar); |
237 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pib[i].piwbar); |
238 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pib[i].piwbear); |
239 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pib[i].piwar); |
240 | 74c62ba8 | aurel32 | } |
241 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->gasket_time); |
242 | 74c62ba8 | aurel32 | } |
243 | 74c62ba8 | aurel32 | |
244 | 74c62ba8 | aurel32 | static int ppce500_pci_load(QEMUFile *f, void *opaque, int version_id) |
245 | 74c62ba8 | aurel32 | { |
246 | 74c62ba8 | aurel32 | PPCE500PCIState *controller = opaque; |
247 | 74c62ba8 | aurel32 | int i;
|
248 | 74c62ba8 | aurel32 | |
249 | 74c62ba8 | aurel32 | if (version_id != 1) |
250 | 74c62ba8 | aurel32 | return -EINVAL;
|
251 | 74c62ba8 | aurel32 | |
252 | 74c62ba8 | aurel32 | pci_device_load(controller->pci_dev, f); |
253 | 74c62ba8 | aurel32 | |
254 | 74c62ba8 | aurel32 | for (i = 0; i < PPCE500_PCI_NR_POBS; i++) { |
255 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pob[i].potar); |
256 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pob[i].potear); |
257 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pob[i].powbar); |
258 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pob[i].powar); |
259 | 74c62ba8 | aurel32 | } |
260 | 74c62ba8 | aurel32 | |
261 | 74c62ba8 | aurel32 | for (i = 0; i < PPCE500_PCI_NR_PIBS; i++) { |
262 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pib[i].pitar); |
263 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pib[i].piwbar); |
264 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pib[i].piwbear); |
265 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pib[i].piwar); |
266 | 74c62ba8 | aurel32 | } |
267 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->gasket_time); |
268 | 74c62ba8 | aurel32 | |
269 | 74c62ba8 | aurel32 | return 0; |
270 | 74c62ba8 | aurel32 | } |
271 | 74c62ba8 | aurel32 | |
272 | c227f099 | Anthony Liguori | PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers)
|
273 | 74c62ba8 | aurel32 | { |
274 | 74c62ba8 | aurel32 | PPCE500PCIState *controller; |
275 | 74c62ba8 | aurel32 | PCIDevice *d; |
276 | 74c62ba8 | aurel32 | int index;
|
277 | 74c62ba8 | aurel32 | static int ppce500_pci_id; |
278 | 74c62ba8 | aurel32 | |
279 | 74c62ba8 | aurel32 | controller = qemu_mallocz(sizeof(PPCE500PCIState));
|
280 | 74c62ba8 | aurel32 | |
281 | 02e2da45 | Paul Brook | controller->pci_state.bus = pci_register_bus(NULL, "pci", |
282 | 02e2da45 | Paul Brook | mpc85xx_pci_set_irq, |
283 | 74c62ba8 | aurel32 | mpc85xx_pci_map_irq, |
284 | 74c62ba8 | aurel32 | pci_irqs, 0x88, 4); |
285 | 74c62ba8 | aurel32 | d = pci_register_device(controller->pci_state.bus, |
286 | 74c62ba8 | aurel32 | "host bridge", sizeof(PCIDevice), |
287 | 74c62ba8 | aurel32 | 0, NULL, NULL); |
288 | 74c62ba8 | aurel32 | |
289 | a770dc7e | aliguori | pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_FREESCALE); |
290 | a770dc7e | aliguori | pci_config_set_device_id(d->config, PCI_DEVICE_ID_MPC8533E); |
291 | 74c62ba8 | aurel32 | pci_config_set_class(d->config, PCI_CLASS_PROCESSOR_POWERPC); |
292 | 74c62ba8 | aurel32 | |
293 | 74c62ba8 | aurel32 | controller->pci_dev = d; |
294 | 74c62ba8 | aurel32 | |
295 | 74c62ba8 | aurel32 | /* CFGADDR */
|
296 | f08b32fe | Isaku Yamahata | index = pci_host_conf_register_mmio_noswap(&controller->pci_state); |
297 | 74c62ba8 | aurel32 | if (index < 0) |
298 | 74c62ba8 | aurel32 | goto free;
|
299 | 74c62ba8 | aurel32 | cpu_register_physical_memory(registers + PCIE500_CFGADDR, 4, index);
|
300 | 74c62ba8 | aurel32 | |
301 | 74c62ba8 | aurel32 | /* CFGDATA */
|
302 | f08b32fe | Isaku Yamahata | index = pci_host_data_register_mmio(&controller->pci_state); |
303 | 74c62ba8 | aurel32 | if (index < 0) |
304 | 74c62ba8 | aurel32 | goto free;
|
305 | 74c62ba8 | aurel32 | cpu_register_physical_memory(registers + PCIE500_CFGDATA, 4, index);
|
306 | 74c62ba8 | aurel32 | |
307 | 1eed09cb | Avi Kivity | index = cpu_register_io_memory(e500_pci_reg_read, |
308 | 74c62ba8 | aurel32 | e500_pci_reg_write, controller); |
309 | 74c62ba8 | aurel32 | if (index < 0) |
310 | 74c62ba8 | aurel32 | goto free;
|
311 | 74c62ba8 | aurel32 | cpu_register_physical_memory(registers + PCIE500_REG_BASE, |
312 | 74c62ba8 | aurel32 | PCIE500_REG_SIZE, index); |
313 | 74c62ba8 | aurel32 | |
314 | 74c62ba8 | aurel32 | /* XXX load/save code not tested. */
|
315 | 74c62ba8 | aurel32 | register_savevm("ppce500_pci", ppce500_pci_id++, 1, |
316 | 74c62ba8 | aurel32 | ppce500_pci_save, ppce500_pci_load, controller); |
317 | 74c62ba8 | aurel32 | |
318 | 74c62ba8 | aurel32 | return controller->pci_state.bus;
|
319 | 74c62ba8 | aurel32 | |
320 | 74c62ba8 | aurel32 | free:
|
321 | 74c62ba8 | aurel32 | printf("%s error\n", __func__);
|
322 | 74c62ba8 | aurel32 | qemu_free(controller); |
323 | 74c62ba8 | aurel32 | return NULL; |
324 | 74c62ba8 | aurel32 | } |