]> git.proxmox.com Git - qemu.git/blame - hw/realview.c
Integrator/CP core qdev conversion
[qemu.git] / hw / realview.c
CommitLineData
5fafdf24 1/*
e69954b9
PB
2 * ARM RealView Baseboard System emulation.
3 *
a1bb27b1 4 * Copyright (c) 2006-2007 CodeSourcery.
e69954b9
PB
5 * Written by Paul Brook
6 *
7 * This code is licenced under the GPL.
8 */
9
2e9bdce5 10#include "sysbus.h"
87ecb68b
PB
11#include "arm-misc.h"
12#include "primecell.h"
13#include "devices.h"
14#include "pci.h"
15#include "net.h"
16#include "sysemu.h"
17#include "boards.h"
e69954b9
PB
18
19/* Board init. */
20
f93eb9ff
AZ
21static struct arm_boot_info realview_binfo = {
22 .loader_start = 0x0,
52b43737 23 .smp_loader_start = 0x80000000,
f93eb9ff
AZ
24 .board_id = 0x33b,
25};
26
fbe1b595 27static void realview_init(ram_addr_t ram_size,
3023f332 28 const char *boot_device,
e69954b9 29 const char *kernel_filename, const char *kernel_cmdline,
94fc95cd 30 const char *initrd_filename, const char *cpu_model)
e69954b9
PB
31{
32 CPUState *env;
7ffab4d7 33 ram_addr_t ram_offset;
d537cf6c 34 qemu_irq *pic;
e69954b9
PB
35 PCIBus *pci_bus;
36 NICInfo *nd;
37 int n;
38 int done_smc = 0;
9ee6e8bb
PB
39 qemu_irq cpu_irq[4];
40 int ncpu;
e69954b9 41
3371d272
PB
42 if (!cpu_model)
43 cpu_model = "arm926";
9ee6e8bb
PB
44 /* FIXME: obey smp_cpus. */
45 if (strcmp(cpu_model, "arm11mpcore") == 0) {
46 ncpu = 4;
47 } else {
48 ncpu = 1;
49 }
50
51 for (n = 0; n < ncpu; n++) {
52 env = cpu_init(cpu_model);
53 if (!env) {
54 fprintf(stderr, "Unable to find CPU definition\n");
55 exit(1);
56 }
57 pic = arm_pic_init_cpu(env);
58 cpu_irq[n] = pic[ARM_PIC_CPU_IRQ];
59 if (n > 0) {
60 /* Set entry point for secondary CPUs. This assumes we're using
61 the init code from arm_boot.c. Real hardware resets all CPUs
62 the same. */
63 env->regs[15] = 0x80000000;
64 }
aaed909a
FB
65 }
66
7ffab4d7 67 ram_offset = qemu_ram_alloc(ram_size);
1235fc06 68 /* ??? RAM should repeat to fill physical memory space. */
e69954b9 69 /* SDRAM at address zero. */
7ffab4d7 70 cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
e69954b9
PB
71
72 arm_sysctl_init(0x10000000, 0xc1400400);
9ee6e8bb
PB
73
74 if (ncpu == 1) {
75 /* ??? The documentation says GIC1 is nFIQ and either GIC2 or GIC3
76 is nIRQ (there are inconsistencies). However Linux 2.6.17 expects
77 GIC1 to be nIRQ and ignores all the others, so do that for now. */
78 pic = realview_gic_init(0x10040000, cpu_irq[0]);
79 } else {
80 pic = mpcore_irq_init(cpu_irq);
81 }
82
86394e96
PB
83 sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]);
84 sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]);
e69954b9 85
a7d518a6
PB
86 sysbus_create_simple("pl011", 0x10009000, pic[12]);
87 sysbus_create_simple("pl011", 0x1000a000, pic[13]);
88 sysbus_create_simple("pl011", 0x1000b000, pic[14]);
89 sysbus_create_simple("pl011", 0x1000c000, pic[15]);
e69954b9
PB
90
91 /* DMA controller is optional, apparently. */
d537cf6c 92 pl080_init(0x10030000, pic[24], 2);
e69954b9 93
d537cf6c
PB
94 sp804_init(0x10011000, pic[4]);
95 sp804_init(0x10012000, pic[5]);
e69954b9 96
2e9bdce5 97 sysbus_create_simple("pl110_versatile", 0x10020000, pic[23]);
e69954b9 98
aa9311d8 99 sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL);
a1bb27b1 100
a63bdb31 101 sysbus_create_simple("pl031", 0x10017000, pic[10]);
7e1543c2 102
e69954b9
PB
103 pci_bus = pci_vpb_init(pic, 48, 1);
104 if (usb_enabled) {
e24ad6f1 105 usb_ohci_init_pci(pci_bus, 3, -1);
e69954b9 106 }
9be5dafe
PB
107 n = drive_get_max_bus(IF_SCSI);
108 while (n >= 0) {
109 pci_create_simple(pci_bus, -1, "lsi53c895a");
110 n--;
e69954b9
PB
111 }
112 for(n = 0; n < nb_nics; n++) {
113 nd = &nd_table[n];
0ae18cee
AL
114
115 if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
d537cf6c 116 smc91c111_init(nd, 0x4e000000, pic[28]);
0ae18cee 117 done_smc = 1;
e69954b9 118 } else {
cb457d76 119 pci_nic_init(pci_bus, nd, -1, "rtl8139");
e69954b9
PB
120 }
121 }
122
123 /* Memory map for RealView Emulation Baseboard: */
124 /* 0x10000000 System registers. */
125 /* 0x10001000 System controller. */
126 /* 0x10002000 Two-Wire Serial Bus. */
127 /* 0x10003000 Reserved. */
128 /* 0x10004000 AACI. */
129 /* 0x10005000 MCI. */
130 /* 0x10006000 KMI0. */
131 /* 0x10007000 KMI1. */
132 /* 0x10008000 Character LCD. */
133 /* 0x10009000 UART0. */
134 /* 0x1000a000 UART1. */
135 /* 0x1000b000 UART2. */
136 /* 0x1000c000 UART3. */
137 /* 0x1000d000 SSPI. */
138 /* 0x1000e000 SCI. */
139 /* 0x1000f000 Reserved. */
140 /* 0x10010000 Watchdog. */
141 /* 0x10011000 Timer 0+1. */
142 /* 0x10012000 Timer 2+3. */
143 /* 0x10013000 GPIO 0. */
144 /* 0x10014000 GPIO 1. */
145 /* 0x10015000 GPIO 2. */
146 /* 0x10016000 Reserved. */
7e1543c2 147 /* 0x10017000 RTC. */
e69954b9
PB
148 /* 0x10018000 DMC. */
149 /* 0x10019000 PCI controller config. */
150 /* 0x10020000 CLCD. */
151 /* 0x10030000 DMA Controller. */
9ee6e8bb
PB
152 /* 0x10040000 GIC1. */
153 /* 0x10050000 GIC2. */
154 /* 0x10060000 GIC3. */
155 /* 0x10070000 GIC4. */
e69954b9
PB
156 /* 0x10080000 SMC. */
157 /* 0x40000000 NOR flash. */
158 /* 0x44000000 DoC flash. */
159 /* 0x48000000 SRAM. */
160 /* 0x4c000000 Configuration flash. */
161 /* 0x4e000000 Ethernet. */
162 /* 0x4f000000 USB. */
163 /* 0x50000000 PISMO. */
164 /* 0x54000000 PISMO. */
165 /* 0x58000000 PISMO. */
166 /* 0x5c000000 PISMO. */
167 /* 0x60000000 PCI. */
168 /* 0x61000000 PCI Self Config. */
169 /* 0x62000000 PCI Config. */
170 /* 0x63000000 PCI IO. */
171 /* 0x64000000 PCI mem 0. */
172 /* 0x68000000 PCI mem 1. */
173 /* 0x6c000000 PCI mem 2. */
174
7ffab4d7
PB
175 /* ??? Hack to map an additional page of ram for the secondary CPU
176 startup code. I guess this works on real hardware because the
177 BootROM happens to be in ROM/flash or in memory that isn't clobbered
178 until after Linux boots the secondary CPUs. */
179 ram_offset = qemu_ram_alloc(0x1000);
180 cpu_register_physical_memory(0x80000000, 0x1000, ram_offset | IO_MEM_RAM);
181
f93eb9ff
AZ
182 realview_binfo.ram_size = ram_size;
183 realview_binfo.kernel_filename = kernel_filename;
184 realview_binfo.kernel_cmdline = kernel_cmdline;
185 realview_binfo.initrd_filename = initrd_filename;
186 realview_binfo.nb_cpus = ncpu;
187 arm_load_kernel(first_cpu, &realview_binfo);
e69954b9
PB
188}
189
190QEMUMachine realview_machine = {
c9b1ae2c
BS
191 .name = "realview",
192 .desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)",
193 .init = realview_init,
c9b1ae2c 194 .use_scsi = 1,
e69954b9 195};