Skip to content

Commit

Permalink
[ot] hw/opentitan: ibex_common, ibexdemo: fix lint warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Emmanuel Blot <[email protected]>
  • Loading branch information
rivos-eblot committed Nov 28, 2023
1 parent 475ab74 commit c3153db
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
13 changes: 9 additions & 4 deletions hw/riscv/ibex_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ void ibex_define_device_props(DeviceState **devices, const IbexDeviceDef *defs,
prop->i, &error_fatal);
break;
case IBEX_PROP_TYPE_UINT:
object_property_set_int(OBJECT(dev), prop->propname,
prop->u, &error_fatal);
object_property_set_uint(OBJECT(dev), prop->propname,
prop->u, &error_fatal);
break;
case IBEX_PROP_TYPE_STR:
object_property_set_str(OBJECT(dev), prop->propname,
Expand Down Expand Up @@ -399,7 +399,7 @@ void ibex_export_gpios(DeviceState **devices, DeviceState *parent,
}
}
}
assert(ngl);
assert(ngl && ngl->in);
ngl->in[export->parent.num] = devirq;
(void)object_ref(OBJECT(devirq));
object_property_add_alias(OBJECT(parent), ppname, OBJECT(dev),
Expand Down Expand Up @@ -435,7 +435,7 @@ void ibex_connect_soc_devices(DeviceState **soc_devices, DeviceState **devices,
DeviceState *socdev = soc_devices[grp];
unsigned in_ix = IBEX_GPIO_GET_IDX(conn->in.num);
qemu_irq in_gpio =
qdev_get_gpio_in_named(socdev, conn->in.name, in_ix);
qdev_get_gpio_in_named(socdev, conn->in.name, (int)in_ix);
if (!in_gpio) {
error_setg(
&error_fatal,
Expand Down Expand Up @@ -507,6 +507,8 @@ DeviceState *ibex_get_child_device(DeviceState *s, const char *typename,
void ibex_unimp_configure(DeviceState *dev, const IbexDeviceDef *def,
DeviceState *parent)
{
(void)parent;

if (def->name) {
qdev_prop_set_string(dev, "name", def->name);
}
Expand All @@ -530,6 +532,7 @@ void ibex_load_kernel(AddressSpace *as)
}

CPUState *cpu;
/* NOLINTNEXTLINE */
CPU_FOREACH(cpu) {
if (!as || cpu->as == as) {
CPURISCVState *env = &RISCV_CPU(cpu)->env;
Expand Down Expand Up @@ -589,7 +592,9 @@ static void rust_demangle_fn(const char *st_name, int st_info,
static void hmp_info_ibex(Monitor *mon, const QDict *qdict)
{
CPUState *cpu;
(void)qdict;

/* NOLINTNEXTLINE */
CPU_FOREACH(cpu) {
vaddr pc;
const char *symbol;
Expand Down
17 changes: 15 additions & 2 deletions hw/riscv/ibexdemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,17 @@ struct IbexDemoMachineState {
static void ibexdemo_soc_gpio_configure(
DeviceState *dev, const IbexDeviceDef *def, DeviceState *parent)
{
(void)def;
(void)parent;
qdev_prop_set_uint32(dev, "in_count", IBEXDEMO_GPIO_IN_MAX);
qdev_prop_set_uint32(dev, "out_count", IBEXDEMO_GPIO_OUT_MAX);
}

static void ibexdemo_soc_hart_configure(
DeviceState *dev, const IbexDeviceDef *def, DeviceState *parent)
{
(void)def;
(void)parent;
IbexDemoSoCState *s = RISCV_IBEXDEMO_SOC(parent);

qdev_prop_set_uint64(dev, "resetvec", s->resetvec);
Expand All @@ -197,20 +201,23 @@ static void ibexdemo_soc_hart_configure(
static void ibexdemo_soc_uart_configure(
DeviceState *dev, const IbexDeviceDef *def, DeviceState *parent)
{
(void)parent;
qdev_prop_set_chr(dev, "chardev", serial_hd(def->instance));
}

/* ------------------------------------------------------------------------ */
/* SoC */
/* ------------------------------------------------------------------------ */

static void ibexdemo_soc_load_boot(IbexDemoSoCState *s)
static void ibexdemo_soc_load_boot(void)
{
/* do not use rom_add_blob_fixed_as as absolute address is not yet known */
MachineState *ms = MACHINE(qdev_get_machine());
void *ram = memory_region_get_ram_ptr(ms->ram);
if (!ram) {
error_setg(&error_fatal, "no main RAM");
/* linter cannot detect error_fatal prevents from returning */
abort();
}
memcpy(ram, IBEXDEMO_BOOT, sizeof(IBEXDEMO_BOOT));
}
Expand All @@ -224,6 +231,8 @@ static void ibexdemo_soc_reset(DeviceState *dev)

static void ibexdemo_soc_realize(DeviceState *dev, Error **errp)
{
(void)errp;

IbexDemoSoCState *s = RISCV_IBEXDEMO_SOC(dev);

MachineState *ms = MACHINE(qdev_get_machine());
Expand All @@ -239,7 +248,7 @@ static void ibexdemo_soc_realize(DeviceState *dev, Error **errp)
ibex_connect_devices(s->devices, ibexdemo_soc_devices,
ARRAY_SIZE(ibexdemo_soc_devices));

ibexdemo_soc_load_boot(s);
ibexdemo_soc_load_boot();

/* load application if provided */
ibex_load_kernel(NULL);
Expand All @@ -262,6 +271,7 @@ static Property ibexdemo_soc_props[] = {
static void ibexdemo_soc_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
(void)data;

device_class_set_props(dc, ibexdemo_soc_props);
dc->reset = &ibexdemo_soc_reset;
Expand Down Expand Up @@ -291,6 +301,7 @@ type_init(ibexdemo_soc_register_types);
static void ibexdemo_board_realize(DeviceState *dev, Error **errp)
{
IbexDemoBoardState *board = RISCV_IBEXDEMO_BOARD(dev);
(void)errp;

IbexDemoSoCState *soc =
RISCV_IBEXDEMO_SOC(board->devices[IBEXDEMO_BOARD_DEV_SOC]);
Expand Down Expand Up @@ -331,6 +342,7 @@ static void ibexdemo_board_instance_init(Object *obj)
static void ibexdemo_board_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
(void)data;

dc->realize = &ibexdemo_board_realize;
}
Expand Down Expand Up @@ -366,6 +378,7 @@ static void ibexdemo_machine_init(MachineState *state)
static void ibexdemo_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
(void)data;

mc->desc = "RISC-V Board compatible with IbexDemo";
mc->init = ibexdemo_machine_init;
Expand Down

0 comments on commit c3153db

Please sign in to comment.