[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 14/16] target/riscv/cpu.c: move 'mvendorid' to riscv_cpu_properti
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 14/16] target/riscv/cpu.c: move 'mvendorid' to riscv_cpu_properties[] |
Date: |
Thu, 21 Dec 2023 14:51:35 -0300 |
Keep all class properties in riscv_cpu_properties[].
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
target/riscv/cpu.c | 69 +++++++++++++++++++++++++---------------------
1 file changed, 37 insertions(+), 32 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 11afc45103..b5f754309a 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1860,6 +1860,41 @@ const PropertyInfo prop_cboz_blksize = {
.set_default_value = qdev_propinfo_set_default_value_uint,
};
+static void prop_mvendorid_set(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ bool dynamic_cpu = riscv_cpu_is_dynamic(obj);
+ RISCVCPU *cpu = RISCV_CPU(obj);
+ uint32_t prev_val = cpu->cfg.mvendorid;
+ uint32_t value;
+
+ if (!visit_type_uint32(v, name, &value, errp)) {
+ return;
+ }
+
+ if (!dynamic_cpu && prev_val != value) {
+ error_setg(errp, "Unable to change %s mvendorid (0x%x)",
+ object_get_typename(obj), prev_val);
+ return;
+ }
+
+ cpu->cfg.mvendorid = value;
+}
+
+static void prop_mvendorid_get(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ uint32_t value = RISCV_CPU(obj)->cfg.mvendorid;
+
+ visit_type_uint32(v, name, &value, errp);
+}
+
+const PropertyInfo prop_mvendorid = {
+ .name = "mvendorid",
+ .get = prop_mvendorid_get,
+ .set = prop_mvendorid_set,
+};
+
static Property riscv_cpu_properties[] = {
DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true),
@@ -1884,6 +1919,8 @@ static Property riscv_cpu_properties[] = {
{.name = "cboz_blocksize", .info = &prop_cboz_blksize,
.set_default = true, .defval.u = 64},
+ {.name = "mvendorid", .info = &prop_mvendorid},
+
#ifndef CONFIG_USER_ONLY
DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC),
#endif
@@ -1948,35 +1985,6 @@ static const struct SysemuCPUOps riscv_sysemu_ops = {
};
#endif
-static void cpu_set_mvendorid(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
-{
- bool dynamic_cpu = riscv_cpu_is_dynamic(obj);
- RISCVCPU *cpu = RISCV_CPU(obj);
- uint32_t prev_val = cpu->cfg.mvendorid;
- uint32_t value;
-
- if (!visit_type_uint32(v, name, &value, errp)) {
- return;
- }
-
- if (!dynamic_cpu && prev_val != value) {
- error_setg(errp, "Unable to change %s mvendorid (0x%x)",
- object_get_typename(obj), prev_val);
- return;
- }
-
- cpu->cfg.mvendorid = value;
-}
-
-static void cpu_get_mvendorid(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
-{
- uint32_t value = RISCV_CPU(obj)->cfg.mvendorid;
-
- visit_type_uint32(v, name, &value, errp);
-}
-
static void cpu_set_mimpid(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
@@ -2086,9 +2094,6 @@ static void riscv_cpu_class_init(ObjectClass *c, void
*data)
cc->gdb_arch_name = riscv_gdb_arch_name;
cc->gdb_get_dynamic_xml = riscv_gdb_get_dynamic_xml;
- object_class_property_add(c, "mvendorid", "uint32", cpu_get_mvendorid,
- cpu_set_mvendorid, NULL, NULL);
-
object_class_property_add(c, "mimpid", "uint64", cpu_get_mimpid,
cpu_set_mimpid, NULL, NULL);
--
2.43.0
- [PATCH 06/16] target/riscv: rework 'priv_spec', (continued)
- [PATCH 06/16] target/riscv: rework 'priv_spec', Daniel Henrique Barboza, 2023/12/21
- [PATCH 08/16] target/riscv: move 'vlen' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 07/16] target/riscv: rework 'vext_spec', Daniel Henrique Barboza, 2023/12/21
- [PATCH 09/16] target/riscv: move 'elen' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 10/16] target/riscv: create finalize_features() for KVM, Daniel Henrique Barboza, 2023/12/21
- [PATCH 11/16] target/riscv: move 'cbom_blocksize' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 12/16] target/riscv: move 'cboz_blocksize' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 13/16] target/riscv: remove riscv_cpu_options[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 15/16] target/riscv/cpu.c: move 'mimpid' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 14/16] target/riscv/cpu.c: move 'mvendorid' to riscv_cpu_properties[],
Daniel Henrique Barboza <=
- [PATCH 16/16] target/riscv/cpu.c: move 'marchid' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21