@samitouri / QOSamiQemu / commits / 750d25fc66

configs/target: Implement per-binary TargetInfo structure for riscv

Defines TargetInfo for 32- and 64-bit riscv binaries. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Anton Johansson <anjo@rev.ng> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Acked-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20260520-hw-riscv-cpu-int-v3-6-d1123ea63d9c@rev.ng> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Anton Johansson committed Apr 30, 2025 at 14:17 UTC 750d25fc6615ff4db87bcf3a6b46e7266e59f5ae
3 files changed +53
configs/targets/meson.build
+1
@@ -1,5 +1,6 @@
1 foreach target : [
2 'arm-softmmu', 'aarch64-softmmu',
3 + 'riscv32-softmmu', 'riscv64-softmmu'
4 ]
5 config_target_info += {target : files(target + '.c')}
6 endforeach
configs/targets/riscv32-softmmu.c new
+26
@@ -0,0 +1,26 @@
1 +/*
2 + * QEMU binary/target API (qemu-system-riscv32)
3 + *
4 + * Copyright (c) rev.ng Labs Srl.
5 + *
6 + * SPDX-License-Identifier: GPL-2.0-or-later
7 + */
8 +
9 +#include "qemu/osdep.h"
10 +#include "qemu/target-info-impl.h"
11 +#include "qemu/target-info-init.h"
12 +#include "hw/riscv/machines-qom.h"
13 +#include "target/riscv/cpu-qom.h"
14 +#include "target/riscv/cpu-param.h"
15 +
16 +static const TargetInfo target_info_riscv32_system = {
17 + .target_name = "riscv32",
18 + .target_arch = SYS_EMU_TARGET_RISCV32,
19 + .long_bits = 32,
20 + .cpu_type = TYPE_RISCV_CPU,
21 + .machine_typename = TYPE_TARGET_RISCV32_MACHINE,
22 + .endianness = ENDIAN_MODE_LITTLE,
23 + .page_bits_init = TARGET_PAGE_BITS,
24 +};
25 +
26 +target_info_init(target_info_riscv32_system)
configs/targets/riscv64-softmmu.c new
+26
@@ -0,0 +1,26 @@
1 +/*
2 + * QEMU binary/target API (qemu-system-riscv64)
3 + *
4 + * Copyright (c) rev.ng Labs Srl.
5 + *
6 + * SPDX-License-Identifier: GPL-2.0-or-later
7 + */
8 +
9 +#include "qemu/osdep.h"
10 +#include "qemu/target-info-impl.h"
11 +#include "qemu/target-info-init.h"
12 +#include "hw/riscv/machines-qom.h"
13 +#include "target/riscv/cpu-qom.h"
14 +#include "target/riscv/cpu-param.h"
15 +
16 +static const TargetInfo target_info_riscv64_system = {
17 + .target_name = "riscv64",
18 + .target_arch = SYS_EMU_TARGET_RISCV64,
19 + .long_bits = 64,
20 + .cpu_type = TYPE_RISCV_CPU,
21 + .machine_typename = TYPE_TARGET_RISCV64_MACHINE,
22 + .endianness = ENDIAN_MODE_LITTLE,
23 + .page_bits_init = TARGET_PAGE_BITS,
24 +};
25 +
26 +target_info_init(target_info_riscv64_system)