]> git.proxmox.com Git - mirror_qemu.git/blob - hw/puv3.c
unicore32-softmmu: Add puv3 soc/board support
[mirror_qemu.git] / hw / puv3.c
1 /*
2 * Generic PKUnity SoC machine and board descriptor
3 *
4 * Copyright (C) 2010-2012 Guan Xuetao
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation, or any later version.
9 * See the COPYING file in the top-level directory.
10 */
11 #include "console.h"
12 #include "elf.h"
13 #include "exec-memory.h"
14 #include "sysbus.h"
15 #include "boards.h"
16 #include "loader.h"
17 #include "pc.h"
18
19 #undef DEBUG_PUV3
20 #include "puv3.h"
21
22 #define KERNEL_LOAD_ADDR 0x03000000
23 #define KERNEL_MAX_SIZE 0x00800000 /* Just a guess */
24
25 static void puv3_soc_init(CPUUniCore32State *env)
26 {
27 /* TODO */
28 }
29
30 static void puv3_board_init(CPUUniCore32State *env, ram_addr_t ram_size)
31 {
32 MemoryRegion *ram_memory = g_new(MemoryRegion, 1);
33
34 /* SDRAM at address zero. */
35 memory_region_init_ram(ram_memory, "puv3.ram", ram_size);
36 vmstate_register_ram_global(ram_memory);
37 memory_region_add_subregion(get_system_memory(), 0, ram_memory);
38 }
39
40 static void puv3_load_kernel(const char *kernel_filename)
41 {
42 int size;
43
44 assert(kernel_filename != NULL);
45
46 /* only zImage format supported */
47 size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
48 KERNEL_MAX_SIZE);
49 if (size < 0) {
50 hw_error("Load kernel error: '%s'\n", kernel_filename);
51 }
52
53 /* cheat curses that we have a graphic console, only under ocd console */
54 graphic_console_init(NULL, NULL, NULL, NULL, NULL);
55 }
56
57 static void puv3_init(ram_addr_t ram_size, const char *boot_device,
58 const char *kernel_filename, const char *kernel_cmdline,
59 const char *initrd_filename, const char *cpu_model)
60 {
61 CPUUniCore32State *env;
62
63 if (initrd_filename) {
64 hw_error("Please use kernel built-in initramdisk.\n");
65 }
66
67 if (!cpu_model) {
68 cpu_model = "UniCore-II";
69 }
70
71 env = cpu_init(cpu_model);
72 if (!env) {
73 hw_error("Unable to find CPU definition\n");
74 }
75
76 puv3_soc_init(env);
77 puv3_board_init(env, ram_size);
78 puv3_load_kernel(kernel_filename);
79 }
80
81 static QEMUMachine puv3_machine = {
82 .name = "puv3",
83 .desc = "PKUnity Version-3 based on UniCore32",
84 .init = puv3_init,
85 .use_scsi = 0,
86 };
87
88 static void puv3_machine_init(void)
89 {
90 qemu_register_machine(&puv3_machine);
91 }
92
93 machine_init(puv3_machine_init)