qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>
To: Bernhard Beschow <shentey@gmail.com>, qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [PATCH 10/13] hw/input/pckbd: QOM'ify IRQ numbers
Date: Mon,  7 Mar 2022 14:43:50 +0100	[thread overview]
Message-ID: <20220307134353.1950-11-philippe.mathieu.daude@gmail.com> (raw)
In-Reply-To: <20220307134353.1950-1-philippe.mathieu.daude@gmail.com>

From: Bernhard Beschow <shentey@gmail.com>

Exposing the IRQ numbers as QOM properties not only allows them to be
configurable but also to be printed by standard QOM mechanisms. This
allows isabus_dev_print() to be retired eventually.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220301220037.76555-4-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/input/pckbd.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index baba62f357..eb77e12f6f 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -26,6 +26,7 @@
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "qemu/timer.h"
+#include "qapi/error.h"
 #include "hw/isa/isa.h"
 #include "migration/vmstate.h"
 #include "hw/acpi/aml-build.h"
@@ -671,6 +672,8 @@ struct ISAKBDState {
     KBDState kbd;
     bool kbd_throttle;
     MemoryRegion io[2];
+    uint8_t kbd_irq;
+    uint8_t mouse_irq;
 };
 
 void i8042_isa_mouse_fake_event(ISAKBDState *isa)
@@ -734,8 +737,20 @@ static void i8042_realizefn(DeviceState *dev, Error **errp)
     ISAKBDState *isa_s = I8042(dev);
     KBDState *s = &isa_s->kbd;
 
-    isa_init_irq(isadev, &s->irq_kbd, 1);
-    isa_init_irq(isadev, &s->irq_mouse, 12);
+    if (isa_s->kbd_irq >= ISA_NUM_IRQS) {
+        error_setg(errp, "Maximum value for \"kbd-irq\" is: %u",
+                   ISA_NUM_IRQS - 1);
+        return;
+    }
+
+    if (isa_s->mouse_irq >= ISA_NUM_IRQS) {
+        error_setg(errp, "Maximum value for \"mouse-irq\" is: %u",
+                   ISA_NUM_IRQS - 1);
+        return;
+    }
+
+    isa_init_irq(isadev, &s->irq_kbd, isa_s->kbd_irq);
+    isa_init_irq(isadev, &s->irq_mouse, isa_s->mouse_irq);
 
     isa_register_ioport(isadev, isa_s->io + 0, 0x60);
     isa_register_ioport(isadev, isa_s->io + 1, 0x64);
@@ -754,6 +769,7 @@ static void i8042_realizefn(DeviceState *dev, Error **errp)
 
 static void i8042_build_aml(ISADevice *isadev, Aml *scope)
 {
+    ISAKBDState *isa_s = I8042(isadev);
     Aml *kbd;
     Aml *mou;
     Aml *crs;
@@ -761,7 +777,7 @@ static void i8042_build_aml(ISADevice *isadev, Aml *scope)
     crs = aml_resource_template();
     aml_append(crs, aml_io(AML_DECODE16, 0x0060, 0x0060, 0x01, 0x01));
     aml_append(crs, aml_io(AML_DECODE16, 0x0064, 0x0064, 0x01, 0x01));
-    aml_append(crs, aml_irq_no_flags(1));
+    aml_append(crs, aml_irq_no_flags(isa_s->kbd_irq));
 
     kbd = aml_device("KBD");
     aml_append(kbd, aml_name_decl("_HID", aml_eisaid("PNP0303")));
@@ -769,7 +785,7 @@ static void i8042_build_aml(ISADevice *isadev, Aml *scope)
     aml_append(kbd, aml_name_decl("_CRS", crs));
 
     crs = aml_resource_template();
-    aml_append(crs, aml_irq_no_flags(12));
+    aml_append(crs, aml_irq_no_flags(isa_s->mouse_irq));
 
     mou = aml_device("MOU");
     aml_append(mou, aml_name_decl("_HID", aml_eisaid("PNP0F13")));
@@ -783,6 +799,8 @@ static void i8042_build_aml(ISADevice *isadev, Aml *scope)
 static Property i8042_properties[] = {
     DEFINE_PROP_BOOL("extended-state", ISAKBDState, kbd.extended_state, true),
     DEFINE_PROP_BOOL("kbd-throttle", ISAKBDState, kbd_throttle, false),
+    DEFINE_PROP_UINT8("kbd-irq", ISAKBDState, kbd_irq, 1),
+    DEFINE_PROP_UINT8("mouse-irq", ISAKBDState, mouse_irq, 12),
     DEFINE_PROP_END_OF_LIST(),
 };
 
-- 
2.34.1



  parent reply	other threads:[~2022-03-07 14:06 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 13:43 [PATCH 00/13] hw: ISA & MIPS patches from Bernhard Beschow Philippe Mathieu-Daudé
2022-03-07 13:43 ` [PATCH 01/13] hw/mips/gt64xxx_pci: Fix PCI IRQ levels to be preserved during migration Philippe Mathieu-Daudé
2022-03-08 18:09   ` Richard Henderson
2022-03-07 13:43 ` [PATCH 02/13] malta: Move PCI interrupt handling from gt64xxx_pci to piix4 Philippe Mathieu-Daudé
2022-03-07 13:43 ` [PATCH 03/13] hw/isa/piix4: Resolve redundant i8259[] attribute Philippe Mathieu-Daudé
2022-03-08 18:18   ` Richard Henderson
2022-03-07 13:43 ` [PATCH 04/13] hw/isa/piix4: Pass PIIX4State as opaque parameter for piix4_set_irq() Philippe Mathieu-Daudé
2022-03-08 18:20   ` Richard Henderson
2022-03-07 13:43 ` [PATCH 05/13] hw/isa/piix4: Resolve global instance variable Philippe Mathieu-Daudé
2022-03-08 18:20   ` Richard Henderson
2022-03-07 13:43 ` [PATCH 06/13] hw/isa/piix4: Replace some magic IRQ constants Philippe Mathieu-Daudé
2022-03-08 18:21   ` Richard Henderson
2022-03-07 13:43 ` [PATCH 07/13] hw/mips/gt64xxx_pci: Resolve gt64120_register() Philippe Mathieu-Daudé
2022-03-08 18:32   ` Richard Henderson
2022-03-07 13:43 ` [PATCH 08/13] hw/rtc/mc146818rtc: QOM'ify IRQ number Philippe Mathieu-Daudé
2022-03-07 13:58   ` Bernhard Beschow
2022-03-07 13:43 ` [PATCH 09/13] hw/rtc/m48t59-isa: " Philippe Mathieu-Daudé
2022-03-07 13:59   ` Bernhard Beschow
2022-03-07 13:43 ` Philippe Mathieu-Daudé [this message]
2022-03-07 13:59   ` [PATCH 10/13] hw/input/pckbd: QOM'ify IRQ numbers Bernhard Beschow
2022-03-07 13:43 ` [PATCH 11/13] hw/isa/isa-bus: Remove isabus_dev_print() Philippe Mathieu-Daudé
2022-03-07 14:00   ` Bernhard Beschow
2022-03-07 13:43 ` [PATCH 12/13] hw/isa: Drop unused attributes from ISADevice Philippe Mathieu-Daudé
2022-03-07 14:01   ` Bernhard Beschow
2022-03-07 13:43 ` [PATCH 13/13] hw/isa: Inline and remove one-line isa_init_irq() Philippe Mathieu-Daudé
2022-03-07 13:54   ` Bernhard Beschow
2022-03-07 14:04 ` [PATCH 00/13] hw: ISA & MIPS patches from Bernhard Beschow Bernhard Beschow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220307134353.1950-11-philippe.mathieu.daude@gmail.com \
    --to=philippe.mathieu.daude@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shentey@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).