From 2b7ae6e0f645f3c3676152f3aa7b8c50a091c486 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 17 Apr 2025 17:59:35 +0200 Subject: [PATCH] qemu: Introduce target_cpu_type() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Introduce the target_cpu_type() helper to access the CPU_RESOLVING_TYPE target-specific definition from target-agnostic code. Reviewed-by: Pierrick Bouvier Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20250417165430.58213-2-philmd@linaro.org> --- MAINTAINERS | 2 ++ include/qemu/target-info.h | 19 +++++++++++++++++++ meson.build | 2 ++ target-info-stub.c | 16 ++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 include/qemu/target-info.h create mode 100644 target-info-stub.c diff --git a/MAINTAINERS b/MAINTAINERS index d82d962f1a..28b1e9ba44 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -496,6 +496,7 @@ F: include/exec/cpu*.h F: include/exec/exec-all.h F: include/exec/target_long.h F: include/qemu/accel.h +F: include/qemu/target-info*.h F: include/system/accel-*.h F: include/system/cpus.h F: include/accel/accel-cpu-target.h @@ -504,6 +505,7 @@ F: accel/Makefile.objs F: accel/stubs/Makefile.objs F: cpu-common.c F: cpu-target.c +F: target-info*.c F: system/cpus.c Apple Silicon HVF CPUs diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h new file mode 100644 index 0000000000..b4cc4888ca --- /dev/null +++ b/include/qemu/target-info.h @@ -0,0 +1,19 @@ +/* + * QEMU target info API + * + * Copyright (c) Linaro + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_TARGET_INFO_H +#define QEMU_TARGET_INFO_H + +/** + * target_cpu_type: + * + * Returns: target CPU base QOM type name (i.e. TYPE_X86_CPU). + */ +const char *target_cpu_type(void); + +#endif diff --git a/meson.build b/meson.build index c736a6f4c4..185c2fb0d1 100644 --- a/meson.build +++ b/meson.build @@ -3795,6 +3795,8 @@ endif common_ss.add(pagevary) specific_ss.add(files('page-target.c', 'page-vary-target.c')) +specific_ss.add(files('target-info-stub.c')) + subdir('backends') subdir('disas') subdir('migration') diff --git a/target-info-stub.c b/target-info-stub.c new file mode 100644 index 0000000000..e5d2195e89 --- /dev/null +++ b/target-info-stub.c @@ -0,0 +1,16 @@ +/* + * QEMU target info stubs (target specific) + * + * Copyright (c) Linaro + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/target-info.h" +#include "cpu.h" + +const char *target_cpu_type(void) +{ + return CPU_RESOLVING_TYPE; +} -- 2.39.5