Am 12.06.20 um 19:54 schrieb Philippe Mathieu-Daudé: > A LED device can be connected to a GPIO output. > > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > include/hw/misc/led.h | 30 ++++++++++++++++ > hw/misc/led.c | 84 +++++++++++++++++++++++++++++++++++++++++++ > MAINTAINERS | 6 ++++ > hw/misc/Kconfig | 3 ++ > hw/misc/Makefile.objs | 1 + > hw/misc/trace-events | 3 ++ > 6 files changed, 127 insertions(+) > create mode 100644 include/hw/misc/led.h > create mode 100644 hw/misc/led.c > > diff --git a/include/hw/misc/led.h b/include/hw/misc/led.h > new file mode 100644 > index 0000000000..427ca1418e > --- /dev/null > +++ b/include/hw/misc/led.h > @@ -0,0 +1,30 @@ > +/* > + * QEMU single LED device > + * > + * Copyright (C) 2020 Philippe Mathieu-Daudé <f4...@amsat.org> > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + */ > +#ifndef HW_MISC_LED_H > +#define HW_MISC_LED_H > + > +#include "hw/qdev-core.h" > +#include "hw/sysbus.h" /* FIXME remove */ > + > +#define TYPE_LED "led" > +#define LED(obj) OBJECT_CHECK(LEDState, (obj), TYPE_LED) > + > +typedef struct LEDState { > + /* Private */ > + SysBusDevice parent_obj; /* FIXME DeviceState */ > + /* Public */ > + > + qemu_irq irq; > + uint8_t current_state; > + > + /* Properties */ > + char *name; > + uint8_t reset_state; /* TODO [GPIO_ACTIVE_LOW, GPIO_ACTIVE_HIGH] */ > +} LEDState; > + > +#endif /* HW_MISC_LED_H */
LEDSTate could be made smaller (less holes) by simply re-ordering the elements: irq, name, current_state, reset_state Kind regards Stefan