]> git.proxmox.com Git - mirror_qemu.git/blame - hw/tricore/tricore_testboard.c
cpu: make cpu_generic_init() abort QEMU on error
[mirror_qemu.git] / hw / tricore / tricore_testboard.c
CommitLineData
e2d05011
BK
1/*
2 * TriCore Baseboard System emulation.
3 *
4 * Copyright (c) 2013-2014 Bastian Koppelmann C-Lab/University Paderborn
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
20
61d9f32b 21#include "qemu/osdep.h"
da34e65c 22#include "qapi/error.h"
4771d756
PB
23#include "qemu-common.h"
24#include "cpu.h"
e2d05011
BK
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"
4be74634 31#include "sysemu/block-backend.h"
e2d05011
BK
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"
37
38
39/* Board init. */
40
41static struct tricore_boot_info tricoretb_binfo;
42
43static void tricore_load_kernel(CPUTriCoreState *env)
44{
45 uint64_t entry;
46 long kernel_size;
47
48 kernel_size = load_elf(tricoretb_binfo.kernel_filename, NULL,
416296a9 49 NULL, &entry, NULL,
e2d05011 50 NULL, 0,
7ef295ea 51 EM_TRICORE, 1, 0);
e2d05011 52 if (kernel_size <= 0) {
d0e31a10 53 error_report("no kernel file '%s'",
e2d05011
BK
54 tricoretb_binfo.kernel_filename);
55 exit(1);
56 }
57 env->PC = entry;
58
59}
60
61static void tricore_testboard_init(MachineState *machine, int board_id)
62{
63 TriCoreCPU *cpu;
64 CPUTriCoreState *env;
65
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);
73
74 if (!machine->cpu_model) {
75 machine->cpu_model = "tc1796";
76 }
a6977312 77 cpu = TRICORE_CPU(cpu_generic_init(TYPE_TRICORE_CPU, machine->cpu_model));
8ef2b256 78 env = &cpu->env;
98a99ce0
PM
79 memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram",
80 2 * 1024 * 1024, &error_fatal);
81 memory_region_init_ram(ext_dram, NULL, "powerlink_ext_d.ram",
82 4 * 1024 * 1024, &error_fatal);
83 memory_region_init_ram(int_cram, NULL, "powerlink_int_c.ram", 48 * 1024,
f8ed85ac 84 &error_fatal);
98a99ce0 85 memory_region_init_ram(int_dram, NULL, "powerlink_int_d.ram", 48 * 1024,
f8ed85ac 86 &error_fatal);
98a99ce0
PM
87 memory_region_init_ram(pcp_data, NULL, "powerlink_pcp_data.ram",
88 16 * 1024, &error_fatal);
89 memory_region_init_ram(pcp_text, NULL, "powerlink_pcp_text.ram",
90 32 * 1024, &error_fatal);
e2d05011
BK
91
92 memory_region_add_subregion(sysmem, 0x80000000, ext_cram);
93 memory_region_add_subregion(sysmem, 0xa1000000, ext_dram);
94 memory_region_add_subregion(sysmem, 0xd4000000, int_cram);
95 memory_region_add_subregion(sysmem, 0xd0000000, int_dram);
96 memory_region_add_subregion(sysmem, 0xf0050000, pcp_data);
97 memory_region_add_subregion(sysmem, 0xf0060000, pcp_text);
98
99 tricoretb_binfo.ram_size = machine->ram_size;
100 tricoretb_binfo.kernel_filename = machine->kernel_filename;
101
102 if (machine->kernel_filename) {
103 tricore_load_kernel(env);
104 }
105}
106
107static void tricoreboard_init(MachineState *machine)
108{
109 tricore_testboard_init(machine, 0x183);
110}
111
e264d29d 112static void ttb_machine_init(MachineClass *mc)
e2d05011 113{
e264d29d
EH
114 mc->desc = "a minimal TriCore board";
115 mc->init = tricoreboard_init;
116 mc->is_default = 0;
e2d05011
BK
117}
118
e264d29d 119DEFINE_MACHINE("tricore_testboard", ttb_machine_init)