]>
git.proxmox.com Git - mirror_qemu.git/blob - hw/puv3.c
2 * Generic PKUnity SoC machine and board descriptor
4 * Copyright (C) 2010-2012 Guan Xuetao
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.
13 #include "exec-memory.h"
22 #define KERNEL_LOAD_ADDR 0x03000000
23 #define KERNEL_MAX_SIZE 0x00800000 /* Just a guess */
25 static void puv3_intc_cpu_handler(void *opaque
, int irq
, int level
)
27 CPUUniCore32State
*env
= opaque
;
31 cpu_interrupt(env
, CPU_INTERRUPT_HARD
);
33 cpu_reset_interrupt(env
, CPU_INTERRUPT_HARD
);
37 static void puv3_soc_init(CPUUniCore32State
*env
)
39 qemu_irq
*cpu_intc
, irqs
[PUV3_IRQS_NR
];
43 /* Initialize interrupt controller */
44 cpu_intc
= qemu_allocate_irqs(puv3_intc_cpu_handler
, env
, 1);
45 dev
= sysbus_create_simple("puv3_intc", PUV3_INTC_BASE
, *cpu_intc
);
46 for (i
= 0; i
< PUV3_IRQS_NR
; i
++) {
47 irqs
[i
] = qdev_get_gpio_in(dev
, i
);
51 static void puv3_board_init(CPUUniCore32State
*env
, ram_addr_t ram_size
)
53 MemoryRegion
*ram_memory
= g_new(MemoryRegion
, 1);
55 /* SDRAM at address zero. */
56 memory_region_init_ram(ram_memory
, "puv3.ram", ram_size
);
57 vmstate_register_ram_global(ram_memory
);
58 memory_region_add_subregion(get_system_memory(), 0, ram_memory
);
61 static void puv3_load_kernel(const char *kernel_filename
)
65 assert(kernel_filename
!= NULL
);
67 /* only zImage format supported */
68 size
= load_image_targphys(kernel_filename
, KERNEL_LOAD_ADDR
,
71 hw_error("Load kernel error: '%s'\n", kernel_filename
);
74 /* cheat curses that we have a graphic console, only under ocd console */
75 graphic_console_init(NULL
, NULL
, NULL
, NULL
, NULL
);
78 static void puv3_init(ram_addr_t ram_size
, const char *boot_device
,
79 const char *kernel_filename
, const char *kernel_cmdline
,
80 const char *initrd_filename
, const char *cpu_model
)
82 CPUUniCore32State
*env
;
84 if (initrd_filename
) {
85 hw_error("Please use kernel built-in initramdisk.\n");
89 cpu_model
= "UniCore-II";
92 env
= cpu_init(cpu_model
);
94 hw_error("Unable to find CPU definition\n");
98 puv3_board_init(env
, ram_size
);
99 puv3_load_kernel(kernel_filename
);
102 static QEMUMachine puv3_machine
= {
104 .desc
= "PKUnity Version-3 based on UniCore32",
109 static void puv3_machine_init(void)
111 qemu_register_machine(&puv3_machine
);
114 machine_init(puv3_machine_init
)