[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/71] hw/core: Add machine_class_default_cpu_type()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 23/71] hw/core: Add machine_class_default_cpu_type() |
Date: |
Fri, 5 Jan 2024 16:42:16 +0100 |
Add a helper to return a machine default CPU type.
If this machine is restricted to a single CPU type,
use it as default, obviously.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231116163726.28952-1-philmd@linaro.org>
---
include/hw/boards.h | 6 ++++++
hw/core/machine.c | 8 ++++++++
system/vl.c | 2 +-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 8af165f4dc..bcfde8a84d 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -24,6 +24,12 @@ OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE)
extern MachineState *current_machine;
+/**
+ * machine_class_default_cpu_type: Return the machine default CPU type.
+ * @mc: Machine class
+ */
+const char *machine_class_default_cpu_type(MachineClass *mc);
+
void machine_add_audiodev_property(MachineClass *mc);
void machine_run_board_init(MachineState *machine, const char *mem_path, Error
**errp);
bool machine_usb(MachineState *machine);
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 2699bcba53..0198b54b39 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1390,6 +1390,14 @@ out:
return r;
}
+const char *machine_class_default_cpu_type(MachineClass *mc)
+{
+ if (mc->valid_cpu_types && !mc->valid_cpu_types[1]) {
+ /* Only a single CPU type allowed: use it as default. */
+ return mc->valid_cpu_types[0];
+ }
+ return mc->default_cpu_type;
+}
void machine_run_board_init(MachineState *machine, const char *mem_path, Error
**errp)
{
diff --git a/system/vl.c b/system/vl.c
index 6b87bfa32c..fbdf8bd55a 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -3737,7 +3737,7 @@ void qemu_init(int argc, char **argv)
migration_object_init();
/* parse features once if machine provides default cpu_type */
- current_machine->cpu_type = machine_class->default_cpu_type;
+ current_machine->cpu_type = machine_class_default_cpu_type(machine_class);
if (cpu_option) {
current_machine->cpu_type = parse_cpu_option(cpu_option);
}
--
2.41.0
- [PULL 16/71] target/openrisc: Use generic cpu_list(), (continued)
- [PULL 16/71] target/openrisc: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 17/71] target/riscv: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 18/71] target/rx: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 20/71] target/tricore: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 19/71] target/sh4: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 21/71] target/xtensa: Use generic cpu_list(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 24/71] machine: Use error handling when CPU type is checked, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 22/71] target: Use generic cpu_model_from_type(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 27/71] machine: Print CPU model name instead of CPU type, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 28/71] hw/arm/virt: Hide host CPU model for tcg, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 23/71] hw/core: Add machine_class_default_cpu_type(),
Philippe Mathieu-Daudé <=
- [PULL 25/71] machine: Introduce helper is_cpu_type_supported(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 26/71] machine: Improve is_cpu_type_supported(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 29/71] hw/arm/virt: Check CPU type in machine_run_board_init(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 30/71] hw/arm/sbsa-ref: Check CPU type in machine_run_board_init(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 32/71] hw/riscv/shakti_c: Check CPU type in machine_run_board_init(), Philippe Mathieu-Daudé, 2024/01/05
- [PULL 34/71] hw/core/cpu: Update description of CPUState::node, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 35/71] hw/cpu/core: Cleanup unused included header in core.c, Philippe Mathieu-Daudé, 2024/01/05
- [PULL 31/71] hw/arm: Check CPU type in machine_run_board_init(), Philippe Mathieu-Daudé, 2024/01/05