Skip to content

Commit

Permalink
target/riscv/cpu.c: move 'mvendorid' to riscv_cpu_properties[]
Browse files Browse the repository at this point in the history
Keep all class properties in riscv_cpu_properties[].

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
tested-by tags added, rebased with Alistair's riscv-to-apply.next.
Message-ID: <20240112140201.127083-7-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
  • Loading branch information
danielhb authored and alistair23 committed Feb 9, 2024
1 parent 08a2538 commit a9a2593
Showing 1 changed file with 37 additions and 32 deletions.
69 changes: 37 additions & 32 deletions target/riscv/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,41 @@ static const PropertyInfo prop_cboz_blksize = {
.set = prop_cboz_blksize_set,
};

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);
}

static const PropertyInfo prop_mvendorid = {
.name = "mvendorid",
.get = prop_mvendorid_get,
.set = prop_mvendorid_set,
};

/*
* RVA22U64 defines some 'named features' or 'synthetic extensions'
* that are cache related: Za64rs, Zic64b, Ziccif, Ziccrse, Ziccamoa
Expand Down Expand Up @@ -2071,6 +2106,8 @@ static Property riscv_cpu_properties[] = {
{.name = "cbop_blocksize", .info = &prop_cbop_blksize},
{.name = "cboz_blocksize", .info = &prop_cboz_blksize},

{.name = "mvendorid", .info = &prop_mvendorid},

#ifndef CONFIG_USER_ONLY
DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC),
#endif
Expand Down Expand Up @@ -2151,35 +2188,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)
{
Expand Down Expand Up @@ -2290,9 +2298,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);

Expand Down

0 comments on commit a9a2593

Please sign in to comment.