[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [PATCH 7/7] arm: Instantiate Microbit board-level devices
From: |
Peter Maydell |
Subject: |
Re: [Qemu-arm] [PATCH 7/7] arm: Instantiate Microbit board-level devices |
Date: |
Thu, 16 Aug 2018 16:22:43 +0100 |
On 11 August 2018 at 10:08, Steffen Görtz <address@hidden> wrote:
> Instantiate the LED matrix and set board-level
> pull-up default values to buttons A and B.
> This is necessary to calm down the microsoft pxt
> javascript runtime available for the micro:bit.
>
> Signed-off-by: Steffen Görtz <address@hidden>
> +static void microbit_reset(void)
> +{
> + MachineState *machine = MACHINE(qdev_get_machine());
> + MicrobitMachineState *s = MICROBIT_MACHINE(machine);
> +
> + qemu_devices_reset();
> +
> + /* Board level pull-up */
> + if (!qtest_enabled()) {
> + qemu_set_irq(qdev_get_gpio_in(DEVICE(&s->nrf51), BUTTON_A_PIN), 1);
> + qemu_set_irq(qdev_get_gpio_in(DEVICE(&s->nrf51), BUTTON_B_PIN), 1);
> + }
Reset functions should not call qemu_set_irq().
The problem is that there's no ordering on device reset functions,
so there's no guarantee that the reset function on this end is
called after the reset function for the device it's trying to set
the input GPIO line for. If the two resets happen in the other order
then the device will forget that the input line was high.
There is no good way to handle a line that is supposed to be
pulled high on reset, I'm afraid. You just have to try to avoid
modelling things in a way that requires it.
(Yes, our modelling of reset is basically broken. It's a
hard design problem that nobody's found the time to tackle
properly. You'll see various more-or-less dubious workarounds
if you dig in the right parts of the code base...)
> +}
> +
>
> static void microbit_machine_init(MachineClass *mc)
> {
> mc->desc = "BBC micro:bit";
> mc->init = microbit_init;
> mc->max_cpus = 1;
> + mc->reset = microbit_reset;
> }
>
> static void microbit_machine_init_class_init(ObjectClass *oc, void *data)
> diff --git a/include/hw/arm/microbit.h b/include/hw/arm/microbit.h
> index 89f0c6bc07..094326b4ae 100644
> --- a/include/hw/arm/microbit.h
> +++ b/include/hw/arm/microbit.h
> @@ -24,6 +24,7 @@ typedef struct MicrobitMachineState {
> MachineState parent_obj;
>
> NRF51State nrf51;
> + LEDMatrixState matrix;
> } MicrobitMachineState;
thanks
-- PMM
- Re: [Qemu-arm] [PATCH 3/7] arm: Add chip variant property to nRF51 SoC, (continued)
[Qemu-arm] [PATCH 4/7] arm: Add additional datasheets and copyright lines, Steffen Görtz, 2018/08/11
[Qemu-arm] [PATCH 5/7] arm: Improve error propagation in nRF51 SOC, Steffen Görtz, 2018/08/11
[Qemu-arm] [PATCH 1/7] hw/arm/nrf51_soc: nRF51 Calculate peripheral id from base address, Steffen Görtz, 2018/08/11
[Qemu-arm] [PATCH 7/7] arm: Instantiate Microbit board-level devices, Steffen Görtz, 2018/08/11
- Re: [Qemu-arm] [PATCH 7/7] arm: Instantiate Microbit board-level devices,
Peter Maydell <=
[Qemu-arm] [PATCH 6/7] arm: Instantiate nRF51 peripherals, Steffen Görtz, 2018/08/11