Statistics
| Branch: | Revision:

root / hw / syborg.c @ 40f16dd1

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 340d96e7 Paul Brook
#include "net.h"
29 4af39611 Paul Brook
30 4af39611 Paul Brook
static struct arm_boot_info syborg_binfo;
31 4af39611 Paul Brook
32 c227f099 Anthony Liguori
static void syborg_init(ram_addr_t ram_size,
33 4af39611 Paul Brook
                        const char *boot_device,
34 4af39611 Paul Brook
                        const char *kernel_filename, const char *kernel_cmdline,
35 4af39611 Paul Brook
                        const char *initrd_filename, const char *cpu_model)
36 4af39611 Paul Brook
{
37 4af39611 Paul Brook
    CPUState *env;
38 4af39611 Paul Brook
    qemu_irq *cpu_pic;
39 4af39611 Paul Brook
    qemu_irq pic[64];
40 c227f099 Anthony Liguori
    ram_addr_t ram_addr;
41 4af39611 Paul Brook
    DeviceState *dev;
42 4af39611 Paul Brook
    int i;
43 4af39611 Paul Brook
44 4af39611 Paul Brook
    if (!cpu_model)
45 4af39611 Paul Brook
        cpu_model = "cortex-a8";
46 4af39611 Paul Brook
    env = cpu_init(cpu_model);
47 4af39611 Paul Brook
    if (!env) {
48 4af39611 Paul Brook
        fprintf(stderr, "Unable to find CPU definition\n");
49 4af39611 Paul Brook
        exit(1);
50 4af39611 Paul Brook
    }
51 4af39611 Paul Brook
52 4af39611 Paul Brook
    /* RAM at address zero. */
53 1724f049 Alex Williamson
    ram_addr = qemu_ram_alloc(NULL, "syborg.ram", ram_size);
54 4af39611 Paul Brook
    cpu_register_physical_memory(0, ram_size, ram_addr | IO_MEM_RAM);
55 4af39611 Paul Brook
56 4af39611 Paul Brook
    cpu_pic = arm_pic_init_cpu(env);
57 4af39611 Paul Brook
    dev = sysbus_create_simple("syborg,interrupt", 0xC0000000,
58 4af39611 Paul Brook
                               cpu_pic[ARM_PIC_CPU_IRQ]);
59 4af39611 Paul Brook
    for (i = 0; i < 64; i++) {
60 067a3ddc Paul Brook
        pic[i] = qdev_get_gpio_in(dev, i);
61 4af39611 Paul Brook
    }
62 4af39611 Paul Brook
63 4af39611 Paul Brook
    sysbus_create_simple("syborg,rtc", 0xC0001000, NULL);
64 4af39611 Paul Brook
65 4af39611 Paul Brook
    dev = qdev_create(NULL, "syborg,timer");
66 ee6847d1 Gerd Hoffmann
    qdev_prop_set_uint32(dev, "frequency", 1000000);
67 e23a1b33 Markus Armbruster
    qdev_init_nofail(dev);
68 4af39611 Paul Brook
    sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xC0002000);
69 4af39611 Paul Brook
    sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[1]);
70 4af39611 Paul Brook
71 4af39611 Paul Brook
    sysbus_create_simple("syborg,keyboard", 0xC0003000, pic[2]);
72 4af39611 Paul Brook
    sysbus_create_simple("syborg,pointer", 0xC0004000, pic[3]);
73 4af39611 Paul Brook
    sysbus_create_simple("syborg,framebuffer", 0xC0005000, pic[4]);
74 4af39611 Paul Brook
    sysbus_create_simple("syborg,serial", 0xC0006000, pic[5]);
75 4af39611 Paul Brook
    sysbus_create_simple("syborg,serial", 0xC0007000, pic[6]);
76 4af39611 Paul Brook
    sysbus_create_simple("syborg,serial", 0xC0008000, pic[7]);
77 4af39611 Paul Brook
    sysbus_create_simple("syborg,serial", 0xC0009000, pic[8]);
78 4af39611 Paul Brook
79 97b15621 Gerd Hoffmann
    if (nd_table[0].vlan || nd_table[0].netdev) {
80 340d96e7 Paul Brook
        DeviceState *dev;
81 340d96e7 Paul Brook
        SysBusDevice *s;
82 340d96e7 Paul Brook
83 340d96e7 Paul Brook
        qemu_check_nic_model(&nd_table[0], "virtio");
84 340d96e7 Paul Brook
        dev = qdev_create(NULL, "syborg,virtio-net");
85 97b15621 Gerd Hoffmann
        qdev_set_nic_properties(dev, &nd_table[0]);
86 e23a1b33 Markus Armbruster
        qdev_init_nofail(dev);
87 340d96e7 Paul Brook
        s = sysbus_from_qdev(dev);
88 340d96e7 Paul Brook
        sysbus_mmio_map(s, 0, 0xc000c000);
89 340d96e7 Paul Brook
        sysbus_connect_irq(s, 0, pic[9]);
90 340d96e7 Paul Brook
    }
91 340d96e7 Paul Brook
92 4af39611 Paul Brook
    syborg_binfo.ram_size = ram_size;
93 4af39611 Paul Brook
    syborg_binfo.kernel_filename = kernel_filename;
94 4af39611 Paul Brook
    syborg_binfo.kernel_cmdline = kernel_cmdline;
95 4af39611 Paul Brook
    syborg_binfo.initrd_filename = initrd_filename;
96 4af39611 Paul Brook
    syborg_binfo.board_id = 0;
97 4af39611 Paul Brook
    arm_load_kernel(env, &syborg_binfo);
98 4af39611 Paul Brook
}
99 4af39611 Paul Brook
100 f80f9ec9 Anthony Liguori
static QEMUMachine syborg_machine = {
101 4af39611 Paul Brook
    .name = "syborg",
102 4af39611 Paul Brook
    .desc = "Syborg (Symbian Virtual Platform)",
103 4af39611 Paul Brook
    .init = syborg_init,
104 4af39611 Paul Brook
};
105 f80f9ec9 Anthony Liguori
106 f80f9ec9 Anthony Liguori
static void syborg_machine_init(void)
107 f80f9ec9 Anthony Liguori
{
108 f80f9ec9 Anthony Liguori
    qemu_register_machine(&syborg_machine);
109 f80f9ec9 Anthony Liguori
}
110 f80f9ec9 Anthony Liguori
111 f80f9ec9 Anthony Liguori
machine_init(syborg_machine_init);