2 * Infineon TriBoard System emulation.
4 * Copyright (c) 2020 Andreas Konopik <andreas.konopik@efs-auto.de>
5 * Copyright (c) 2020 David Brenken <david.brenken@efs-auto.de>
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.
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.
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/>.
21 #include "qemu/osdep.h"
22 #include "qemu/units.h"
23 #include "qapi/error.h"
24 #include "hw/qdev-properties.h"
27 #include "hw/loader.h"
28 #include "exec/address-spaces.h"
30 #include "hw/tricore/tricore.h"
31 #include "qemu/error-report.h"
33 #include "hw/tricore/triboard.h"
34 #include "hw/tricore/tc27x_soc.h"
36 static void tricore_load_kernel(const char *kernel_filename
)
43 kernel_size
= load_elf(kernel_filename
, NULL
,
44 NULL
, NULL
, &entry
, NULL
,
47 if (kernel_size
<= 0) {
48 error_report("no kernel file '%s'", kernel_filename
);
51 cpu
= TRICORE_CPU(first_cpu
);
57 static void triboard_machine_init(MachineState
*machine
)
59 TriBoardMachineState
*ms
= TRIBOARD_MACHINE(machine
);
60 TriBoardMachineClass
*amc
= TRIBOARD_MACHINE_GET_CLASS(machine
);
62 object_initialize_child(OBJECT(machine
), "soc", &ms
->tc27x_soc
,
64 sysbus_realize(SYS_BUS_DEVICE(&ms
->tc27x_soc
), &error_fatal
);
66 if (machine
->kernel_filename
) {
67 tricore_load_kernel(machine
->kernel_filename
);
71 static void triboard_machine_tc277d_class_init(ObjectClass
*oc
,
74 MachineClass
*mc
= MACHINE_CLASS(oc
);
75 TriBoardMachineClass
*amc
= TRIBOARD_MACHINE_CLASS(oc
);
77 mc
->init
= triboard_machine_init
;
78 mc
->desc
= "Infineon AURIX TriBoard TC277 (D-Step)";
80 amc
->soc_name
= "tc277d-soc";
83 static const TypeInfo triboard_machine_types
[] = {
85 .name
= MACHINE_TYPE_NAME("KIT_AURIX_TC277_TRB"),
86 .parent
= TYPE_TRIBOARD_MACHINE
,
87 .class_init
= triboard_machine_tc277d_class_init
,
89 .name
= TYPE_TRIBOARD_MACHINE
,
90 .parent
= TYPE_MACHINE
,
91 .instance_size
= sizeof(TriBoardMachineState
),
92 .class_size
= sizeof(TriBoardMachineClass
),
97 DEFINE_TYPES(triboard_machine_types
)