Skip to contentSkip to conversation

hw/isa: Introduce definitions for default IRQ values

PATCH In review Philippe Mathieu-Daudé 4 participants 23 messages Oct 11, 2020 – Oct 13, 2020

lore
Share & tools
lore
#0 lore raw

cover hw/isa: Introduce definitions for default IRQ values

Replace various magic values by definitions to make the code easier to read.

This probably makes sense to merge this series via the 'PC chipset' tree, rather than qemu-trivial@.

Regards,

Phil.

Philippe Mathieu-Daudé (10):
hw/isa: Introduce IsaIrqNumber enum
hw/isa: Add the ISA_IRQ_KBD_DEFAULT definition
hw/isa: Add the ISA_IRQ_SER_DEFAULT definition
hw/isa: Add the ISA_IRQ_TPM_DEFAULT definition
hw/isa: Add the ISA_IRQ_FDC_DEFAULT definition
hw/isa: Add the ISA_IRQ_PAR_DEFAULT definition
hw/isa: Add the ISA_IRQ_RTC_DEFAULT definition
hw/isa: Add the ISA_IRQ_NET_DEFAULT definition
hw/isa: Add the ISA_IRQ_MOU_DEFAULT definition
hw/isa: Add the ISA_IRQ_IDE_DEFAULT definition

 include/hw/isa/isa.h         | 13 ++++++++++++-
 include/hw/rtc/mc146818rtc.h |  1 -
 hw/block/fdc.c               |  4 ++--
 hw/char/parallel.c           |  2 +-
 hw/i386/acpi-build.c         |  2 +-
 hw/ide/isa.c                 |  2 +-
 hw/input/pckbd.c             |  2 +-
 hw/ipmi/isa_ipmi_bt.c        |  2 +-
 hw/ipmi/isa_ipmi_kcs.c       |  2 +-
 hw/isa/piix4.c               |  2 +-
 hw/net/ne2000-isa.c          |  2 +-
 hw/rtc/m48t59-isa.c          |  2 +-
 hw/rtc/mc146818rtc.c         |  4 ++--
 hw/sparc64/sun4u.c           | 10 +++++-----
 hw/timer/hpet.c              |  8 ++++----
 hw/tpm/tpm_tis_isa.c         |  2 +-
 tests/qtest/rtc-test.c       |  8 ++++----
 17 files changed, 39 insertions(+), 29 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/10 hw/isa: Introduce IsaIrqNumber enum

We are going to list all default ISA IRQs. As all the definitions are related, introduce the IsaIrqNumber type to enumerate them.

---
 include/hw/isa/isa.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/hw/isa/isa.h +3 -1
index ddaae89a853..2a052ffa025 100644
@@ -8,7 +8,9 @@
 #include "hw/qdev-core.h"
 #include "qom/object.h"
 
-#define ISA_NUM_IRQS 16
+enum IsaIrqNumber {
+    ISA_NUM_IRQS        = 16
+};
 
 #define TYPE_ISA_DEVICE "isa-device"
 OBJECT_DECLARE_TYPE(ISADevice, ISADeviceClass, ISA_DEVICE)
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/10 hw/isa: Add the ISA_IRQ_KBD_DEFAULT definition

In reply to Philippe Mathieu-Daudé

The PS2 keyboard uses IRQ #1 by default. Add this
default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
 include/hw/isa/isa.h | 1 +
 hw/sparc64/sun4u.c   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
include/hw/isa/isa.h +1 -0
index 2a052ffa025..e139b88c992 100644
@@ -9,6 +9,7 @@
 #include "qom/object.h"
 
 enum IsaIrqNumber {
+    ISA_IRQ_KBD_DEFAULT =  1,
     ISA_NUM_IRQS        = 16
 };
 
hw/sparc64/sun4u.c +1 -1
index ad5ca2472a4..d4c39490cd9 100644
@@ -615,7 +615,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_LPT_IRQ));
     qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 6,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_FDD_IRQ));
-    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 1,
+    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", ISA_IRQ_KBD_DEFAULT,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_KBD_IRQ));
     qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 12,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_MSE_IRQ));
Signature · 1 line
2.26.2
#3 lore raw

PATCH 3/10 hw/isa: Add the ISA_IRQ_SER_DEFAULT definition

In reply to Philippe Mathieu-Daudé

The first serial port uses IRQ #4 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
 include/hw/isa/isa.h | 1 +
 hw/sparc64/sun4u.c   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
include/hw/isa/isa.h +1 -0
index e139b88c992..519296d5823 100644
@@ -10,6 +10,7 @@
 
 enum IsaIrqNumber {
     ISA_IRQ_KBD_DEFAULT =  1,
+    ISA_IRQ_SER_DEFAULT =  4,
     ISA_NUM_IRQS        = 16
 };
 
hw/sparc64/sun4u.c +1 -1
index d4c39490cd9..6e42467d5cc 100644
@@ -619,7 +619,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_KBD_IRQ));
     qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 12,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_MSE_IRQ));
-    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 4,
+    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", ISA_IRQ_SER_DEFAULT,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_SER_IRQ));
 
     switch (vga_interface_type) {
Signature · 1 line
2.26.2
#4 lore raw

Re: [PATCH 03/10] hw/isa: Add the ISA_IRQ_SER_DEFAULT definition

Quoted 1 line · Philippe Mathieu-Daudé

The first serial port uses IRQ #4 by default. Add this

      ^^^^^
Quoted 1 line

+ ISA_IRQ_SER_DEFAULT = 4,

... so name this SER1 maybe? And add SER2 = 3?

take care,
Gerd

#5 lore raw

PATCH 4/10 hw/isa: Add the ISA_IRQ_TPM_DEFAULT definition

In reply to Philippe Mathieu-Daudé

The TPM TIS device uses IRQ #5 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
 include/hw/isa/isa.h   | 1 +
 hw/i386/acpi-build.c   | 2 +-
 hw/ipmi/isa_ipmi_bt.c  | 2 +-
 hw/ipmi/isa_ipmi_kcs.c | 2 +-
 hw/tpm/tpm_tis_isa.c   | 2 +-
 5 files changed, 5 insertions(+), 4 deletions(-)
include/hw/isa/isa.h +1 -0
index 519296d5823..e4f2aed004f 100644
@@ -11,6 +11,7 @@
 enum IsaIrqNumber {
     ISA_IRQ_KBD_DEFAULT =  1,
     ISA_IRQ_SER_DEFAULT =  4,
+    ISA_IRQ_TPM_DEFAULT =  5,
     ISA_NUM_IRQS        = 16
 };
 
hw/i386/acpi-build.c +1 -1
index 45ad2f95334..2b6038ab015 100644
@@ -1886,7 +1886,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                     Rewrite to take IRQ from TPM device model and
                     fix default IRQ value there to use some unused IRQ
                  */
-                /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
+                /* aml_append(crs, aml_irq_no_flags(ISA_IRQ_TPM_DEFAULT)); */
                 aml_append(dev, aml_name_decl("_CRS", crs));
 
                 tpm_build_ppi_acpi(tpm, dev);
hw/ipmi/isa_ipmi_bt.c +1 -1
index b7c2ad557b2..13a92bd2c44 100644
@@ -137,7 +137,7 @@ static void *isa_ipmi_bt_get_backend_data(IPMIInterface *ii)
 
 static Property ipmi_isa_properties[] = {
     DEFINE_PROP_UINT32("ioport", ISAIPMIBTDevice, bt.io_base,  0xe4),
-    DEFINE_PROP_INT32("irq",   ISAIPMIBTDevice, isairq,  5),
+    DEFINE_PROP_INT32("irq", ISAIPMIBTDevice, isairq, ISA_IRQ_TPM_DEFAULT),
     DEFINE_PROP_END_OF_LIST(),
 };
 
hw/ipmi/isa_ipmi_kcs.c +1 -1
index 7dd6bf0040a..c956b539688 100644
@@ -144,7 +144,7 @@ static void *isa_ipmi_kcs_get_backend_data(IPMIInterface *ii)
 
 static Property ipmi_isa_properties[] = {
     DEFINE_PROP_UINT32("ioport", ISAIPMIKCSDevice, kcs.io_base,  0xca2),
-    DEFINE_PROP_INT32("irq",   ISAIPMIKCSDevice, isairq,  5),
+    DEFINE_PROP_INT32("irq", ISAIPMIKCSDevice, isairq, ISA_IRQ_TPM_DEFAULT),
     DEFINE_PROP_END_OF_LIST(),
 };
 
hw/tpm/tpm_tis_isa.c +1 -1
index 6fd876eebf1..5a4afda42df 100644
@@ -91,7 +91,7 @@ static void tpm_tis_isa_reset(DeviceState *dev)
 }
 
 static Property tpm_tis_isa_properties[] = {
-    DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, TPM_TIS_IRQ),
+    DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, ISA_IRQ_TPM_DEFAULT),
     DEFINE_PROP_TPMBE("tpmdev", TPMStateISA, state.be_driver),
     DEFINE_PROP_BOOL("ppi", TPMStateISA, state.ppi_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
Signature · 1 line
2.26.2
#6 lore raw

Re: [PATCH 04/10] hw/isa: Add the ISA_IRQ_TPM_DEFAULT definition

Quoted 58 lines · Philippe Mathieu-Daudé

The TPM TIS device uses IRQ #5 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
  include/hw/isa/isa.h   | 1 +
  hw/i386/acpi-build.c   | 2 +-
  hw/ipmi/isa_ipmi_bt.c  | 2 +-
  hw/ipmi/isa_ipmi_kcs.c | 2 +-
  hw/tpm/tpm_tis_isa.c   | 2 +-
  5 files changed, 5 insertions(+), 4 deletions(-)
include/hw/isa/isa.h +1 -0
index 519296d5823..e4f2aed004f 100644
@@ -11,6 +11,7 @@
  enum IsaIrqNumber {
      ISA_IRQ_KBD_DEFAULT =  1,
      ISA_IRQ_SER_DEFAULT =  4,
+    ISA_IRQ_TPM_DEFAULT =  5,
      ISA_NUM_IRQS        = 16
  };
 
hw/i386/acpi-build.c +1 -1
index 45ad2f95334..2b6038ab015 100644
@@ -1886,7 +1886,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                      Rewrite to take IRQ from TPM device model and
                      fix default IRQ value there to use some unused IRQ
                   */
-                /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
+                /* aml_append(crs, aml_irq_no_flags(ISA_IRQ_TPM_DEFAULT)); */
                  aml_append(dev, aml_name_decl("_CRS", crs));
 
                  tpm_build_ppi_acpi(tpm, dev);
hw/ipmi/isa_ipmi_bt.c +1 -1
index b7c2ad557b2..13a92bd2c44 100644
@@ -137,7 +137,7 @@ static void *isa_ipmi_bt_get_backend_data(IPMIInterface *ii)
 
  static Property ipmi_isa_properties[] = {
      DEFINE_PROP_UINT32("ioport", ISAIPMIBTDevice, bt.io_base,  0xe4),
-    DEFINE_PROP_INT32("irq",   ISAIPMIBTDevice, isairq,  5),
+    DEFINE_PROP_INT32("irq", ISAIPMIBTDevice, isairq, ISA_IRQ_TPM_DEFAULT),
      DEFINE_PROP_END_OF_LIST(),
  };
 
hw/ipmi/isa_ipmi_kcs.c +0 -0
index 7dd6bf0040a..c956b539688 100644

hw/ipmi/isa_ipmi_kcs.c static void *isa_ipmi_kcs_get_backend_data(IPMIInterface *ii) · line 149

Quoted 7 lines
hw/ipmi/isa_ipmi_kcs.c +1 -1
@@ -144,7 +144,7 @@ static void *isa_ipmi_kcs_get_backend_data(IPMIInterface *ii)
 
  static Property ipmi_isa_properties[] = {
      DEFINE_PROP_UINT32("ioport", ISAIPMIKCSDevice, kcs.io_base,  0xca2),
-    DEFINE_PROP_INT32("irq",   ISAIPMIKCSDevice, isairq,  5),
+    DEFINE_PROP_INT32("irq", ISAIPMIKCSDevice, isairq, ISA_IRQ_TPM_DEFAULT),
      DEFINE_PROP_END_OF_LIST(),
  };

I don't know what these devices do but this looks like an unwanted clash.

Quoted 13 lines
hw/tpm/tpm_tis_isa.c +1 -1
index 6fd876eebf1..5a4afda42df 100644
@@ -91,7 +91,7 @@ static void tpm_tis_isa_reset(DeviceState *dev)
  }
 
  static Property tpm_tis_isa_properties[] = {
-    DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, TPM_TIS_IRQ),
+    DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, ISA_IRQ_TPM_DEFAULT),
      DEFINE_PROP_TPMBE("tpmdev", TPMStateISA, state.be_driver),
      DEFINE_PROP_BOOL("ppi", TPMStateISA, state.ppi_enabled, true),
      DEFINE_PROP_END_OF_LIST(),
#7 lore raw

Re: [PATCH 04/10] hw/isa: Add the ISA_IRQ_TPM_DEFAULT definition

Quoted 64 lines · Stefan Berger
Quoted 63 lines · Philippe Mathieu-Daudé

The TPM TIS device uses IRQ #5 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
  include/hw/isa/isa.h   | 1 +
  hw/i386/acpi-build.c   | 2 +-
  hw/ipmi/isa_ipmi_bt.c  | 2 +-
  hw/ipmi/isa_ipmi_kcs.c | 2 +-
  hw/tpm/tpm_tis_isa.c   | 2 +-

  5 files changed, 5 insertions(+), 4 deletions(-)
include/hw/isa/isa.h +1 -0
index 519296d5823..e4f2aed004f 100644
@@ -11,6 +11,7 @@
   enum IsaIrqNumber {
       ISA_IRQ_KBD_DEFAULT =  1,
       ISA_IRQ_SER_DEFAULT =  4,
+    ISA_IRQ_TPM_DEFAULT =  5,

      ISA_NUM_IRQS        = 16
  };

hw/i386/acpi-build.c +0 -0
index 45ad2f95334..2b6038ab015 100644
@@ -1886,7 +1886,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,

                      Rewrite to take IRQ from TPM device model and fix default IRQ value there to use some unused IRQ */
-                /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */ +                /* aml_append(crs, aml_irq_no_flags(ISA_IRQ_TPM_DEFAULT)); */
                  aml_append(dev, aml_name_decl("_CRS", crs));

                  tpm_build_ppi_acpi(tpm, dev);

hw/ipmi/isa_ipmi_bt.c +1 -1
index b7c2ad557b2..13a92bd2c44 100644
@@ -137,7 +137,7 @@ static void 
 *isa_ipmi_bt_get_backend_data(IPMIInterface *ii)
 
   static Property ipmi_isa_properties[] = {
       DEFINE_PROP_UINT32("ioport", ISAIPMIBTDevice, bt.io_base,  0xe4),
-    DEFINE_PROP_INT32("irq",   ISAIPMIBTDevice, isairq,  5),
+    DEFINE_PROP_INT32("irq", ISAIPMIBTDevice, isairq, 
 ISA_IRQ_TPM_DEFAULT),
       DEFINE_PROP_END_OF_LIST(),

  };

hw/ipmi/isa_ipmi_kcs.c +0 -0
index 7dd6bf0040a..c956b539688 100644
@@ -144,7 +144,7 @@ static void 
 *isa_ipmi_kcs_get_backend_data(IPMIInterface *ii)
 
Quoted 10 lines
Quoted 7 lines
hw/ipmi/isa_ipmi_kcs.c +1 -1
   static Property ipmi_isa_properties[] = {
       DEFINE_PROP_UINT32("ioport", ISAIPMIKCSDevice, kcs.io_base,  0xca2),
-    DEFINE_PROP_INT32("irq",   ISAIPMIKCSDevice, isairq,  5),
+    DEFINE_PROP_INT32("irq", ISAIPMIKCSDevice, isairq, 
 ISA_IRQ_TPM_DEFAULT),
       DEFINE_PROP_END_OF_LIST(),

  };

I don't know what these devices do but this looks like an unwanted clash.

Yes, sorry :( Maybe better to drop this patch.

Quoted 18 lines
Quoted 15 lines
hw/tpm/tpm_tis_isa.c +1 -1
index 6fd876eebf1..5a4afda42df 100644
@@ -91,7 +91,7 @@ static void tpm_tis_isa_reset(DeviceState *dev)
   }
 
   static Property tpm_tis_isa_properties[] = {
-    DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, TPM_TIS_IRQ),
+    DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, 
 ISA_IRQ_TPM_DEFAULT),
       DEFINE_PROP_TPMBE("tpmdev", TPMStateISA, state.be_driver),
       DEFINE_PROP_BOOL("ppi", TPMStateISA, state.ppi_enabled, true),

      DEFINE_PROP_END_OF_LIST(),

#8 lore raw

Re: [PATCH 04/10] hw/isa: Add the ISA_IRQ_TPM_DEFAULT definition

In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

The TPM TIS device uses IRQ #5 by default. Add this default definition to the IsaIrqNumber enum.

IRQ 5 has no fixed assignment. All kinds of add-on isa cards (sound, net) used to use irq #5 by default because that one wasn't assigned otherwise. Seems these days tpm and ipmi use it ...

take care,
Gerd

#9 lore raw

Re: [PATCH 04/10] hw/isa: Add the ISA_IRQ_TPM_DEFAULT definition

Quoted 7 lines · Gerd Hoffmann
Quoted 2 lines · Philippe Mathieu-Daudé

The TPM TIS device uses IRQ #5 by default. Add this default definition to the IsaIrqNumber enum.

IRQ 5 has no fixed assignment. All kinds of add-on isa cards (sound, net) used to use irq #5 by default because that one wasn't assigned otherwise. Seems these days tpm and ipmi use it ...

Yes, I'll drop this patch.

Thanks,

Phil.

#10 lore raw

Re: [PATCH 04/10] hw/isa: Add the ISA_IRQ_TPM_DEFAULT definition

Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Gerd Hoffmann
Quoted 2 lines · Philippe Mathieu-Daudé

The TPM TIS device uses IRQ #5 by default. Add this default definition to the IsaIrqNumber enum.

IRQ 5 has no fixed assignment.  All kinds of add-on isa cards (sound, net) used to use irq #5 by default because that one wasn't assigned otherwise.  Seems these days tpm and ipmi use it ...

Yes, I'll drop this patch.

I think this patch is good but maybe the name should be a different one. Rather than having these numbers in the code you could maybe call it something like this here, which makes grepping through the code a bit easier:

    ISA_IRQ_IRQ5 =  5,

Regards,

   Stefan

Quoted 4 lines

Thanks,

Phil.

#11 lore raw

PATCH 5/10 hw/isa: Add the ISA_IRQ_FDC_DEFAULT definition

In reply to Philippe Mathieu-Daudé

The floppy disk controller uses IRQ #6 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
 include/hw/isa/isa.h | 1 +
 hw/block/fdc.c       | 4 ++--
 hw/sparc64/sun4u.c   | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
include/hw/isa/isa.h +1 -0
index e4f2aed004f..214a6730598 100644
@@ -12,6 +12,7 @@ enum IsaIrqNumber {
     ISA_IRQ_KBD_DEFAULT =  1,
     ISA_IRQ_SER_DEFAULT =  4,
     ISA_IRQ_TPM_DEFAULT =  5,
+    ISA_IRQ_FDC_DEFAULT =  6,
     ISA_NUM_IRQS        = 16
 };
 
hw/block/fdc.c +2 -2
index 4c2c35e223a..531fc4c0b72 100644
@@ -2855,7 +2855,7 @@ static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope)
     crs = aml_resource_template();
     aml_append(crs, aml_io(AML_DECODE16, 0x03F2, 0x03F2, 0x00, 0x04));
     aml_append(crs, aml_io(AML_DECODE16, 0x03F7, 0x03F7, 0x00, 0x01));
-    aml_append(crs, aml_irq_no_flags(6));
+    aml_append(crs, aml_irq_no_flags(ISA_IRQ_FDC_DEFAULT));
     aml_append(crs,
         aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, 2));
 
@@ -2889,7 +2889,7 @@ static const VMStateDescription vmstate_isa_fdc ={
 
 static Property isa_fdc_properties[] = {
     DEFINE_PROP_UINT32("iobase", FDCtrlISABus, iobase, 0x3f0),
-    DEFINE_PROP_UINT32("irq", FDCtrlISABus, irq, 6),
+    DEFINE_PROP_UINT32("irq", FDCtrlISABus, irq, ISA_IRQ_FDC_DEFAULT),
     DEFINE_PROP_UINT32("dma", FDCtrlISABus, dma, 2),
     DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.qdev_for_drives[0].blk),
     DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.qdev_for_drives[1].blk),
hw/sparc64/sun4u.c +1 -1
index 6e42467d5cc..458dc215e6f 100644
@@ -613,7 +613,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
     /* Wire up "well-known" ISA IRQs to PBM legacy obio IRQs */
     qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 7,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_LPT_IRQ));
-    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 6,
+    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", ISA_IRQ_FDC_DEFAULT,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_FDD_IRQ));
     qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", ISA_IRQ_KBD_DEFAULT,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_KBD_IRQ));
Signature · 1 line
2.26.2
#13 lore raw

PATCH 6/10 hw/isa: Add the ISA_IRQ_PAR_DEFAULT definition

In reply to Philippe Mathieu-Daudé

The parallel port uses IRQ #7 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
 include/hw/isa/isa.h | 1 +
 hw/char/parallel.c   | 2 +-
 hw/sparc64/sun4u.c   | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)
include/hw/isa/isa.h +1 -0
index 214a6730598..081fa446152 100644
@@ -13,6 +13,7 @@ enum IsaIrqNumber {
     ISA_IRQ_SER_DEFAULT =  4,
     ISA_IRQ_TPM_DEFAULT =  5,
     ISA_IRQ_FDC_DEFAULT =  6,
+    ISA_IRQ_PAR_DEFAULT =  7,
     ISA_NUM_IRQS        = 16
 };
 
hw/char/parallel.c +1 -1
index 8b418abf719..9e0d80ec0d0 100644
@@ -636,7 +636,7 @@ bool parallel_mm_init(MemoryRegion *address_space,
 static Property parallel_isa_properties[] = {
     DEFINE_PROP_UINT32("index", ISAParallelState, index,   -1),
     DEFINE_PROP_UINT32("iobase", ISAParallelState, iobase,  -1),
-    DEFINE_PROP_UINT32("irq",   ISAParallelState, isairq,  7),
+    DEFINE_PROP_UINT32("irq",   ISAParallelState, isairq,  ISA_IRQ_PAR_DEFAULT),
     DEFINE_PROP_CHR("chardev",  ISAParallelState, state.chr),
     DEFINE_PROP_END_OF_LIST(),
 };
hw/sparc64/sun4u.c +1 -1
index 458dc215e6f..c5b3e838ac2 100644
@@ -611,7 +611,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
     pci_realize_and_unref(ebus, pci_busA, &error_fatal);
 
     /* Wire up "well-known" ISA IRQs to PBM legacy obio IRQs */
-    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 7,
+    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", ISA_IRQ_PAR_DEFAULT,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_LPT_IRQ));
     qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", ISA_IRQ_FDC_DEFAULT,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_FDD_IRQ));
Signature · 1 line
2.26.2
#14 lore raw

PATCH 7/10 hw/isa: Add the ISA_IRQ_RTC_DEFAULT definition

In reply to Philippe Mathieu-Daudé

The RTC time keep clock ses IRQ #8 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
 include/hw/isa/isa.h         | 1 +
 include/hw/rtc/mc146818rtc.h | 1 -
 hw/isa/piix4.c               | 2 +-
 hw/rtc/m48t59-isa.c          | 2 +-
 hw/rtc/mc146818rtc.c         | 4 ++--
 hw/timer/hpet.c              | 8 ++++----
 tests/qtest/rtc-test.c       | 8 ++++----
 7 files changed, 13 insertions(+), 13 deletions(-)
include/hw/isa/isa.h +1 -0
index 081fa446152..9f78ff11246 100644
@@ -14,6 +14,7 @@ enum IsaIrqNumber {
     ISA_IRQ_TPM_DEFAULT =  5,
     ISA_IRQ_FDC_DEFAULT =  6,
     ISA_IRQ_PAR_DEFAULT =  7,
+    ISA_IRQ_RTC_DEFAULT =  8,
     ISA_NUM_IRQS        = 16
 };
 
include/hw/rtc/mc146818rtc.h +0 -1
index 5b45b229244..1cca26399ce 100644
@@ -47,7 +47,6 @@ struct RTCState {
     QLIST_ENTRY(RTCState) link;
 };
 
-#define RTC_ISA_IRQ 8
 #define RTC_ISA_BASE 0x70
 
 ISADevice *mc146818_rtc_init(ISABus *bus, int base_year,
hw/isa/piix4.c +1 -1
index a50d97834c7..d9cceff9c84 100644
@@ -185,7 +185,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, ISA_IRQ_RTC_DEFAULT);
 
     piix4_dev = dev;
 }
hw/rtc/m48t59-isa.c +1 -1
index cae315e4885..bdde427a945 100644
@@ -124,7 +124,7 @@ static void m48t59_isa_realize(DeviceState *dev, Error **errp)
 
     s->model = u->info.model;
     s->size = u->info.size;
-    isa_init_irq(isadev, &s->IRQ, 8);
+    isa_init_irq(isadev, &s->IRQ, ISA_IRQ_RTC_DEFAULT);
     m48t59_realize_common(s, errp);
     memory_region_init_io(&d->io, OBJECT(dev), &m48t59_io_ops, s, "m48t59", 4);
     if (d->io_base != 0) {
hw/rtc/mc146818rtc.c +2 -2
index 7a38540cb9d..ba156b9a0bd 100644
@@ -981,7 +981,7 @@ ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
     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, ISA_IRQ_RTC_DEFAULT);
     }
 
     object_property_add_alias(qdev_get_machine(), "rtc-time", OBJECT(isadev),
@@ -1020,7 +1020,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(ISA_IRQ_RTC_DEFAULT));
 
     dev = aml_device("RTC");
     aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0B00")));
hw/timer/hpet.c +4 -4
index 05fd86af817..579a9faecf3 100644
@@ -196,7 +196,7 @@ static void update_irq(struct HPETTimer *timer, int set)
          * timer0 be routed to IRQ0 in NON-APIC or IRQ2 in the I/O APIC,
          * timer1 be routed to IRQ8 in NON-APIC or IRQ8 in the I/O APIC.
          */
-        route = (timer->tn == 0) ? 0 : RTC_ISA_IRQ;
+        route = (timer->tn == 0) ? 0 : ISA_IRQ_RTC_DEFAULT;
     } else {
         route = timer_int_route(timer);
     }
@@ -615,11 +615,11 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
             if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) {
                 qemu_set_irq(s->pit_enabled, 0);
                 qemu_irq_lower(s->irqs[0]);
-                qemu_irq_lower(s->irqs[RTC_ISA_IRQ]);
+                qemu_irq_lower(s->irqs[ISA_IRQ_RTC_DEFAULT]);
             } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) {
                 qemu_irq_lower(s->irqs[0]);
                 qemu_set_irq(s->pit_enabled, 1);
-                qemu_set_irq(s->irqs[RTC_ISA_IRQ], s->rtc_irq_level);
+                qemu_set_irq(s->irqs[ISA_IRQ_RTC_DEFAULT], s->rtc_irq_level);
             }
             break;
         case HPET_CFG + 4:
@@ -711,7 +711,7 @@ static void hpet_handle_legacy_irq(void *opaque, int n, int level)
     } else {
         s->rtc_irq_level = level;
         if (!hpet_in_legacy_mode(s)) {
-            qemu_set_irq(s->irqs[RTC_ISA_IRQ], level);
+            qemu_set_irq(s->irqs[ISA_IRQ_RTC_DEFAULT], level);
         }
     }
 }
tests/qtest/rtc-test.c +4 -4
index c7af34f6b1b..9ae90d4925c 100644
@@ -278,7 +278,7 @@ static void alarm_time(void)
     /* set DEC mode */
     cmos_write(RTC_REG_B, REG_B_24H | REG_B_DM);
 
-    g_assert(!get_irq(RTC_ISA_IRQ));
+    g_assert(!get_irq(ISA_IRQ_RTC_DEFAULT));
     cmos_read(RTC_REG_C);
 
     now.tm_sec = (now.tm_sec + 2) % 60;
@@ -288,14 +288,14 @@ static void alarm_time(void)
     cmos_write(RTC_REG_B, cmos_read(RTC_REG_B) | REG_B_AIE);
 
     for (i = 0; i < 2 + wiggle; i++) {
-        if (get_irq(RTC_ISA_IRQ)) {
+        if (get_irq(ISA_IRQ_RTC_DEFAULT)) {
             break;
         }
 
         clock_step(1000000000);
     }
 
-    g_assert(get_irq(RTC_ISA_IRQ));
+    g_assert(get_irq(ISA_IRQ_RTC_DEFAULT));
     g_assert((cmos_read(RTC_REG_C) & REG_C_AF) != 0);
     g_assert(cmos_read(RTC_REG_C) == 0);
 }
@@ -645,7 +645,7 @@ static void uip_stuck(void)
 
 static uint64_t wait_periodic_interrupt(uint64_t real_time)
 {
-    while (!get_irq(RTC_ISA_IRQ)) {
+    while (!get_irq(ISA_IRQ_RTC_DEFAULT)) {
         real_time = clock_step_next();
     }
 
Signature · 1 line
2.26.2
#15 lore raw

PATCH 8/10 hw/isa: Add the ISA_IRQ_NET_DEFAULT definition

In reply to Philippe Mathieu-Daudé

The network devices use IRQ #9 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
 include/hw/isa/isa.h | 1 +
 hw/net/ne2000-isa.c  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
include/hw/isa/isa.h +1 -0
index 9f78ff11246..11166592246 100644
@@ -15,6 +15,7 @@ enum IsaIrqNumber {
     ISA_IRQ_FDC_DEFAULT =  6,
     ISA_IRQ_PAR_DEFAULT =  7,
     ISA_IRQ_RTC_DEFAULT =  8,
+    ISA_IRQ_NET_DEFAULT =  9,
     ISA_NUM_IRQS        = 16
 };
 
hw/net/ne2000-isa.c +1 -1
index dd6f6e34d3c..e31e86c14af 100644
@@ -80,7 +80,7 @@ static void isa_ne2000_realizefn(DeviceState *dev, Error **errp)
 
 static Property ne2000_isa_properties[] = {
     DEFINE_PROP_UINT32("iobase", ISANE2000State, iobase, 0x300),
-    DEFINE_PROP_UINT32("irq",   ISANE2000State, isairq, 9),
+    DEFINE_PROP_UINT32("irq", ISANE2000State, isairq, ISA_IRQ_NET_DEFAULT),
     DEFINE_NIC_PROPERTIES(ISANE2000State, ne2000.c),
     DEFINE_PROP_END_OF_LIST(),
 };
Signature · 1 line
2.26.2
#16 lore raw

Re: [PATCH 08/10] hw/isa: Add the ISA_IRQ_NET_DEFAULT definition

Quoted 2 lines · Philippe Mathieu-Daudé

The network devices use IRQ #9 by default. Add this default definition to the IsaIrqNumber enum.

IRQ #9 seems to be sort-of standard for acpi. Not sure whenever that is actually written down somewhere. IIRC in pre-ACPI days it was free like irq #5.

take care,
Gerd

#17 lore raw

Re: [PATCH 08/10] hw/isa: Add the ISA_IRQ_NET_DEFAULT definition

Quoted 7 lines · Gerd Hoffmann
Quoted 2 lines · Philippe Mathieu-Daudé

The network devices use IRQ #9 by default. Add this default definition to the IsaIrqNumber enum.

IRQ #9 seems to be sort-of standard for acpi. Not sure whenever that is actually written down somewhere. IIRC in pre-ACPI days it was free like irq #5.

OK, I'll drop this patch.

Thanks,

Phil.

#18 lore raw

Re: [PATCH 08/10] hw/isa: Add the ISA_IRQ_NET_DEFAULT definition

In reply to Gerd Hoffmann
Quoted 6 lines · Gerd Hoffmann
Quoted 2 lines · Philippe Mathieu-Daudé

The network devices use IRQ #9 by default. Add this default definition to the IsaIrqNumber enum.

IRQ #9 seems to be sort-of standard for acpi. Not sure whenever that is actually written down somewhere. IIRC in pre-ACPI days it was free like irq #5.

Best docu I could find was this one:

https://en.wikipedia.org/wiki/Interrupt_request_(PC_architecture)#Master_PIC

Quoted 4 lines

take care,
Gerd

#19 lore raw

PATCH 9/10 hw/isa: Add the ISA_IRQ_MOU_DEFAULT definition

In reply to Philippe Mathieu-Daudé

The PS2 mouse uses IRQ #12 by default. Add this
default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
 include/hw/isa/isa.h | 1 +
 hw/input/pckbd.c     | 2 +-
 hw/sparc64/sun4u.c   | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)
include/hw/isa/isa.h +1 -0
index 11166592246..43cdc3c47b6 100644
@@ -16,6 +16,7 @@ enum IsaIrqNumber {
     ISA_IRQ_PAR_DEFAULT =  7,
     ISA_IRQ_RTC_DEFAULT =  8,
     ISA_IRQ_NET_DEFAULT =  9,
+    ISA_IRQ_MOU_DEFAULT = 12,
     ISA_NUM_IRQS        = 16
 };
 
hw/input/pckbd.c +1 -1
index dde85ba6c68..140c992b03b 100644
@@ -577,7 +577,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_IRQ_MOU_DEFAULT));
 
     mou = aml_device("MOU");
     aml_append(mou, aml_name_decl("_HID", aml_eisaid("PNP0F13")));
hw/sparc64/sun4u.c +1 -1
index c5b3e838ac2..ddd51c7cbbe 100644
@@ -617,7 +617,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_FDD_IRQ));
     qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", ISA_IRQ_KBD_DEFAULT,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_KBD_IRQ));
-    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", 12,
+    qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", ISA_IRQ_MOU_DEFAULT,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_MSE_IRQ));
     qdev_connect_gpio_out_named(DEVICE(ebus), "isa-irq", ISA_IRQ_SER_DEFAULT,
         qdev_get_gpio_in_named(DEVICE(sabre), "pbm-irq", OBIO_SER_IRQ));
Signature · 1 line
2.26.2
#20 lore raw

PATCH 10/10 hw/isa: Add the ISA_IRQ_IDE_DEFAULT definition

In reply to Philippe Mathieu-Daudé

The IDE controller uses IRQ #14 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
 include/hw/isa/isa.h | 1 +
 hw/ide/isa.c         | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
include/hw/isa/isa.h +1 -0
index 43cdc3c47b6..05622ee11e2 100644
@@ -17,6 +17,7 @@ enum IsaIrqNumber {
     ISA_IRQ_RTC_DEFAULT =  8,
     ISA_IRQ_NET_DEFAULT =  9,
     ISA_IRQ_MOU_DEFAULT = 12,
+    ISA_IRQ_IDE_DEFAULT = 14,
     ISA_NUM_IRQS        = 16
 };
 
hw/ide/isa.c +1 -1
index 6bc19de2265..2412d568937 100644
@@ -108,7 +108,7 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
 static Property isa_ide_properties[] = {
     DEFINE_PROP_UINT32("iobase",  ISAIDEState, iobase,  0x1f0),
     DEFINE_PROP_UINT32("iobase2", ISAIDEState, iobase2, 0x3f6),
-    DEFINE_PROP_UINT32("irq",    ISAIDEState, isairq,  14),
+    DEFINE_PROP_UINT32("irq", ISAIDEState, isairq, ISA_IRQ_IDE_DEFAULT),
     DEFINE_PROP_END_OF_LIST(),
 };
 
Signature · 1 line
2.26.2
Acked-by on v1 10/10
#21 lore raw

Re: [PATCH 10/10] hw/isa: Add the ISA_IRQ_IDE_DEFAULT definition

Quoted 30 lines · Philippe Mathieu-Daudé

The IDE controller uses IRQ #14 by default. Add this default definition to the IsaIrqNumber enum.

Avoid magic values in the code, replace them by the newly introduced definition.

---
  include/hw/isa/isa.h | 1 +
  hw/ide/isa.c         | 2 +-
  2 files changed, 2 insertions(+), 1 deletion(-)
include/hw/isa/isa.h +1 -0
index 43cdc3c47b6..05622ee11e2 100644
@@ -17,6 +17,7 @@ enum IsaIrqNumber {
      ISA_IRQ_RTC_DEFAULT =  8,
      ISA_IRQ_NET_DEFAULT =  9,
      ISA_IRQ_MOU_DEFAULT = 12,
+    ISA_IRQ_IDE_DEFAULT = 14,
      ISA_NUM_IRQS        = 16
  };
 
hw/ide/isa.c +0 -0
index 6bc19de2265..2412d568937 100644

hw/ide/isa.c ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq, · line 114

Quoted 8 lines
hw/ide/isa.c +1 -1
@@ -108,7 +108,7 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
  static Property isa_ide_properties[] = {
      DEFINE_PROP_UINT32("iobase",  ISAIDEState, iobase,  0x1f0),
      DEFINE_PROP_UINT32("iobase2", ISAIDEState, iobase2, 0x3f6),
-    DEFINE_PROP_UINT32("irq",    ISAIDEState, isairq,  14),
+    DEFINE_PROP_UINT32("irq", ISAIDEState, isairq, ISA_IRQ_IDE_DEFAULT),
      DEFINE_PROP_END_OF_LIST(),
  };
 
#22 lore raw

Re: [PATCH 10/10] hw/isa: Add the ISA_IRQ_IDE_DEFAULT definition

In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

The IDE controller uses IRQ #14 by default. Add this default definition to the IsaIrqNumber enum.

primary, while secondary uses IRQ 15.

take care,
Gerd