target/riscv/cpu.c: make misa_ext_cfgs[] 'const'
The array isn't marked as 'const' because we're initializing their elements in riscv_cpu_add_misa_properties(), 'name' and 'description' fields. In a closer look we can see that we're not using these 2 fields after creating the MISA properties. And we can create the properties by using riscv_get_misa_ext_name() and riscv_get_misa_ext_description() directly. Remove the 'name' and 'description' fields from RISCVCPUMisaExtConfig and make misa_ext_cfgs[] a const array. Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20230925175709.35696-17-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
fce8bb5d08
commit
1dbb6104ff
@ -1208,8 +1208,6 @@ static void riscv_cpu_init(Object *obj)
|
||||
}
|
||||
|
||||
typedef struct RISCVCPUMisaExtConfig {
|
||||
const char *name;
|
||||
const char *description;
|
||||
target_ulong misa_bit;
|
||||
bool enabled;
|
||||
} RISCVCPUMisaExtConfig;
|
||||
@ -1313,7 +1311,7 @@ const char *riscv_get_misa_ext_description(uint32_t bit)
|
||||
#define MISA_CFG(_bit, _enabled) \
|
||||
{.misa_bit = _bit, .enabled = _enabled}
|
||||
|
||||
static RISCVCPUMisaExtConfig misa_ext_cfgs[] = {
|
||||
static const RISCVCPUMisaExtConfig misa_ext_cfgs[] = {
|
||||
MISA_CFG(RVA, true),
|
||||
MISA_CFG(RVC, true),
|
||||
MISA_CFG(RVD, true),
|
||||
@ -1340,25 +1338,22 @@ void riscv_cpu_add_misa_properties(Object *cpu_obj)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(misa_ext_cfgs); i++) {
|
||||
RISCVCPUMisaExtConfig *misa_cfg = &misa_ext_cfgs[i];
|
||||
const RISCVCPUMisaExtConfig *misa_cfg = &misa_ext_cfgs[i];
|
||||
int bit = misa_cfg->misa_bit;
|
||||
|
||||
misa_cfg->name = riscv_get_misa_ext_name(bit);
|
||||
misa_cfg->description = riscv_get_misa_ext_description(bit);
|
||||
const char *name = riscv_get_misa_ext_name(bit);
|
||||
const char *desc = riscv_get_misa_ext_description(bit);
|
||||
|
||||
/* Check if KVM already created the property */
|
||||
if (object_property_find(cpu_obj, misa_cfg->name)) {
|
||||
if (object_property_find(cpu_obj, name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
object_property_add(cpu_obj, misa_cfg->name, "bool",
|
||||
object_property_add(cpu_obj, name, "bool",
|
||||
cpu_get_misa_ext_cfg,
|
||||
cpu_set_misa_ext_cfg,
|
||||
NULL, (void *)misa_cfg);
|
||||
object_property_set_description(cpu_obj, misa_cfg->name,
|
||||
misa_cfg->description);
|
||||
object_property_set_bool(cpu_obj, misa_cfg->name,
|
||||
misa_cfg->enabled, NULL);
|
||||
object_property_set_description(cpu_obj, name, desc);
|
||||
object_property_set_bool(cpu_obj, name, misa_cfg->enabled, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user