qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 08/13] hw/rtc/mc146818rtc: QOM'ify IRQ number


From: Bernhard Beschow
Subject: Re: [PATCH 08/13] hw/rtc/mc146818rtc: QOM'ify IRQ number
Date: Mon, 07 Mar 2022 13:58:25 +0000

Am 7. März 2022 13:43:48 UTC schrieb "Philippe Mathieu-Daudé" 
<philippe.mathieu.daude@gmail.com>:
>From: Bernhard Beschow <shentey@gmail.com>
>
>Exposing the IRQ number as a QOM property not only allows it to be
>configurable but also to be displayed in HMP:
>
>Before:
>
>(qemu) info qtree
>       ...
>          dev: mc146818rtc, id ""
>            gpio-out "" 1
>            base_year = 0 (0x0)
>            lost_tick_policy = "discard"
>
>After:
>
>          dev: mc146818rtc, id ""
>            gpio-out "" 1
>            base_year = 0 (0x0)
>            irq = 8 (0x8)
>            lost_tick_policy = "discard"
>
>The reason the IRQ number didn's show up before is that this device does not
>call isa_init_irq().
>
>Signed-off-by: Bernhard Beschow <shentey@gmail.com>
>Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>Message-Id: <20220301220037.76555-2-shentey@gmail.com>
>Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>---
> hw/isa/piix4.c               |  2 +-
> hw/rtc/mc146818rtc.c         | 13 +++++++++++--
> include/hw/rtc/mc146818rtc.h |  1 +
> 3 files changed, 13 insertions(+), 3 deletions(-)
>
>diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
>index f876c71750..fc3c8b3fd1 100644
>--- a/hw/isa/piix4.c
>+++ b/hw/isa/piix4.c
>@@ -216,7 +216,7 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
>     if (!qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), errp)) {
>         return;
>     }
>-    isa_init_irq(ISA_DEVICE(&s->rtc), &s->rtc.irq, RTC_ISA_IRQ);
>+    isa_init_irq(ISA_DEVICE(&s->rtc), &s->rtc.irq, s->rtc.isairq);
> }
> 
> static void piix4_init(Object *obj)
>diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
>index ac9a60c90e..f235c2ddbe 100644
>--- a/hw/rtc/mc146818rtc.c
>+++ b/hw/rtc/mc146818rtc.c
>@@ -912,6 +912,11 @@ static void rtc_realizefn(DeviceState *dev, Error **errp)
>         s->base_year = 0;
>     }
> 
>+    if (s->isairq >= ISA_NUM_IRQS) {
>+        error_setg(errp, "Maximum value for \"irq\" is: %u", ISA_NUM_IRQS - 
>1);
>+        return;
>+    }
>+
>     rtc_set_date_from_host(isadev);
> 
>     switch (s->lost_tick_policy) {
>@@ -957,15 +962,17 @@ ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, 
>qemu_irq intercept_irq)
> {
>     DeviceState *dev;
>     ISADevice *isadev;
>+    RTCState *s;
> 
>     isadev = isa_new(TYPE_MC146818_RTC);
>     dev = DEVICE(isadev);
>+    s = MC146818_RTC(isadev);
>     qdev_prop_set_int32(dev, "base_year", base_year);
>     isa_realize_and_unref(isadev, bus, &error_fatal);
>     if (intercept_irq) {
>         qdev_connect_gpio_out(dev, 0, intercept_irq);
>     } else {
>-        isa_connect_gpio_out(isadev, 0, RTC_ISA_IRQ);
>+        isa_connect_gpio_out(isadev, 0, s->isairq);
>     }
> 
>     object_property_add_alias(qdev_get_machine(), "rtc-time", OBJECT(isadev),
>@@ -976,6 +983,7 @@ ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, 
>qemu_irq intercept_irq)
> 
> static Property mc146818rtc_properties[] = {
>     DEFINE_PROP_INT32("base_year", RTCState, base_year, 1980),
>+    DEFINE_PROP_UINT8("irq", RTCState, isairq, RTC_ISA_IRQ),
>     DEFINE_PROP_LOSTTICKPOLICY("lost_tick_policy", RTCState,
>                                lost_tick_policy, LOST_TICK_POLICY_DISCARD),
>     DEFINE_PROP_END_OF_LIST(),
>@@ -1011,6 +1019,7 @@ static void rtc_reset_hold(Object *obj)
> 
> static void rtc_build_aml(ISADevice *isadev, Aml *scope)
> {
>+    RTCState *s = MC146818_RTC(isadev);
>     Aml *dev;
>     Aml *crs;
> 
>@@ -1021,7 +1030,7 @@ static void rtc_build_aml(ISADevice *isadev, Aml *scope)
>     crs = aml_resource_template();
>     aml_append(crs, aml_io(AML_DECODE16, RTC_ISA_BASE, RTC_ISA_BASE,
>                            0x01, 0x08));
>-    aml_append(crs, aml_irq_no_flags(RTC_ISA_IRQ));
>+    aml_append(crs, aml_irq_no_flags(s->isairq));
> 
>     dev = aml_device("RTC");
>     aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0B00")));
>diff --git a/include/hw/rtc/mc146818rtc.h b/include/hw/rtc/mc146818rtc.h
>index 5b45b22924..deef93f89a 100644
>--- a/include/hw/rtc/mc146818rtc.h
>+++ b/include/hw/rtc/mc146818rtc.h
>@@ -25,6 +25,7 @@ struct RTCState {
>     MemoryRegion coalesced_io;
>     uint8_t cmos_data[128];
>     uint8_t cmos_index;
>+    uint8_t isairq;
>     int32_t base_year;
>     uint64_t base_rtc;
>     uint64_t last_update;

Reviewed-by: Bernhard Beschow <shentey@gmail.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]