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