qemu-devel
[Top][All Lists]
Advanced

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

[RFC PATCH 17/40] target/arm: Copy cp_regs from ARMCPUClass


From: Richard Henderson
Subject: [RFC PATCH 17/40] target/arm: Copy cp_regs from ARMCPUClass
Date: Tue, 3 Jan 2023 10:16:23 -0800

Create a hash table of cpregs in ARMCPUClass and copy to the
instance in arm_cpu_init.  Population of this new table will
come in a future patch.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/cpu-qom.h |  3 +++
 target/arm/cpu.c     | 23 +++++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
index 832b2cccf9..36d7fa9779 100644
--- a/target/arm/cpu-qom.h
+++ b/target/arm/cpu-qom.h
@@ -111,6 +111,9 @@ struct ARMCPUClass {
     DeviceRealize parent_realize;
     ResettablePhases parent_phases;
 
+    /* Coprocessor information */
+    GHashTable *cp_regs;
+
     /* 'compatible' string for this CPU for Linux device trees */
     const char *dtb_compatible;
 
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index a46fa424d3..da58f1fae7 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1178,14 +1178,29 @@ uint64_t arm_build_mp_affinity(int idx, uint8_t 
clustersz)
     return (Aff1 << ARM_AFF1_SHIFT) | Aff0;
 }
 
+static void copy_cp_regs_1(gpointer key, gpointer value, gpointer user)
+{
+    GHashTable *new_table = user;
+    ARMCPRegInfo *new_reg = g_memdup(value, sizeof(ARMCPRegInfo));
+    bool ok = g_hash_table_insert(new_table, key, new_reg);
+    g_assert(ok);
+}
+
+static GHashTable *copy_cp_regs(GHashTable *cp_regs)
+{
+    GHashTable *ret = g_hash_table_new_full(g_direct_hash, g_direct_equal,
+                                            NULL, g_free);
+
+    g_hash_table_foreach(cp_regs, copy_cp_regs_1, ret);
+    return ret;
+}
+
 static void arm_cpu_initfn(Object *obj)
 {
     ARMCPU *cpu = ARM_CPU(obj);
     ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu);
 
     cpu_set_cpustate_pointers(cpu);
-    cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal,
-                                         NULL, g_free);
 
     QLIST_INIT(&cpu->pre_el_change_hooks);
     QLIST_INIT(&cpu->el_change_hooks);
@@ -1219,6 +1234,8 @@ static void arm_cpu_initfn(Object *obj)
     cpu->gic_pribits = acc->gic_pribits;
     cpu->kvm_target = acc->kvm_target;
 
+    cpu->cp_regs = copy_cp_regs(acc->cp_regs);
+
 #ifdef CONFIG_USER_ONLY
 # ifdef TARGET_AARCH64
     /*
@@ -2337,6 +2354,8 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc, void 
*data)
     const ARMCPUInfo *info = data;
 
     acc->info = info;
+    acc->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal,
+                                         NULL, g_free);
     if (info->class_init) {
         info->class_init(acc);
     }
-- 
2.34.1




reply via email to

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