Message ID | 20230520054510.68822-5-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw/riscv/opentitan: Correct QOM type/size of OpenTitanState | expand |
On 5/20/23 02:45, Philippe Mathieu-Daudé wrote: > Expand the DEFINE_MACHINE() macro, converting the class_init() > handler. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> > include/hw/riscv/opentitan.h | 3 ++- > hw/riscv/opentitan.c | 10 +++++++--- > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h > index fd70226ed8..806ff73528 100644 > --- a/include/hw/riscv/opentitan.h > +++ b/include/hw/riscv/opentitan.h > @@ -24,6 +24,7 @@ > #include "hw/char/ibex_uart.h" > #include "hw/timer/ibex_timer.h" > #include "hw/ssi/ibex_spi_host.h" > +#include "hw/boards.h" > #include "qom/object.h" > > #define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc" > @@ -53,7 +54,7 @@ struct LowRISCIbexSoCState { > MemoryRegion flash_alias; > }; > > -#define TYPE_OPENTITAN_MACHINE "opentitan" > +#define TYPE_OPENTITAN_MACHINE MACHINE_TYPE_NAME("opentitan") > > typedef struct OpenTitanState { > /*< private >*/ > diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c > index 7d7159ea30..9535308197 100644 > --- a/hw/riscv/opentitan.c > +++ b/hw/riscv/opentitan.c > @@ -108,8 +108,10 @@ static void opentitan_machine_init(MachineState *machine) > } > } > > -static void opentitan_machine_class_init(MachineClass *mc) > +static void opentitan_machine_class_init(ObjectClass *oc, void *data) > { > + MachineClass *mc = MACHINE_CLASS(oc); > + > mc->desc = "RISC-V Board compatible with OpenTitan"; > mc->init = opentitan_machine_init; > mc->max_cpus = 1; > @@ -118,8 +120,6 @@ static void opentitan_machine_class_init(MachineClass *mc) > mc->default_ram_size = ibex_memmap[IBEX_DEV_RAM].size; > } > > -DEFINE_MACHINE(TYPE_OPENTITAN_MACHINE, opentitan_machine_class_init) > - > static void lowrisc_ibex_soc_init(Object *obj) > { > LowRISCIbexSoCState *s = RISCV_IBEX_SOC(obj); > @@ -327,6 +327,10 @@ static const TypeInfo open_titan_types[] = { > .instance_size = sizeof(LowRISCIbexSoCState), > .instance_init = lowrisc_ibex_soc_init, > .class_init = lowrisc_ibex_soc_class_init, > + }, { > + .name = TYPE_OPENTITAN_MACHINE, > + .parent = TYPE_MACHINE, > + .class_init = opentitan_machine_class_init, > } > }; >
On Sat, May 20, 2023 at 3:47 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > Expand the DEFINE_MACHINE() macro, converting the class_init() > handler. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > include/hw/riscv/opentitan.h | 3 ++- > hw/riscv/opentitan.c | 10 +++++++--- > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h > index fd70226ed8..806ff73528 100644 > --- a/include/hw/riscv/opentitan.h > +++ b/include/hw/riscv/opentitan.h > @@ -24,6 +24,7 @@ > #include "hw/char/ibex_uart.h" > #include "hw/timer/ibex_timer.h" > #include "hw/ssi/ibex_spi_host.h" > +#include "hw/boards.h" > #include "qom/object.h" > > #define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc" > @@ -53,7 +54,7 @@ struct LowRISCIbexSoCState { > MemoryRegion flash_alias; > }; > > -#define TYPE_OPENTITAN_MACHINE "opentitan" > +#define TYPE_OPENTITAN_MACHINE MACHINE_TYPE_NAME("opentitan") > > typedef struct OpenTitanState { > /*< private >*/ > diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c > index 7d7159ea30..9535308197 100644 > --- a/hw/riscv/opentitan.c > +++ b/hw/riscv/opentitan.c > @@ -108,8 +108,10 @@ static void opentitan_machine_init(MachineState *machine) > } > } > > -static void opentitan_machine_class_init(MachineClass *mc) > +static void opentitan_machine_class_init(ObjectClass *oc, void *data) > { > + MachineClass *mc = MACHINE_CLASS(oc); > + > mc->desc = "RISC-V Board compatible with OpenTitan"; > mc->init = opentitan_machine_init; > mc->max_cpus = 1; > @@ -118,8 +120,6 @@ static void opentitan_machine_class_init(MachineClass *mc) > mc->default_ram_size = ibex_memmap[IBEX_DEV_RAM].size; > } > > -DEFINE_MACHINE(TYPE_OPENTITAN_MACHINE, opentitan_machine_class_init) > - > static void lowrisc_ibex_soc_init(Object *obj) > { > LowRISCIbexSoCState *s = RISCV_IBEX_SOC(obj); > @@ -327,6 +327,10 @@ static const TypeInfo open_titan_types[] = { > .instance_size = sizeof(LowRISCIbexSoCState), > .instance_init = lowrisc_ibex_soc_init, > .class_init = lowrisc_ibex_soc_class_init, > + }, { > + .name = TYPE_OPENTITAN_MACHINE, > + .parent = TYPE_MACHINE, > + .class_init = opentitan_machine_class_init, > } > }; > > -- > 2.38.1 > >
diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h index fd70226ed8..806ff73528 100644 --- a/include/hw/riscv/opentitan.h +++ b/include/hw/riscv/opentitan.h @@ -24,6 +24,7 @@ #include "hw/char/ibex_uart.h" #include "hw/timer/ibex_timer.h" #include "hw/ssi/ibex_spi_host.h" +#include "hw/boards.h" #include "qom/object.h" #define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc" @@ -53,7 +54,7 @@ struct LowRISCIbexSoCState { MemoryRegion flash_alias; }; -#define TYPE_OPENTITAN_MACHINE "opentitan" +#define TYPE_OPENTITAN_MACHINE MACHINE_TYPE_NAME("opentitan") typedef struct OpenTitanState { /*< private >*/ diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 7d7159ea30..9535308197 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -108,8 +108,10 @@ static void opentitan_machine_init(MachineState *machine) } } -static void opentitan_machine_class_init(MachineClass *mc) +static void opentitan_machine_class_init(ObjectClass *oc, void *data) { + MachineClass *mc = MACHINE_CLASS(oc); + mc->desc = "RISC-V Board compatible with OpenTitan"; mc->init = opentitan_machine_init; mc->max_cpus = 1; @@ -118,8 +120,6 @@ static void opentitan_machine_class_init(MachineClass *mc) mc->default_ram_size = ibex_memmap[IBEX_DEV_RAM].size; } -DEFINE_MACHINE(TYPE_OPENTITAN_MACHINE, opentitan_machine_class_init) - static void lowrisc_ibex_soc_init(Object *obj) { LowRISCIbexSoCState *s = RISCV_IBEX_SOC(obj); @@ -327,6 +327,10 @@ static const TypeInfo open_titan_types[] = { .instance_size = sizeof(LowRISCIbexSoCState), .instance_init = lowrisc_ibex_soc_init, .class_init = lowrisc_ibex_soc_class_init, + }, { + .name = TYPE_OPENTITAN_MACHINE, + .parent = TYPE_MACHINE, + .class_init = opentitan_machine_class_init, } };
Expand the DEFINE_MACHINE() macro, converting the class_init() handler. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/hw/riscv/opentitan.h | 3 ++- hw/riscv/opentitan.c | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-)