[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
- [RFC PATCH 26/40] target/arm: Rename 'cpu' to 'acc' in class init functions, (continued)
- [RFC PATCH 26/40] target/arm: Rename 'cpu' to 'acc' in class init functions, Richard Henderson, 2023/01/03
- [RFC PATCH 19/40] target/arm: Move most cpu initialization to the class, Richard Henderson, 2023/01/03
- [RFC PATCH 21/40] target/arm: Remove aarch64 check from aarch64_host_object_init, Richard Henderson, 2023/01/03
- [RFC PATCH 20/40] target/arm: Merge kvm64.c with kvm.c, Richard Henderson, 2023/01/03
- [RFC PATCH 23/40] target/arm: Probe KVM host into ARMCPUClass, Richard Henderson, 2023/01/03
- [RFC PATCH 24/40] target/arm/hvf: Probe host into ARMCPUClass, Richard Henderson, 2023/01/03
- [RFC PATCH 17/40] target/arm: Copy cp_regs from ARMCPUClass,
Richard Henderson <=
- [RFC PATCH 22/40] target/arm: Hoist feature and dtb_compatible from KVM, HVF, Richard Henderson, 2023/01/03
- [RFC PATCH 25/40] target/arm/hvf: Use offsetof in hvf_arm_get_host_cpu_features, Richard Henderson, 2023/01/03
- [RFC PATCH 27/40] target/arm: Split out strongarm_class_init, Richard Henderson, 2023/01/03
- [RFC PATCH 28/40] target/arm: Split out xscale*_class_init, Richard Henderson, 2023/01/03
- [RFC PATCH 30/40] target/arm: Move feature bit propagation to class init, Richard Henderson, 2023/01/03
- [RFC PATCH 29/40] target/arm: Remove m-profile has_vfp and has_dsp properties, Richard Henderson, 2023/01/03
- [RFC PATCH 31/40] target/arm: Get and set class properties in the monitor, Richard Henderson, 2023/01/03
- [RFC PATCH 32/40] target/arm: Move "midr" to class property, Richard Henderson, 2023/01/03