]> git.proxmox.com Git - mirror_qemu.git/blame - hw/tricore/tricore_testboard.c
hw/arm/smmuv3: Include missing 'hw/registerfields.h' header
[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
eb85394f 9 * version 2.1 of the License, or (at your option) any later version.
e2d05011
BK
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"
b000325a 22#include "qemu/units.h"
da34e65c 23#include "qapi/error.h"
4771d756 24#include "cpu.h"
e2d05011 25#include "net/net.h"
e2d05011
BK
26#include "hw/boards.h"
27#include "hw/loader.h"
e2d05011
BK
28#include "elf.h"
29#include "hw/tricore/tricore.h"
582079c9 30#include "hw/tricore/tricore_testdevice.h"
e2d05011
BK
31#include "qemu/error-report.h"
32
33
34/* Board init. */
35
36static struct tricore_boot_info tricoretb_binfo;
37
38static void tricore_load_kernel(CPUTriCoreState *env)
39{
40 uint64_t entry;
41 long kernel_size;
42
43 kernel_size = load_elf(tricoretb_binfo.kernel_filename, NULL,
4366e1db 44 NULL, NULL, &entry, NULL,
6cdda0ff 45 NULL, NULL, 0,
7ef295ea 46 EM_TRICORE, 1, 0);
e2d05011 47 if (kernel_size <= 0) {
d0e31a10 48 error_report("no kernel file '%s'",
e2d05011
BK
49 tricoretb_binfo.kernel_filename);
50 exit(1);
51 }
52 env->PC = entry;
53
54}
55
56static void tricore_testboard_init(MachineState *machine, int board_id)
57{
58 TriCoreCPU *cpu;
59 CPUTriCoreState *env;
582079c9 60 TriCoreTestDeviceState *test_dev;
e2d05011
BK
61
62 MemoryRegion *sysmem = get_system_memory();
63 MemoryRegion *ext_cram = g_new(MemoryRegion, 1);
64 MemoryRegion *ext_dram = g_new(MemoryRegion, 1);
65 MemoryRegion *int_cram = g_new(MemoryRegion, 1);
66 MemoryRegion *int_dram = g_new(MemoryRegion, 1);
67 MemoryRegion *pcp_data = g_new(MemoryRegion, 1);
68 MemoryRegion *pcp_text = g_new(MemoryRegion, 1);
69
0f550c5c 70 cpu = TRICORE_CPU(cpu_create(machine->cpu_type));
8ef2b256 71 env = &cpu->env;
98a99ce0 72 memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram",
b000325a 73 2 * MiB, &error_fatal);
98a99ce0 74 memory_region_init_ram(ext_dram, NULL, "powerlink_ext_d.ram",
b000325a
PMD
75 4 * MiB, &error_fatal);
76 memory_region_init_ram(int_cram, NULL, "powerlink_int_c.ram", 48 * KiB,
f8ed85ac 77 &error_fatal);
b000325a 78 memory_region_init_ram(int_dram, NULL, "powerlink_int_d.ram", 48 * KiB,
f8ed85ac 79 &error_fatal);
98a99ce0 80 memory_region_init_ram(pcp_data, NULL, "powerlink_pcp_data.ram",
b000325a 81 16 * KiB, &error_fatal);
98a99ce0 82 memory_region_init_ram(pcp_text, NULL, "powerlink_pcp_text.ram",
b000325a 83 32 * KiB, &error_fatal);
e2d05011
BK
84
85 memory_region_add_subregion(sysmem, 0x80000000, ext_cram);
86 memory_region_add_subregion(sysmem, 0xa1000000, ext_dram);
87 memory_region_add_subregion(sysmem, 0xd4000000, int_cram);
88 memory_region_add_subregion(sysmem, 0xd0000000, int_dram);
89 memory_region_add_subregion(sysmem, 0xf0050000, pcp_data);
90 memory_region_add_subregion(sysmem, 0xf0060000, pcp_text);
91
582079c9
BK
92 test_dev = g_new(TriCoreTestDeviceState, 1);
93 object_initialize(test_dev, sizeof(TriCoreTestDeviceState),
94 TYPE_TRICORE_TESTDEVICE);
95 memory_region_add_subregion(sysmem, 0xf0000000, &test_dev->iomem);
96
97
e2d05011
BK
98 tricoretb_binfo.ram_size = machine->ram_size;
99 tricoretb_binfo.kernel_filename = machine->kernel_filename;
100
101 if (machine->kernel_filename) {
102 tricore_load_kernel(env);
103 }
104}
105
106static void tricoreboard_init(MachineState *machine)
107{
108 tricore_testboard_init(machine, 0x183);
109}
110
e264d29d 111static void ttb_machine_init(MachineClass *mc)
e2d05011 112{
e264d29d
EH
113 mc->desc = "a minimal TriCore board";
114 mc->init = tricoreboard_init;
0f550c5c 115 mc->default_cpu_type = TRICORE_CPU_TYPE_NAME("tc1796");
e2d05011
BK
116}
117
e264d29d 118DEFINE_MACHINE("tricore_testboard", ttb_machine_init)