Statistics
| Branch: | Revision:

root / hw / syborg.c @ 78895427

History | View | Annotate | Download (3.9 kB)

1 4af39611 Paul Brook
/*
2 4af39611 Paul Brook
 * Syborg (Symbian Virtual Platform) reference board
3 4af39611 Paul Brook
 *
4 4af39611 Paul Brook
 * Copyright (c) 2009 CodeSourcery
5 4af39611 Paul Brook
 *
6 4af39611 Paul Brook
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 4af39611 Paul Brook
 * of this software and associated documentation files (the "Software"), to deal
8 4af39611 Paul Brook
 * in the Software without restriction, including without limitation the rights
9 4af39611 Paul Brook
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 4af39611 Paul Brook
 * copies of the Software, and to permit persons to whom the Software is
11 4af39611 Paul Brook
 * furnished to do so, subject to the following conditions:
12 4af39611 Paul Brook
 *
13 4af39611 Paul Brook
 * The above copyright notice and this permission notice shall be included in
14 4af39611 Paul Brook
 * all copies or substantial portions of the Software.
15 4af39611 Paul Brook
 *
16 4af39611 Paul Brook
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 4af39611 Paul Brook
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 4af39611 Paul Brook
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 4af39611 Paul Brook
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 4af39611 Paul Brook
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 4af39611 Paul Brook
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 4af39611 Paul Brook
 * THE SOFTWARE.
23 4af39611 Paul Brook
 */
24 4af39611 Paul Brook
25 4af39611 Paul Brook
#include "sysbus.h"
26 4af39611 Paul Brook
#include "boards.h"
27 4af39611 Paul Brook
#include "arm-misc.h"
28 4af39611 Paul Brook
#include "sysemu.h"
29 340d96e7 Paul Brook
#include "net.h"
30 4af39611 Paul Brook
31 4af39611 Paul Brook
static struct arm_boot_info syborg_binfo;
32 4af39611 Paul Brook
33 c227f099 Anthony Liguori
static void syborg_init(ram_addr_t ram_size,
34 4af39611 Paul Brook
                        const char *boot_device,
35 4af39611 Paul Brook
                        const char *kernel_filename, const char *kernel_cmdline,
36 4af39611 Paul Brook
                        const char *initrd_filename, const char *cpu_model)
37 4af39611 Paul Brook
{
38 4af39611 Paul Brook
    CPUState *env;
39 4af39611 Paul Brook
    qemu_irq *cpu_pic;
40 4af39611 Paul Brook
    qemu_irq pic[64];
41 c227f099 Anthony Liguori
    ram_addr_t ram_addr;
42 4af39611 Paul Brook
    DeviceState *dev;
43 4af39611 Paul Brook
    int i;
44 4af39611 Paul Brook
45 4af39611 Paul Brook
    if (!cpu_model)
46 4af39611 Paul Brook
        cpu_model = "cortex-a8";
47 4af39611 Paul Brook
    env = cpu_init(cpu_model);
48 4af39611 Paul Brook
    if (!env) {
49 4af39611 Paul Brook
        fprintf(stderr, "Unable to find CPU definition\n");
50 4af39611 Paul Brook
        exit(1);
51 4af39611 Paul Brook
    }
52 4af39611 Paul Brook
53 4af39611 Paul Brook
    /* RAM at address zero. */
54 1724f049 Alex Williamson
    ram_addr = qemu_ram_alloc(NULL, "syborg.ram", ram_size);
55 4af39611 Paul Brook
    cpu_register_physical_memory(0, ram_size, ram_addr | IO_MEM_RAM);
56 4af39611 Paul Brook
57 4af39611 Paul Brook
    cpu_pic = arm_pic_init_cpu(env);
58 4af39611 Paul Brook
    dev = sysbus_create_simple("syborg,interrupt", 0xC0000000,
59 4af39611 Paul Brook
                               cpu_pic[ARM_PIC_CPU_IRQ]);
60 4af39611 Paul Brook
    for (i = 0; i < 64; i++) {
61 067a3ddc Paul Brook
        pic[i] = qdev_get_gpio_in(dev, i);
62 4af39611 Paul Brook
    }
63 4af39611 Paul Brook
64 4af39611 Paul Brook
    sysbus_create_simple("syborg,rtc", 0xC0001000, NULL);
65 4af39611 Paul Brook
66 4af39611 Paul Brook
    dev = qdev_create(NULL, "syborg,timer");
67 ee6847d1 Gerd Hoffmann
    qdev_prop_set_uint32(dev, "frequency", 1000000);
68 e23a1b33 Markus Armbruster
    qdev_init_nofail(dev);
69 4af39611 Paul Brook
    sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xC0002000);
70 4af39611 Paul Brook
    sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[1]);
71 4af39611 Paul Brook
72 4af39611 Paul Brook
    sysbus_create_simple("syborg,keyboard", 0xC0003000, pic[2]);
73 4af39611 Paul Brook
    sysbus_create_simple("syborg,pointer", 0xC0004000, pic[3]);
74 4af39611 Paul Brook
    sysbus_create_simple("syborg,framebuffer", 0xC0005000, pic[4]);
75 4af39611 Paul Brook
    sysbus_create_simple("syborg,serial", 0xC0006000, pic[5]);
76 4af39611 Paul Brook
    sysbus_create_simple("syborg,serial", 0xC0007000, pic[6]);
77 4af39611 Paul Brook
    sysbus_create_simple("syborg,serial", 0xC0008000, pic[7]);
78 4af39611 Paul Brook
    sysbus_create_simple("syborg,serial", 0xC0009000, pic[8]);
79 4af39611 Paul Brook
80 97b15621 Gerd Hoffmann
    if (nd_table[0].vlan || nd_table[0].netdev) {
81 340d96e7 Paul Brook
        DeviceState *dev;
82 340d96e7 Paul Brook
        SysBusDevice *s;
83 340d96e7 Paul Brook
84 340d96e7 Paul Brook
        qemu_check_nic_model(&nd_table[0], "virtio");
85 340d96e7 Paul Brook
        dev = qdev_create(NULL, "syborg,virtio-net");
86 97b15621 Gerd Hoffmann
        qdev_set_nic_properties(dev, &nd_table[0]);
87 e23a1b33 Markus Armbruster
        qdev_init_nofail(dev);
88 340d96e7 Paul Brook
        s = sysbus_from_qdev(dev);
89 340d96e7 Paul Brook
        sysbus_mmio_map(s, 0, 0xc000c000);
90 340d96e7 Paul Brook
        sysbus_connect_irq(s, 0, pic[9]);
91 340d96e7 Paul Brook
    }
92 340d96e7 Paul Brook
93 4af39611 Paul Brook
    syborg_binfo.ram_size = ram_size;
94 4af39611 Paul Brook
    syborg_binfo.kernel_filename = kernel_filename;
95 4af39611 Paul Brook
    syborg_binfo.kernel_cmdline = kernel_cmdline;
96 4af39611 Paul Brook
    syborg_binfo.initrd_filename = initrd_filename;
97 4af39611 Paul Brook
    syborg_binfo.board_id = 0;
98 4af39611 Paul Brook
    arm_load_kernel(env, &syborg_binfo);
99 4af39611 Paul Brook
}
100 4af39611 Paul Brook
101 f80f9ec9 Anthony Liguori
static QEMUMachine syborg_machine = {
102 4af39611 Paul Brook
    .name = "syborg",
103 4af39611 Paul Brook
    .desc = "Syborg (Symbian Virtual Platform)",
104 4af39611 Paul Brook
    .init = syborg_init,
105 4af39611 Paul Brook
};
106 f80f9ec9 Anthony Liguori
107 f80f9ec9 Anthony Liguori
static void syborg_machine_init(void)
108 f80f9ec9 Anthony Liguori
{
109 f80f9ec9 Anthony Liguori
    qemu_register_machine(&syborg_machine);
110 f80f9ec9 Anthony Liguori
}
111 f80f9ec9 Anthony Liguori
112 f80f9ec9 Anthony Liguori
machine_init(syborg_machine_init);