]>
Commit | Line | Data |
---|---|---|
5fafdf24 | 1 | /* |
b5ff1b31 FB |
2 | * ARM Integrator CP System emulation. |
3 | * | |
a1bb27b1 | 4 | * Copyright (c) 2005-2007 CodeSourcery. |
b5ff1b31 FB |
5 | * Written by Paul Brook |
6 | * | |
8e31bf38 | 7 | * This code is licensed under the GPL |
b5ff1b31 FB |
8 | */ |
9 | ||
83c9f4ca | 10 | #include "hw/sysbus.h" |
bd2be150 | 11 | #include "hw/devices.h" |
83c9f4ca | 12 | #include "hw/boards.h" |
bd2be150 | 13 | #include "hw/arm/arm.h" |
b8616055 | 14 | #include "hw/misc/arm_integrator_debug.h" |
1422e32d | 15 | #include "net/net.h" |
022c62cb | 16 | #include "exec/address-spaces.h" |
9c17d615 | 17 | #include "sysemu/sysemu.h" |
b5ff1b31 | 18 | |
257ec289 AF |
19 | #define TYPE_INTEGRATOR_CM "integrator_core" |
20 | #define INTEGRATOR_CM(obj) \ | |
21 | OBJECT_CHECK(IntegratorCMState, (obj), TYPE_INTEGRATOR_CM) | |
22 | ||
23 | typedef struct IntegratorCMState { | |
24 | /*< private >*/ | |
25 | SysBusDevice parent_obj; | |
26 | /*< public >*/ | |
27 | ||
71d9bc50 | 28 | MemoryRegion iomem; |
ee6847d1 | 29 | uint32_t memsz; |
211adf4d | 30 | MemoryRegion flash; |
b5ff1b31 FB |
31 | uint32_t cm_osc; |
32 | uint32_t cm_ctrl; | |
33 | uint32_t cm_lock; | |
34 | uint32_t cm_auxosc; | |
35 | uint32_t cm_sdram; | |
36 | uint32_t cm_init; | |
37 | uint32_t cm_flags; | |
38 | uint32_t cm_nvflags; | |
39 | uint32_t int_level; | |
40 | uint32_t irq_enabled; | |
41 | uint32_t fiq_enabled; | |
257ec289 | 42 | } IntegratorCMState; |
b5ff1b31 FB |
43 | |
44 | static uint8_t integrator_spd[128] = { | |
45 | 128, 8, 4, 11, 9, 1, 64, 0, 2, 0xa0, 0xa0, 0, 0, 8, 0, 1, | |
46 | 0xe, 4, 0x1c, 1, 2, 0x20, 0xc0, 0, 0, 0, 0, 0x30, 0x28, 0x30, 0x28, 0x40 | |
47 | }; | |
48 | ||
a8170e5e | 49 | static uint64_t integratorcm_read(void *opaque, hwaddr offset, |
71d9bc50 | 50 | unsigned size) |
b5ff1b31 | 51 | { |
257ec289 | 52 | IntegratorCMState *s = opaque; |
b5ff1b31 FB |
53 | if (offset >= 0x100 && offset < 0x200) { |
54 | /* CM_SPD */ | |
55 | if (offset >= 0x180) | |
56 | return 0; | |
57 | return integrator_spd[offset >> 2]; | |
58 | } | |
59 | switch (offset >> 2) { | |
60 | case 0: /* CM_ID */ | |
61 | return 0x411a3001; | |
62 | case 1: /* CM_PROC */ | |
63 | return 0; | |
64 | case 2: /* CM_OSC */ | |
65 | return s->cm_osc; | |
66 | case 3: /* CM_CTRL */ | |
67 | return s->cm_ctrl; | |
68 | case 4: /* CM_STAT */ | |
69 | return 0x00100000; | |
70 | case 5: /* CM_LOCK */ | |
71 | if (s->cm_lock == 0xa05f) { | |
72 | return 0x1a05f; | |
73 | } else { | |
74 | return s->cm_lock; | |
75 | } | |
76 | case 6: /* CM_LMBUSCNT */ | |
77 | /* ??? High frequency timer. */ | |
2ac71179 | 78 | hw_error("integratorcm_read: CM_LMBUSCNT"); |
b5ff1b31 FB |
79 | case 7: /* CM_AUXOSC */ |
80 | return s->cm_auxosc; | |
81 | case 8: /* CM_SDRAM */ | |
82 | return s->cm_sdram; | |
83 | case 9: /* CM_INIT */ | |
84 | return s->cm_init; | |
85 | case 10: /* CM_REFCT */ | |
86 | /* ??? High frequency timer. */ | |
2ac71179 | 87 | hw_error("integratorcm_read: CM_REFCT"); |
b5ff1b31 FB |
88 | case 12: /* CM_FLAGS */ |
89 | return s->cm_flags; | |
90 | case 14: /* CM_NVFLAGS */ | |
91 | return s->cm_nvflags; | |
92 | case 16: /* CM_IRQ_STAT */ | |
93 | return s->int_level & s->irq_enabled; | |
94 | case 17: /* CM_IRQ_RSTAT */ | |
95 | return s->int_level; | |
96 | case 18: /* CM_IRQ_ENSET */ | |
97 | return s->irq_enabled; | |
98 | case 20: /* CM_SOFT_INTSET */ | |
99 | return s->int_level & 1; | |
100 | case 24: /* CM_FIQ_STAT */ | |
101 | return s->int_level & s->fiq_enabled; | |
102 | case 25: /* CM_FIQ_RSTAT */ | |
103 | return s->int_level; | |
104 | case 26: /* CM_FIQ_ENSET */ | |
105 | return s->fiq_enabled; | |
106 | case 32: /* CM_VOLTAGE_CTL0 */ | |
107 | case 33: /* CM_VOLTAGE_CTL1 */ | |
108 | case 34: /* CM_VOLTAGE_CTL2 */ | |
109 | case 35: /* CM_VOLTAGE_CTL3 */ | |
110 | /* ??? Voltage control unimplemented. */ | |
111 | return 0; | |
112 | default: | |
2ac71179 PB |
113 | hw_error("integratorcm_read: Unimplemented offset 0x%x\n", |
114 | (int)offset); | |
b5ff1b31 FB |
115 | return 0; |
116 | } | |
117 | } | |
118 | ||
257ec289 | 119 | static void integratorcm_do_remap(IntegratorCMState *s) |
b5ff1b31 | 120 | { |
563c2bf3 PM |
121 | /* Sync memory region state with CM_CTRL REMAP bit: |
122 | * bit 0 => flash at address 0; bit 1 => RAM | |
123 | */ | |
124 | memory_region_set_enabled(&s->flash, !(s->cm_ctrl & 4)); | |
b5ff1b31 FB |
125 | } |
126 | ||
257ec289 | 127 | static void integratorcm_set_ctrl(IntegratorCMState *s, uint32_t value) |
b5ff1b31 FB |
128 | { |
129 | if (value & 8) { | |
df3f457b | 130 | qemu_system_reset_request(); |
b5ff1b31 | 131 | } |
df3f457b PM |
132 | if ((s->cm_ctrl ^ value) & 1) { |
133 | /* (value & 1) != 0 means the green "MISC LED" is lit. | |
134 | * We don't have any nice place to display LEDs. printf is a bad | |
135 | * idea because Linux uses the LED as a heartbeat and the output | |
136 | * will swamp anything else on the terminal. | |
137 | */ | |
b5ff1b31 | 138 | } |
df3f457b PM |
139 | /* Note that the RESET bit [3] always reads as zero */ |
140 | s->cm_ctrl = (s->cm_ctrl & ~5) | (value & 5); | |
563c2bf3 | 141 | integratorcm_do_remap(s); |
b5ff1b31 FB |
142 | } |
143 | ||
257ec289 | 144 | static void integratorcm_update(IntegratorCMState *s) |
b5ff1b31 FB |
145 | { |
146 | /* ??? The CPU irq/fiq is raised when either the core module or base PIC | |
147 | are active. */ | |
148 | if (s->int_level & (s->irq_enabled | s->fiq_enabled)) | |
2ac71179 | 149 | hw_error("Core module interrupt\n"); |
b5ff1b31 FB |
150 | } |
151 | ||
a8170e5e | 152 | static void integratorcm_write(void *opaque, hwaddr offset, |
71d9bc50 | 153 | uint64_t value, unsigned size) |
b5ff1b31 | 154 | { |
257ec289 | 155 | IntegratorCMState *s = opaque; |
b5ff1b31 FB |
156 | switch (offset >> 2) { |
157 | case 2: /* CM_OSC */ | |
158 | if (s->cm_lock == 0xa05f) | |
159 | s->cm_osc = value; | |
160 | break; | |
161 | case 3: /* CM_CTRL */ | |
162 | integratorcm_set_ctrl(s, value); | |
163 | break; | |
164 | case 5: /* CM_LOCK */ | |
165 | s->cm_lock = value & 0xffff; | |
166 | break; | |
167 | case 7: /* CM_AUXOSC */ | |
168 | if (s->cm_lock == 0xa05f) | |
169 | s->cm_auxosc = value; | |
170 | break; | |
171 | case 8: /* CM_SDRAM */ | |
172 | s->cm_sdram = value; | |
173 | break; | |
174 | case 9: /* CM_INIT */ | |
175 | /* ??? This can change the memory bus frequency. */ | |
176 | s->cm_init = value; | |
177 | break; | |
178 | case 12: /* CM_FLAGSS */ | |
179 | s->cm_flags |= value; | |
180 | break; | |
181 | case 13: /* CM_FLAGSC */ | |
182 | s->cm_flags &= ~value; | |
183 | break; | |
184 | case 14: /* CM_NVFLAGSS */ | |
185 | s->cm_nvflags |= value; | |
186 | break; | |
187 | case 15: /* CM_NVFLAGSS */ | |
188 | s->cm_nvflags &= ~value; | |
189 | break; | |
190 | case 18: /* CM_IRQ_ENSET */ | |
191 | s->irq_enabled |= value; | |
192 | integratorcm_update(s); | |
193 | break; | |
194 | case 19: /* CM_IRQ_ENCLR */ | |
195 | s->irq_enabled &= ~value; | |
196 | integratorcm_update(s); | |
197 | break; | |
198 | case 20: /* CM_SOFT_INTSET */ | |
199 | s->int_level |= (value & 1); | |
200 | integratorcm_update(s); | |
201 | break; | |
202 | case 21: /* CM_SOFT_INTCLR */ | |
203 | s->int_level &= ~(value & 1); | |
204 | integratorcm_update(s); | |
205 | break; | |
206 | case 26: /* CM_FIQ_ENSET */ | |
207 | s->fiq_enabled |= value; | |
208 | integratorcm_update(s); | |
209 | break; | |
210 | case 27: /* CM_FIQ_ENCLR */ | |
211 | s->fiq_enabled &= ~value; | |
212 | integratorcm_update(s); | |
213 | break; | |
214 | case 32: /* CM_VOLTAGE_CTL0 */ | |
215 | case 33: /* CM_VOLTAGE_CTL1 */ | |
216 | case 34: /* CM_VOLTAGE_CTL2 */ | |
217 | case 35: /* CM_VOLTAGE_CTL3 */ | |
218 | /* ??? Voltage control unimplemented. */ | |
219 | break; | |
220 | default: | |
2ac71179 PB |
221 | hw_error("integratorcm_write: Unimplemented offset 0x%x\n", |
222 | (int)offset); | |
b5ff1b31 FB |
223 | break; |
224 | } | |
225 | } | |
226 | ||
227 | /* Integrator/CM control registers. */ | |
228 | ||
71d9bc50 BC |
229 | static const MemoryRegionOps integratorcm_ops = { |
230 | .read = integratorcm_read, | |
231 | .write = integratorcm_write, | |
232 | .endianness = DEVICE_NATIVE_ENDIAN, | |
b5ff1b31 FB |
233 | }; |
234 | ||
81a322d4 | 235 | static int integratorcm_init(SysBusDevice *dev) |
b5ff1b31 | 236 | { |
257ec289 | 237 | IntegratorCMState *s = INTEGRATOR_CM(dev); |
b5ff1b31 | 238 | |
b5ff1b31 FB |
239 | s->cm_osc = 0x01000048; |
240 | /* ??? What should the high bits of this value be? */ | |
241 | s->cm_auxosc = 0x0007feff; | |
242 | s->cm_sdram = 0x00011122; | |
ee6847d1 | 243 | if (s->memsz >= 256) { |
b5ff1b31 FB |
244 | integrator_spd[31] = 64; |
245 | s->cm_sdram |= 0x10; | |
ee6847d1 | 246 | } else if (s->memsz >= 128) { |
b5ff1b31 FB |
247 | integrator_spd[31] = 32; |
248 | s->cm_sdram |= 0x0c; | |
ee6847d1 | 249 | } else if (s->memsz >= 64) { |
b5ff1b31 FB |
250 | integrator_spd[31] = 16; |
251 | s->cm_sdram |= 0x08; | |
ee6847d1 | 252 | } else if (s->memsz >= 32) { |
b5ff1b31 FB |
253 | integrator_spd[31] = 4; |
254 | s->cm_sdram |= 0x04; | |
255 | } else { | |
256 | integrator_spd[31] = 2; | |
257 | } | |
258 | memcpy(integrator_spd + 73, "QEMU-MEMORY", 11); | |
259 | s->cm_init = 0x00000112; | |
64bde0f3 | 260 | memory_region_init_ram(&s->flash, OBJECT(s), "integrator.flash", 0x100000); |
c5705a77 | 261 | vmstate_register_ram_global(&s->flash); |
b5ff1b31 | 262 | |
64bde0f3 | 263 | memory_region_init_io(&s->iomem, OBJECT(s), &integratorcm_ops, s, |
71d9bc50 | 264 | "integratorcm", 0x00800000); |
750ecd44 | 265 | sysbus_init_mmio(dev, &s->iomem); |
71d9bc50 | 266 | |
563c2bf3 | 267 | integratorcm_do_remap(s); |
b5ff1b31 | 268 | /* ??? Save/restore. */ |
81a322d4 | 269 | return 0; |
b5ff1b31 FB |
270 | } |
271 | ||
272 | /* Integrator/CP hardware emulation. */ | |
273 | /* Primary interrupt controller. */ | |
274 | ||
91b64626 AF |
275 | #define TYPE_INTEGRATOR_PIC "integrator_pic" |
276 | #define INTEGRATOR_PIC(obj) \ | |
277 | OBJECT_CHECK(icp_pic_state, (obj), TYPE_INTEGRATOR_PIC) | |
278 | ||
279 | typedef struct icp_pic_state { | |
280 | /*< private >*/ | |
281 | SysBusDevice parent_obj; | |
282 | /*< public >*/ | |
283 | ||
284 | MemoryRegion iomem; | |
285 | uint32_t level; | |
286 | uint32_t irq_enabled; | |
287 | uint32_t fiq_enabled; | |
288 | qemu_irq parent_irq; | |
289 | qemu_irq parent_fiq; | |
b5ff1b31 FB |
290 | } icp_pic_state; |
291 | ||
b5ff1b31 FB |
292 | static void icp_pic_update(icp_pic_state *s) |
293 | { | |
cdbdb648 | 294 | uint32_t flags; |
b5ff1b31 | 295 | |
d537cf6c PB |
296 | flags = (s->level & s->irq_enabled); |
297 | qemu_set_irq(s->parent_irq, flags != 0); | |
298 | flags = (s->level & s->fiq_enabled); | |
299 | qemu_set_irq(s->parent_fiq, flags != 0); | |
b5ff1b31 FB |
300 | } |
301 | ||
cdbdb648 | 302 | static void icp_pic_set_irq(void *opaque, int irq, int level) |
b5ff1b31 | 303 | { |
80337b66 | 304 | icp_pic_state *s = (icp_pic_state *)opaque; |
b5ff1b31 | 305 | if (level) |
80337b66 | 306 | s->level |= 1 << irq; |
b5ff1b31 | 307 | else |
80337b66 | 308 | s->level &= ~(1 << irq); |
b5ff1b31 FB |
309 | icp_pic_update(s); |
310 | } | |
311 | ||
a8170e5e | 312 | static uint64_t icp_pic_read(void *opaque, hwaddr offset, |
61074e46 | 313 | unsigned size) |
b5ff1b31 FB |
314 | { |
315 | icp_pic_state *s = (icp_pic_state *)opaque; | |
316 | ||
b5ff1b31 FB |
317 | switch (offset >> 2) { |
318 | case 0: /* IRQ_STATUS */ | |
319 | return s->level & s->irq_enabled; | |
320 | case 1: /* IRQ_RAWSTAT */ | |
321 | return s->level; | |
322 | case 2: /* IRQ_ENABLESET */ | |
323 | return s->irq_enabled; | |
324 | case 4: /* INT_SOFTSET */ | |
325 | return s->level & 1; | |
326 | case 8: /* FRQ_STATUS */ | |
327 | return s->level & s->fiq_enabled; | |
328 | case 9: /* FRQ_RAWSTAT */ | |
329 | return s->level; | |
330 | case 10: /* FRQ_ENABLESET */ | |
331 | return s->fiq_enabled; | |
332 | case 3: /* IRQ_ENABLECLR */ | |
333 | case 5: /* INT_SOFTCLR */ | |
334 | case 11: /* FRQ_ENABLECLR */ | |
335 | default: | |
29bfb117 | 336 | printf ("icp_pic_read: Bad register offset 0x%x\n", (int)offset); |
b5ff1b31 FB |
337 | return 0; |
338 | } | |
339 | } | |
340 | ||
a8170e5e | 341 | static void icp_pic_write(void *opaque, hwaddr offset, |
61074e46 | 342 | uint64_t value, unsigned size) |
b5ff1b31 FB |
343 | { |
344 | icp_pic_state *s = (icp_pic_state *)opaque; | |
b5ff1b31 FB |
345 | |
346 | switch (offset >> 2) { | |
347 | case 2: /* IRQ_ENABLESET */ | |
348 | s->irq_enabled |= value; | |
349 | break; | |
350 | case 3: /* IRQ_ENABLECLR */ | |
351 | s->irq_enabled &= ~value; | |
352 | break; | |
353 | case 4: /* INT_SOFTSET */ | |
354 | if (value & 1) | |
d537cf6c | 355 | icp_pic_set_irq(s, 0, 1); |
b5ff1b31 FB |
356 | break; |
357 | case 5: /* INT_SOFTCLR */ | |
358 | if (value & 1) | |
d537cf6c | 359 | icp_pic_set_irq(s, 0, 0); |
b5ff1b31 FB |
360 | break; |
361 | case 10: /* FRQ_ENABLESET */ | |
362 | s->fiq_enabled |= value; | |
363 | break; | |
364 | case 11: /* FRQ_ENABLECLR */ | |
365 | s->fiq_enabled &= ~value; | |
366 | break; | |
367 | case 0: /* IRQ_STATUS */ | |
368 | case 1: /* IRQ_RAWSTAT */ | |
369 | case 8: /* FRQ_STATUS */ | |
370 | case 9: /* FRQ_RAWSTAT */ | |
371 | default: | |
29bfb117 | 372 | printf ("icp_pic_write: Bad register offset 0x%x\n", (int)offset); |
b5ff1b31 FB |
373 | return; |
374 | } | |
375 | icp_pic_update(s); | |
376 | } | |
377 | ||
61074e46 BC |
378 | static const MemoryRegionOps icp_pic_ops = { |
379 | .read = icp_pic_read, | |
380 | .write = icp_pic_write, | |
381 | .endianness = DEVICE_NATIVE_ENDIAN, | |
b5ff1b31 FB |
382 | }; |
383 | ||
91b64626 | 384 | static int icp_pic_init(SysBusDevice *sbd) |
b5ff1b31 | 385 | { |
91b64626 AF |
386 | DeviceState *dev = DEVICE(sbd); |
387 | icp_pic_state *s = INTEGRATOR_PIC(dev); | |
b5ff1b31 | 388 | |
91b64626 AF |
389 | qdev_init_gpio_in(dev, icp_pic_set_irq, 32); |
390 | sysbus_init_irq(sbd, &s->parent_irq); | |
391 | sysbus_init_irq(sbd, &s->parent_fiq); | |
64bde0f3 PB |
392 | memory_region_init_io(&s->iomem, OBJECT(s), &icp_pic_ops, s, |
393 | "icp-pic", 0x00800000); | |
91b64626 | 394 | sysbus_init_mmio(sbd, &s->iomem); |
81a322d4 | 395 | return 0; |
b5ff1b31 FB |
396 | } |
397 | ||
b5ff1b31 | 398 | /* CP control registers. */ |
0c36493e | 399 | |
a8170e5e | 400 | static uint64_t icp_control_read(void *opaque, hwaddr offset, |
0c36493e | 401 | unsigned size) |
b5ff1b31 | 402 | { |
b5ff1b31 FB |
403 | switch (offset >> 2) { |
404 | case 0: /* CP_IDFIELD */ | |
405 | return 0x41034003; | |
406 | case 1: /* CP_FLASHPROG */ | |
407 | return 0; | |
408 | case 2: /* CP_INTREG */ | |
409 | return 0; | |
410 | case 3: /* CP_DECODE */ | |
411 | return 0x11; | |
412 | default: | |
2ac71179 | 413 | hw_error("icp_control_read: Bad offset %x\n", (int)offset); |
b5ff1b31 FB |
414 | return 0; |
415 | } | |
416 | } | |
417 | ||
a8170e5e | 418 | static void icp_control_write(void *opaque, hwaddr offset, |
0c36493e | 419 | uint64_t value, unsigned size) |
b5ff1b31 | 420 | { |
b5ff1b31 FB |
421 | switch (offset >> 2) { |
422 | case 1: /* CP_FLASHPROG */ | |
423 | case 2: /* CP_INTREG */ | |
424 | case 3: /* CP_DECODE */ | |
425 | /* Nothing interesting implemented yet. */ | |
426 | break; | |
427 | default: | |
2ac71179 | 428 | hw_error("icp_control_write: Bad offset %x\n", (int)offset); |
b5ff1b31 FB |
429 | } |
430 | } | |
b5ff1b31 | 431 | |
0c36493e BC |
432 | static const MemoryRegionOps icp_control_ops = { |
433 | .read = icp_control_read, | |
434 | .write = icp_control_write, | |
435 | .endianness = DEVICE_NATIVE_ENDIAN, | |
b5ff1b31 FB |
436 | }; |
437 | ||
a8170e5e | 438 | static void icp_control_init(hwaddr base) |
b5ff1b31 | 439 | { |
0c36493e | 440 | MemoryRegion *io; |
b5ff1b31 | 441 | |
0c36493e | 442 | io = (MemoryRegion *)g_malloc0(sizeof(MemoryRegion)); |
2c9b15ca | 443 | memory_region_init_io(io, NULL, &icp_control_ops, NULL, |
0c36493e BC |
444 | "control", 0x00800000); |
445 | memory_region_add_subregion(get_system_memory(), base, io); | |
b5ff1b31 FB |
446 | /* ??? Save/restore. */ |
447 | } | |
448 | ||
449 | ||
b5ff1b31 FB |
450 | /* Board init. */ |
451 | ||
f93eb9ff AZ |
452 | static struct arm_boot_info integrator_binfo = { |
453 | .loader_start = 0x0, | |
454 | .board_id = 0x113, | |
455 | }; | |
456 | ||
5f072e1f | 457 | static void integratorcp_init(QEMUMachineInitArgs *args) |
b5ff1b31 | 458 | { |
5f072e1f EH |
459 | ram_addr_t ram_size = args->ram_size; |
460 | const char *cpu_model = args->cpu_model; | |
461 | const char *kernel_filename = args->kernel_filename; | |
462 | const char *kernel_cmdline = args->kernel_cmdline; | |
463 | const char *initrd_filename = args->initrd_filename; | |
393a9eab | 464 | ARMCPU *cpu; |
211adf4d AK |
465 | MemoryRegion *address_space_mem = get_system_memory(); |
466 | MemoryRegion *ram = g_new(MemoryRegion, 1); | |
467 | MemoryRegion *ram_alias = g_new(MemoryRegion, 1); | |
a7086888 | 468 | qemu_irq pic[32]; |
a7086888 PB |
469 | DeviceState *dev; |
470 | int i; | |
b5ff1b31 | 471 | |
393a9eab | 472 | if (!cpu_model) { |
3371d272 | 473 | cpu_model = "arm926"; |
393a9eab AF |
474 | } |
475 | cpu = cpu_arm_init(cpu_model); | |
476 | if (!cpu) { | |
aaed909a FB |
477 | fprintf(stderr, "Unable to find CPU definition\n"); |
478 | exit(1); | |
479 | } | |
393a9eab | 480 | |
2c9b15ca | 481 | memory_region_init_ram(ram, NULL, "integrator.ram", ram_size); |
c5705a77 | 482 | vmstate_register_ram_global(ram); |
b5ff1b31 | 483 | /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */ |
1235fc06 | 484 | /* ??? RAM should repeat to fill physical memory space. */ |
b5ff1b31 | 485 | /* SDRAM at address zero*/ |
211adf4d | 486 | memory_region_add_subregion(address_space_mem, 0, ram); |
b5ff1b31 | 487 | /* And again at address 0x80000000 */ |
2c9b15ca | 488 | memory_region_init_alias(ram_alias, NULL, "ram.alias", ram, 0, ram_size); |
211adf4d | 489 | memory_region_add_subregion(address_space_mem, 0x80000000, ram_alias); |
b5ff1b31 | 490 | |
257ec289 | 491 | dev = qdev_create(NULL, TYPE_INTEGRATOR_CM); |
ee6847d1 | 492 | qdev_prop_set_uint32(dev, "memsz", ram_size >> 20); |
e23a1b33 | 493 | qdev_init_nofail(dev); |
a7086888 PB |
494 | sysbus_mmio_map((SysBusDevice *)dev, 0, 0x10000000); |
495 | ||
91b64626 | 496 | dev = sysbus_create_varargs(TYPE_INTEGRATOR_PIC, 0x14000000, |
99d228d6 PM |
497 | qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ), |
498 | qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_FIQ), | |
499 | NULL); | |
a7086888 | 500 | for (i = 0; i < 32; i++) { |
067a3ddc | 501 | pic[i] = qdev_get_gpio_in(dev, i); |
a7086888 | 502 | } |
91b64626 | 503 | sysbus_create_simple(TYPE_INTEGRATOR_PIC, 0xca000000, pic[26]); |
6a824ec3 PB |
504 | sysbus_create_varargs("integrator_pit", 0x13000000, |
505 | pic[5], pic[6], pic[7], NULL); | |
a63bdb31 | 506 | sysbus_create_simple("pl031", 0x15000000, pic[8]); |
a7d518a6 PB |
507 | sysbus_create_simple("pl011", 0x16000000, pic[1]); |
508 | sysbus_create_simple("pl011", 0x17000000, pic[2]); | |
b5ff1b31 | 509 | icp_control_init(0xcb000000); |
86394e96 PB |
510 | sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]); |
511 | sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]); | |
b8616055 | 512 | sysbus_create_simple(TYPE_INTEGRATOR_DEBUG, 0x1a000000, 0); |
aa9311d8 | 513 | sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL); |
a005d073 | 514 | if (nd_table[0].used) |
0ae18cee | 515 | smc91c111_init(&nd_table[0], 0xc8000000, pic[27]); |
2e9bdce5 PB |
516 | |
517 | sysbus_create_simple("pl110", 0xc0000000, pic[22]); | |
b5ff1b31 | 518 | |
f93eb9ff AZ |
519 | integrator_binfo.ram_size = ram_size; |
520 | integrator_binfo.kernel_filename = kernel_filename; | |
521 | integrator_binfo.kernel_cmdline = kernel_cmdline; | |
522 | integrator_binfo.initrd_filename = initrd_filename; | |
3aaa8dfa | 523 | arm_load_kernel(cpu, &integrator_binfo); |
b5ff1b31 FB |
524 | } |
525 | ||
f80f9ec9 | 526 | static QEMUMachine integratorcp_machine = { |
4b32e168 AL |
527 | .name = "integratorcp", |
528 | .desc = "ARM Integrator/CP (ARM926EJ-S)", | |
529 | .init = integratorcp_init, | |
0c257437 | 530 | .is_default = 1, |
b5ff1b31 | 531 | }; |
a7086888 | 532 | |
f80f9ec9 AL |
533 | static void integratorcp_machine_init(void) |
534 | { | |
535 | qemu_register_machine(&integratorcp_machine); | |
536 | } | |
537 | ||
538 | machine_init(integratorcp_machine_init); | |
539 | ||
999e12bb | 540 | static Property core_properties[] = { |
257ec289 | 541 | DEFINE_PROP_UINT32("memsz", IntegratorCMState, memsz, 0), |
999e12bb AL |
542 | DEFINE_PROP_END_OF_LIST(), |
543 | }; | |
544 | ||
545 | static void core_class_init(ObjectClass *klass, void *data) | |
546 | { | |
39bffca2 | 547 | DeviceClass *dc = DEVICE_CLASS(klass); |
999e12bb AL |
548 | SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); |
549 | ||
550 | k->init = integratorcm_init; | |
39bffca2 | 551 | dc->props = core_properties; |
999e12bb AL |
552 | } |
553 | ||
8c43a6f0 | 554 | static const TypeInfo core_info = { |
257ec289 | 555 | .name = TYPE_INTEGRATOR_CM, |
39bffca2 | 556 | .parent = TYPE_SYS_BUS_DEVICE, |
257ec289 | 557 | .instance_size = sizeof(IntegratorCMState), |
39bffca2 | 558 | .class_init = core_class_init, |
999e12bb AL |
559 | }; |
560 | ||
561 | static void icp_pic_class_init(ObjectClass *klass, void *data) | |
562 | { | |
563 | SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | |
564 | ||
565 | sdc->init = icp_pic_init; | |
566 | } | |
567 | ||
8c43a6f0 | 568 | static const TypeInfo icp_pic_info = { |
91b64626 | 569 | .name = TYPE_INTEGRATOR_PIC, |
39bffca2 AL |
570 | .parent = TYPE_SYS_BUS_DEVICE, |
571 | .instance_size = sizeof(icp_pic_state), | |
572 | .class_init = icp_pic_class_init, | |
ee6847d1 GH |
573 | }; |
574 | ||
83f7d43a | 575 | static void integratorcp_register_types(void) |
a7086888 | 576 | { |
39bffca2 AL |
577 | type_register_static(&icp_pic_info); |
578 | type_register_static(&core_info); | |
a7086888 PB |
579 | } |
580 | ||
83f7d43a | 581 | type_init(integratorcp_register_types) |