diff mbox series

[RFC,PATCH-for-10.1,01/19] qemu: Introduce TargetInfo API in 'target_info.h'

Message ID 20250403234914.9154-2-philmd@linaro.org
State New
Headers show
Series qemu: Introduce TargetInfo API (for single binary) | expand

Commit Message

Philippe Mathieu-Daudé April 3, 2025, 11:48 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 meson.build                     |  9 +++++++++
 include/exec/poison.h           |  1 +
 include/qemu/target_info-impl.h | 21 +++++++++++++++++++++
 include/qemu/target_info.h      | 18 ++++++++++++++++++
 target_info-stub.c              | 23 +++++++++++++++++++++++
 target_info.c                   | 16 ++++++++++++++++
 6 files changed, 88 insertions(+)
 create mode 100644 include/qemu/target_info-impl.h
 create mode 100644 include/qemu/target_info.h
 create mode 100644 target_info-stub.c
 create mode 100644 target_info.c
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index bcb9d39a387..de9c9dacd35 100644
--- a/meson.build
+++ b/meson.build
@@ -3262,6 +3262,9 @@  host_kconfig = \
 
 ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
 
+target_info = [
+]
+
 default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
 actual_target_dirs = []
 fdt_required = []
@@ -3368,6 +3371,9 @@  foreach target : target_dirs
       config_target_data.set(k, v)
     endif
   endforeach
+  if target not in target_info
+    config_target_data.set('TARGET_INFO_STUB_NEEDED', 1)
+  endif
   config_target_data.set('QEMU_ARCH',
                          'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper())
   config_target_h += {target: configure_file(output: target + '-config-target.h',
@@ -3807,6 +3813,9 @@  endif
 common_ss.add(pagevary)
 specific_ss.add(files('page-target.c', 'page-vary-target.c'))
 
+specific_ss.add(files('target_info-stub.c'))
+common_ss.add(files('target_info.c'))
+
 subdir('backends')
 subdir('disas')
 subdir('migration')
diff --git a/include/exec/poison.h b/include/exec/poison.h
index bc422719d80..00aedc41d82 100644
--- a/include/exec/poison.h
+++ b/include/exec/poison.h
@@ -38,6 +38,7 @@ 
 #pragma GCC poison TARGET_BIG_ENDIAN
 #pragma GCC poison TCG_GUEST_DEFAULT_MO
 #pragma GCC poison TARGET_HAS_PRECISE_SMC
+#pragma GCC poison TARGET_INFO_STUB_NEEDED
 
 #pragma GCC poison TARGET_LONG_BITS
 #pragma GCC poison TARGET_FMT_lx
diff --git a/include/qemu/target_info-impl.h b/include/qemu/target_info-impl.h
new file mode 100644
index 00000000000..b340e192fce
--- /dev/null
+++ b/include/qemu/target_info-impl.h
@@ -0,0 +1,21 @@ 
+/*
+ * QEMU binary helpers
+ *
+ *  Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_TARGET_INFO_IMPL_H
+#define QEMU_TARGET_INFO_IMPL_H
+
+#include "qemu/target_info.h"
+
+struct BinaryTargetInfo {
+
+    /* runtime equivalent of TARGET_INFO_STUB_NEEDED definition */
+    bool is_stub;
+
+};
+
+#endif
diff --git a/include/qemu/target_info.h b/include/qemu/target_info.h
new file mode 100644
index 00000000000..fab3f3153ea
--- /dev/null
+++ b/include/qemu/target_info.h
@@ -0,0 +1,18 @@ 
+/*
+ * QEMU binary helpers
+ *
+ *  Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_TARGET_INFO_H
+#define QEMU_TARGET_INFO_H
+
+typedef struct BinaryTargetInfo BinaryTargetInfo;
+
+const BinaryTargetInfo *target_info(void);
+
+bool target_info_is_stub(void);
+
+#endif
diff --git a/target_info-stub.c b/target_info-stub.c
new file mode 100644
index 00000000000..d683a05977d
--- /dev/null
+++ b/target_info-stub.c
@@ -0,0 +1,23 @@ 
+/*
+ * QEMU target info stubs
+ *
+ *  Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/target_info-impl.h"
+
+#ifdef TARGET_INFO_STUB_NEEDED
+
+static const BinaryTargetInfo target_info_stub = {
+    .is_stub = true,
+};
+
+const BinaryTargetInfo *target_info(void)
+{
+    return &target_info_stub;
+}
+
+#endif /* TARGET_INFO_STUB_NEEDED */
diff --git a/target_info.c b/target_info.c
new file mode 100644
index 00000000000..cb17d29b86d
--- /dev/null
+++ b/target_info.c
@@ -0,0 +1,16 @@ 
+/*
+ * QEMU legacy binary helpers
+ *
+ *  Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/target_info-impl.h"
+#include "qemu/target_info.h"
+
+bool target_info_is_stub(void)
+{
+    return target_info()->is_stub;
+}