]>
Commit | Line | Data |
---|---|---|
34602f99 AK |
1 | /* |
2 | * Infineon TriBoard System emulation. | |
3 | * | |
4 | * Copyright (c) 2020 Andreas Konopik <[email protected]> | |
5 | * Copyright (c) 2020 David Brenken <[email protected]> | |
6 | * | |
7 | * This library is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU Lesser General Public | |
9 | * License as published by the Free Software Foundation; either | |
10 | * version 2 of the License, or (at your option) any later version. | |
11 | * | |
12 | * This library is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * Lesser General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU Lesser General Public | |
18 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
21 | #include "qemu/osdep.h" | |
22 | #include "qemu/units.h" | |
23 | #include "qapi/error.h" | |
24 | #include "hw/qdev-properties.h" | |
25 | #include "cpu.h" | |
26 | #include "net/net.h" | |
34602f99 AK |
27 | #include "hw/loader.h" |
28 | #include "exec/address-spaces.h" | |
29 | #include "elf.h" | |
30 | #include "hw/tricore/tricore.h" | |
31 | #include "qemu/error-report.h" | |
32 | ||
33 | #include "hw/tricore/triboard.h" | |
34 | #include "hw/tricore/tc27x_soc.h" | |
35 | ||
36 | static void tricore_load_kernel(const char *kernel_filename) | |
37 | { | |
38 | uint64_t entry; | |
39 | long kernel_size; | |
40 | TriCoreCPU *cpu; | |
41 | CPUTriCoreState *env; | |
42 | ||
43 | kernel_size = load_elf(kernel_filename, NULL, | |
44 | NULL, NULL, &entry, NULL, | |
45 | NULL, NULL, 0, | |
46 | EM_TRICORE, 1, 0); | |
47 | if (kernel_size <= 0) { | |
48 | error_report("no kernel file '%s'", kernel_filename); | |
49 | exit(1); | |
50 | } | |
51 | cpu = TRICORE_CPU(first_cpu); | |
52 | env = &cpu->env; | |
53 | env->PC = entry; | |
54 | } | |
55 | ||
56 | ||
57 | static void triboard_machine_init(MachineState *machine) | |
58 | { | |
59 | TriBoardMachineState *ms = TRIBOARD_MACHINE(machine); | |
60 | TriBoardMachineClass *amc = TRIBOARD_MACHINE_GET_CLASS(machine); | |
61 | ||
62 | object_initialize_child(OBJECT(machine), "soc", &ms->tc27x_soc, | |
63 | amc->soc_name); | |
64 | sysbus_realize(SYS_BUS_DEVICE(&ms->tc27x_soc), &error_fatal); | |
65 | ||
66 | if (machine->kernel_filename) { | |
67 | tricore_load_kernel(machine->kernel_filename); | |
68 | } | |
69 | } | |
70 | ||
71 | static void triboard_machine_tc277d_class_init(ObjectClass *oc, | |
72 | void *data) | |
73 | { | |
74 | MachineClass *mc = MACHINE_CLASS(oc); | |
75 | TriBoardMachineClass *amc = TRIBOARD_MACHINE_CLASS(oc); | |
76 | ||
77 | mc->init = triboard_machine_init; | |
78 | mc->desc = "Infineon AURIX TriBoard TC277 (D-Step)"; | |
79 | mc->max_cpus = 1; | |
80 | amc->soc_name = "tc277d-soc"; | |
81 | }; | |
82 | ||
83 | static const TypeInfo triboard_machine_types[] = { | |
84 | { | |
85 | .name = MACHINE_TYPE_NAME("KIT_AURIX_TC277_TRB"), | |
86 | .parent = TYPE_TRIBOARD_MACHINE, | |
87 | .class_init = triboard_machine_tc277d_class_init, | |
88 | }, { | |
89 | .name = TYPE_TRIBOARD_MACHINE, | |
90 | .parent = TYPE_MACHINE, | |
91 | .instance_size = sizeof(TriBoardMachineState), | |
92 | .class_size = sizeof(TriBoardMachineClass), | |
93 | .abstract = true, | |
94 | }, | |
95 | }; | |
96 | ||
97 | DEFINE_TYPES(triboard_machine_types) |