root / hw / realview.c @ 91011d4f
History | View | Annotate | Download (8 kB)
1 | 5fafdf24 | ths | /*
|
---|---|---|---|
2 | e69954b9 | pbrook | * ARM RealView Baseboard System emulation.
|
3 | e69954b9 | pbrook | *
|
4 | a1bb27b1 | pbrook | * Copyright (c) 2006-2007 CodeSourcery.
|
5 | e69954b9 | pbrook | * Written by Paul Brook
|
6 | e69954b9 | pbrook | *
|
7 | e69954b9 | pbrook | * This code is licenced under the GPL.
|
8 | e69954b9 | pbrook | */
|
9 | e69954b9 | pbrook | |
10 | 2e9bdce5 | Paul Brook | #include "sysbus.h" |
11 | 87ecb68b | pbrook | #include "arm-misc.h" |
12 | 87ecb68b | pbrook | #include "primecell.h" |
13 | 87ecb68b | pbrook | #include "devices.h" |
14 | 87ecb68b | pbrook | #include "pci.h" |
15 | 87ecb68b | pbrook | #include "net.h" |
16 | 87ecb68b | pbrook | #include "sysemu.h" |
17 | 87ecb68b | pbrook | #include "boards.h" |
18 | e69954b9 | pbrook | |
19 | e69954b9 | pbrook | /* Board init. */
|
20 | e69954b9 | pbrook | |
21 | f93eb9ff | balrog | static struct arm_boot_info realview_binfo = { |
22 | f93eb9ff | balrog | .loader_start = 0x0,
|
23 | 52b43737 | pbrook | .smp_loader_start = 0x80000000,
|
24 | f93eb9ff | balrog | .board_id = 0x33b,
|
25 | f93eb9ff | balrog | }; |
26 | f93eb9ff | balrog | |
27 | be0f204a | Paul Brook | static void secondary_cpu_reset(void *opaque) |
28 | be0f204a | Paul Brook | { |
29 | be0f204a | Paul Brook | CPUState *env = opaque; |
30 | be0f204a | Paul Brook | |
31 | be0f204a | Paul Brook | cpu_reset(env); |
32 | be0f204a | Paul Brook | /* Set entry point for secondary CPUs. This assumes we're using
|
33 | be0f204a | Paul Brook | the init code from arm_boot.c. Real hardware resets all CPUs
|
34 | be0f204a | Paul Brook | the same. */
|
35 | be0f204a | Paul Brook | env->regs[15] = 0x80000000; |
36 | be0f204a | Paul Brook | } |
37 | be0f204a | Paul Brook | |
38 | c988bfad | Paul Brook | enum realview_board_type {
|
39 | c988bfad | Paul Brook | BOARD_EB, |
40 | c988bfad | Paul Brook | BOARD_EB_MPCORE |
41 | c988bfad | Paul Brook | }; |
42 | c988bfad | Paul Brook | |
43 | c227f099 | Anthony Liguori | static void realview_init(ram_addr_t ram_size, |
44 | 3023f332 | aliguori | const char *boot_device, |
45 | e69954b9 | pbrook | const char *kernel_filename, const char *kernel_cmdline, |
46 | c988bfad | Paul Brook | const char *initrd_filename, const char *cpu_model, |
47 | c988bfad | Paul Brook | enum realview_board_type board_type)
|
48 | e69954b9 | pbrook | { |
49 | c988bfad | Paul Brook | CPUState *env = NULL;
|
50 | c227f099 | Anthony Liguori | ram_addr_t ram_offset; |
51 | 0027b06d | Paul Brook | DeviceState *dev; |
52 | c988bfad | Paul Brook | SysBusDevice *busdev; |
53 | fe7e8758 | Paul Brook | qemu_irq *irqp; |
54 | fe7e8758 | Paul Brook | qemu_irq pic[64];
|
55 | e69954b9 | pbrook | PCIBus *pci_bus; |
56 | e69954b9 | pbrook | NICInfo *nd; |
57 | e69954b9 | pbrook | int n;
|
58 | e69954b9 | pbrook | int done_smc = 0; |
59 | 9ee6e8bb | pbrook | qemu_irq cpu_irq[4];
|
60 | c988bfad | Paul Brook | int is_mpcore = (board_type == BOARD_EB_MPCORE);
|
61 | 26e92f65 | Paul Brook | uint32_t proc_id = 0;
|
62 | e69954b9 | pbrook | |
63 | c988bfad | Paul Brook | for (n = 0; n < smp_cpus; n++) { |
64 | 9ee6e8bb | pbrook | env = cpu_init(cpu_model); |
65 | 9ee6e8bb | pbrook | if (!env) {
|
66 | 9ee6e8bb | pbrook | fprintf(stderr, "Unable to find CPU definition\n");
|
67 | 9ee6e8bb | pbrook | exit(1);
|
68 | 9ee6e8bb | pbrook | } |
69 | fe7e8758 | Paul Brook | irqp = arm_pic_init_cpu(env); |
70 | fe7e8758 | Paul Brook | cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; |
71 | 9ee6e8bb | pbrook | if (n > 0) { |
72 | be0f204a | Paul Brook | qemu_register_reset(secondary_cpu_reset, env); |
73 | 9ee6e8bb | pbrook | } |
74 | aaed909a | bellard | } |
75 | 26e92f65 | Paul Brook | if (arm_feature(env, ARM_FEATURE_V7)) {
|
76 | 26e92f65 | Paul Brook | proc_id = 0x0e000000;
|
77 | 26e92f65 | Paul Brook | } else if (arm_feature(env, ARM_FEATURE_V6K)) { |
78 | 26e92f65 | Paul Brook | proc_id = 0x06000000;
|
79 | 26e92f65 | Paul Brook | } else if (arm_feature(env, ARM_FEATURE_V6)) { |
80 | 26e92f65 | Paul Brook | proc_id = 0x04000000;
|
81 | 26e92f65 | Paul Brook | } else {
|
82 | 26e92f65 | Paul Brook | proc_id = 0x02000000;
|
83 | 26e92f65 | Paul Brook | } |
84 | aaed909a | bellard | |
85 | 7ffab4d7 | pbrook | ram_offset = qemu_ram_alloc(ram_size); |
86 | 1235fc06 | ths | /* ??? RAM should repeat to fill physical memory space. */
|
87 | e69954b9 | pbrook | /* SDRAM at address zero. */
|
88 | 7ffab4d7 | pbrook | cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
|
89 | e69954b9 | pbrook | |
90 | 26e92f65 | Paul Brook | arm_sysctl_init(0x10000000, 0xc1400400, proc_id); |
91 | 9ee6e8bb | pbrook | |
92 | c988bfad | Paul Brook | if (is_mpcore) {
|
93 | c988bfad | Paul Brook | dev = qdev_create(NULL, "realview_mpcore"); |
94 | c988bfad | Paul Brook | qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
|
95 | c988bfad | Paul Brook | qdev_init_nofail(dev); |
96 | c988bfad | Paul Brook | busdev = sysbus_from_qdev(dev); |
97 | c988bfad | Paul Brook | for (n = 0; n < smp_cpus; n++) { |
98 | c988bfad | Paul Brook | sysbus_connect_irq(busdev, n, cpu_irq[n]); |
99 | c988bfad | Paul Brook | } |
100 | 9ee6e8bb | pbrook | } else {
|
101 | c988bfad | Paul Brook | dev = sysbus_create_simple("realview_gic", 0x10040000, cpu_irq[0]); |
102 | fe7e8758 | Paul Brook | } |
103 | fe7e8758 | Paul Brook | for (n = 0; n < 64; n++) { |
104 | 067a3ddc | Paul Brook | pic[n] = qdev_get_gpio_in(dev, n); |
105 | 9ee6e8bb | pbrook | } |
106 | 9ee6e8bb | pbrook | |
107 | 86394e96 | Paul Brook | sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]); |
108 | 86394e96 | Paul Brook | sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]); |
109 | e69954b9 | pbrook | |
110 | a7d518a6 | Paul Brook | sysbus_create_simple("pl011", 0x10009000, pic[12]); |
111 | a7d518a6 | Paul Brook | sysbus_create_simple("pl011", 0x1000a000, pic[13]); |
112 | a7d518a6 | Paul Brook | sysbus_create_simple("pl011", 0x1000b000, pic[14]); |
113 | a7d518a6 | Paul Brook | sysbus_create_simple("pl011", 0x1000c000, pic[15]); |
114 | e69954b9 | pbrook | |
115 | e69954b9 | pbrook | /* DMA controller is optional, apparently. */
|
116 | b4496b13 | Paul Brook | sysbus_create_simple("pl081", 0x10030000, pic[24]); |
117 | e69954b9 | pbrook | |
118 | 6a824ec3 | Paul Brook | sysbus_create_simple("sp804", 0x10011000, pic[4]); |
119 | 6a824ec3 | Paul Brook | sysbus_create_simple("sp804", 0x10012000, pic[5]); |
120 | e69954b9 | pbrook | |
121 | 2e9bdce5 | Paul Brook | sysbus_create_simple("pl110_versatile", 0x10020000, pic[23]); |
122 | e69954b9 | pbrook | |
123 | aa9311d8 | Paul Brook | sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL); |
124 | a1bb27b1 | pbrook | |
125 | a63bdb31 | Paul Brook | sysbus_create_simple("pl031", 0x10017000, pic[10]); |
126 | 7e1543c2 | pbrook | |
127 | 0027b06d | Paul Brook | dev = sysbus_create_varargs("realview_pci", 0x60000000, |
128 | 0027b06d | Paul Brook | pic[48], pic[49], pic[50], pic[51], NULL); |
129 | 02e2da45 | Paul Brook | pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
|
130 | e69954b9 | pbrook | if (usb_enabled) {
|
131 | 5b19d9a2 | Gerd Hoffmann | usb_ohci_init_pci(pci_bus, -1);
|
132 | e69954b9 | pbrook | } |
133 | 9be5dafe | Paul Brook | n = drive_get_max_bus(IF_SCSI); |
134 | 9be5dafe | Paul Brook | while (n >= 0) { |
135 | 9be5dafe | Paul Brook | pci_create_simple(pci_bus, -1, "lsi53c895a"); |
136 | 9be5dafe | Paul Brook | n--; |
137 | e69954b9 | pbrook | } |
138 | e69954b9 | pbrook | for(n = 0; n < nb_nics; n++) { |
139 | e69954b9 | pbrook | nd = &nd_table[n]; |
140 | 0ae18cee | aliguori | |
141 | 0ae18cee | aliguori | if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) { |
142 | d537cf6c | pbrook | smc91c111_init(nd, 0x4e000000, pic[28]); |
143 | 0ae18cee | aliguori | done_smc = 1;
|
144 | e69954b9 | pbrook | } else {
|
145 | 07caea31 | Markus Armbruster | pci_nic_init_nofail(nd, "rtl8139", NULL); |
146 | e69954b9 | pbrook | } |
147 | e69954b9 | pbrook | } |
148 | e69954b9 | pbrook | |
149 | e69954b9 | pbrook | /* Memory map for RealView Emulation Baseboard: */
|
150 | e69954b9 | pbrook | /* 0x10000000 System registers. */
|
151 | e69954b9 | pbrook | /* 0x10001000 System controller. */
|
152 | e69954b9 | pbrook | /* 0x10002000 Two-Wire Serial Bus. */
|
153 | e69954b9 | pbrook | /* 0x10003000 Reserved. */
|
154 | e69954b9 | pbrook | /* 0x10004000 AACI. */
|
155 | e69954b9 | pbrook | /* 0x10005000 MCI. */
|
156 | e69954b9 | pbrook | /* 0x10006000 KMI0. */
|
157 | e69954b9 | pbrook | /* 0x10007000 KMI1. */
|
158 | e69954b9 | pbrook | /* 0x10008000 Character LCD. */
|
159 | e69954b9 | pbrook | /* 0x10009000 UART0. */
|
160 | e69954b9 | pbrook | /* 0x1000a000 UART1. */
|
161 | e69954b9 | pbrook | /* 0x1000b000 UART2. */
|
162 | e69954b9 | pbrook | /* 0x1000c000 UART3. */
|
163 | e69954b9 | pbrook | /* 0x1000d000 SSPI. */
|
164 | e69954b9 | pbrook | /* 0x1000e000 SCI. */
|
165 | e69954b9 | pbrook | /* 0x1000f000 Reserved. */
|
166 | e69954b9 | pbrook | /* 0x10010000 Watchdog. */
|
167 | e69954b9 | pbrook | /* 0x10011000 Timer 0+1. */
|
168 | e69954b9 | pbrook | /* 0x10012000 Timer 2+3. */
|
169 | e69954b9 | pbrook | /* 0x10013000 GPIO 0. */
|
170 | e69954b9 | pbrook | /* 0x10014000 GPIO 1. */
|
171 | e69954b9 | pbrook | /* 0x10015000 GPIO 2. */
|
172 | e69954b9 | pbrook | /* 0x10016000 Reserved. */
|
173 | 7e1543c2 | pbrook | /* 0x10017000 RTC. */
|
174 | e69954b9 | pbrook | /* 0x10018000 DMC. */
|
175 | e69954b9 | pbrook | /* 0x10019000 PCI controller config. */
|
176 | e69954b9 | pbrook | /* 0x10020000 CLCD. */
|
177 | e69954b9 | pbrook | /* 0x10030000 DMA Controller. */
|
178 | 9ee6e8bb | pbrook | /* 0x10040000 GIC1. */
|
179 | 9ee6e8bb | pbrook | /* 0x10050000 GIC2. */
|
180 | 9ee6e8bb | pbrook | /* 0x10060000 GIC3. */
|
181 | 9ee6e8bb | pbrook | /* 0x10070000 GIC4. */
|
182 | e69954b9 | pbrook | /* 0x10080000 SMC. */
|
183 | e69954b9 | pbrook | /* 0x40000000 NOR flash. */
|
184 | e69954b9 | pbrook | /* 0x44000000 DoC flash. */
|
185 | e69954b9 | pbrook | /* 0x48000000 SRAM. */
|
186 | e69954b9 | pbrook | /* 0x4c000000 Configuration flash. */
|
187 | e69954b9 | pbrook | /* 0x4e000000 Ethernet. */
|
188 | e69954b9 | pbrook | /* 0x4f000000 USB. */
|
189 | e69954b9 | pbrook | /* 0x50000000 PISMO. */
|
190 | e69954b9 | pbrook | /* 0x54000000 PISMO. */
|
191 | e69954b9 | pbrook | /* 0x58000000 PISMO. */
|
192 | e69954b9 | pbrook | /* 0x5c000000 PISMO. */
|
193 | e69954b9 | pbrook | /* 0x60000000 PCI. */
|
194 | e69954b9 | pbrook | /* 0x61000000 PCI Self Config. */
|
195 | e69954b9 | pbrook | /* 0x62000000 PCI Config. */
|
196 | e69954b9 | pbrook | /* 0x63000000 PCI IO. */
|
197 | e69954b9 | pbrook | /* 0x64000000 PCI mem 0. */
|
198 | e69954b9 | pbrook | /* 0x68000000 PCI mem 1. */
|
199 | e69954b9 | pbrook | /* 0x6c000000 PCI mem 2. */
|
200 | e69954b9 | pbrook | |
201 | 7ffab4d7 | pbrook | /* ??? Hack to map an additional page of ram for the secondary CPU
|
202 | 7ffab4d7 | pbrook | startup code. I guess this works on real hardware because the
|
203 | 7ffab4d7 | pbrook | BootROM happens to be in ROM/flash or in memory that isn't clobbered
|
204 | 7ffab4d7 | pbrook | until after Linux boots the secondary CPUs. */
|
205 | 7ffab4d7 | pbrook | ram_offset = qemu_ram_alloc(0x1000);
|
206 | 7ffab4d7 | pbrook | cpu_register_physical_memory(0x80000000, 0x1000, ram_offset | IO_MEM_RAM); |
207 | 7ffab4d7 | pbrook | |
208 | f93eb9ff | balrog | realview_binfo.ram_size = ram_size; |
209 | f93eb9ff | balrog | realview_binfo.kernel_filename = kernel_filename; |
210 | f93eb9ff | balrog | realview_binfo.kernel_cmdline = kernel_cmdline; |
211 | f93eb9ff | balrog | realview_binfo.initrd_filename = initrd_filename; |
212 | c988bfad | Paul Brook | realview_binfo.nb_cpus = smp_cpus; |
213 | f93eb9ff | balrog | arm_load_kernel(first_cpu, &realview_binfo); |
214 | e69954b9 | pbrook | } |
215 | e69954b9 | pbrook | |
216 | c988bfad | Paul Brook | static void realview_eb_init(ram_addr_t ram_size, |
217 | c988bfad | Paul Brook | const char *boot_device, |
218 | c988bfad | Paul Brook | const char *kernel_filename, const char *kernel_cmdline, |
219 | c988bfad | Paul Brook | const char *initrd_filename, const char *cpu_model) |
220 | c988bfad | Paul Brook | { |
221 | c988bfad | Paul Brook | if (!cpu_model) {
|
222 | c988bfad | Paul Brook | cpu_model = "arm926";
|
223 | c988bfad | Paul Brook | } |
224 | c988bfad | Paul Brook | realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline, |
225 | c988bfad | Paul Brook | initrd_filename, cpu_model, BOARD_EB); |
226 | c988bfad | Paul Brook | } |
227 | c988bfad | Paul Brook | |
228 | c988bfad | Paul Brook | static void realview_eb_mpcore_init(ram_addr_t ram_size, |
229 | c988bfad | Paul Brook | const char *boot_device, |
230 | c988bfad | Paul Brook | const char *kernel_filename, const char *kernel_cmdline, |
231 | c988bfad | Paul Brook | const char *initrd_filename, const char *cpu_model) |
232 | c988bfad | Paul Brook | { |
233 | c988bfad | Paul Brook | if (!cpu_model) {
|
234 | c988bfad | Paul Brook | cpu_model = "arm11mpcore";
|
235 | c988bfad | Paul Brook | } |
236 | c988bfad | Paul Brook | realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline, |
237 | c988bfad | Paul Brook | initrd_filename, cpu_model, BOARD_EB_MPCORE); |
238 | c988bfad | Paul Brook | } |
239 | c988bfad | Paul Brook | |
240 | c988bfad | Paul Brook | static QEMUMachine realview_eb_machine = {
|
241 | c988bfad | Paul Brook | .name = "realview-eb",
|
242 | c9b1ae2c | blueswir1 | .desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)",
|
243 | c988bfad | Paul Brook | .init = realview_eb_init, |
244 | c988bfad | Paul Brook | .use_scsi = 1,
|
245 | c988bfad | Paul Brook | }; |
246 | c988bfad | Paul Brook | |
247 | c988bfad | Paul Brook | static QEMUMachine realview_eb_mpcore_machine = {
|
248 | c988bfad | Paul Brook | .name = "realview-eb-mpcore",
|
249 | c988bfad | Paul Brook | .desc = "ARM RealView Emulation Baseboard (ARM11MPCore)",
|
250 | c988bfad | Paul Brook | .init = realview_eb_mpcore_init, |
251 | c9b1ae2c | blueswir1 | .use_scsi = 1,
|
252 | c988bfad | Paul Brook | .max_cpus = 4,
|
253 | e69954b9 | pbrook | }; |
254 | f80f9ec9 | Anthony Liguori | |
255 | f80f9ec9 | Anthony Liguori | static void realview_machine_init(void) |
256 | f80f9ec9 | Anthony Liguori | { |
257 | c988bfad | Paul Brook | qemu_register_machine(&realview_eb_machine); |
258 | c988bfad | Paul Brook | qemu_register_machine(&realview_eb_mpcore_machine); |
259 | f80f9ec9 | Anthony Liguori | } |
260 | f80f9ec9 | Anthony Liguori | |
261 | f80f9ec9 | Anthony Liguori | machine_init(realview_machine_init); |