diff mbox series

[6/6] hw/arm/raspi: Get the CPU core count from the revision code

Message ID 20200203082619.7426-7-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show
Series hw/arm/raspi: Dynamically create machines based on the board revision | expand

Commit Message

Philippe Mathieu-Daudé Feb. 3, 2020, 8:26 a.m. UTC
The number of cores is tied to the SoC, and we already know how
to extract the Chip ID from the revision code. Use it to determine
the number of cores.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/raspi.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 12dc4d1486..aff5d57261 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -39,9 +39,10 @@  enum BoardIdChip {
 
 static const struct {
     const char *soc_name;
+    int cores_count;
 } soc_config[] = {
-    [C_BCM2836] = {TYPE_BCM2836},
-    [C_BCM2837] = {TYPE_BCM2837},
+    [C_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS},
+    [C_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS},
 };
 
 typedef struct RaspiMachineState {
@@ -113,6 +114,11 @@  static const char *board_soc_name(const RaspiBoardInfo *config)
     return soc_config[board_chip_id(config)].soc_name;
 }
 
+static int cpu_cores_count(const RaspiBoardInfo *config)
+{
+    return soc_config[board_chip_id(config)].cores_count;
+}
+
 static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
 {
     static const uint32_t smpboot[] = {
@@ -312,9 +318,7 @@  static void raspi_machine_class_init(ObjectClass *oc, void *data)
     mc->no_parallel = 1;
     mc->no_floppy = 1;
     mc->no_cdrom = 1;
-    mc->max_cpus = BCM283X_NCPUS;
-    mc->min_cpus = BCM283X_NCPUS;
-    mc->default_cpus = BCM283X_NCPUS;
+    mc->default_cpus = mc->min_cpus = mc->max_cpus = cpu_cores_count(config);
     mc->default_ram_size = board_ram_size(config);
     mc->ignore_memory_transaction_failures = true;
 }