Re: [PATCH v2 9/9] hw/misc/mps2-fpgaio.c: add GPIOALT2 register
Peter Maydell <[email protected]>
| Newsgroups | org.nongnu.qemu-arm,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <CAFEAcA8rTw8VtRrcOxs4ihqFLwCKeQUMar3HE7ijGsC9bZf5Qw@mail.gmail.com> |
On Wed, 5 Aug 2026 at 16:30, Simon Xu <[email protected]> wrote: > > Add GPIOALT2 register for new an555 board. > Implement register access as RW with LOG_UNIMP for writes. > Add "has-gpioalt2" property to make each board configurable. > > Reviewed-by: Owen Giles <[email protected]> > Reviewed-by: Robert Elliott <[email protected]> > Signed-off-by: Simon Xu <[email protected]> This patch should go in the series before the one where we add the an555 board, so that all the features it's supposed to have are implemented before we expose it to users. > static void mps2_fpgaio_class_init(ObjectClass *klass, const void *data) > diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h > index edd9f23121..7512686616 100644 > --- a/include/hw/misc/mps2-fpgaio.h > +++ b/include/hw/misc/mps2-fpgaio.h > @@ -40,11 +40,13 @@ struct MPS2FPGAIO { > uint32_t num_leds; > bool has_switches; > bool has_dbgctrl; > + bool has_gpioalt2; > > uint32_t led0; > uint32_t prescale; > uint32_t misc; > uint32_t dbgctrl; > + uint32_t gpioalt2; We need to migrate this new device state. To do that we'll have to add a new vmstate subsection to the mps2_fpgaio_vmstate. If you look at iotkit-sysctl.c you can see an example of how this is done: you add a new .subsections to the vmstate, which contains &mps2_fpgaio_gpioalt2_vmstate, plus a NULL terminator. That new mps2_fpgaio_gpioalt2_vmstate should look like this: static const VMStateDescription mps2_fpgaio_gpioalt2_vmstate = { .name = "mps2-fpgaio/gpioalt2", .version_id = 1, .minimum_version_id = 1, .needed = needed_gpioalt2, .fields = (const VMStateField[]) { VMSTATE_UINT32(gpioalt2, MPS2FPGAIO), VMSTATE_END_OF_LIST() } }; The needed_gpioalt2 function should return true if has_gpioalt2. (It gets passed the MPS2FPGAIO* as a void*, so you need to cast it to the right type with the QOM macro.) thanks -- PMM