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