mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
For the single-binary, we want to be able to retrieve at runtime the current target among the different ones available. A consequence is that we can't rely on existing target_info() definition since it will create a conflict once more than one target is available. To solve this, we add TargetInfo in QOM, with this hierarchy. We define one class "target-info-X" per target, that inherits from abstract class "target-info". Using concrete vs abstract class ensure we can easily filter "target-info-X" from all QOM types. Associated TargetInfo is directly set through class initialization, without relying on any instance. For user mode, we simply define target_info() like it was done previously. In this patch, we keep the same definition for system-mode also, and it will be replaced in next commits. We will introduce detection of target from QOM, so we need to make sure those types are registered early. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260514172303.1484273-4-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
/*
|
|
* QEMU binary/target API (QOM types)
|
|
*
|
|
* Copyright (c) Linaro
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qapi/error.h"
|
|
#include "qom/object.h"
|
|
#include "qemu/target-info-impl.h"
|
|
#include "qemu/target-info-init.h"
|
|
#include "qemu/target-info-qom.h"
|
|
#include "hw/arm/machines-qom.h"
|
|
|
|
static const TypeInfo target_info_types[] = {
|
|
{
|
|
.name = TYPE_TARGET_ARM_MACHINE,
|
|
.parent = TYPE_INTERFACE,
|
|
},
|
|
{
|
|
.name = TYPE_TARGET_AARCH64_MACHINE,
|
|
.parent = TYPE_INTERFACE,
|
|
},
|
|
};
|
|
|
|
DEFINE_TYPES(target_info_types)
|
|
|
|
static void target_info_qom_class_init(ObjectClass *oc, const void * data)
|
|
{
|
|
TargetInfoQomClass *klass = TARGET_INFO_CLASS(oc);
|
|
klass->target_info = data;
|
|
}
|
|
|
|
static const TypeInfo target_info_parent_type = {
|
|
.name = TYPE_TARGET_INFO,
|
|
.parent = TYPE_OBJECT,
|
|
.instance_size = sizeof(TargetInfoQom),
|
|
.class_size = sizeof(TargetInfoQomClass),
|
|
/* use class_base_init so children classes can set class_data accordingly */
|
|
.class_base_init = target_info_qom_class_init,
|
|
/* children classes will be concrete, which allows to easily query them
|
|
* without listing this parent class also */
|
|
.abstract = true,
|
|
};
|
|
|
|
DEFINE_TARGET_INFO_TYPE(target_info_parent_type)
|