qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH] vl.c: add is_system_on_chip flag to force board


From: Philippe Mathieu-Daudé
Subject: [Qemu-devel] [RFC PATCH] vl.c: add is_system_on_chip flag to force board default cpu
Date: Mon, 18 Sep 2017 18:57:19 -0300

add a property to restrict the CPU for SoCs once on machine creation and avoid
duplicate code in each board.

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
Based-on: address@hidden

 include/hw/boards.h |  3 +++
 vl.c                | 11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 6b67adaef6..20dc0a0ab9 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -129,6 +129,8 @@ typedef struct {
  *    specifies default CPU_TYPE, which will be used for parsing target
  *    specific features and for creating CPUs if CPU name wasn't provided
  *    explicitly at CLI
+ * @is_system_on_chip:
+ *    If true, board does not support other CPUs than default_cpu_type.
  * @minimum_page_bits:
  *    If non-zero, the board promises never to create a CPU with a page size
  *    smaller than this, so QEMU can use a more efficient larger page
@@ -182,6 +184,7 @@ struct MachineClass {
     const char *hw_version;
     ram_addr_t default_ram_size;
     const char *default_cpu_type;
+    bool is_system_on_chip;
     bool option_rom_has_mr;
     bool rom_file_has_mr;
     int minimum_page_bits;
diff --git a/vl.c b/vl.c
index fb6a700e55..6e59ffa856 100644
--- a/vl.c
+++ b/vl.c
@@ -4717,10 +4717,21 @@ int main(int argc, char **argv, char **envp)
     current_machine->cpu_model = cpu_model;
 
 
+    if (machine_class->is_system_on_chip && !machine_class->default_cpu_type) {
+        error_report("System-on-Chip must have a default CPU type");
+        exit(1);
+    }
     /* parse features once if machine provides default cpu_type */
     if (machine_class->default_cpu_type) {
         current_machine->cpu_type = machine_class->default_cpu_type;
         if (cpu_model) {
+            if (machine_class->is_system_on_chip) {
+                if (strcmp(cpu_model, machine_class->default_cpu_type) != 0) {
+                    error_report("This board can only be used with CPU %s",
+                                 machine_class->default_cpu_type);
+                    exit(1);
+                }
+            }
             current_machine->cpu_type =
                 cpu_parse_cpu_model(machine_class->default_cpu_type, 
cpu_model);
         }
-- 
2.14.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]