Statistics
| Branch: | Revision:

root / hw / realview.c @ 7830cf78

History | View | Annotate | Download (12.6 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 8e31bf38 Matthew Fernandez
 * This code is licensed 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 a2cb15b0 Michael S. Tsirkin
#include "pci/pci.h"
15 1422e32d Paolo Bonzini
#include "net/net.h"
16 9c17d615 Paolo Bonzini
#include "sysemu/sysemu.h"
17 87ecb68b pbrook
#include "boards.h"
18 d1157ca4 Oskar Andero
#include "i2c.h"
19 9c17d615 Paolo Bonzini
#include "sysemu/blockdev.h"
20 022c62cb Paolo Bonzini
#include "exec/address-spaces.h"
21 e69954b9 pbrook
22 0ef849d7 Paul Brook
#define SMP_BOOT_ADDR 0xe0000000
23 078758d0 Evgeny Voevodin
#define SMP_BOOTREG_ADDR 0x10000030
24 eee48504 Paul Brook
25 e69954b9 pbrook
/* Board init.  */
26 e69954b9 pbrook
27 f93eb9ff balrog
static struct arm_boot_info realview_binfo = {
28 0ef849d7 Paul Brook
    .smp_loader_start = SMP_BOOT_ADDR,
29 078758d0 Evgeny Voevodin
    .smp_bootreg_addr = SMP_BOOTREG_ADDR,
30 f93eb9ff balrog
};
31 f93eb9ff balrog
32 f7c70325 Paul Brook
/* The following two lists must be consistent.  */
33 c988bfad Paul Brook
enum realview_board_type {
34 c988bfad Paul Brook
    BOARD_EB,
35 0ef849d7 Paul Brook
    BOARD_EB_MPCORE,
36 f7c70325 Paul Brook
    BOARD_PB_A8,
37 f7c70325 Paul Brook
    BOARD_PBX_A9,
38 f7c70325 Paul Brook
};
39 f7c70325 Paul Brook
40 d05ac8fa Blue Swirl
static const int realview_board_id[] = {
41 f7c70325 Paul Brook
    0x33b,
42 f7c70325 Paul Brook
    0x33b,
43 f7c70325 Paul Brook
    0x769,
44 f7c70325 Paul Brook
    0x76d
45 c988bfad Paul Brook
};
46 c988bfad Paul Brook
47 db4ff6f1 Peter Maydell
static void realview_init(QEMUMachineInitArgs *args,
48 db4ff6f1 Peter Maydell
                          enum realview_board_type board_type)
49 e69954b9 pbrook
{
50 9077f01b Andreas Färber
    ARMCPU *cpu = NULL;
51 9077f01b Andreas Färber
    CPUARMState *env;
52 35e87820 Avi Kivity
    MemoryRegion *sysmem = get_system_memory();
53 35e87820 Avi Kivity
    MemoryRegion *ram_lo = g_new(MemoryRegion, 1);
54 35e87820 Avi Kivity
    MemoryRegion *ram_hi = g_new(MemoryRegion, 1);
55 35e87820 Avi Kivity
    MemoryRegion *ram_alias = g_new(MemoryRegion, 1);
56 35e87820 Avi Kivity
    MemoryRegion *ram_hack = g_new(MemoryRegion, 1);
57 03a0e944 Peter Maydell
    DeviceState *dev, *sysctl, *gpio2, *pl041;
58 c988bfad Paul Brook
    SysBusDevice *busdev;
59 fe7e8758 Paul Brook
    qemu_irq *irqp;
60 fe7e8758 Paul Brook
    qemu_irq pic[64];
61 26883c69 Peter Maydell
    qemu_irq mmc_irq[2];
62 e69954b9 pbrook
    PCIBus *pci_bus;
63 e69954b9 pbrook
    NICInfo *nd;
64 eee48504 Paul Brook
    i2c_bus *i2c;
65 e69954b9 pbrook
    int n;
66 0ef849d7 Paul Brook
    int done_nic = 0;
67 9ee6e8bb pbrook
    qemu_irq cpu_irq[4];
68 f7c70325 Paul Brook
    int is_mpcore = 0;
69 f7c70325 Paul Brook
    int is_pb = 0;
70 26e92f65 Paul Brook
    uint32_t proc_id = 0;
71 0ef849d7 Paul Brook
    uint32_t sys_id;
72 0ef849d7 Paul Brook
    ram_addr_t low_ram_size;
73 db4ff6f1 Peter Maydell
    ram_addr_t ram_size = args->ram_size;
74 e69954b9 pbrook
75 f7c70325 Paul Brook
    switch (board_type) {
76 f7c70325 Paul Brook
    case BOARD_EB:
77 f7c70325 Paul Brook
        break;
78 f7c70325 Paul Brook
    case BOARD_EB_MPCORE:
79 f7c70325 Paul Brook
        is_mpcore = 1;
80 f7c70325 Paul Brook
        break;
81 f7c70325 Paul Brook
    case BOARD_PB_A8:
82 f7c70325 Paul Brook
        is_pb = 1;
83 f7c70325 Paul Brook
        break;
84 f7c70325 Paul Brook
    case BOARD_PBX_A9:
85 f7c70325 Paul Brook
        is_mpcore = 1;
86 f7c70325 Paul Brook
        is_pb = 1;
87 f7c70325 Paul Brook
        break;
88 f7c70325 Paul Brook
    }
89 c988bfad Paul Brook
    for (n = 0; n < smp_cpus; n++) {
90 db4ff6f1 Peter Maydell
        cpu = cpu_arm_init(args->cpu_model);
91 9077f01b Andreas Färber
        if (!cpu) {
92 9ee6e8bb pbrook
            fprintf(stderr, "Unable to find CPU definition\n");
93 9ee6e8bb pbrook
            exit(1);
94 9ee6e8bb pbrook
        }
95 4bd74661 Andreas Färber
        irqp = arm_pic_init_cpu(cpu);
96 fe7e8758 Paul Brook
        cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ];
97 aaed909a bellard
    }
98 9077f01b Andreas Färber
    env = &cpu->env;
99 26e92f65 Paul Brook
    if (arm_feature(env, ARM_FEATURE_V7)) {
100 f7c70325 Paul Brook
        if (is_mpcore) {
101 f7c70325 Paul Brook
            proc_id = 0x0c000000;
102 f7c70325 Paul Brook
        } else {
103 f7c70325 Paul Brook
            proc_id = 0x0e000000;
104 f7c70325 Paul Brook
        }
105 26e92f65 Paul Brook
    } else if (arm_feature(env, ARM_FEATURE_V6K)) {
106 26e92f65 Paul Brook
        proc_id = 0x06000000;
107 26e92f65 Paul Brook
    } else if (arm_feature(env, ARM_FEATURE_V6)) {
108 26e92f65 Paul Brook
        proc_id = 0x04000000;
109 26e92f65 Paul Brook
    } else {
110 26e92f65 Paul Brook
        proc_id = 0x02000000;
111 26e92f65 Paul Brook
    }
112 aaed909a bellard
113 21a88941 Paul Brook
    if (is_pb && ram_size > 0x20000000) {
114 21a88941 Paul Brook
        /* Core tile RAM.  */
115 21a88941 Paul Brook
        low_ram_size = ram_size - 0x20000000;
116 21a88941 Paul Brook
        ram_size = 0x20000000;
117 c5705a77 Avi Kivity
        memory_region_init_ram(ram_lo, "realview.lowmem", low_ram_size);
118 c5705a77 Avi Kivity
        vmstate_register_ram_global(ram_lo);
119 35e87820 Avi Kivity
        memory_region_add_subregion(sysmem, 0x20000000, ram_lo);
120 21a88941 Paul Brook
    }
121 21a88941 Paul Brook
122 c5705a77 Avi Kivity
    memory_region_init_ram(ram_hi, "realview.highmem", ram_size);
123 c5705a77 Avi Kivity
    vmstate_register_ram_global(ram_hi);
124 0ef849d7 Paul Brook
    low_ram_size = ram_size;
125 0ef849d7 Paul Brook
    if (low_ram_size > 0x10000000)
126 0ef849d7 Paul Brook
      low_ram_size = 0x10000000;
127 e69954b9 pbrook
    /* SDRAM at address zero.  */
128 35e87820 Avi Kivity
    memory_region_init_alias(ram_alias, "realview.alias",
129 35e87820 Avi Kivity
                             ram_hi, 0, low_ram_size);
130 35e87820 Avi Kivity
    memory_region_add_subregion(sysmem, 0, ram_alias);
131 0ef849d7 Paul Brook
    if (is_pb) {
132 0ef849d7 Paul Brook
        /* And again at a high address.  */
133 35e87820 Avi Kivity
        memory_region_add_subregion(sysmem, 0x70000000, ram_hi);
134 0ef849d7 Paul Brook
    } else {
135 0ef849d7 Paul Brook
        ram_size = low_ram_size;
136 0ef849d7 Paul Brook
    }
137 e69954b9 pbrook
138 0ef849d7 Paul Brook
    sys_id = is_pb ? 0x01780500 : 0xc1400400;
139 26883c69 Peter Maydell
    sysctl = qdev_create(NULL, "realview_sysctl");
140 26883c69 Peter Maydell
    qdev_prop_set_uint32(sysctl, "sys_id", sys_id);
141 26883c69 Peter Maydell
    qdev_prop_set_uint32(sysctl, "proc_id", proc_id);
142 7a65c8cc Peter Maydell
    qdev_init_nofail(sysctl);
143 1356b98d Andreas Färber
    sysbus_mmio_map(SYS_BUS_DEVICE(sysctl), 0, 0x10000000);
144 9ee6e8bb pbrook
145 c988bfad Paul Brook
    if (is_mpcore) {
146 a8170e5e Avi Kivity
        hwaddr periphbase;
147 f7c70325 Paul Brook
        dev = qdev_create(NULL, is_pb ? "a9mpcore_priv": "realview_mpcore");
148 c988bfad Paul Brook
        qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
149 c988bfad Paul Brook
        qdev_init_nofail(dev);
150 1356b98d Andreas Färber
        busdev = SYS_BUS_DEVICE(dev);
151 f7c70325 Paul Brook
        if (is_pb) {
152 96eacf64 Peter Maydell
            periphbase = 0x1f000000;
153 f7c70325 Paul Brook
        } else {
154 96eacf64 Peter Maydell
            periphbase = 0x10100000;
155 f7c70325 Paul Brook
        }
156 96eacf64 Peter Maydell
        sysbus_mmio_map(busdev, 0, periphbase);
157 c988bfad Paul Brook
        for (n = 0; n < smp_cpus; n++) {
158 c988bfad Paul Brook
            sysbus_connect_irq(busdev, n, cpu_irq[n]);
159 c988bfad Paul Brook
        }
160 96eacf64 Peter Maydell
        sysbus_create_varargs("l2x0", periphbase + 0x2000, NULL);
161 96eacf64 Peter Maydell
        /* Both A9 and 11MPCore put the GIC CPU i/f at base + 0x100 */
162 96eacf64 Peter Maydell
        realview_binfo.gic_cpu_if_addr = periphbase + 0x100;
163 9ee6e8bb pbrook
    } else {
164 0ef849d7 Paul Brook
        uint32_t gic_addr = is_pb ? 0x1e000000 : 0x10040000;
165 0ef849d7 Paul Brook
        /* For now just create the nIRQ GIC, and ignore the others.  */
166 0ef849d7 Paul Brook
        dev = sysbus_create_simple("realview_gic", gic_addr, cpu_irq[0]);
167 fe7e8758 Paul Brook
    }
168 fe7e8758 Paul Brook
    for (n = 0; n < 64; n++) {
169 067a3ddc Paul Brook
        pic[n] = qdev_get_gpio_in(dev, n);
170 9ee6e8bb pbrook
    }
171 9ee6e8bb pbrook
172 03a0e944 Peter Maydell
    pl041 = qdev_create(NULL, "pl041");
173 03a0e944 Peter Maydell
    qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512);
174 03a0e944 Peter Maydell
    qdev_init_nofail(pl041);
175 1356b98d Andreas Färber
    sysbus_mmio_map(SYS_BUS_DEVICE(pl041), 0, 0x10004000);
176 1356b98d Andreas Färber
    sysbus_connect_irq(SYS_BUS_DEVICE(pl041), 0, pic[19]);
177 03a0e944 Peter Maydell
178 86394e96 Paul Brook
    sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]);
179 86394e96 Paul Brook
    sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]);
180 e69954b9 pbrook
181 a7d518a6 Paul Brook
    sysbus_create_simple("pl011", 0x10009000, pic[12]);
182 a7d518a6 Paul Brook
    sysbus_create_simple("pl011", 0x1000a000, pic[13]);
183 a7d518a6 Paul Brook
    sysbus_create_simple("pl011", 0x1000b000, pic[14]);
184 a7d518a6 Paul Brook
    sysbus_create_simple("pl011", 0x1000c000, pic[15]);
185 e69954b9 pbrook
186 e69954b9 pbrook
    /* DMA controller is optional, apparently.  */
187 b4496b13 Paul Brook
    sysbus_create_simple("pl081", 0x10030000, pic[24]);
188 e69954b9 pbrook
189 6a824ec3 Paul Brook
    sysbus_create_simple("sp804", 0x10011000, pic[4]);
190 6a824ec3 Paul Brook
    sysbus_create_simple("sp804", 0x10012000, pic[5]);
191 e69954b9 pbrook
192 26883c69 Peter Maydell
    sysbus_create_simple("pl061", 0x10013000, pic[6]);
193 26883c69 Peter Maydell
    sysbus_create_simple("pl061", 0x10014000, pic[7]);
194 26883c69 Peter Maydell
    gpio2 = sysbus_create_simple("pl061", 0x10015000, pic[8]);
195 26883c69 Peter Maydell
196 acb9b722 Peter Maydell
    sysbus_create_simple("pl111", 0x10020000, pic[23]);
197 e69954b9 pbrook
198 26883c69 Peter Maydell
    dev = sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL);
199 26883c69 Peter Maydell
    /* Wire up MMC card detect and read-only signals. These have
200 26883c69 Peter Maydell
     * to go to both the PL061 GPIO and the sysctl register.
201 26883c69 Peter Maydell
     * Note that the PL181 orders these lines (readonly,inserted)
202 26883c69 Peter Maydell
     * and the PL061 has them the other way about. Also the card
203 26883c69 Peter Maydell
     * detect line is inverted.
204 26883c69 Peter Maydell
     */
205 26883c69 Peter Maydell
    mmc_irq[0] = qemu_irq_split(
206 26883c69 Peter Maydell
        qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT),
207 26883c69 Peter Maydell
        qdev_get_gpio_in(gpio2, 1));
208 26883c69 Peter Maydell
    mmc_irq[1] = qemu_irq_split(
209 26883c69 Peter Maydell
        qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN),
210 26883c69 Peter Maydell
        qemu_irq_invert(qdev_get_gpio_in(gpio2, 0)));
211 26883c69 Peter Maydell
    qdev_connect_gpio_out(dev, 0, mmc_irq[0]);
212 26883c69 Peter Maydell
    qdev_connect_gpio_out(dev, 1, mmc_irq[1]);
213 a1bb27b1 pbrook
214 a63bdb31 Paul Brook
    sysbus_create_simple("pl031", 0x10017000, pic[10]);
215 7e1543c2 pbrook
216 0ef849d7 Paul Brook
    if (!is_pb) {
217 7d6e771f Peter Maydell
        dev = qdev_create(NULL, "realview_pci");
218 1356b98d Andreas Färber
        busdev = SYS_BUS_DEVICE(dev);
219 7d6e771f Peter Maydell
        qdev_init_nofail(dev);
220 7d6e771f Peter Maydell
        sysbus_mmio_map(busdev, 0, 0x61000000); /* PCI self-config */
221 7d6e771f Peter Maydell
        sysbus_mmio_map(busdev, 1, 0x62000000); /* PCI config */
222 7d6e771f Peter Maydell
        sysbus_mmio_map(busdev, 2, 0x63000000); /* PCI I/O */
223 7d6e771f Peter Maydell
        sysbus_connect_irq(busdev, 0, pic[48]);
224 7d6e771f Peter Maydell
        sysbus_connect_irq(busdev, 1, pic[49]);
225 7d6e771f Peter Maydell
        sysbus_connect_irq(busdev, 2, pic[50]);
226 7d6e771f Peter Maydell
        sysbus_connect_irq(busdev, 3, pic[51]);
227 0ef849d7 Paul Brook
        pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
228 094b287f zhlcindy@gmail.com
        if (usb_enabled(false)) {
229 afb9a60e Gerd Hoffmann
            pci_create_simple(pci_bus, -1, "pci-ohci");
230 0ef849d7 Paul Brook
        }
231 0ef849d7 Paul Brook
        n = drive_get_max_bus(IF_SCSI);
232 0ef849d7 Paul Brook
        while (n >= 0) {
233 0ef849d7 Paul Brook
            pci_create_simple(pci_bus, -1, "lsi53c895a");
234 0ef849d7 Paul Brook
            n--;
235 0ef849d7 Paul Brook
        }
236 e69954b9 pbrook
    }
237 e69954b9 pbrook
    for(n = 0; n < nb_nics; n++) {
238 e69954b9 pbrook
        nd = &nd_table[n];
239 0ae18cee aliguori
240 e6b3c8ca Peter Maydell
        if (!done_nic && (!nd->model ||
241 e6b3c8ca Peter Maydell
                    strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0)) {
242 0ef849d7 Paul Brook
            if (is_pb) {
243 0ef849d7 Paul Brook
                lan9118_init(nd, 0x4e000000, pic[28]);
244 0ef849d7 Paul Brook
            } else {
245 0ef849d7 Paul Brook
                smc91c111_init(nd, 0x4e000000, pic[28]);
246 0ef849d7 Paul Brook
            }
247 0ef849d7 Paul Brook
            done_nic = 1;
248 e69954b9 pbrook
        } else {
249 07caea31 Markus Armbruster
            pci_nic_init_nofail(nd, "rtl8139", NULL);
250 e69954b9 pbrook
        }
251 e69954b9 pbrook
    }
252 e69954b9 pbrook
253 d1157ca4 Oskar Andero
    dev = sysbus_create_simple("versatile_i2c", 0x10002000, NULL);
254 eee48504 Paul Brook
    i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
255 eee48504 Paul Brook
    i2c_create_slave(i2c, "ds1338", 0x68);
256 eee48504 Paul Brook
257 e69954b9 pbrook
    /* Memory map for RealView Emulation Baseboard:  */
258 e69954b9 pbrook
    /* 0x10000000 System registers.  */
259 e69954b9 pbrook
    /*  0x10001000 System controller.  */
260 eee48504 Paul Brook
    /* 0x10002000 Two-Wire Serial Bus.  */
261 e69954b9 pbrook
    /* 0x10003000 Reserved.  */
262 e69954b9 pbrook
    /*  0x10004000 AACI.  */
263 e69954b9 pbrook
    /*  0x10005000 MCI.  */
264 e69954b9 pbrook
    /* 0x10006000 KMI0.  */
265 e69954b9 pbrook
    /* 0x10007000 KMI1.  */
266 0ef849d7 Paul Brook
    /*  0x10008000 Character LCD. (EB) */
267 e69954b9 pbrook
    /* 0x10009000 UART0.  */
268 e69954b9 pbrook
    /* 0x1000a000 UART1.  */
269 e69954b9 pbrook
    /* 0x1000b000 UART2.  */
270 e69954b9 pbrook
    /* 0x1000c000 UART3.  */
271 e69954b9 pbrook
    /*  0x1000d000 SSPI.  */
272 e69954b9 pbrook
    /*  0x1000e000 SCI.  */
273 e69954b9 pbrook
    /* 0x1000f000 Reserved.  */
274 e69954b9 pbrook
    /*  0x10010000 Watchdog.  */
275 e69954b9 pbrook
    /* 0x10011000 Timer 0+1.  */
276 e69954b9 pbrook
    /* 0x10012000 Timer 2+3.  */
277 e69954b9 pbrook
    /*  0x10013000 GPIO 0.  */
278 e69954b9 pbrook
    /*  0x10014000 GPIO 1.  */
279 e69954b9 pbrook
    /*  0x10015000 GPIO 2.  */
280 0ef849d7 Paul Brook
    /*  0x10002000 Two-Wire Serial Bus - DVI. (PB) */
281 7e1543c2 pbrook
    /* 0x10017000 RTC.  */
282 e69954b9 pbrook
    /*  0x10018000 DMC.  */
283 e69954b9 pbrook
    /*  0x10019000 PCI controller config.  */
284 e69954b9 pbrook
    /*  0x10020000 CLCD.  */
285 e69954b9 pbrook
    /* 0x10030000 DMA Controller.  */
286 0ef849d7 Paul Brook
    /* 0x10040000 GIC1. (EB) */
287 0ef849d7 Paul Brook
    /*  0x10050000 GIC2. (EB) */
288 0ef849d7 Paul Brook
    /*  0x10060000 GIC3. (EB) */
289 0ef849d7 Paul Brook
    /*  0x10070000 GIC4. (EB) */
290 e69954b9 pbrook
    /*  0x10080000 SMC.  */
291 0ef849d7 Paul Brook
    /* 0x1e000000 GIC1. (PB) */
292 0ef849d7 Paul Brook
    /*  0x1e001000 GIC2. (PB) */
293 0ef849d7 Paul Brook
    /*  0x1e002000 GIC3. (PB) */
294 0ef849d7 Paul Brook
    /*  0x1e003000 GIC4. (PB) */
295 e69954b9 pbrook
    /*  0x40000000 NOR flash.  */
296 e69954b9 pbrook
    /*  0x44000000 DoC flash.  */
297 e69954b9 pbrook
    /*  0x48000000 SRAM.  */
298 e69954b9 pbrook
    /*  0x4c000000 Configuration flash.  */
299 e69954b9 pbrook
    /* 0x4e000000 Ethernet.  */
300 e69954b9 pbrook
    /*  0x4f000000 USB.  */
301 e69954b9 pbrook
    /*  0x50000000 PISMO.  */
302 e69954b9 pbrook
    /*  0x54000000 PISMO.  */
303 e69954b9 pbrook
    /*  0x58000000 PISMO.  */
304 e69954b9 pbrook
    /*  0x5c000000 PISMO.  */
305 e69954b9 pbrook
    /* 0x60000000 PCI.  */
306 e69954b9 pbrook
    /* 0x61000000 PCI Self Config.  */
307 e69954b9 pbrook
    /* 0x62000000 PCI Config.  */
308 e69954b9 pbrook
    /* 0x63000000 PCI IO.  */
309 e69954b9 pbrook
    /* 0x64000000 PCI mem 0.  */
310 e69954b9 pbrook
    /* 0x68000000 PCI mem 1.  */
311 e69954b9 pbrook
    /* 0x6c000000 PCI mem 2.  */
312 e69954b9 pbrook
313 7ffab4d7 pbrook
    /* ??? Hack to map an additional page of ram for the secondary CPU
314 7ffab4d7 pbrook
       startup code.  I guess this works on real hardware because the
315 7ffab4d7 pbrook
       BootROM happens to be in ROM/flash or in memory that isn't clobbered
316 7ffab4d7 pbrook
       until after Linux boots the secondary CPUs.  */
317 c5705a77 Avi Kivity
    memory_region_init_ram(ram_hack, "realview.hack", 0x1000);
318 c5705a77 Avi Kivity
    vmstate_register_ram_global(ram_hack);
319 35e87820 Avi Kivity
    memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, ram_hack);
320 7ffab4d7 pbrook
321 f93eb9ff balrog
    realview_binfo.ram_size = ram_size;
322 db4ff6f1 Peter Maydell
    realview_binfo.kernel_filename = args->kernel_filename;
323 db4ff6f1 Peter Maydell
    realview_binfo.kernel_cmdline = args->kernel_cmdline;
324 db4ff6f1 Peter Maydell
    realview_binfo.initrd_filename = args->initrd_filename;
325 c988bfad Paul Brook
    realview_binfo.nb_cpus = smp_cpus;
326 f7c70325 Paul Brook
    realview_binfo.board_id = realview_board_id[board_type];
327 21a88941 Paul Brook
    realview_binfo.loader_start = (board_type == BOARD_PB_A8 ? 0x70000000 : 0);
328 3aaa8dfa Andreas Färber
    arm_load_kernel(arm_env_get_cpu(first_cpu), &realview_binfo);
329 e69954b9 pbrook
}
330 e69954b9 pbrook
331 5f072e1f Eduardo Habkost
static void realview_eb_init(QEMUMachineInitArgs *args)
332 c988bfad Paul Brook
{
333 db4ff6f1 Peter Maydell
    if (!args->cpu_model) {
334 db4ff6f1 Peter Maydell
        args->cpu_model = "arm926";
335 c988bfad Paul Brook
    }
336 db4ff6f1 Peter Maydell
    realview_init(args, BOARD_EB);
337 c988bfad Paul Brook
}
338 c988bfad Paul Brook
339 5f072e1f Eduardo Habkost
static void realview_eb_mpcore_init(QEMUMachineInitArgs *args)
340 c988bfad Paul Brook
{
341 db4ff6f1 Peter Maydell
    if (!args->cpu_model) {
342 db4ff6f1 Peter Maydell
        args->cpu_model = "arm11mpcore";
343 c988bfad Paul Brook
    }
344 db4ff6f1 Peter Maydell
    realview_init(args, BOARD_EB_MPCORE);
345 c988bfad Paul Brook
}
346 c988bfad Paul Brook
347 5f072e1f Eduardo Habkost
static void realview_pb_a8_init(QEMUMachineInitArgs *args)
348 0ef849d7 Paul Brook
{
349 db4ff6f1 Peter Maydell
    if (!args->cpu_model) {
350 db4ff6f1 Peter Maydell
        args->cpu_model = "cortex-a8";
351 0ef849d7 Paul Brook
    }
352 db4ff6f1 Peter Maydell
    realview_init(args, BOARD_PB_A8);
353 0ef849d7 Paul Brook
}
354 0ef849d7 Paul Brook
355 5f072e1f Eduardo Habkost
static void realview_pbx_a9_init(QEMUMachineInitArgs *args)
356 f7c70325 Paul Brook
{
357 db4ff6f1 Peter Maydell
    if (!args->cpu_model) {
358 db4ff6f1 Peter Maydell
        args->cpu_model = "cortex-a9";
359 f7c70325 Paul Brook
    }
360 db4ff6f1 Peter Maydell
    realview_init(args, BOARD_PBX_A9);
361 f7c70325 Paul Brook
}
362 f7c70325 Paul Brook
363 c988bfad Paul Brook
static QEMUMachine realview_eb_machine = {
364 c988bfad Paul Brook
    .name = "realview-eb",
365 c9b1ae2c blueswir1
    .desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)",
366 c988bfad Paul Brook
    .init = realview_eb_init,
367 2d0d2837 Christian Borntraeger
    .block_default_type = IF_SCSI,
368 e4ada29e Avik Sil
    DEFAULT_MACHINE_OPTIONS,
369 c988bfad Paul Brook
};
370 c988bfad Paul Brook
371 c988bfad Paul Brook
static QEMUMachine realview_eb_mpcore_machine = {
372 c988bfad Paul Brook
    .name = "realview-eb-mpcore",
373 c988bfad Paul Brook
    .desc = "ARM RealView Emulation Baseboard (ARM11MPCore)",
374 c988bfad Paul Brook
    .init = realview_eb_mpcore_init,
375 2d0d2837 Christian Borntraeger
    .block_default_type = IF_SCSI,
376 c988bfad Paul Brook
    .max_cpus = 4,
377 e4ada29e Avik Sil
    DEFAULT_MACHINE_OPTIONS,
378 e69954b9 pbrook
};
379 f80f9ec9 Anthony Liguori
380 0ef849d7 Paul Brook
static QEMUMachine realview_pb_a8_machine = {
381 0ef849d7 Paul Brook
    .name = "realview-pb-a8",
382 0ef849d7 Paul Brook
    .desc = "ARM RealView Platform Baseboard for Cortex-A8",
383 0ef849d7 Paul Brook
    .init = realview_pb_a8_init,
384 e4ada29e Avik Sil
    DEFAULT_MACHINE_OPTIONS,
385 f7c70325 Paul Brook
};
386 f7c70325 Paul Brook
387 f7c70325 Paul Brook
static QEMUMachine realview_pbx_a9_machine = {
388 f7c70325 Paul Brook
    .name = "realview-pbx-a9",
389 f7c70325 Paul Brook
    .desc = "ARM RealView Platform Baseboard Explore for Cortex-A9",
390 f7c70325 Paul Brook
    .init = realview_pbx_a9_init,
391 2d0d2837 Christian Borntraeger
    .block_default_type = IF_SCSI,
392 f7c70325 Paul Brook
    .max_cpus = 4,
393 e4ada29e Avik Sil
    DEFAULT_MACHINE_OPTIONS,
394 0ef849d7 Paul Brook
};
395 0ef849d7 Paul Brook
396 f80f9ec9 Anthony Liguori
static void realview_machine_init(void)
397 f80f9ec9 Anthony Liguori
{
398 c988bfad Paul Brook
    qemu_register_machine(&realview_eb_machine);
399 c988bfad Paul Brook
    qemu_register_machine(&realview_eb_mpcore_machine);
400 0ef849d7 Paul Brook
    qemu_register_machine(&realview_pb_a8_machine);
401 f7c70325 Paul Brook
    qemu_register_machine(&realview_pbx_a9_machine);
402 f80f9ec9 Anthony Liguori
}
403 f80f9ec9 Anthony Liguori
404 f80f9ec9 Anthony Liguori
machine_init(realview_machine_init);