target-i386: Fix eflags.TF/#DB handling of syscall/sysret insns
[qemu/ar7.git] / hw / tricore / tricore_testboard.c
blob19dd5872077715ebc931a9dd1ba20d5e48371059
1 /*
2 * TriCore Baseboard System emulation.
4 * Copyright (c) 2013-2014 Bastian Koppelmann C-Lab/University Paderborn
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "qemu/osdep.h"
22 #include "qapi/error.h"
23 #include "qemu-common.h"
24 #include "cpu.h"
25 #include "hw/hw.h"
26 #include "hw/devices.h"
27 #include "net/net.h"
28 #include "sysemu/sysemu.h"
29 #include "hw/boards.h"
30 #include "hw/loader.h"
31 #include "sysemu/block-backend.h"
32 #include "exec/address-spaces.h"
33 #include "hw/block/flash.h"
34 #include "elf.h"
35 #include "hw/tricore/tricore.h"
36 #include "qemu/error-report.h"
39 /* Board init. */
41 static struct tricore_boot_info tricoretb_binfo;
43 static void tricore_load_kernel(CPUTriCoreState *env)
45 uint64_t entry;
46 long kernel_size;
48 kernel_size = load_elf(tricoretb_binfo.kernel_filename, NULL,
49 NULL, &entry, NULL,
50 NULL, 0,
51 EM_TRICORE, 1, 0);
52 if (kernel_size <= 0) {
53 error_report("qemu: no kernel file '%s'",
54 tricoretb_binfo.kernel_filename);
55 exit(1);
57 env->PC = entry;
61 static void tricore_testboard_init(MachineState *machine, int board_id)
63 TriCoreCPU *cpu;
64 CPUTriCoreState *env;
66 MemoryRegion *sysmem = get_system_memory();
67 MemoryRegion *ext_cram = g_new(MemoryRegion, 1);
68 MemoryRegion *ext_dram = g_new(MemoryRegion, 1);
69 MemoryRegion *int_cram = g_new(MemoryRegion, 1);
70 MemoryRegion *int_dram = g_new(MemoryRegion, 1);
71 MemoryRegion *pcp_data = g_new(MemoryRegion, 1);
72 MemoryRegion *pcp_text = g_new(MemoryRegion, 1);
74 if (!machine->cpu_model) {
75 machine->cpu_model = "tc1796";
77 cpu = cpu_tricore_init(machine->cpu_model);
78 if (!cpu) {
79 error_report("Unable to find CPU definition");
80 exit(1);
82 env = &cpu->env;
83 memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram", 2*1024*1024,
84 &error_fatal);
85 vmstate_register_ram_global(ext_cram);
86 memory_region_init_ram(ext_dram, NULL, "powerlink_ext_d.ram", 4*1024*1024,
87 &error_fatal);
88 vmstate_register_ram_global(ext_dram);
89 memory_region_init_ram(int_cram, NULL, "powerlink_int_c.ram", 48*1024,
90 &error_fatal);
91 vmstate_register_ram_global(int_cram);
92 memory_region_init_ram(int_dram, NULL, "powerlink_int_d.ram", 48*1024,
93 &error_fatal);
94 vmstate_register_ram_global(int_dram);
95 memory_region_init_ram(pcp_data, NULL, "powerlink_pcp_data.ram", 16*1024,
96 &error_fatal);
97 vmstate_register_ram_global(pcp_data);
98 memory_region_init_ram(pcp_text, NULL, "powerlink_pcp_text.ram", 32*1024,
99 &error_fatal);
100 vmstate_register_ram_global(pcp_text);
102 memory_region_add_subregion(sysmem, 0x80000000, ext_cram);
103 memory_region_add_subregion(sysmem, 0xa1000000, ext_dram);
104 memory_region_add_subregion(sysmem, 0xd4000000, int_cram);
105 memory_region_add_subregion(sysmem, 0xd0000000, int_dram);
106 memory_region_add_subregion(sysmem, 0xf0050000, pcp_data);
107 memory_region_add_subregion(sysmem, 0xf0060000, pcp_text);
109 tricoretb_binfo.ram_size = machine->ram_size;
110 tricoretb_binfo.kernel_filename = machine->kernel_filename;
112 if (machine->kernel_filename) {
113 tricore_load_kernel(env);
117 static void tricoreboard_init(MachineState *machine)
119 tricore_testboard_init(machine, 0x183);
122 static void ttb_machine_init(MachineClass *mc)
124 mc->desc = "a minimal TriCore board";
125 mc->init = tricoreboard_init;
126 mc->is_default = 0;
129 DEFINE_MACHINE("tricore_testboard", ttb_machine_init)