All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/50] hppa: general improvements and tidy-ups
@ 2022-04-21 19:30 Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 01/50] dino: checkpatch fixes Mark Cave-Ayland
                   ` (50 more replies)
  0 siblings, 51 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This patchset started off when I noticed that dino.c was accessing parent_obj
directly rather than using a QOM cast. After fixing that I noticed quite a few
other improvements that could be done to bring hppa up to our recommended
coding standards.

The main aim of this patchset is to de-couple the dino and lasi devices from
the board using QOM to handle the initialisation instead of having global
device init functions. Included in this is switching the onboard devices
over to use qdev GPIOs for wiring instead of directly allocating QEMU IRQs.

Along the way I've renamed the board config from CONFIG_DINO to
CONFIG_HPPA_GENERIC since that better represents the machine type, and then
used CONFIG_DINO and CONFIG_LASI for the appropriate devices which have been
moved to hw/pci-host/dino.c and hw/misc/lasi.c respectively.

After the reorganisation it was trivial to remove hppa_sys.h and the majority
of pci.c which wasn't being used. Finally I tidied up the use of the QOM
machine type macros in machine.c.

The result has been lightly tested with a tiny Linux image I had lying around
for testing my recent ESP changes, so more testing is welcome. There is a bit
more work to be done sorting out the lasips2 device init and machine init, but
since the patchset is already quite big I can follow up with that once this
series has been merged.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


Mark Cave-Ayland (50):
  dino: checkpatch fixes
  dino: move registers from dino_init() to DINO_PCI_BRIDGE init function
  dino: move PCI bus initialisation to dino_pcihost_init()
  dino: move PCI windows initialisation to dino_pcihost_init()
  dino: add memory-as property containing a link to the memory address
    space
  dino: move pci_setup_iommu() to dino_pcihost_init()
  dino: move PCI bus master address space setup to
    dino_pcihost_realize()
  dino: move initial register configuration to new dino_pcihost_reset()
    function
  dino: use QOM cast instead of directly referencing parent_obj
  dino: return PCIBus from dino_init() using qdev_get_child_bus()
  dino: split declarations from dino.c into dino.h
  hppa: use new CONFIG_HPPA_GENERIC option instead of CONFIG_DINO to
    build hppa machine
  dino: change dino_init() to return the DINO device instead of PCIBus
  machine.c: map DINO device during board configuration
  dino.h: add defines for DINO IRQ numbers
  dino: define IRQ inputs as qdev GPIOs
  dino: wire up serial IRQ using a qdev GPIO in machine.c
  dino: remove unused dino_set_timer_irq() IRQ handler
  hppa: move dino_init() from dino.c to machine.c
  dino: use numerical constant for iar0 and iar1 reset values
  dino: move DINO HPA constants from hppa_hardware.h to dino.h
  dino: move from hw/hppa to hw/pci-host
  lasi: checkpatch fixes
  lasi: move memory region initialisation to new lasi_init() function
  lasi: move register memory mapping from lasi.c to machine.c
  lasi: move initialisation of iar and rtc to new lasi_reset() function
  lasi: move LASIState and associated QOM structures to lasi.h
  lasi: replace lasi_get_irq() with defined constants
  lasi: define IRQ inputs as qdev GPIOs
  lasi: use qdev GPIOs to wire up IRQs in lasi_initfn()
  lasi: fix serial port initialisation
  lasi: update lasi_initfn() to return LASIState
  lasi: move LAN initialisation to machine.c
  lasi: move parallel port initialisation to machine.c
  lasi: move second serial port initialisation to machine.c
  lasi: move PS2 initialisation to machine.c
  lasi: remove address space parameter from lasi_initfn()
  lasi: move lasi_initfn() to machine.c
  lasi: use constants for device register offsets
  lasi: use numerical constant for iar reset value
  hppa: move device headers from hppa_sys.h into individual .c files
  lasi: move from hw/hppa to hw/misc
  hppa: move hppa_pci_ignore_ops from pci.c to machine.c
  hppa: remove hw/hppa/pci.c
  hppa: remove unused trace-events from from hw/hppa
  hppa: move enable_lan() define from hppa_sys.h to machine.c
  hppa: remove the empty hppa_sys.h file
  hppa: use MACHINE QOM macros for defining the hppa machine
  hppa: fold machine_hppa_machine_init() into
    machine_hppa_machine_init_class_init()
  hppa: simplify machine function names in machine.c

 MAINTAINERS                              |   4 +
 configs/devices/hppa-softmmu/default.mak |   2 +-
 hw/hppa/Kconfig                          |   5 +-
 hw/hppa/hppa_hardware.h                  |   5 -
 hw/hppa/hppa_sys.h                       |  24 ---
 hw/hppa/machine.c                        | 122 +++++++++---
 hw/hppa/meson.build                      |   2 +-
 hw/hppa/pci.c                            |  88 ---------
 hw/hppa/trace-events                     |  14 --
 hw/misc/Kconfig                          |   3 +
 hw/{hppa => misc}/lasi.c                 | 161 ++++------------
 hw/misc/meson.build                      |   3 +
 hw/misc/trace-events                     |   5 +
 hw/pci-host/Kconfig                      |   4 +
 hw/{hppa => pci-host}/dino.c             | 231 +++++++----------------
 hw/pci-host/meson.build                  |   3 +
 hw/pci-host/trace-events                 |   5 +
 include/hw/misc/lasi.h                   |  78 ++++++++
 include/hw/pci-host/dino.h               | 146 ++++++++++++++
 meson.build                              |   1 -
 20 files changed, 462 insertions(+), 444 deletions(-)
 delete mode 100644 hw/hppa/hppa_sys.h
 delete mode 100644 hw/hppa/pci.c
 delete mode 100644 hw/hppa/trace-events
 rename hw/{hppa => misc}/lasi.c (60%)
 rename hw/{hppa => pci-host}/dino.c (71%)
 create mode 100644 include/hw/misc/lasi.h
 create mode 100644 include/hw/pci-host/dino.h

-- 
2.20.1



^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 01/50] dino: checkpatch fixes
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 22:19   ` Richard Henderson
  2022-04-21 19:30 ` [PATCH 02/50] dino: move registers from dino_init() to DINO_PCI_BRIDGE init function Mark Cave-Ayland
                   ` (49 subsequent siblings)
  50 siblings, 1 reply; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index eab96dd84e..4031cfb7f0 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -101,8 +101,10 @@ static const uint32_t reg800_keep_bits[DINO800_REGS] = {
 struct DinoState {
     PCIHostState parent_obj;
 
-    /* PCI_CONFIG_ADDR is parent_obj.config_reg, via pci_host_conf_be_ops,
-       so that we can map PCI_CONFIG_DATA to pci_host_data_be_ops.  */
+    /*
+     * PCI_CONFIG_ADDR is parent_obj.config_reg, via pci_host_conf_be_ops,
+     * so that we can map PCI_CONFIG_DATA to pci_host_data_be_ops.
+     */
     uint32_t config_reg_dino; /* keep original copy, including 2 lowest bits */
 
     uint32_t iar0;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 02/50] dino: move registers from dino_init() to DINO_PCI_BRIDGE init function
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 01/50] dino: checkpatch fixes Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 03/50] dino: move PCI bus initialisation to dino_pcihost_init() Mark Cave-Ayland
                   ` (48 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 44 +++++++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 4031cfb7f0..9401b68ff7 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -526,21 +526,6 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     s->iar0 = s->iar1 = CPU_HPA + 3;
     s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */
 
-    /* Dino PCI access from main memory.  */
-    memory_region_init_io(&s->this_mem, OBJECT(s), &dino_chip_ops,
-                          s, "dino", 4096);
-    memory_region_add_subregion(addr_space, DINO_HPA, &s->this_mem);
-
-    /* Dino PCI config. */
-    memory_region_init_io(&s->parent_obj.conf_mem, OBJECT(&s->parent_obj),
-                          &dino_config_addr_ops, dev, "pci-conf-idx", 4);
-    memory_region_init_io(&s->parent_obj.data_mem, OBJECT(&s->parent_obj),
-                          &dino_config_data_ops, dev, "pci-conf-data", 4);
-    memory_region_add_subregion(&s->this_mem, DINO_PCI_CONFIG_ADDR,
-                                &s->parent_obj.conf_mem);
-    memory_region_add_subregion(&s->this_mem, DINO_CONFIG_DATA,
-                                &s->parent_obj.data_mem);
-
     /* Dino PCI bus memory.  */
     memory_region_init(&s->pci_mem, OBJECT(s), "pci-memory", 4 * GiB);
 
@@ -550,6 +535,9 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     s->parent_obj.bus = b;
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
+    memory_region_add_subregion(addr_space, DINO_HPA,
+                                sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
+
     /* Set up windows into PCI bus memory.  */
     for (i = 1; i < 31; i++) {
         uint32_t addr = 0xf0000000 + i * DINO_MEM_CHUNK_SIZE;
@@ -588,6 +576,31 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     return b;
 }
 
+static void dino_pcihost_init(Object *obj)
+{
+    DinoState *s = DINO_PCI_HOST_BRIDGE(obj);
+    PCIHostState *phb = PCI_HOST_BRIDGE(obj);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+
+    /* Dino PCI access from main memory.  */
+    memory_region_init_io(&s->this_mem, OBJECT(s), &dino_chip_ops,
+                          s, "dino", 4096);
+
+    /* Dino PCI config. */
+    memory_region_init_io(&phb->conf_mem, OBJECT(phb),
+                          &dino_config_addr_ops, DEVICE(s),
+                          "pci-conf-idx", 4);
+    memory_region_init_io(&phb->data_mem, OBJECT(phb),
+                          &dino_config_data_ops, DEVICE(s),
+                          "pci-conf-data", 4);
+    memory_region_add_subregion(&s->this_mem, DINO_PCI_CONFIG_ADDR,
+                                &phb->conf_mem);
+    memory_region_add_subregion(&s->this_mem, DINO_CONFIG_DATA,
+                                &phb->data_mem);
+
+    sysbus_init_mmio(sbd, &s->this_mem);
+}
+
 static void dino_pcihost_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -598,6 +611,7 @@ static void dino_pcihost_class_init(ObjectClass *klass, void *data)
 static const TypeInfo dino_pcihost_info = {
     .name          = TYPE_DINO_PCI_HOST_BRIDGE,
     .parent        = TYPE_PCI_HOST_BRIDGE,
+    .instance_init = dino_pcihost_init,
     .instance_size = sizeof(DinoState),
     .class_init    = dino_pcihost_class_init,
 };
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 03/50] dino: move PCI bus initialisation to dino_pcihost_init()
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 01/50] dino: checkpatch fixes Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 02/50] dino: move registers from dino_init() to DINO_PCI_BRIDGE init function Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 04/50] dino: move PCI windows " Mark Cave-Ayland
                   ` (47 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 9401b68ff7..c6c01ea14c 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -526,13 +526,7 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     s->iar0 = s->iar1 = CPU_HPA + 3;
     s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */
 
-    /* Dino PCI bus memory.  */
-    memory_region_init(&s->pci_mem, OBJECT(s), "pci-memory", 4 * GiB);
-
-    b = pci_register_root_bus(dev, "pci", dino_set_irq, dino_pci_map_irq, s,
-                              &s->pci_mem, get_system_io(),
-                              PCI_DEVFN(0, 0), 32, TYPE_PCI_BUS);
-    s->parent_obj.bus = b;
+    b = s->parent_obj.bus;
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
     memory_region_add_subregion(addr_space, DINO_HPA,
@@ -598,6 +592,14 @@ static void dino_pcihost_init(Object *obj)
     memory_region_add_subregion(&s->this_mem, DINO_CONFIG_DATA,
                                 &phb->data_mem);
 
+    /* Dino PCI bus memory.  */
+    memory_region_init(&s->pci_mem, OBJECT(s), "pci-memory", 4 * GiB);
+
+    phb->bus = pci_register_root_bus(DEVICE(s), "pci",
+                                     dino_set_irq, dino_pci_map_irq, s,
+                                     &s->pci_mem, get_system_io(),
+                                     PCI_DEVFN(0, 0), 32, TYPE_PCI_BUS);
+
     sysbus_init_mmio(sbd, &s->this_mem);
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 04/50] dino: move PCI windows initialisation to dino_pcihost_init()
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (2 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 03/50] dino: move PCI bus initialisation to dino_pcihost_init() Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 05/50] dino: add memory-as property containing a link to the memory address space Mark Cave-Ayland
                   ` (46 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index c6c01ea14c..bc27aad5dc 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -519,7 +519,6 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     DeviceState *dev;
     DinoState *s;
     PCIBus *b;
-    int i;
 
     dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE);
     s = DINO_PCI_HOST_BRIDGE(dev);
@@ -532,16 +531,6 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     memory_region_add_subregion(addr_space, DINO_HPA,
                                 sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
 
-    /* Set up windows into PCI bus memory.  */
-    for (i = 1; i < 31; i++) {
-        uint32_t addr = 0xf0000000 + i * DINO_MEM_CHUNK_SIZE;
-        char *name = g_strdup_printf("PCI Outbound Window %d", i);
-        memory_region_init_alias(&s->pci_mem_alias[i], OBJECT(s),
-                                 name, &s->pci_mem, addr,
-                                 DINO_MEM_CHUNK_SIZE);
-        g_free(name);
-    }
-
     /* Set up PCI view of memory: Bus master address space.  */
     memory_region_init(&s->bm, OBJECT(s), "bm-dino", 4 * GiB);
     memory_region_init_alias(&s->bm_ram_alias, OBJECT(s),
@@ -575,6 +564,7 @@ static void dino_pcihost_init(Object *obj)
     DinoState *s = DINO_PCI_HOST_BRIDGE(obj);
     PCIHostState *phb = PCI_HOST_BRIDGE(obj);
     SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+    int i;
 
     /* Dino PCI access from main memory.  */
     memory_region_init_io(&s->this_mem, OBJECT(s), &dino_chip_ops,
@@ -600,6 +590,16 @@ static void dino_pcihost_init(Object *obj)
                                      &s->pci_mem, get_system_io(),
                                      PCI_DEVFN(0, 0), 32, TYPE_PCI_BUS);
 
+    /* Set up windows into PCI bus memory.  */
+    for (i = 1; i < 31; i++) {
+        uint32_t addr = 0xf0000000 + i * DINO_MEM_CHUNK_SIZE;
+        char *name = g_strdup_printf("PCI Outbound Window %d", i);
+        memory_region_init_alias(&s->pci_mem_alias[i], OBJECT(s),
+                                 name, &s->pci_mem, addr,
+                                 DINO_MEM_CHUNK_SIZE);
+        g_free(name);
+    }
+
     sysbus_init_mmio(sbd, &s->this_mem);
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 05/50] dino: add memory-as property containing a link to the memory address space
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (3 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 04/50] dino: move PCI windows " Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 06/50] dino: move pci_setup_iommu() to dino_pcihost_init() Mark Cave-Ayland
                   ` (45 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index bc27aad5dc..13b2210462 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -17,6 +17,7 @@
 #include "hw/irq.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
+#include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "hppa_sys.h"
 #include "trace.h"
@@ -124,6 +125,8 @@ struct DinoState {
     MemoryRegion pci_mem;
     MemoryRegion pci_mem_alias[32];
 
+    MemoryRegion *memory_as;
+
     AddressSpace bm_as;
     MemoryRegion bm;
     MemoryRegion bm_ram_alias;
@@ -521,6 +524,8 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     PCIBus *b;
 
     dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE);
+    object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space),
+                             &error_fatal);
     s = DINO_PCI_HOST_BRIDGE(dev);
     s->iar0 = s->iar1 = CPU_HPA + 3;
     s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */
@@ -603,10 +608,17 @@ static void dino_pcihost_init(Object *obj)
     sysbus_init_mmio(sbd, &s->this_mem);
 }
 
+static Property dino_pcihost_properties[] = {
+    DEFINE_PROP_LINK("memory-as", DinoState, memory_as, TYPE_MEMORY_REGION,
+                     MemoryRegion *),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void dino_pcihost_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
+    device_class_set_props(dc, dino_pcihost_properties);
     dc->vmsd = &vmstate_dino;
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 06/50] dino: move pci_setup_iommu() to dino_pcihost_init()
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (4 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 05/50] dino: add memory-as property containing a link to the memory address space Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 07/50] dino: move PCI bus master address space setup to dino_pcihost_realize() Mark Cave-Ayland
                   ` (44 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 13b2210462..dcebb9f98f 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -556,7 +556,6 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     memory_region_add_subregion(&s->bm, 0xfff00000,
                                 &s->bm_cpu_alias);
     address_space_init(&s->bm_as, &s->bm, "pci-bm");
-    pci_setup_iommu(b, dino_pcihost_set_iommu, s);
 
     *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0);
     *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0);
@@ -605,6 +604,8 @@ static void dino_pcihost_init(Object *obj)
         g_free(name);
     }
 
+    pci_setup_iommu(phb->bus, dino_pcihost_set_iommu, s);
+
     sysbus_init_mmio(sbd, &s->this_mem);
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 07/50] dino: move PCI bus master address space setup to dino_pcihost_realize()
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (5 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 06/50] dino: move pci_setup_iommu() to dino_pcihost_init() Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 08/50] dino: move initial register configuration to new dino_pcihost_reset() function Mark Cave-Ayland
                   ` (43 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Add a new dino_pcihost_unrealize() function to remove the address space when the
device is unrealized.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index dcebb9f98f..ae79ddbf5c 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -536,17 +536,27 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     memory_region_add_subregion(addr_space, DINO_HPA,
                                 sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
 
+    *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0);
+    *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0);
+
+    return b;
+}
+
+static void dino_pcihost_realize(DeviceState *dev, Error **errp)
+{
+    DinoState *s = DINO_PCI_HOST_BRIDGE(dev);
+
     /* Set up PCI view of memory: Bus master address space.  */
     memory_region_init(&s->bm, OBJECT(s), "bm-dino", 4 * GiB);
     memory_region_init_alias(&s->bm_ram_alias, OBJECT(s),
-                             "bm-system", addr_space, 0,
+                             "bm-system", s->memory_as, 0,
                              0xf0000000 + DINO_MEM_CHUNK_SIZE);
     memory_region_init_alias(&s->bm_pci_alias, OBJECT(s),
                              "bm-pci", &s->pci_mem,
                              0xf0000000 + DINO_MEM_CHUNK_SIZE,
                              30 * DINO_MEM_CHUNK_SIZE);
     memory_region_init_alias(&s->bm_cpu_alias, OBJECT(s),
-                             "bm-cpu", addr_space, 0xfff00000,
+                             "bm-cpu", s->memory_as, 0xfff00000,
                              0xfffff);
     memory_region_add_subregion(&s->bm, 0,
                                 &s->bm_ram_alias);
@@ -555,12 +565,15 @@ PCIBus *dino_init(MemoryRegion *addr_space,
                                 &s->bm_pci_alias);
     memory_region_add_subregion(&s->bm, 0xfff00000,
                                 &s->bm_cpu_alias);
+
     address_space_init(&s->bm_as, &s->bm, "pci-bm");
+}
 
-    *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0);
-    *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0);
+static void dino_pcihost_unrealize(DeviceState *dev)
+{
+    DinoState *s = DINO_PCI_HOST_BRIDGE(dev);
 
-    return b;
+    address_space_destroy(&s->bm_as);
 }
 
 static void dino_pcihost_init(Object *obj)
@@ -619,6 +632,8 @@ static void dino_pcihost_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
+    dc->realize = dino_pcihost_realize;
+    dc->unrealize = dino_pcihost_unrealize;
     device_class_set_props(dc, dino_pcihost_properties);
     dc->vmsd = &vmstate_dino;
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 08/50] dino: move initial register configuration to new dino_pcihost_reset() function
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (6 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 07/50] dino: move PCI bus master address space setup to dino_pcihost_realize() Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 09/50] dino: use QOM cast instead of directly referencing parent_obj Mark Cave-Ayland
                   ` (42 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index ae79ddbf5c..d3cd8578a1 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -527,8 +527,6 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space),
                              &error_fatal);
     s = DINO_PCI_HOST_BRIDGE(dev);
-    s->iar0 = s->iar1 = CPU_HPA + 3;
-    s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */
 
     b = s->parent_obj.bus;
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
@@ -542,6 +540,14 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     return b;
 }
 
+static void dino_pcihost_reset(DeviceState *dev)
+{
+    DinoState *s = DINO_PCI_HOST_BRIDGE(dev);
+
+    s->iar0 = s->iar1 = CPU_HPA + 3;
+    s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */
+}
+
 static void dino_pcihost_realize(DeviceState *dev, Error **errp)
 {
     DinoState *s = DINO_PCI_HOST_BRIDGE(dev);
@@ -632,6 +638,7 @@ static void dino_pcihost_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
+    dc->reset = dino_pcihost_reset;
     dc->realize = dino_pcihost_realize;
     dc->unrealize = dino_pcihost_unrealize;
     device_class_set_props(dc, dino_pcihost_properties);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 09/50] dino: use QOM cast instead of directly referencing parent_obj
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (7 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 08/50] dino: move initial register configuration to new dino_pcihost_reset() function Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 10/50] dino: return PCIBus from dino_init() using qdev_get_child_bus() Mark Cave-Ayland
                   ` (41 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Use a QOM cast in both dino_chip_read_with_attrs() and dino_chip_write_with_attrs()
instead of directly referencing parent_obj.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index d3cd8578a1..77b8089664 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -205,6 +205,7 @@ static MemTxResult dino_chip_read_with_attrs(void *opaque, hwaddr addr,
                                              MemTxAttrs attrs)
 {
     DinoState *s = opaque;
+    PCIHostState *phb = PCI_HOST_BRIDGE(s);
     MemTxResult ret = MEMTX_OK;
     AddressSpace *io;
     uint16_t ioaddr;
@@ -214,7 +215,7 @@ static MemTxResult dino_chip_read_with_attrs(void *opaque, hwaddr addr,
     case DINO_PCI_IO_DATA ... DINO_PCI_IO_DATA + 3:
         /* Read from PCI IO space. */
         io = &address_space_io;
-        ioaddr = s->parent_obj.config_reg + (addr & 3);
+        ioaddr = phb->config_reg + (addr & 3);
         switch (size) {
         case 1:
             val = address_space_ldub(io, ioaddr, attrs, &ret);
@@ -297,6 +298,7 @@ static MemTxResult dino_chip_write_with_attrs(void *opaque, hwaddr addr,
                                               MemTxAttrs attrs)
 {
     DinoState *s = opaque;
+    PCIHostState *phb = PCI_HOST_BRIDGE(s);
     AddressSpace *io;
     MemTxResult ret;
     uint16_t ioaddr;
@@ -308,7 +310,7 @@ static MemTxResult dino_chip_write_with_attrs(void *opaque, hwaddr addr,
     case DINO_IO_DATA ... DINO_PCI_IO_DATA + 3:
         /* Write into PCI IO space.  */
         io = &address_space_io;
-        ioaddr = s->parent_obj.config_reg + (addr & 3);
+        ioaddr = phb->config_reg + (addr & 3);
         switch (size) {
         case 1:
             address_space_stb(io, ioaddr, val, attrs, &ret);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 10/50] dino: return PCIBus from dino_init() using qdev_get_child_bus()
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (8 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 09/50] dino: use QOM cast instead of directly referencing parent_obj Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 11/50] dino: split declarations from dino.c into dino.h Mark Cave-Ayland
                   ` (40 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This allows access to the PCI bus without having to reference parent_obj directly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 77b8089664..d89b48493f 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -523,14 +523,12 @@ PCIBus *dino_init(MemoryRegion *addr_space,
 {
     DeviceState *dev;
     DinoState *s;
-    PCIBus *b;
+    PCIBus *pci_bus;
 
     dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE);
     object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space),
                              &error_fatal);
     s = DINO_PCI_HOST_BRIDGE(dev);
-
-    b = s->parent_obj.bus;
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
     memory_region_add_subregion(addr_space, DINO_HPA,
@@ -539,7 +537,8 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0);
     *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0);
 
-    return b;
+    pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci"));
+    return pci_bus;
 }
 
 static void dino_pcihost_reset(DeviceState *dev)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 11/50] dino: split declarations from dino.c into dino.h
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (9 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 10/50] dino: return PCIBus from dino_init() using qdev_get_child_bus() Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 12/50] hppa: use new CONFIG_HPPA_GENERIC option instead of CONFIG_DINO to build hppa machine Mark Cave-Ayland
                   ` (39 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This is to allow access to DinoState from outside dino.c. With the changes to
the headers it is now possible to remove the duplicate definition for
TYPE_DINO_PCI_HOST_BRIDGE from hppa_sys.h.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c     | 111 +--------------------------------------
 hw/hppa/dino.h     | 127 +++++++++++++++++++++++++++++++++++++++++++++
 hw/hppa/hppa_sys.h |   2 -
 3 files changed, 128 insertions(+), 112 deletions(-)
 create mode 100644 hw/hppa/dino.h

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index d89b48493f..01546ff6fc 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -18,122 +18,13 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/qdev-properties.h"
+#include "dino.h"
 #include "migration/vmstate.h"
 #include "hppa_sys.h"
 #include "trace.h"
 #include "qom/object.h"
 
 
-#define TYPE_DINO_PCI_HOST_BRIDGE "dino-pcihost"
-
-#define DINO_IAR0               0x004
-#define DINO_IODC               0x008
-#define DINO_IRR0               0x00C  /* RO */
-#define DINO_IAR1               0x010
-#define DINO_IRR1               0x014  /* RO */
-#define DINO_IMR                0x018
-#define DINO_IPR                0x01C
-#define DINO_TOC_ADDR           0x020
-#define DINO_ICR                0x024
-#define DINO_ILR                0x028  /* RO */
-#define DINO_IO_COMMAND         0x030  /* WO */
-#define DINO_IO_STATUS          0x034  /* RO */
-#define DINO_IO_CONTROL         0x038
-#define DINO_IO_GSC_ERR_RESP    0x040  /* RO */
-#define DINO_IO_ERR_INFO        0x044  /* RO */
-#define DINO_IO_PCI_ERR_RESP    0x048  /* RO */
-#define DINO_IO_FBB_EN          0x05c
-#define DINO_IO_ADDR_EN         0x060
-#define DINO_PCI_CONFIG_ADDR    0x064
-#define DINO_PCI_CONFIG_DATA    0x068
-#define DINO_PCI_IO_DATA        0x06c
-#define DINO_PCI_MEM_DATA       0x070  /* Dino 3.x only */
-#define DINO_GSC2X_CONFIG       0x7b4  /* RO */
-#define DINO_GMASK              0x800
-#define DINO_PAMR               0x804
-#define DINO_PAPR               0x808
-#define DINO_DAMODE             0x80c
-#define DINO_PCICMD             0x810
-#define DINO_PCISTS             0x814  /* R/WC */
-#define DINO_MLTIM              0x81c
-#define DINO_BRDG_FEAT          0x820
-#define DINO_PCIROR             0x824
-#define DINO_PCIWOR             0x828
-#define DINO_TLTIM              0x830
-
-#define DINO_IRQS         11      /* bits 0-10 are architected */
-#define DINO_IRR_MASK     0x5ff   /* only 10 bits are implemented */
-#define DINO_LOCAL_IRQS   (DINO_IRQS + 1)
-#define DINO_MASK_IRQ(x)  (1 << (x))
-
-#define PCIINTA   0x001
-#define PCIINTB   0x002
-#define PCIINTC   0x004
-#define PCIINTD   0x008
-#define PCIINTE   0x010
-#define PCIINTF   0x020
-#define GSCEXTINT 0x040
-/* #define xxx       0x080 - bit 7 is "default" */
-/* #define xxx    0x100 - bit 8 not used */
-/* #define xxx    0x200 - bit 9 not used */
-#define RS232INT  0x400
-
-#define DINO_MEM_CHUNK_SIZE (8 * MiB)
-
-OBJECT_DECLARE_SIMPLE_TYPE(DinoState, DINO_PCI_HOST_BRIDGE)
-
-#define DINO800_REGS (1 + (DINO_TLTIM - DINO_GMASK) / 4)
-static const uint32_t reg800_keep_bits[DINO800_REGS] = {
-    MAKE_64BIT_MASK(0, 1),  /* GMASK */
-    MAKE_64BIT_MASK(0, 7),  /* PAMR */
-    MAKE_64BIT_MASK(0, 7),  /* PAPR */
-    MAKE_64BIT_MASK(0, 8),  /* DAMODE */
-    MAKE_64BIT_MASK(0, 7),  /* PCICMD */
-    MAKE_64BIT_MASK(0, 9),  /* PCISTS */
-    MAKE_64BIT_MASK(0, 32), /* Undefined */
-    MAKE_64BIT_MASK(0, 8),  /* MLTIM */
-    MAKE_64BIT_MASK(0, 30), /* BRDG_FEAT */
-    MAKE_64BIT_MASK(0, 24), /* PCIROR */
-    MAKE_64BIT_MASK(0, 22), /* PCIWOR */
-    MAKE_64BIT_MASK(0, 32), /* Undocumented */
-    MAKE_64BIT_MASK(0, 9),  /* TLTIM */
-};
-
-struct DinoState {
-    PCIHostState parent_obj;
-
-    /*
-     * PCI_CONFIG_ADDR is parent_obj.config_reg, via pci_host_conf_be_ops,
-     * so that we can map PCI_CONFIG_DATA to pci_host_data_be_ops.
-     */
-    uint32_t config_reg_dino; /* keep original copy, including 2 lowest bits */
-
-    uint32_t iar0;
-    uint32_t iar1;
-    uint32_t imr;
-    uint32_t ipr;
-    uint32_t icr;
-    uint32_t ilr;
-    uint32_t io_fbb_en;
-    uint32_t io_addr_en;
-    uint32_t io_control;
-    uint32_t toc_addr;
-
-    uint32_t reg800[DINO800_REGS];
-
-    MemoryRegion this_mem;
-    MemoryRegion pci_mem;
-    MemoryRegion pci_mem_alias[32];
-
-    MemoryRegion *memory_as;
-
-    AddressSpace bm_as;
-    MemoryRegion bm;
-    MemoryRegion bm_ram_alias;
-    MemoryRegion bm_pci_alias;
-    MemoryRegion bm_cpu_alias;
-};
-
 /*
  * Dino can forward memory accesses from the CPU in the range between
  * 0xf0800000 and 0xff000000 to the PCI bus.
diff --git a/hw/hppa/dino.h b/hw/hppa/dino.h
new file mode 100644
index 0000000000..1a26667377
--- /dev/null
+++ b/hw/hppa/dino.h
@@ -0,0 +1,127 @@
+/*
+ * HP-PARISC Dino PCI chipset emulation, as in B160L and similiar machines
+ *
+ * (C) 2017-2019 by Helge Deller <deller@gmx.de>
+ *
+ * This work is licensed under the GNU GPL license version 2 or later.
+ *
+ * Documentation available at:
+ * https://parisc.wiki.kernel.org/images-parisc/9/91/Dino_ers.pdf
+ * https://parisc.wiki.kernel.org/images-parisc/7/70/Dino_3_1_Errata.pdf
+ */
+
+#ifndef DINO_H
+#define DINO_H
+
+#include "hw/pci/pci_host.h"
+
+#define TYPE_DINO_PCI_HOST_BRIDGE "dino-pcihost"
+OBJECT_DECLARE_SIMPLE_TYPE(DinoState, DINO_PCI_HOST_BRIDGE)
+
+#define DINO_IAR0               0x004
+#define DINO_IODC               0x008
+#define DINO_IRR0               0x00C  /* RO */
+#define DINO_IAR1               0x010
+#define DINO_IRR1               0x014  /* RO */
+#define DINO_IMR                0x018
+#define DINO_IPR                0x01C
+#define DINO_TOC_ADDR           0x020
+#define DINO_ICR                0x024
+#define DINO_ILR                0x028  /* RO */
+#define DINO_IO_COMMAND         0x030  /* WO */
+#define DINO_IO_STATUS          0x034  /* RO */
+#define DINO_IO_CONTROL         0x038
+#define DINO_IO_GSC_ERR_RESP    0x040  /* RO */
+#define DINO_IO_ERR_INFO        0x044  /* RO */
+#define DINO_IO_PCI_ERR_RESP    0x048  /* RO */
+#define DINO_IO_FBB_EN          0x05c
+#define DINO_IO_ADDR_EN         0x060
+#define DINO_PCI_CONFIG_ADDR    0x064
+#define DINO_PCI_CONFIG_DATA    0x068
+#define DINO_PCI_IO_DATA        0x06c
+#define DINO_PCI_MEM_DATA       0x070  /* Dino 3.x only */
+#define DINO_GSC2X_CONFIG       0x7b4  /* RO */
+#define DINO_GMASK              0x800
+#define DINO_PAMR               0x804
+#define DINO_PAPR               0x808
+#define DINO_DAMODE             0x80c
+#define DINO_PCICMD             0x810
+#define DINO_PCISTS             0x814  /* R/WC */
+#define DINO_MLTIM              0x81c
+#define DINO_BRDG_FEAT          0x820
+#define DINO_PCIROR             0x824
+#define DINO_PCIWOR             0x828
+#define DINO_TLTIM              0x830
+
+#define DINO_IRQS         11      /* bits 0-10 are architected */
+#define DINO_IRR_MASK     0x5ff   /* only 10 bits are implemented */
+#define DINO_LOCAL_IRQS   (DINO_IRQS + 1)
+#define DINO_MASK_IRQ(x)  (1 << (x))
+
+#define PCIINTA   0x001
+#define PCIINTB   0x002
+#define PCIINTC   0x004
+#define PCIINTD   0x008
+#define PCIINTE   0x010
+#define PCIINTF   0x020
+#define GSCEXTINT 0x040
+/* #define xxx       0x080 - bit 7 is "default" */
+/* #define xxx    0x100 - bit 8 not used */
+/* #define xxx    0x200 - bit 9 not used */
+#define RS232INT  0x400
+
+#define DINO_MEM_CHUNK_SIZE (8 * MiB)
+
+#define DINO800_REGS (1 + (DINO_TLTIM - DINO_GMASK) / 4)
+static const uint32_t reg800_keep_bits[DINO800_REGS] = {
+    MAKE_64BIT_MASK(0, 1),  /* GMASK */
+    MAKE_64BIT_MASK(0, 7),  /* PAMR */
+    MAKE_64BIT_MASK(0, 7),  /* PAPR */
+    MAKE_64BIT_MASK(0, 8),  /* DAMODE */
+    MAKE_64BIT_MASK(0, 7),  /* PCICMD */
+    MAKE_64BIT_MASK(0, 9),  /* PCISTS */
+    MAKE_64BIT_MASK(0, 32), /* Undefined */
+    MAKE_64BIT_MASK(0, 8),  /* MLTIM */
+    MAKE_64BIT_MASK(0, 30), /* BRDG_FEAT */
+    MAKE_64BIT_MASK(0, 24), /* PCIROR */
+    MAKE_64BIT_MASK(0, 22), /* PCIWOR */
+    MAKE_64BIT_MASK(0, 32), /* Undocumented */
+    MAKE_64BIT_MASK(0, 9),  /* TLTIM */
+};
+
+struct DinoState {
+    PCIHostState parent_obj;
+
+    /*
+     * PCI_CONFIG_ADDR is parent_obj.config_reg, via pci_host_conf_be_ops,
+     * so that we can map PCI_CONFIG_DATA to pci_host_data_be_ops.
+     */
+    uint32_t config_reg_dino; /* keep original copy, including 2 lowest bits */
+
+    uint32_t iar0;
+    uint32_t iar1;
+    uint32_t imr;
+    uint32_t ipr;
+    uint32_t icr;
+    uint32_t ilr;
+    uint32_t io_fbb_en;
+    uint32_t io_addr_en;
+    uint32_t io_control;
+    uint32_t toc_addr;
+
+    uint32_t reg800[DINO800_REGS];
+
+    MemoryRegion this_mem;
+    MemoryRegion pci_mem;
+    MemoryRegion pci_mem_alias[32];
+
+    MemoryRegion *memory_as;
+
+    AddressSpace bm_as;
+    MemoryRegion bm;
+    MemoryRegion bm_ram_alias;
+    MemoryRegion bm_pci_alias;
+    MemoryRegion bm_cpu_alias;
+};
+
+#endif
diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 0b18271cc9..9d8b28ec01 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -14,8 +14,6 @@ PCIBus *dino_init(MemoryRegion *, qemu_irq *, qemu_irq *);
 DeviceState *lasi_init(MemoryRegion *);
 #define enable_lasi_lan()       0
 
-#define TYPE_DINO_PCI_HOST_BRIDGE "dino-pcihost"
-
 /* hppa_pci.c.  */
 extern const MemoryRegionOps hppa_pci_ignore_ops;
 extern const MemoryRegionOps hppa_pci_conf1_ops;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 12/50] hppa: use new CONFIG_HPPA_GENERIC option instead of CONFIG_DINO to build hppa machine
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (10 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 11/50] dino: split declarations from dino.c into dino.h Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 13/50] dino: change dino_init() to return the DINO device instead of PCIBus Mark Cave-Ayland
                   ` (38 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

DINO refers to the GSC-PCI bridge device which will soon be handled separately,
so instead use HPPA_GENERIC in reference to "HPPA generic machine" used in the
machine description.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 configs/devices/hppa-softmmu/default.mak | 2 +-
 hw/hppa/Kconfig                          | 2 +-
 hw/hppa/meson.build                      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/configs/devices/hppa-softmmu/default.mak b/configs/devices/hppa-softmmu/default.mak
index b64c5eb3ff..03b07c29d4 100644
--- a/configs/devices/hppa-softmmu/default.mak
+++ b/configs/devices/hppa-softmmu/default.mak
@@ -6,4 +6,4 @@
 
 # Boards:
 #
-CONFIG_DINO=y
+CONFIG_HPPA_GENERIC=y
diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig
index 22948db025..02e101f139 100644
--- a/hw/hppa/Kconfig
+++ b/hw/hppa/Kconfig
@@ -1,4 +1,4 @@
-config DINO
+config HPPA_GENERIC
     bool
     imply PCI_DEVICES
     imply E1000_PCI
diff --git a/hw/hppa/meson.build b/hw/hppa/meson.build
index 1deae83aee..af37b4469e 100644
--- a/hw/hppa/meson.build
+++ b/hw/hppa/meson.build
@@ -1,4 +1,4 @@
 hppa_ss = ss.source_set()
-hppa_ss.add(when: 'CONFIG_DINO', if_true: files('pci.c', 'machine.c', 'dino.c', 'lasi.c'))
+hppa_ss.add(when: 'CONFIG_HPPA_GENERIC', if_true: files('pci.c', 'machine.c', 'dino.c', 'lasi.c'))
 
 hw_arch += {'hppa': hppa_ss}
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 13/50] dino: change dino_init() to return the DINO device instead of PCIBus
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (11 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 12/50] hppa: use new CONFIG_HPPA_GENERIC option instead of CONFIG_DINO to build hppa machine Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 14/50] machine.c: map DINO device during board configuration Mark Cave-Ayland
                   ` (37 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This is in preparation for using more qdev APIs during the configuration of the
HPPA generic machine.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c     | 8 +++-----
 hw/hppa/hppa_sys.h | 3 ++-
 hw/hppa/machine.c  | 6 ++++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 01546ff6fc..6c488c908e 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -409,12 +409,11 @@ static void dino_set_serial_irq(void *opaque, int irq, int level)
     dino_set_irq(opaque, 10, level);
 }
 
-PCIBus *dino_init(MemoryRegion *addr_space,
-                  qemu_irq *p_rtc_irq, qemu_irq *p_ser_irq)
+DinoState *dino_init(MemoryRegion *addr_space,
+                     qemu_irq *p_rtc_irq, qemu_irq *p_ser_irq)
 {
     DeviceState *dev;
     DinoState *s;
-    PCIBus *pci_bus;
 
     dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE);
     object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space),
@@ -428,8 +427,7 @@ PCIBus *dino_init(MemoryRegion *addr_space,
     *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0);
     *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0);
 
-    pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci"));
-    return pci_bus;
+    return s;
 }
 
 static void dino_pcihost_reset(DeviceState *dev)
diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 9d8b28ec01..88773d2c35 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -9,8 +9,9 @@
 #include "hw/intc/i8259.h"
 
 #include "hppa_hardware.h"
+#include "dino.h"
 
-PCIBus *dino_init(MemoryRegion *, qemu_irq *, qemu_irq *);
+DinoState *dino_init(MemoryRegion *, qemu_irq *, qemu_irq *);
 DeviceState *lasi_init(MemoryRegion *);
 #define enable_lasi_lan()       0
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index f7595c0857..f23ebd9548 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -17,6 +17,7 @@
 #include "hw/char/serial.h"
 #include "hw/net/lasi_82596.h"
 #include "hw/nmi.h"
+#include "dino.h"
 #include "hppa_sys.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
@@ -126,7 +127,7 @@ static void machine_hppa_init(MachineState *machine)
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
-    DeviceState *dev;
+    DeviceState *dev, *dino_dev;
     PCIBus *pci_bus;
     ISABus *isa_bus;
     qemu_irq rtc_irq, serial_irq;
@@ -166,7 +167,8 @@ static void machine_hppa_init(MachineState *machine)
     lasi_init(addr_space);
 
     /* Init Dino (PCI host bus chip).  */
-    pci_bus = dino_init(addr_space, &rtc_irq, &serial_irq);
+    dino_dev = DEVICE(dino_init(addr_space, &rtc_irq, &serial_irq));
+    pci_bus = PCI_BUS(qdev_get_child_bus(dino_dev, "pci"));
     assert(pci_bus);
 
     /* Create ISA bus. */
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 14/50] machine.c: map DINO device during board configuration
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (12 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 13/50] dino: change dino_init() to return the DINO device instead of PCIBus Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 15/50] dino.h: add defines for DINO IRQ numbers Mark Cave-Ayland
                   ` (36 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c    | 3 ---
 hw/hppa/machine.c | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 6c488c908e..82f301653b 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -421,9 +421,6 @@ DinoState *dino_init(MemoryRegion *addr_space,
     s = DINO_PCI_HOST_BRIDGE(dev);
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
-    memory_region_add_subregion(addr_space, DINO_HPA,
-                                sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0));
-
     *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0);
     *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0);
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index f23ebd9548..e16305d195 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -168,6 +168,9 @@ static void machine_hppa_init(MachineState *machine)
 
     /* Init Dino (PCI host bus chip).  */
     dino_dev = DEVICE(dino_init(addr_space, &rtc_irq, &serial_irq));
+    memory_region_add_subregion(addr_space, DINO_HPA,
+                                sysbus_mmio_get_region(
+                                    SYS_BUS_DEVICE(dino_dev), 0));
     pci_bus = PCI_BUS(qdev_get_child_bus(dino_dev, "pci"));
     assert(pci_bus);
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 15/50] dino.h: add defines for DINO IRQ numbers
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (13 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 14/50] machine.c: map DINO device during board configuration Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 16/50] dino: define IRQ inputs as qdev GPIOs Mark Cave-Ayland
                   ` (35 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This is to allow the DINO IRQs to be defined as qdev GPIOs.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/hppa/dino.h b/hw/hppa/dino.h
index 1a26667377..70fb8c52c8 100644
--- a/hw/hppa/dino.h
+++ b/hw/hppa/dino.h
@@ -58,6 +58,18 @@ OBJECT_DECLARE_SIMPLE_TYPE(DinoState, DINO_PCI_HOST_BRIDGE)
 #define DINO_LOCAL_IRQS   (DINO_IRQS + 1)
 #define DINO_MASK_IRQ(x)  (1 << (x))
 
+#define DINO_IRQ_PCIINTA   0
+#define DINO_IRQ_PCIINTB   1
+#define DINO_IRQ_PCIINTC   2
+#define DINO_IRQ_PCIINTD   3
+#define DINO_IRQ_PCIINTE   4
+#define DINO_IRQ_PCIINTF   5
+#define DINO_IRQ_GSCEXTINT 6
+#define DINO_IRQ_BUSERRINT 7
+#define DINO_IRQ_PS2INT    8
+#define DINO_IRQ_UNUSED    9
+#define DINO_IRQ_RS232INT  10
+
 #define PCIINTA   0x001
 #define PCIINTB   0x002
 #define PCIINTC   0x004
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 16/50] dino: define IRQ inputs as qdev GPIOs
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (14 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 15/50] dino.h: add defines for DINO IRQ numbers Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 17/50] dino: wire up serial IRQ using a qdev GPIO in machine.c Mark Cave-Ayland
                   ` (34 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 2 ++
 hw/hppa/dino.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 82f301653b..f58aebf94d 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -513,6 +513,8 @@ static void dino_pcihost_init(Object *obj)
     pci_setup_iommu(phb->bus, dino_pcihost_set_iommu, s);
 
     sysbus_init_mmio(sbd, &s->this_mem);
+
+    qdev_init_gpio_in(DEVICE(obj), dino_set_irq, DINO_IRQS);
 }
 
 static Property dino_pcihost_properties[] = {
diff --git a/hw/hppa/dino.h b/hw/hppa/dino.h
index 70fb8c52c8..ca380515f2 100644
--- a/hw/hppa/dino.h
+++ b/hw/hppa/dino.h
@@ -134,6 +134,8 @@ struct DinoState {
     MemoryRegion bm_ram_alias;
     MemoryRegion bm_pci_alias;
     MemoryRegion bm_cpu_alias;
+
+    qemu_irq irqs[DINO_IRQS];
 };
 
 #endif
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 17/50] dino: wire up serial IRQ using a qdev GPIO in machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (15 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 16/50] dino: define IRQ inputs as qdev GPIOs Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 18/50] dino: remove unused dino_set_timer_irq() IRQ handler Mark Cave-Ayland
                   ` (33 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This makes it unnecessary to allocate a separate IRQ for the serial port.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c     | 8 +-------
 hw/hppa/hppa_sys.h | 2 +-
 hw/hppa/machine.c  | 7 ++++---
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index f58aebf94d..80ffe27188 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -404,13 +404,8 @@ static void dino_set_timer_irq(void *opaque, int irq, int level)
     /* ??? Not connected.  */
 }
 
-static void dino_set_serial_irq(void *opaque, int irq, int level)
-{
-    dino_set_irq(opaque, 10, level);
-}
-
 DinoState *dino_init(MemoryRegion *addr_space,
-                     qemu_irq *p_rtc_irq, qemu_irq *p_ser_irq)
+                     qemu_irq *p_rtc_irq)
 {
     DeviceState *dev;
     DinoState *s;
@@ -422,7 +417,6 @@ DinoState *dino_init(MemoryRegion *addr_space,
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
     *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0);
-    *p_ser_irq = qemu_allocate_irq(dino_set_serial_irq, s, 0);
 
     return s;
 }
diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 88773d2c35..c238e7ebc8 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -11,7 +11,7 @@
 #include "hppa_hardware.h"
 #include "dino.h"
 
-DinoState *dino_init(MemoryRegion *, qemu_irq *, qemu_irq *);
+DinoState *dino_init(MemoryRegion *, qemu_irq *);
 DeviceState *lasi_init(MemoryRegion *);
 #define enable_lasi_lan()       0
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index e16305d195..df7a47d07d 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -130,7 +130,7 @@ static void machine_hppa_init(MachineState *machine)
     DeviceState *dev, *dino_dev;
     PCIBus *pci_bus;
     ISABus *isa_bus;
-    qemu_irq rtc_irq, serial_irq;
+    qemu_irq rtc_irq;
     char *firmware_filename;
     uint64_t firmware_low, firmware_high;
     long size;
@@ -167,7 +167,7 @@ static void machine_hppa_init(MachineState *machine)
     lasi_init(addr_space);
 
     /* Init Dino (PCI host bus chip).  */
-    dino_dev = DEVICE(dino_init(addr_space, &rtc_irq, &serial_irq));
+    dino_dev = DEVICE(dino_init(addr_space, &rtc_irq));
     memory_region_add_subregion(addr_space, DINO_HPA,
                                 sysbus_mmio_get_region(
                                     SYS_BUS_DEVICE(dino_dev), 0));
@@ -184,7 +184,8 @@ static void machine_hppa_init(MachineState *machine)
     /* Serial code setup.  */
     if (serial_hd(0)) {
         uint32_t addr = DINO_UART_HPA + 0x800;
-        serial_mm_init(addr_space, addr, 0, serial_irq,
+        serial_mm_init(addr_space, addr, 0,
+                       qdev_get_gpio_in(dino_dev, DINO_IRQ_RS232INT),
                        115200, serial_hd(0), DEVICE_BIG_ENDIAN);
     }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 18/50] dino: remove unused dino_set_timer_irq() IRQ handler
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (16 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 17/50] dino: wire up serial IRQ using a qdev GPIO in machine.c Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 19/50] hppa: move dino_init() from dino.c to machine.c Mark Cave-Ayland
                   ` (32 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

According to the comments in dino.c the timer IRQ is unused, so remove the empty
dino_set_timer_irq() handler function and simply pass NULL to mc146818_rtc_init()
in machine.c instead.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c     | 10 +---------
 hw/hppa/hppa_sys.h |  2 +-
 hw/hppa/machine.c  |  5 ++---
 3 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 80ffe27188..d8baf139d6 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -399,13 +399,7 @@ static int dino_pci_map_irq(PCIDevice *d, int irq_num)
     return slot & 0x03;
 }
 
-static void dino_set_timer_irq(void *opaque, int irq, int level)
-{
-    /* ??? Not connected.  */
-}
-
-DinoState *dino_init(MemoryRegion *addr_space,
-                     qemu_irq *p_rtc_irq)
+DinoState *dino_init(MemoryRegion *addr_space)
 {
     DeviceState *dev;
     DinoState *s;
@@ -416,8 +410,6 @@ DinoState *dino_init(MemoryRegion *addr_space,
     s = DINO_PCI_HOST_BRIDGE(dev);
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
-    *p_rtc_irq = qemu_allocate_irq(dino_set_timer_irq, s, 0);
-
     return s;
 }
 
diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index c238e7ebc8..ebedecf1c8 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -11,7 +11,7 @@
 #include "hppa_hardware.h"
 #include "dino.h"
 
-DinoState *dino_init(MemoryRegion *, qemu_irq *);
+DinoState *dino_init(MemoryRegion *);
 DeviceState *lasi_init(MemoryRegion *);
 #define enable_lasi_lan()       0
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index df7a47d07d..b7f9ac51d8 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -130,7 +130,6 @@ static void machine_hppa_init(MachineState *machine)
     DeviceState *dev, *dino_dev;
     PCIBus *pci_bus;
     ISABus *isa_bus;
-    qemu_irq rtc_irq;
     char *firmware_filename;
     uint64_t firmware_low, firmware_high;
     long size;
@@ -167,7 +166,7 @@ static void machine_hppa_init(MachineState *machine)
     lasi_init(addr_space);
 
     /* Init Dino (PCI host bus chip).  */
-    dino_dev = DEVICE(dino_init(addr_space, &rtc_irq));
+    dino_dev = DEVICE(dino_init(addr_space));
     memory_region_add_subregion(addr_space, DINO_HPA,
                                 sysbus_mmio_get_region(
                                     SYS_BUS_DEVICE(dino_dev), 0));
@@ -179,7 +178,7 @@ static void machine_hppa_init(MachineState *machine)
     assert(isa_bus);
 
     /* Realtime clock, used by firmware for PDC_TOD call. */
-    mc146818_rtc_init(isa_bus, 2000, rtc_irq);
+    mc146818_rtc_init(isa_bus, 2000, NULL);
 
     /* Serial code setup.  */
     if (serial_hd(0)) {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 19/50] hppa: move dino_init() from dino.c to machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (17 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 18/50] dino: remove unused dino_set_timer_irq() IRQ handler Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 20/50] dino: use numerical constant for iar0 and iar1 reset values Mark Cave-Ayland
                   ` (31 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Now that dino_init() is completely decoupled from dino.c it can be moved to
machine.c with the rest of the board configuration.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c     | 14 --------------
 hw/hppa/hppa_sys.h |  2 --
 hw/hppa/machine.c  | 12 ++++++++++++
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index d8baf139d6..6d12c385aa 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -399,20 +399,6 @@ static int dino_pci_map_irq(PCIDevice *d, int irq_num)
     return slot & 0x03;
 }
 
-DinoState *dino_init(MemoryRegion *addr_space)
-{
-    DeviceState *dev;
-    DinoState *s;
-
-    dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE);
-    object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space),
-                             &error_fatal);
-    s = DINO_PCI_HOST_BRIDGE(dev);
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
-
-    return s;
-}
-
 static void dino_pcihost_reset(DeviceState *dev)
 {
     DinoState *s = DINO_PCI_HOST_BRIDGE(dev);
diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index ebedecf1c8..7c31dd8396 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -9,9 +9,7 @@
 #include "hw/intc/i8259.h"
 
 #include "hppa_hardware.h"
-#include "dino.h"
 
-DinoState *dino_init(MemoryRegion *);
 DeviceState *lasi_init(MemoryRegion *);
 #define enable_lasi_lan()       0
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index b7f9ac51d8..7b8cfce3c9 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -122,6 +122,18 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     return fw_cfg;
 }
 
+static DinoState *dino_init(MemoryRegion *addr_space)
+{
+    DeviceState *dev;
+
+    dev = qdev_new(TYPE_DINO_PCI_HOST_BRIDGE);
+    object_property_set_link(OBJECT(dev), "memory-as", OBJECT(addr_space),
+                             &error_fatal);
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+
+    return DINO_PCI_HOST_BRIDGE(dev);
+}
+
 static void machine_hppa_init(MachineState *machine)
 {
     const char *kernel_filename = machine->kernel_filename;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 20/50] dino: use numerical constant for iar0 and iar1 reset values
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (18 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 19/50] hppa: move dino_init() from dino.c to machine.c Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 21/50] dino: move DINO HPA constants from hppa_hardware.h to dino.h Mark Cave-Ayland
                   ` (30 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This is to allow us to decouple the DINO device from the board logic. The choice
of using a hard-coded constant (along with a comment) is to match how this is
already done for toc_addr. If it is decided later that these values need to be
configurable then they can easily be converted to qdev properties.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 6d12c385aa..aa7f812e22 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -403,7 +403,7 @@ static void dino_pcihost_reset(DeviceState *dev)
 {
     DinoState *s = DINO_PCI_HOST_BRIDGE(dev);
 
-    s->iar0 = s->iar1 = CPU_HPA + 3;
+    s->iar0 = s->iar1 = 0xFFFB0000 + 3; /* CPU_HPA + 3 */
     s->toc_addr = 0xFFFA0030; /* IO_COMMAND of CPU */
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 21/50] dino: move DINO HPA constants from hppa_hardware.h to dino.h
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (19 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 20/50] dino: use numerical constant for iar0 and iar1 reset values Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 22/50] dino: move from hw/hppa to hw/pci-host Mark Cave-Ayland
                   ` (29 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This is to allow us to decouple the DINO device from the board logic.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/dino.h          | 5 +++++
 hw/hppa/hppa_hardware.h | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/hppa/dino.h b/hw/hppa/dino.h
index ca380515f2..a1b0184940 100644
--- a/hw/hppa/dino.h
+++ b/hw/hppa/dino.h
@@ -101,6 +101,11 @@ static const uint32_t reg800_keep_bits[DINO800_REGS] = {
     MAKE_64BIT_MASK(0, 9),  /* TLTIM */
 };
 
+/* offsets to DINO HPA: */
+#define DINO_PCI_ADDR           0x064
+#define DINO_CONFIG_DATA        0x068
+#define DINO_IO_DATA            0x06c
+
 struct DinoState {
     PCIHostState parent_obj;
 
diff --git a/hw/hppa/hppa_hardware.h b/hw/hppa/hppa_hardware.h
index 5edf577563..8b6b9222cb 100644
--- a/hw/hppa/hppa_hardware.h
+++ b/hw/hppa/hppa_hardware.h
@@ -30,11 +30,6 @@
 #define PCI_HPA         DINO_HPA        /* PCI bus */
 #define IDE_HPA         0xf9000000      /* Boot disc controller */
 
-/* offsets to DINO HPA: */
-#define DINO_PCI_ADDR           0x064
-#define DINO_CONFIG_DATA        0x068
-#define DINO_IO_DATA            0x06c
-
 #define PORT_PCI_CMD    (PCI_HPA + DINO_PCI_ADDR)
 #define PORT_PCI_DATA   (PCI_HPA + DINO_CONFIG_DATA)
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 22/50] dino: move from hw/hppa to hw/pci-host
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (20 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 21/50] dino: move DINO HPA constants from hppa_hardware.h to dino.h Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 23/50] lasi: checkpatch fixes Mark Cave-Ayland
                   ` (28 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Move the DINO device implementation from hw/hppa to hw/pci-host so that it is
located with all the other PCI host bridges.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 MAINTAINERS                             | 2 ++
 hw/hppa/Kconfig                         | 2 +-
 hw/hppa/machine.c                       | 2 +-
 hw/hppa/meson.build                     | 2 +-
 hw/hppa/trace-events                    | 5 -----
 hw/pci-host/Kconfig                     | 4 ++++
 hw/{hppa => pci-host}/dino.c            | 3 +--
 hw/pci-host/meson.build                 | 3 +++
 hw/pci-host/trace-events                | 5 +++++
 {hw/hppa => include/hw/pci-host}/dino.h | 0
 10 files changed, 18 insertions(+), 10 deletions(-)
 rename hw/{hppa => pci-host}/dino.c (99%)
 rename {hw/hppa => include/hw/pci-host}/dino.h (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 294c88ace9..07f85829b0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1114,7 +1114,9 @@ S: Odd Fixes
 F: configs/devices/hppa-softmmu/default.mak
 F: hw/hppa/
 F: hw/net/*i82596*
+F: hw/pci-host/dino.c
 F: include/hw/net/lasi_82596.h
+F: include/hw/pci-host/dino.h
 F: pc-bios/hppa-firmware.img
 
 M68K Machines
diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig
index 02e101f139..666a7319d6 100644
--- a/hw/hppa/Kconfig
+++ b/hw/hppa/Kconfig
@@ -3,7 +3,7 @@ config HPPA_GENERIC
     imply PCI_DEVICES
     imply E1000_PCI
     imply VIRTIO_VGA
-    select PCI
+    select DINO
     select SERIAL
     select ISA_BUS
     select I8259
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 7b8cfce3c9..b66e95982e 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -17,7 +17,7 @@
 #include "hw/char/serial.h"
 #include "hw/net/lasi_82596.h"
 #include "hw/nmi.h"
-#include "dino.h"
+#include "hw/pci-host/dino.h"
 #include "hppa_sys.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
diff --git a/hw/hppa/meson.build b/hw/hppa/meson.build
index af37b4469e..d3f839c6aa 100644
--- a/hw/hppa/meson.build
+++ b/hw/hppa/meson.build
@@ -1,4 +1,4 @@
 hppa_ss = ss.source_set()
-hppa_ss.add(when: 'CONFIG_HPPA_GENERIC', if_true: files('pci.c', 'machine.c', 'dino.c', 'lasi.c'))
+hppa_ss.add(when: 'CONFIG_HPPA_GENERIC', if_true: files('pci.c', 'machine.c', 'lasi.c'))
 
 hw_arch += {'hppa': hppa_ss}
diff --git a/hw/hppa/trace-events b/hw/hppa/trace-events
index 3f42be9056..871a473771 100644
--- a/hw/hppa/trace-events
+++ b/hw/hppa/trace-events
@@ -3,11 +3,6 @@
 # pci.c
 hppa_pci_iack_write(void) ""
 
-# dino.c
-dino_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d"
-dino_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
-dino_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
-
 # lasi.c
 lasi_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d"
 lasi_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
diff --git a/hw/pci-host/Kconfig b/hw/pci-host/Kconfig
index 2b5f7d58cc..38fd2ee8f3 100644
--- a/hw/pci-host/Kconfig
+++ b/hw/pci-host/Kconfig
@@ -77,3 +77,7 @@ config MV64361
     bool
     select PCI
     select I8259
+
+config DINO
+    bool
+    select PCI
diff --git a/hw/hppa/dino.c b/hw/pci-host/dino.c
similarity index 99%
rename from hw/hppa/dino.c
rename to hw/pci-host/dino.c
index aa7f812e22..f257c24e64 100644
--- a/hw/hppa/dino.c
+++ b/hw/pci-host/dino.c
@@ -18,9 +18,8 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/qdev-properties.h"
-#include "dino.h"
+#include "hw/pci-host/dino.h"
 #include "migration/vmstate.h"
-#include "hppa_sys.h"
 #include "trace.h"
 #include "qom/object.h"
 
diff --git a/hw/pci-host/meson.build b/hw/pci-host/meson.build
index 4c4f39c15c..c07596d0d1 100644
--- a/hw/pci-host/meson.build
+++ b/hw/pci-host/meson.build
@@ -25,6 +25,9 @@ pci_ss.add(when: 'CONFIG_MV64361', if_true: files('mv64361.c'))
 # ARM devices
 pci_ss.add(when: 'CONFIG_VERSATILE_PCI', if_true: files('versatile.c'))
 
+# HPPA devices
+pci_ss.add(when: 'CONFIG_DINO', if_true: files('dino.c'))
+
 softmmu_ss.add_all(when: 'CONFIG_PCI', if_true: pci_ss)
 
 specific_ss.add(when: 'CONFIG_PCI_POWERNV', if_true: files(
diff --git a/hw/pci-host/trace-events b/hw/pci-host/trace-events
index 6e5d8d3355..437e66ff50 100644
--- a/hw/pci-host/trace-events
+++ b/hw/pci-host/trace-events
@@ -34,3 +34,8 @@ unin_read(uint64_t addr, uint64_t value) "addr=0x%" PRIx64 " val=0x%"PRIx64
 pnv_phb4_xive_notify(uint64_t notif_port, uint64_t data) "notif=@0x%"PRIx64" data=0x%"PRIx64
 pnv_phb4_xive_notify_ic(uint64_t addr, uint64_t data) "addr=@0x%"PRIx64" data=0x%"PRIx64
 pnv_phb4_xive_notify_abt(uint64_t notif_port, uint64_t data) "notif=@0x%"PRIx64" data=0x%"PRIx64
+
+# dino.c
+dino_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d"
+dino_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
+dino_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
diff --git a/hw/hppa/dino.h b/include/hw/pci-host/dino.h
similarity index 100%
rename from hw/hppa/dino.h
rename to include/hw/pci-host/dino.h
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 23/50] lasi: checkpatch fixes
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (21 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 22/50] dino: move from hw/hppa to hw/pci-host Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 24/50] lasi: move memory region initialisation to new lasi_init() function Mark Cave-Ayland
                   ` (27 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 88c3791eb6..3b77fba1c6 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -169,10 +169,11 @@ static MemTxResult lasi_chip_write_with_attrs(void *opaque, hwaddr addr,
         break;
     case LASI_IMR:
         s->imr = val;
-        if (((val & LASI_IRQ_BITS) != val) && (val != 0xffffffff))
+        if (((val & LASI_IRQ_BITS) != val) && (val != 0xffffffff)) {
             qemu_log_mask(LOG_GUEST_ERROR,
                 "LASI: tried to set invalid %lx IMR value.\n",
                 (unsigned long) val);
+        }
         break;
     case LASI_IPR:
         /* Any write to IPR clears the register. */
@@ -200,8 +201,9 @@ static MemTxResult lasi_chip_write_with_attrs(void *opaque, hwaddr addr,
         break;
 
     case LASI_PCR:
-        if (val == 0x02) /* immediately power off */
+        if (val == 0x02) { /* immediately power off */
             qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
+        }
         break;
     case LASI_ERRLOG:
         s->errlog = val;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 24/50] lasi: move memory region initialisation to new lasi_init() function
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (22 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 23/50] lasi: checkpatch fixes Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 25/50] lasi: move register memory mapping from lasi.c to machine.c Mark Cave-Ayland
                   ` (26 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Create a new lasi_init() instance initialisation function and move the LASI
memory region initialisation into it. Rename the existing lasi_init() function
to lasi_initfn() for now.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/hppa_sys.h |  2 +-
 hw/hppa/lasi.c     | 13 ++++++++++---
 hw/hppa/machine.c  |  2 +-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 7c31dd8396..0929dedded 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -10,7 +10,7 @@
 
 #include "hppa_hardware.h"
 
-DeviceState *lasi_init(MemoryRegion *);
+DeviceState *lasi_initfn(MemoryRegion *);
 #define enable_lasi_lan()       0
 
 /* hppa_pci.c.  */
diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 3b77fba1c6..c028b7786e 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -296,7 +296,7 @@ static int lasi_get_irq(unsigned long hpa)
     }
 }
 
-DeviceState *lasi_init(MemoryRegion *address_space)
+DeviceState *lasi_initfn(MemoryRegion *address_space)
 {
     DeviceState *dev;
     LasiState *s;
@@ -306,8 +306,6 @@ DeviceState *lasi_init(MemoryRegion *address_space)
     s->iar = CPU_HPA + 3;
 
     /* Lasi access from main memory.  */
-    memory_region_init_io(&s->this_mem, OBJECT(s), &lasi_chip_ops,
-                          s, "lasi", 0x100000);
     memory_region_add_subregion(address_space, LASI_HPA, &s->this_mem);
 
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
@@ -347,6 +345,14 @@ DeviceState *lasi_init(MemoryRegion *address_space)
     return dev;
 }
 
+static void lasi_init(Object *obj)
+{
+    LasiState *s = LASI_CHIP(obj);
+
+    memory_region_init_io(&s->this_mem, OBJECT(s), &lasi_chip_ops,
+                          s, "lasi", 0x100000);
+}
+
 static void lasi_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -357,6 +363,7 @@ static void lasi_class_init(ObjectClass *klass, void *data)
 static const TypeInfo lasi_pcihost_info = {
     .name          = TYPE_LASI_CHIP,
     .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_init = lasi_init,
     .instance_size = sizeof(LasiState),
     .class_init    = lasi_class_init,
 };
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index b66e95982e..debc788c2e 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -175,7 +175,7 @@ static void machine_hppa_init(MachineState *machine)
 
 
     /* Init Lasi chip */
-    lasi_init(addr_space);
+    lasi_initfn(addr_space);
 
     /* Init Dino (PCI host bus chip).  */
     dino_dev = DEVICE(dino_init(addr_space));
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 25/50] lasi: move register memory mapping from lasi.c to machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (23 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 24/50] lasi: move memory region initialisation to new lasi_init() function Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 26/50] lasi: move initialisation of iar and rtc to new lasi_reset() function Mark Cave-Ayland
                   ` (25 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

The device register should be mapped directly by the board code.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c    | 7 +++----
 hw/hppa/machine.c | 7 +++++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index c028b7786e..08ebe7c6d9 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -304,10 +304,6 @@ DeviceState *lasi_initfn(MemoryRegion *address_space)
     dev = qdev_new(TYPE_LASI_CHIP);
     s = LASI_CHIP(dev);
     s->iar = CPU_HPA + 3;
-
-    /* Lasi access from main memory.  */
-    memory_region_add_subregion(address_space, LASI_HPA, &s->this_mem);
-
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
     /* LAN */
@@ -348,9 +344,12 @@ DeviceState *lasi_initfn(MemoryRegion *address_space)
 static void lasi_init(Object *obj)
 {
     LasiState *s = LASI_CHIP(obj);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
 
     memory_region_init_io(&s->this_mem, OBJECT(s), &lasi_chip_ops,
                           s, "lasi", 0x100000);
+
+    sysbus_init_mmio(sbd, &s->this_mem);
 }
 
 static void lasi_class_init(ObjectClass *klass, void *data)
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index debc788c2e..ace44f91d6 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -139,7 +139,7 @@ static void machine_hppa_init(MachineState *machine)
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
-    DeviceState *dev, *dino_dev;
+    DeviceState *dev, *dino_dev, *lasi_dev;
     PCIBus *pci_bus;
     ISABus *isa_bus;
     char *firmware_filename;
@@ -175,7 +175,10 @@ static void machine_hppa_init(MachineState *machine)
 
 
     /* Init Lasi chip */
-    lasi_initfn(addr_space);
+    lasi_dev = lasi_initfn(addr_space);
+    memory_region_add_subregion(addr_space, LASI_HPA,
+                                sysbus_mmio_get_region(
+                                    SYS_BUS_DEVICE(lasi_dev), 0));
 
     /* Init Dino (PCI host bus chip).  */
     dino_dev = DEVICE(dino_init(addr_space));
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 26/50] lasi: move initialisation of iar and rtc to new lasi_reset() function
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (24 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 25/50] lasi: move register memory mapping from lasi.c to machine.c Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 27/50] lasi: move LASIState and associated QOM structures to lasi.h Mark Cave-Ayland
                   ` (24 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 08ebe7c6d9..242713c7bd 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -303,7 +303,6 @@ DeviceState *lasi_initfn(MemoryRegion *address_space)
 
     dev = qdev_new(TYPE_LASI_CHIP);
     s = LASI_CHIP(dev);
-    s->iar = CPU_HPA + 3;
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
     /* LAN */
@@ -319,11 +318,6 @@ DeviceState *lasi_initfn(MemoryRegion *address_space)
     parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0,
                      lpt_irq, parallel_hds[0]);
 
-    /* Real time clock (RTC), it's only one 32-bit counter @9000 */
-
-    s->rtc = time(NULL);
-    s->rtc_ref = 0;
-
     if (serial_hd(1)) {
         /* Serial port */
         qemu_irq serial_irq = qemu_allocate_irq(lasi_set_irq, s,
@@ -341,6 +335,17 @@ DeviceState *lasi_initfn(MemoryRegion *address_space)
     return dev;
 }
 
+static void lasi_reset(DeviceState *dev)
+{
+    LasiState *s = LASI_CHIP(dev);
+
+    s->iar = CPU_HPA + 3;
+
+    /* Real time clock (RTC), it's only one 32-bit counter @9000 */
+    s->rtc = time(NULL);
+    s->rtc_ref = 0;
+}
+
 static void lasi_init(Object *obj)
 {
     LasiState *s = LASI_CHIP(obj);
@@ -356,6 +361,7 @@ static void lasi_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
+    dc->reset = lasi_reset;
     dc->vmsd = &vmstate_lasi;
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 27/50] lasi: move LASIState and associated QOM structures to lasi.h
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (25 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 26/50] lasi: move initialisation of iar and rtc to new lasi_reset() function Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 28/50] lasi: replace lasi_get_irq() with defined constants Mark Cave-Ayland
                   ` (23 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c | 44 +-------------------------------------
 hw/hppa/lasi.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 43 deletions(-)
 create mode 100644 hw/hppa/lasi.h

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 242713c7bd..c1dfd5310f 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -24,50 +24,8 @@
 #include "hw/input/lasips2.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
+#include "lasi.h"
 
-#define TYPE_LASI_CHIP "lasi-chip"
-
-#define LASI_IRR        0x00    /* RO */
-#define LASI_IMR        0x04
-#define LASI_IPR        0x08
-#define LASI_ICR        0x0c
-#define LASI_IAR        0x10
-
-#define LASI_PCR        0x0C000 /* LASI Power Control register */
-#define LASI_ERRLOG     0x0C004 /* LASI Error Logging register */
-#define LASI_VER        0x0C008 /* LASI Version Control register */
-#define LASI_IORESET    0x0C00C /* LASI I/O Reset register */
-#define LASI_AMR        0x0C010 /* LASI Arbitration Mask register */
-#define LASI_IO_CONF    0x7FFFE /* LASI primary configuration register */
-#define LASI_IO_CONF2   0x7FFFF /* LASI secondary configuration register */
-
-#define LASI_BIT(x)     (1ul << (x))
-#define LASI_IRQ_BITS   (LASI_BIT(5) | LASI_BIT(7) | LASI_BIT(8) | LASI_BIT(9) \
-            | LASI_BIT(13) | LASI_BIT(14) | LASI_BIT(16) | LASI_BIT(17) \
-            | LASI_BIT(18) | LASI_BIT(19) | LASI_BIT(20) | LASI_BIT(21) \
-            | LASI_BIT(26))
-
-#define ICR_BUS_ERROR_BIT  LASI_BIT(8)  /* bit 8 in ICR */
-#define ICR_TOC_BIT        LASI_BIT(1)  /* bit 1 in ICR */
-
-OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP)
-
-struct LasiState {
-    PCIHostState parent_obj;
-
-    uint32_t irr;
-    uint32_t imr;
-    uint32_t ipr;
-    uint32_t icr;
-    uint32_t iar;
-
-    uint32_t errlog;
-    uint32_t amr;
-    uint32_t rtc;
-    time_t rtc_ref;
-
-    MemoryRegion this_mem;
-};
 
 static bool lasi_chip_mem_valid(void *opaque, hwaddr addr,
                                 unsigned size, bool is_write,
diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h
new file mode 100644
index 0000000000..559aae2560
--- /dev/null
+++ b/hw/hppa/lasi.h
@@ -0,0 +1,58 @@
+/*
+ * HP-PARISC Lasi chipset emulation.
+ *
+ * (C) 2019 by Helge Deller <deller@gmx.de>
+ *
+ * This work is licensed under the GNU GPL license version 2 or later.
+ *
+ * Documentation available at:
+ * https://parisc.wiki.kernel.org/images-parisc/7/79/Lasi_ers.pdf
+ */
+
+#ifndef LASI_H
+#define LASI_H
+
+#define TYPE_LASI_CHIP "lasi-chip"
+OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP)
+
+#define LASI_IRR        0x00    /* RO */
+#define LASI_IMR        0x04
+#define LASI_IPR        0x08
+#define LASI_ICR        0x0c
+#define LASI_IAR        0x10
+
+#define LASI_PCR        0x0C000 /* LASI Power Control register */
+#define LASI_ERRLOG     0x0C004 /* LASI Error Logging register */
+#define LASI_VER        0x0C008 /* LASI Version Control register */
+#define LASI_IORESET    0x0C00C /* LASI I/O Reset register */
+#define LASI_AMR        0x0C010 /* LASI Arbitration Mask register */
+#define LASI_IO_CONF    0x7FFFE /* LASI primary configuration register */
+#define LASI_IO_CONF2   0x7FFFF /* LASI secondary configuration register */
+
+#define LASI_BIT(x)     (1ul << (x))
+#define LASI_IRQ_BITS   (LASI_BIT(5) | LASI_BIT(7) | LASI_BIT(8) | LASI_BIT(9) \
+            | LASI_BIT(13) | LASI_BIT(14) | LASI_BIT(16) | LASI_BIT(17) \
+            | LASI_BIT(18) | LASI_BIT(19) | LASI_BIT(20) | LASI_BIT(21) \
+            | LASI_BIT(26))
+
+#define ICR_BUS_ERROR_BIT  LASI_BIT(8)  /* bit 8 in ICR */
+#define ICR_TOC_BIT        LASI_BIT(1)  /* bit 1 in ICR */
+
+struct LasiState {
+    PCIHostState parent_obj;
+
+    uint32_t irr;
+    uint32_t imr;
+    uint32_t ipr;
+    uint32_t icr;
+    uint32_t iar;
+
+    uint32_t errlog;
+    uint32_t amr;
+    uint32_t rtc;
+    time_t rtc_ref;
+
+    MemoryRegion this_mem;
+};
+
+#endif
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 28/50] lasi: replace lasi_get_irq() with defined constants
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (26 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 27/50] lasi: move LASIState and associated QOM structures to lasi.h Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 29/50] lasi: define IRQ inputs as qdev GPIOs Mark Cave-Ayland
                   ` (22 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c | 31 ++++---------------------------
 hw/hppa/lasi.h |  9 +++++++++
 2 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index c1dfd5310f..ec079601a1 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -231,29 +231,6 @@ static void lasi_set_irq(void *opaque, int irq, int level)
     }
 }
 
-static int lasi_get_irq(unsigned long hpa)
-{
-    switch (hpa) {
-    case LASI_HPA:
-        return 14;
-    case LASI_UART_HPA:
-        return 5;
-    case LASI_LPT_HPA:
-        return 7;
-    case LASI_LAN_HPA:
-        return 8;
-    case LASI_SCSI_HPA:
-        return 9;
-    case LASI_AUDIO_HPA:
-        return 13;
-    case LASI_PS2KBD_HPA:
-    case LASI_PS2MOU_HPA:
-        return 26;
-    default:
-        g_assert_not_reached();
-    }
-}
-
 DeviceState *lasi_initfn(MemoryRegion *address_space)
 {
     DeviceState *dev;
@@ -266,20 +243,20 @@ DeviceState *lasi_initfn(MemoryRegion *address_space)
     /* LAN */
     if (enable_lasi_lan()) {
         qemu_irq lan_irq = qemu_allocate_irq(lasi_set_irq, s,
-                lasi_get_irq(LASI_LAN_HPA));
+                                             LASI_IRQ_LAN_HPA);
         lasi_82596_init(address_space, LASI_LAN_HPA, lan_irq);
     }
 
     /* Parallel port */
     qemu_irq lpt_irq = qemu_allocate_irq(lasi_set_irq, s,
-            lasi_get_irq(LASI_LPT_HPA));
+                                         LASI_IRQ_LPT_HPA);
     parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0,
                      lpt_irq, parallel_hds[0]);
 
     if (serial_hd(1)) {
         /* Serial port */
         qemu_irq serial_irq = qemu_allocate_irq(lasi_set_irq, s,
-                lasi_get_irq(LASI_UART_HPA));
+                                                LASI_IRQ_UART_HPA);
         serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0,
                 serial_irq, 8000000 / 16,
                 serial_hd(0), DEVICE_NATIVE_ENDIAN);
@@ -287,7 +264,7 @@ DeviceState *lasi_initfn(MemoryRegion *address_space)
 
     /* PS/2 Keyboard/Mouse */
     qemu_irq ps2kbd_irq = qemu_allocate_irq(lasi_set_irq, s,
-            lasi_get_irq(LASI_PS2KBD_HPA));
+                                            LASI_IRQ_PS2KBD_HPA);
     lasips2_init(address_space, LASI_PS2KBD_HPA,  ps2kbd_irq);
 
     return dev;
diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h
index 559aae2560..f40546da6e 100644
--- a/hw/hppa/lasi.h
+++ b/hw/hppa/lasi.h
@@ -38,6 +38,15 @@ OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP)
 #define ICR_BUS_ERROR_BIT  LASI_BIT(8)  /* bit 8 in ICR */
 #define ICR_TOC_BIT        LASI_BIT(1)  /* bit 1 in ICR */
 
+#define LASI_IRQ_HPA        14
+#define LASI_IRQ_UART_HPA   5
+#define LASI_IRQ_LPT_HPA    7
+#define LASI_IRQ_LAN_HPA    8
+#define LASI_IRQ_SCSI_HPA   9
+#define LASI_IRQ_AUDIO_HPA  13
+#define LASI_IRQ_PS2KBD_HPA 26
+#define LASI_IRQ_PS2MOU_HPA 26
+
 struct LasiState {
     PCIHostState parent_obj;
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 29/50] lasi: define IRQ inputs as qdev GPIOs
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (27 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 28/50] lasi: replace lasi_get_irq() with defined constants Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 30/50] lasi: use qdev GPIOs to wire up IRQs in lasi_initfn() Mark Cave-Ayland
                   ` (21 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c | 2 ++
 hw/hppa/lasi.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index ec079601a1..9489a80bad 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -290,6 +290,8 @@ static void lasi_init(Object *obj)
                           s, "lasi", 0x100000);
 
     sysbus_init_mmio(sbd, &s->this_mem);
+
+    qdev_init_gpio_in(DEVICE(obj), lasi_set_irq, LASI_IRQS);
 }
 
 static void lasi_class_init(ObjectClass *klass, void *data)
diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h
index f40546da6e..63a2be3740 100644
--- a/hw/hppa/lasi.h
+++ b/hw/hppa/lasi.h
@@ -38,6 +38,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP)
 #define ICR_BUS_ERROR_BIT  LASI_BIT(8)  /* bit 8 in ICR */
 #define ICR_TOC_BIT        LASI_BIT(1)  /* bit 1 in ICR */
 
+#define LASI_IRQS           27
+
 #define LASI_IRQ_HPA        14
 #define LASI_IRQ_UART_HPA   5
 #define LASI_IRQ_LPT_HPA    7
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 30/50] lasi: use qdev GPIOs to wire up IRQs in lasi_initfn()
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (28 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 29/50] lasi: define IRQ inputs as qdev GPIOs Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 31/50] lasi: fix serial port initialisation Mark Cave-Ayland
                   ` (20 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 9489a80bad..32c7514d3a 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -234,38 +234,31 @@ static void lasi_set_irq(void *opaque, int irq, int level)
 DeviceState *lasi_initfn(MemoryRegion *address_space)
 {
     DeviceState *dev;
-    LasiState *s;
 
     dev = qdev_new(TYPE_LASI_CHIP);
-    s = LASI_CHIP(dev);
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
     /* LAN */
     if (enable_lasi_lan()) {
-        qemu_irq lan_irq = qemu_allocate_irq(lasi_set_irq, s,
-                                             LASI_IRQ_LAN_HPA);
-        lasi_82596_init(address_space, LASI_LAN_HPA, lan_irq);
+        lasi_82596_init(address_space, LASI_LAN_HPA,
+                        qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA));
     }
 
     /* Parallel port */
-    qemu_irq lpt_irq = qemu_allocate_irq(lasi_set_irq, s,
-                                         LASI_IRQ_LPT_HPA);
     parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0,
-                     lpt_irq, parallel_hds[0]);
+                     qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA),
+                     parallel_hds[0]);
 
     if (serial_hd(1)) {
         /* Serial port */
-        qemu_irq serial_irq = qemu_allocate_irq(lasi_set_irq, s,
-                                                LASI_IRQ_UART_HPA);
         serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0,
-                serial_irq, 8000000 / 16,
+                qdev_get_gpio_in(dev, LASI_IRQ_UART_HPA), 8000000 / 16,
                 serial_hd(0), DEVICE_NATIVE_ENDIAN);
     }
 
     /* PS/2 Keyboard/Mouse */
-    qemu_irq ps2kbd_irq = qemu_allocate_irq(lasi_set_irq, s,
-                                            LASI_IRQ_PS2KBD_HPA);
-    lasips2_init(address_space, LASI_PS2KBD_HPA,  ps2kbd_irq);
+    lasips2_init(address_space, LASI_PS2KBD_HPA,
+                 qdev_get_gpio_in(dev, LASI_IRQ_PS2KBD_HPA));
 
     return dev;
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 31/50] lasi: fix serial port initialisation
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (29 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 30/50] lasi: use qdev GPIOs to wire up IRQs in lasi_initfn() Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 32/50] lasi: update lasi_initfn() to return LASIState Mark Cave-Ayland
                   ` (19 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

The existing code checks for serial_hd(1) but sets the LASI serial port chardev
to serial_hd(0). Use serial_hd(1) for the LASI serial port and also set the
serial port endian to DEVICE_BIG_ENDIAN (which also matches the endian of the
existing serial port).

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 32c7514d3a..219eb779f3 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -253,7 +253,7 @@ DeviceState *lasi_initfn(MemoryRegion *address_space)
         /* Serial port */
         serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0,
                 qdev_get_gpio_in(dev, LASI_IRQ_UART_HPA), 8000000 / 16,
-                serial_hd(0), DEVICE_NATIVE_ENDIAN);
+                serial_hd(1), DEVICE_BIG_ENDIAN);
     }
 
     /* PS/2 Keyboard/Mouse */
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 32/50] lasi: update lasi_initfn() to return LASIState
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (30 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 31/50] lasi: fix serial port initialisation Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 33/50] lasi: move LAN initialisation to machine.c Mark Cave-Ayland
                   ` (18 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/hppa_sys.h | 3 ++-
 hw/hppa/lasi.c     | 4 ++--
 hw/hppa/machine.c  | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 0929dedded..3832b787d1 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -7,10 +7,11 @@
 #include "hw/pci/pci_host.h"
 #include "hw/boards.h"
 #include "hw/intc/i8259.h"
+#include "lasi.h"
 
 #include "hppa_hardware.h"
 
-DeviceState *lasi_initfn(MemoryRegion *);
+LasiState *lasi_initfn(MemoryRegion *);
 #define enable_lasi_lan()       0
 
 /* hppa_pci.c.  */
diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 219eb779f3..65139bb29b 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -231,7 +231,7 @@ static void lasi_set_irq(void *opaque, int irq, int level)
     }
 }
 
-DeviceState *lasi_initfn(MemoryRegion *address_space)
+LasiState *lasi_initfn(MemoryRegion *address_space)
 {
     DeviceState *dev;
 
@@ -260,7 +260,7 @@ DeviceState *lasi_initfn(MemoryRegion *address_space)
     lasips2_init(address_space, LASI_PS2KBD_HPA,
                  qdev_get_gpio_in(dev, LASI_IRQ_PS2KBD_HPA));
 
-    return dev;
+    return LASI_CHIP(dev);
 }
 
 static void lasi_reset(DeviceState *dev)
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index ace44f91d6..be311294a8 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -18,6 +18,7 @@
 #include "hw/net/lasi_82596.h"
 #include "hw/nmi.h"
 #include "hw/pci-host/dino.h"
+#include "lasi.h"
 #include "hppa_sys.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
@@ -175,7 +176,7 @@ static void machine_hppa_init(MachineState *machine)
 
 
     /* Init Lasi chip */
-    lasi_dev = lasi_initfn(addr_space);
+    lasi_dev = DEVICE(lasi_initfn(addr_space));
     memory_region_add_subregion(addr_space, LASI_HPA,
                                 sysbus_mmio_get_region(
                                     SYS_BUS_DEVICE(lasi_dev), 0));
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 33/50] lasi: move LAN initialisation to machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (31 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 32/50] lasi: update lasi_initfn() to return LASIState Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 34/50] lasi: move parallel port " Mark Cave-Ayland
                   ` (17 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c    | 7 -------
 hw/hppa/machine.c | 5 +++++
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 65139bb29b..88ff9141e4 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -18,7 +18,6 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/runstate.h"
 #include "hppa_sys.h"
-#include "hw/net/lasi_82596.h"
 #include "hw/char/parallel.h"
 #include "hw/char/serial.h"
 #include "hw/input/lasips2.h"
@@ -238,12 +237,6 @@ LasiState *lasi_initfn(MemoryRegion *address_space)
     dev = qdev_new(TYPE_LASI_CHIP);
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
-    /* LAN */
-    if (enable_lasi_lan()) {
-        lasi_82596_init(address_space, LASI_LAN_HPA,
-                        qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA));
-    }
-
     /* Parallel port */
     parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0,
                      qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA),
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index be311294a8..c29528d03b 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -221,6 +221,11 @@ static void machine_hppa_init(MachineState *machine)
     }
 
     /* Network setup. */
+    if (enable_lasi_lan()) {
+        lasi_82596_init(addr_space, LASI_LAN_HPA,
+                        qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA));
+    }
+
     for (i = 0; i < nb_nics; i++) {
         if (!enable_lasi_lan()) {
             pci_nic_init_nofail(&nd_table[i], pci_bus, "tulip", NULL);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 34/50] lasi: move parallel port initialisation to machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (32 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 33/50] lasi: move LAN initialisation to machine.c Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 35/50] lasi: move second serial " Mark Cave-Ayland
                   ` (16 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c    | 6 ------
 hw/hppa/machine.c | 6 ++++++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 88ff9141e4..6faa98dca5 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -18,7 +18,6 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/runstate.h"
 #include "hppa_sys.h"
-#include "hw/char/parallel.h"
 #include "hw/char/serial.h"
 #include "hw/input/lasips2.h"
 #include "migration/vmstate.h"
@@ -237,11 +236,6 @@ LasiState *lasi_initfn(MemoryRegion *address_space)
     dev = qdev_new(TYPE_LASI_CHIP);
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
-    /* Parallel port */
-    parallel_mm_init(address_space, LASI_LPT_HPA + 0x800, 0,
-                     qdev_get_gpio_in(dev, LASI_IRQ_LAN_HPA),
-                     parallel_hds[0]);
-
     if (serial_hd(1)) {
         /* Serial port */
         serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0,
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index c29528d03b..c03312c301 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -15,6 +15,7 @@
 #include "hw/rtc/mc146818rtc.h"
 #include "hw/timer/i8254.h"
 #include "hw/char/serial.h"
+#include "hw/char/parallel.h"
 #include "hw/net/lasi_82596.h"
 #include "hw/nmi.h"
 #include "hw/pci-host/dino.h"
@@ -204,6 +205,11 @@ static void machine_hppa_init(MachineState *machine)
                        115200, serial_hd(0), DEVICE_BIG_ENDIAN);
     }
 
+    /* Parallel port */
+    parallel_mm_init(addr_space, LASI_LPT_HPA + 0x800, 0,
+                     qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA),
+                     parallel_hds[0]);
+
     /* fw_cfg configuration interface */
     create_fw_cfg(machine);
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 35/50] lasi: move second serial port initialisation to machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (33 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 34/50] lasi: move parallel port " Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 36/50] lasi: move PS2 " Mark Cave-Ayland
                   ` (15 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c    | 8 --------
 hw/hppa/machine.c | 7 +++++++
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 6faa98dca5..753a08d454 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -18,7 +18,6 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/runstate.h"
 #include "hppa_sys.h"
-#include "hw/char/serial.h"
 #include "hw/input/lasips2.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
@@ -236,13 +235,6 @@ LasiState *lasi_initfn(MemoryRegion *address_space)
     dev = qdev_new(TYPE_LASI_CHIP);
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
-    if (serial_hd(1)) {
-        /* Serial port */
-        serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0,
-                qdev_get_gpio_in(dev, LASI_IRQ_UART_HPA), 8000000 / 16,
-                serial_hd(1), DEVICE_BIG_ENDIAN);
-    }
-
     /* PS/2 Keyboard/Mouse */
     lasips2_init(address_space, LASI_PS2KBD_HPA,
                  qdev_get_gpio_in(dev, LASI_IRQ_PS2KBD_HPA));
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index c03312c301..1ef9ac5d8f 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -205,6 +205,13 @@ static void machine_hppa_init(MachineState *machine)
                        115200, serial_hd(0), DEVICE_BIG_ENDIAN);
     }
 
+    if (serial_hd(1)) {
+        /* Serial port */
+        serial_mm_init(addr_space, LASI_UART_HPA + 0x800, 0,
+                qdev_get_gpio_in(lasi_dev, LASI_IRQ_UART_HPA), 8000000 / 16,
+                serial_hd(1), DEVICE_BIG_ENDIAN);
+    }
+
     /* Parallel port */
     parallel_mm_init(addr_space, LASI_LPT_HPA + 0x800, 0,
                      qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA),
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 36/50] lasi: move PS2 initialisation to machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (34 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 35/50] lasi: move second serial " Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 37/50] lasi: remove address space parameter from lasi_initfn() Mark Cave-Ayland
                   ` (14 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c    | 5 -----
 hw/hppa/machine.c | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 753a08d454..9d8c9e3936 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -18,7 +18,6 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/runstate.h"
 #include "hppa_sys.h"
-#include "hw/input/lasips2.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
 #include "lasi.h"
@@ -235,10 +234,6 @@ LasiState *lasi_initfn(MemoryRegion *address_space)
     dev = qdev_new(TYPE_LASI_CHIP);
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 
-    /* PS/2 Keyboard/Mouse */
-    lasips2_init(address_space, LASI_PS2KBD_HPA,
-                 qdev_get_gpio_in(dev, LASI_IRQ_PS2KBD_HPA));
-
     return LASI_CHIP(dev);
 }
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 1ef9ac5d8f..094f5138b4 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -16,6 +16,7 @@
 #include "hw/timer/i8254.h"
 #include "hw/char/serial.h"
 #include "hw/char/parallel.h"
+#include "hw/input/lasips2.h"
 #include "hw/net/lasi_82596.h"
 #include "hw/nmi.h"
 #include "hw/pci-host/dino.h"
@@ -245,6 +246,10 @@ static void machine_hppa_init(MachineState *machine)
         }
     }
 
+    /* PS/2 Keyboard/Mouse */
+    lasips2_init(addr_space, LASI_PS2KBD_HPA,
+                 qdev_get_gpio_in(lasi_dev, LASI_IRQ_PS2KBD_HPA));
+
     /* register power switch emulation */
     qemu_register_powerdown_notifier(&hppa_system_powerdown_notifier);
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 37/50] lasi: remove address space parameter from lasi_initfn()
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (35 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 36/50] lasi: move PS2 " Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 38/50] lasi: move lasi_initfn() to machine.c Mark Cave-Ayland
                   ` (13 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Now that all of the LASI devices are mapped by the board, this parameter is no
longer required.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/hppa_sys.h | 2 +-
 hw/hppa/lasi.c     | 2 +-
 hw/hppa/machine.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 3832b787d1..31e3856059 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -11,7 +11,7 @@
 
 #include "hppa_hardware.h"
 
-LasiState *lasi_initfn(MemoryRegion *);
+LasiState *lasi_initfn(void);
 #define enable_lasi_lan()       0
 
 /* hppa_pci.c.  */
diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 9d8c9e3936..81c8e4d2d9 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -227,7 +227,7 @@ static void lasi_set_irq(void *opaque, int irq, int level)
     }
 }
 
-LasiState *lasi_initfn(MemoryRegion *address_space)
+LasiState *lasi_initfn(void)
 {
     DeviceState *dev;
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 094f5138b4..c4b2e69241 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -178,7 +178,7 @@ static void machine_hppa_init(MachineState *machine)
 
 
     /* Init Lasi chip */
-    lasi_dev = DEVICE(lasi_initfn(addr_space));
+    lasi_dev = DEVICE(lasi_initfn());
     memory_region_add_subregion(addr_space, LASI_HPA,
                                 sysbus_mmio_get_region(
                                     SYS_BUS_DEVICE(lasi_dev), 0));
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 38/50] lasi: move lasi_initfn() to machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (36 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 37/50] lasi: remove address space parameter from lasi_initfn() Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 39/50] lasi: use constants for device register offsets Mark Cave-Ayland
                   ` (12 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Move the simplified lasi_initfn() back to machine.c whilst also renaming it
back to its original lasi_init() name.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/hppa_sys.h |  2 --
 hw/hppa/lasi.c     | 10 ----------
 hw/hppa/machine.c  | 12 +++++++++++-
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 31e3856059..f7a127be19 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -7,11 +7,9 @@
 #include "hw/pci/pci_host.h"
 #include "hw/boards.h"
 #include "hw/intc/i8259.h"
-#include "lasi.h"
 
 #include "hppa_hardware.h"
 
-LasiState *lasi_initfn(void);
 #define enable_lasi_lan()       0
 
 /* hppa_pci.c.  */
diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 81c8e4d2d9..ad50880a13 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -227,16 +227,6 @@ static void lasi_set_irq(void *opaque, int irq, int level)
     }
 }
 
-LasiState *lasi_initfn(void)
-{
-    DeviceState *dev;
-
-    dev = qdev_new(TYPE_LASI_CHIP);
-    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
-
-    return LASI_CHIP(dev);
-}
-
 static void lasi_reset(DeviceState *dev)
 {
     LasiState *s = LASI_CHIP(dev);
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index c4b2e69241..c8eee6398a 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -125,6 +125,16 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     return fw_cfg;
 }
 
+static LasiState *lasi_init(void)
+{
+    DeviceState *dev;
+
+    dev = qdev_new(TYPE_LASI_CHIP);
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+
+    return LASI_CHIP(dev);
+}
+
 static DinoState *dino_init(MemoryRegion *addr_space)
 {
     DeviceState *dev;
@@ -178,7 +188,7 @@ static void machine_hppa_init(MachineState *machine)
 
 
     /* Init Lasi chip */
-    lasi_dev = DEVICE(lasi_initfn());
+    lasi_dev = DEVICE(lasi_init());
     memory_region_add_subregion(addr_space, LASI_HPA,
                                 sysbus_mmio_get_region(
                                     SYS_BUS_DEVICE(lasi_dev), 0));
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 39/50] lasi: use constants for device register offsets
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (37 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 38/50] lasi: move lasi_initfn() to machine.c Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 40/50] lasi: use numerical constant for iar reset value Mark Cave-Ayland
                   ` (11 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Instead of generating the offset based upon the physical address of the
register, add constants for each of the device registers to lasi.h and
update lasi.c to use them.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c | 28 ++++++++++++++--------------
 hw/hppa/lasi.h |  5 +++++
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index ad50880a13..11ca33fba3 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -36,10 +36,10 @@ static bool lasi_chip_mem_valid(void *opaque, hwaddr addr,
     case LASI_ICR:
     case LASI_IAR:
 
-    case (LASI_LAN_HPA - LASI_HPA):
-    case (LASI_LPT_HPA - LASI_HPA):
-    case (LASI_UART_HPA - LASI_HPA):
-    case (LASI_RTC_HPA - LASI_HPA):
+    case LASI_LPT:
+    case LASI_UART:
+    case LASI_LAN:
+    case LASI_RTC:
 
     case LASI_PCR ... LASI_AMR:
         ret = true;
@@ -76,12 +76,12 @@ static MemTxResult lasi_chip_read_with_attrs(void *opaque, hwaddr addr,
         val = s->iar;
         break;
 
-    case (LASI_LAN_HPA - LASI_HPA):
-    case (LASI_LPT_HPA - LASI_HPA):
-    case (LASI_UART_HPA - LASI_HPA):
+    case LASI_LPT:
+    case LASI_UART:
+    case LASI_LAN:
         val = 0;
         break;
-    case (LASI_RTC_HPA - LASI_HPA):
+    case LASI_RTC:
         val = time(NULL);
         val += s->rtc_ref;
         break;
@@ -141,16 +141,16 @@ static MemTxResult lasi_chip_write_with_attrs(void *opaque, hwaddr addr,
         s->iar = val;
         break;
 
-    case (LASI_LAN_HPA - LASI_HPA):
-        /* XXX: reset LAN card */
-        break;
-    case (LASI_LPT_HPA - LASI_HPA):
+    case LASI_LPT:
         /* XXX: reset parallel port */
         break;
-    case (LASI_UART_HPA - LASI_HPA):
+    case LASI_UART:
         /* XXX: reset serial port */
         break;
-    case (LASI_RTC_HPA - LASI_HPA):
+    case LASI_LAN:
+        /* XXX: reset LAN card */
+        break;
+    case LASI_RTC:
         s->rtc_ref = val - time(NULL);
         break;
 
diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h
index 63a2be3740..11cf7d6b0b 100644
--- a/hw/hppa/lasi.h
+++ b/hw/hppa/lasi.h
@@ -21,6 +21,11 @@ OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP)
 #define LASI_ICR        0x0c
 #define LASI_IAR        0x10
 
+#define LASI_LPT        0x02000
+#define LASI_UART       0x05000
+#define LASI_LAN        0x07000
+#define LASI_RTC        0x09000
+
 #define LASI_PCR        0x0C000 /* LASI Power Control register */
 #define LASI_ERRLOG     0x0C004 /* LASI Error Logging register */
 #define LASI_VER        0x0C008 /* LASI Version Control register */
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 40/50] lasi: use numerical constant for iar reset value
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (38 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 39/50] lasi: use constants for device register offsets Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 41/50] hppa: move device headers from hppa_sys.h into individual .c files Mark Cave-Ayland
                   ` (10 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This is to allow us to decouple the LASI device from the board logic. If it is
decided later that this value needs to be configurable then it can easily be
converted to a qdev property.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/lasi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/hppa/lasi.c b/hw/hppa/lasi.c
index 11ca33fba3..5ef36f3f58 100644
--- a/hw/hppa/lasi.c
+++ b/hw/hppa/lasi.c
@@ -231,7 +231,7 @@ static void lasi_reset(DeviceState *dev)
 {
     LasiState *s = LASI_CHIP(dev);
 
-    s->iar = CPU_HPA + 3;
+    s->iar = 0xFFFB0000 + 3; /* CPU_HPA + 3 */
 
     /* Real time clock (RTC), it's only one 32-bit counter @9000 */
     s->rtc = time(NULL);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 41/50] hppa: move device headers from hppa_sys.h into individual .c files
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (39 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 40/50] lasi: use numerical constant for iar reset value Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 42/50] lasi: move from hw/hppa to hw/misc Mark Cave-Ayland
                   ` (9 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/hppa_sys.h | 3 ---
 hw/hppa/lasi.h     | 4 ++++
 hw/hppa/machine.c  | 2 ++
 hw/hppa/pci.c      | 3 +++
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index f7a127be19..9964d4a7a7 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -3,10 +3,7 @@
 #ifndef HW_HPPA_SYS_H
 #define HW_HPPA_SYS_H
 
-#include "hw/pci/pci.h"
-#include "hw/pci/pci_host.h"
 #include "hw/boards.h"
-#include "hw/intc/i8259.h"
 
 #include "hppa_hardware.h"
 
diff --git a/hw/hppa/lasi.h b/hw/hppa/lasi.h
index 11cf7d6b0b..ecc7065ce8 100644
--- a/hw/hppa/lasi.h
+++ b/hw/hppa/lasi.h
@@ -12,6 +12,10 @@
 #ifndef LASI_H
 #define LASI_H
 
+#include "exec/address-spaces.h"
+#include "hw/pci/pci_host.h"
+#include "hw/boards.h"
+
 #define TYPE_LASI_CHIP "lasi-chip"
 OBJECT_DECLARE_SIMPLE_TYPE(LasiState, LASI_CHIP)
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index c8eee6398a..ebf447a9eb 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -16,9 +16,11 @@
 #include "hw/timer/i8254.h"
 #include "hw/char/serial.h"
 #include "hw/char/parallel.h"
+#include "hw/intc/i8259.h"
 #include "hw/input/lasips2.h"
 #include "hw/net/lasi_82596.h"
 #include "hw/nmi.h"
+#include "hw/pci/pci.h"
 #include "hw/pci-host/dino.h"
 #include "lasi.h"
 #include "hppa_sys.h"
diff --git a/hw/hppa/pci.c b/hw/hppa/pci.c
index 32609aba63..a92dcb6b9e 100644
--- a/hw/hppa/pci.c
+++ b/hw/hppa/pci.c
@@ -6,6 +6,9 @@
 #include "qemu/osdep.h"
 #include "hppa_sys.h"
 #include "qemu/log.h"
+#include "hw/pci/pci.h"
+#include "hw/pci/pci_host.h"
+#include "hw/intc/i8259.h"
 #include "trace.h"
 
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 42/50] lasi: move from hw/hppa to hw/misc
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (40 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 41/50] hppa: move device headers from hppa_sys.h into individual .c files Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 43/50] hppa: move hppa_pci_ignore_ops from pci.c to machine.c Mark Cave-Ayland
                   ` (8 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Move the LASI device implementation from hw/hppa to hw/misc so that it is
located with all the other miscellaneous devices.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 MAINTAINERS                         | 2 ++
 hw/hppa/Kconfig                     | 1 +
 hw/hppa/machine.c                   | 2 +-
 hw/hppa/meson.build                 | 2 +-
 hw/hppa/trace-events                | 5 -----
 hw/misc/Kconfig                     | 3 +++
 hw/{hppa => misc}/lasi.c            | 3 +--
 hw/misc/meson.build                 | 3 +++
 hw/misc/trace-events                | 5 +++++
 {hw/hppa => include/hw/misc}/lasi.h | 0
 10 files changed, 17 insertions(+), 9 deletions(-)
 rename hw/{hppa => misc}/lasi.c (99%)
 rename {hw/hppa => include/hw/misc}/lasi.h (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 07f85829b0..162a1732d8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1114,7 +1114,9 @@ S: Odd Fixes
 F: configs/devices/hppa-softmmu/default.mak
 F: hw/hppa/
 F: hw/net/*i82596*
+F: hw/misc/lasi.c
 F: hw/pci-host/dino.c
+F: include/hw/misc/lasi.h
 F: include/hw/net/lasi_82596.h
 F: include/hw/pci-host/dino.h
 F: pc-bios/hppa-firmware.img
diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig
index 666a7319d6..99cc483263 100644
--- a/hw/hppa/Kconfig
+++ b/hw/hppa/Kconfig
@@ -4,6 +4,7 @@ config HPPA_GENERIC
     imply E1000_PCI
     imply VIRTIO_VGA
     select DINO
+    select LASI
     select SERIAL
     select ISA_BUS
     select I8259
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index ebf447a9eb..98ba7b65dc 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -22,7 +22,7 @@
 #include "hw/nmi.h"
 #include "hw/pci/pci.h"
 #include "hw/pci-host/dino.h"
-#include "lasi.h"
+#include "hw/misc/lasi.h"
 #include "hppa_sys.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
diff --git a/hw/hppa/meson.build b/hw/hppa/meson.build
index d3f839c6aa..92878d9ac1 100644
--- a/hw/hppa/meson.build
+++ b/hw/hppa/meson.build
@@ -1,4 +1,4 @@
 hppa_ss = ss.source_set()
-hppa_ss.add(when: 'CONFIG_HPPA_GENERIC', if_true: files('pci.c', 'machine.c', 'lasi.c'))
+hppa_ss.add(when: 'CONFIG_HPPA_GENERIC', if_true: files('pci.c', 'machine.c'))
 
 hw_arch += {'hppa': hppa_ss}
diff --git a/hw/hppa/trace-events b/hw/hppa/trace-events
index 871a473771..1a4fbe2fa8 100644
--- a/hw/hppa/trace-events
+++ b/hw/hppa/trace-events
@@ -2,8 +2,3 @@
 
 # pci.c
 hppa_pci_iack_write(void) ""
-
-# lasi.c
-lasi_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d"
-lasi_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
-lasi_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
index 507058d8bf..cbabe9f78c 100644
--- a/hw/misc/Kconfig
+++ b/hw/misc/Kconfig
@@ -171,4 +171,7 @@ config SIFIVE_U_PRCI
 config VIRT_CTRL
     bool
 
+config LASI
+    bool
+
 source macio/Kconfig
diff --git a/hw/hppa/lasi.c b/hw/misc/lasi.c
similarity index 99%
rename from hw/hppa/lasi.c
rename to hw/misc/lasi.c
index 5ef36f3f58..23a7634a8c 100644
--- a/hw/hppa/lasi.c
+++ b/hw/misc/lasi.c
@@ -17,10 +17,9 @@
 #include "hw/irq.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/runstate.h"
-#include "hppa_sys.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
-#include "lasi.h"
+#include "hw/misc/lasi.h"
 
 
 static bool lasi_chip_mem_valid(void *opaque, hwaddr addr,
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
index 2ff05c7afa..132b7b7344 100644
--- a/hw/misc/meson.build
+++ b/hw/misc/meson.build
@@ -134,3 +134,6 @@ specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_cmgcr.c', 'mips_cp
 specific_ss.add(when: 'CONFIG_MIPS_ITU', if_true: files('mips_itu.c'))
 
 specific_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c'))
+
+# HPPA devices
+softmmu_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c'))
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
index 4e0c7973a4..c5e37b0154 100644
--- a/hw/misc/trace-events
+++ b/hw/misc/trace-events
@@ -263,3 +263,8 @@ virt_ctrl_write(void *dev, unsigned int addr, unsigned int size, uint64_t value)
 virt_ctrl_reset(void *dev) "ctrl: %p"
 virt_ctrl_realize(void *dev) "ctrl: %p"
 virt_ctrl_instance_init(void *dev) "ctrl: %p"
+
+# lasi.c
+lasi_chip_mem_valid(uint64_t addr, uint32_t val) "access to addr 0x%"PRIx64" is %d"
+lasi_chip_read(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
+lasi_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
diff --git a/hw/hppa/lasi.h b/include/hw/misc/lasi.h
similarity index 100%
rename from hw/hppa/lasi.h
rename to include/hw/misc/lasi.h
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 43/50] hppa: move hppa_pci_ignore_ops from pci.c to machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (41 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 42/50] lasi: move from hw/hppa to hw/misc Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 44/50] hppa: remove hw/hppa/pci.c Mark Cave-Ayland
                   ` (7 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

The memory region only has one user which is for ensuring accesses to the ISA
bus memory do not fault.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/hppa_sys.h |  1 -
 hw/hppa/machine.c  | 23 +++++++++++++++++++++++
 hw/hppa/pci.c      | 26 --------------------------
 3 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 9964d4a7a7..d984b2895d 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -10,7 +10,6 @@
 #define enable_lasi_lan()       0
 
 /* hppa_pci.c.  */
-extern const MemoryRegionOps hppa_pci_ignore_ops;
 extern const MemoryRegionOps hppa_pci_conf1_ops;
 extern const MemoryRegionOps hppa_pci_iack_ops;
 
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 98ba7b65dc..7fb41ff0e7 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -57,6 +57,29 @@ static Notifier hppa_system_powerdown_notifier = {
     .notify = hppa_powerdown_req
 };
 
+/* Fallback for unassigned PCI I/O operations.  Avoids MCHK.  */
+static uint64_t ignore_read(void *opaque, hwaddr addr, unsigned size)
+{
+    return 0;
+}
+
+static void ignore_write(void *opaque, hwaddr addr, uint64_t v, unsigned size)
+{
+}
+
+static const MemoryRegionOps hppa_pci_ignore_ops = {
+    .read = ignore_read,
+    .write = ignore_write,
+    .endianness = DEVICE_BIG_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 8,
+    },
+    .impl = {
+        .min_access_size = 1,
+        .max_access_size = 8,
+    },
+};
 
 static ISABus *hppa_isa_bus(void)
 {
diff --git a/hw/hppa/pci.c b/hw/hppa/pci.c
index a92dcb6b9e..4d62d54c22 100644
--- a/hw/hppa/pci.c
+++ b/hw/hppa/pci.c
@@ -12,32 +12,6 @@
 #include "trace.h"
 
 
-/* Fallback for unassigned PCI I/O operations.  Avoids MCHK.  */
-
-static uint64_t ignore_read(void *opaque, hwaddr addr, unsigned size)
-{
-    return 0;
-}
-
-static void ignore_write(void *opaque, hwaddr addr, uint64_t v, unsigned size)
-{
-}
-
-const MemoryRegionOps hppa_pci_ignore_ops = {
-    .read = ignore_read,
-    .write = ignore_write,
-    .endianness = DEVICE_BIG_ENDIAN,
-    .valid = {
-        .min_access_size = 1,
-        .max_access_size = 8,
-    },
-    .impl = {
-        .min_access_size = 1,
-        .max_access_size = 8,
-    },
-};
-
-
 /* PCI config space reads/writes, to byte-word addressable memory.  */
 static uint64_t bw_conf1_read(void *opaque, hwaddr addr,
                               unsigned size)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 44/50] hppa: remove hw/hppa/pci.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (42 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 43/50] hppa: move hppa_pci_ignore_ops from pci.c to machine.c Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 45/50] hppa: remove unused trace-events from from hw/hppa Mark Cave-Ayland
                   ` (6 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

The functions and definitions in this file are not used anywhere within the
generic hppa machine.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/hppa_sys.h   |  6 ----
 hw/hppa/meson.build  |  2 +-
 hw/hppa/pci.c        | 65 --------------------------------------------
 hw/hppa/trace-events |  3 --
 4 files changed, 1 insertion(+), 75 deletions(-)
 delete mode 100644 hw/hppa/pci.c

diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index d984b2895d..17e2c6dec1 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -3,14 +3,8 @@
 #ifndef HW_HPPA_SYS_H
 #define HW_HPPA_SYS_H
 
-#include "hw/boards.h"
-
 #include "hppa_hardware.h"
 
 #define enable_lasi_lan()       0
 
-/* hppa_pci.c.  */
-extern const MemoryRegionOps hppa_pci_conf1_ops;
-extern const MemoryRegionOps hppa_pci_iack_ops;
-
 #endif
diff --git a/hw/hppa/meson.build b/hw/hppa/meson.build
index 92878d9ac1..28175d27a4 100644
--- a/hw/hppa/meson.build
+++ b/hw/hppa/meson.build
@@ -1,4 +1,4 @@
 hppa_ss = ss.source_set()
-hppa_ss.add(when: 'CONFIG_HPPA_GENERIC', if_true: files('pci.c', 'machine.c'))
+hppa_ss.add(when: 'CONFIG_HPPA_GENERIC', if_true: files('machine.c'))
 
 hw_arch += {'hppa': hppa_ss}
diff --git a/hw/hppa/pci.c b/hw/hppa/pci.c
deleted file mode 100644
index 4d62d54c22..0000000000
--- a/hw/hppa/pci.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * QEMU HP-PARISC PCI support functions.
- *
- */
-
-#include "qemu/osdep.h"
-#include "hppa_sys.h"
-#include "qemu/log.h"
-#include "hw/pci/pci.h"
-#include "hw/pci/pci_host.h"
-#include "hw/intc/i8259.h"
-#include "trace.h"
-
-
-/* PCI config space reads/writes, to byte-word addressable memory.  */
-static uint64_t bw_conf1_read(void *opaque, hwaddr addr,
-                              unsigned size)
-{
-    PCIBus *b = opaque;
-    return pci_data_read(b, addr, size);
-}
-
-static void bw_conf1_write(void *opaque, hwaddr addr,
-                           uint64_t val, unsigned size)
-{
-    PCIBus *b = opaque;
-    pci_data_write(b, addr, val, size);
-}
-
-const MemoryRegionOps hppa_pci_conf1_ops = {
-    .read = bw_conf1_read,
-    .write = bw_conf1_write,
-    .endianness = DEVICE_BIG_ENDIAN,
-    .impl = {
-        .min_access_size = 1,
-        .max_access_size = 4,
-    },
-};
-
-/* PCI/EISA Interrupt Acknowledge Cycle.  */
-
-static uint64_t iack_read(void *opaque, hwaddr addr, unsigned size)
-{
-    return pic_read_irq(isa_pic);
-}
-
-static void special_write(void *opaque, hwaddr addr,
-                          uint64_t val, unsigned size)
-{
-    trace_hppa_pci_iack_write();
-}
-
-const MemoryRegionOps hppa_pci_iack_ops = {
-    .read = iack_read,
-    .write = special_write,
-    .endianness = DEVICE_BIG_ENDIAN,
-    .valid = {
-        .min_access_size = 4,
-        .max_access_size = 4,
-    },
-    .impl = {
-        .min_access_size = 4,
-        .max_access_size = 4,
-    },
-};
diff --git a/hw/hppa/trace-events b/hw/hppa/trace-events
index 1a4fbe2fa8..23bc9b19b9 100644
--- a/hw/hppa/trace-events
+++ b/hw/hppa/trace-events
@@ -1,4 +1 @@
 # See docs/devel/tracing.rst for syntax documentation.
-
-# pci.c
-hppa_pci_iack_write(void) ""
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 45/50] hppa: remove unused trace-events from from hw/hppa
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (43 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 44/50] hppa: remove hw/hppa/pci.c Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 46/50] hppa: move enable_lan() define from hppa_sys.h to machine.c Mark Cave-Ayland
                   ` (5 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Now that there are no longer any devices in hw/hppa the trace-events file is
empty and can be removed.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/trace-events | 1 -
 meson.build          | 1 -
 2 files changed, 2 deletions(-)
 delete mode 100644 hw/hppa/trace-events

diff --git a/hw/hppa/trace-events b/hw/hppa/trace-events
deleted file mode 100644
index 23bc9b19b9..0000000000
--- a/hw/hppa/trace-events
+++ /dev/null
@@ -1 +0,0 @@
-# See docs/devel/tracing.rst for syntax documentation.
diff --git a/meson.build b/meson.build
index d083c6b7bf..8e6b97ba19 100644
--- a/meson.build
+++ b/meson.build
@@ -2713,7 +2713,6 @@ if have_system
     'hw/char',
     'hw/display',
     'hw/dma',
-    'hw/hppa',
     'hw/hyperv',
     'hw/i2c',
     'hw/i386',
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 46/50] hppa: move enable_lan() define from hppa_sys.h to machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (44 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 45/50] hppa: remove unused trace-events from from hw/hppa Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 47/50] hppa: remove the empty hppa_sys.h file Mark Cave-Ayland
                   ` (4 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Now that the board configuration is in one place, the define is only needed when
wiring up the board in machine.c.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/hppa_sys.h | 2 --
 hw/hppa/machine.c  | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
index 17e2c6dec1..e7f65cad75 100644
--- a/hw/hppa/hppa_sys.h
+++ b/hw/hppa/hppa_sys.h
@@ -5,6 +5,4 @@
 
 #include "hppa_hardware.h"
 
-#define enable_lasi_lan()       0
-
 #endif
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 7fb41ff0e7..d61e2ea4e4 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -36,6 +36,9 @@
 
 #define HPA_POWER_BUTTON (FIRMWARE_END - 0x10)
 
+#define enable_lasi_lan()       0
+
+
 static void hppa_powerdown_req(Notifier *n, void *opaque)
 {
     hwaddr soft_power_reg = HPA_POWER_BUTTON;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 47/50] hppa: remove the empty hppa_sys.h file
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (45 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 46/50] hppa: move enable_lan() define from hppa_sys.h to machine.c Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 48/50] hppa: use MACHINE QOM macros for defining the hppa machine Mark Cave-Ayland
                   ` (3 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

This file is now just a simple wrapper that includes hppa_hardware.h so remove
the file completely, and update its single user in machine.c to include
hppa_hardware.h directly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/hppa_sys.h | 8 --------
 hw/hppa/machine.c  | 2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)
 delete mode 100644 hw/hppa/hppa_sys.h

diff --git a/hw/hppa/hppa_sys.h b/hw/hppa/hppa_sys.h
deleted file mode 100644
index e7f65cad75..0000000000
--- a/hw/hppa/hppa_sys.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* HPPA cores and system support chips.  */
-
-#ifndef HW_HPPA_SYS_H
-#define HW_HPPA_SYS_H
-
-#include "hppa_hardware.h"
-
-#endif
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index d61e2ea4e4..13942ec596 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -23,7 +23,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci-host/dino.h"
 #include "hw/misc/lasi.h"
-#include "hppa_sys.h"
+#include "hppa_hardware.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
 #include "net/net.h"
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 48/50] hppa: use MACHINE QOM macros for defining the hppa machine
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (46 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 47/50] hppa: remove the empty hppa_sys.h file Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:30 ` [PATCH 49/50] hppa: fold machine_hppa_machine_init() into machine_hppa_machine_init_class_init() Mark Cave-Ayland
                   ` (2 subsequent siblings)
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/machine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 13942ec596..dc9950d5d5 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -471,8 +471,8 @@ static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data)
 }
 
 static const TypeInfo machine_hppa_machine_init_typeinfo = {
-    .name = ("hppa" "-machine"),
-    .parent = "machine",
+    .name = MACHINE_TYPE_NAME("hppa"),
+    .parent = TYPE_MACHINE,
     .class_init = machine_hppa_machine_init_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_NMI },
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 49/50] hppa: fold machine_hppa_machine_init() into machine_hppa_machine_init_class_init()
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (47 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 48/50] hppa: use MACHINE QOM macros for defining the hppa machine Mark Cave-Ayland
@ 2022-04-21 19:30 ` Mark Cave-Ayland
  2022-04-21 19:31 ` [PATCH 50/50] hppa: simplify machine function names in machine.c Mark Cave-Ayland
  2022-04-28 16:58 ` [PATCH 00/50] hppa: general improvements and tidy-ups Helge Deller
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:30 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

There is no need for a separate function to set the machine class properties
separately from the others.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/machine.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index dc9950d5d5..3176c7897e 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -446,8 +446,11 @@ static void hppa_nmi(NMIState *n, int cpu_index, Error **errp)
     }
 }
 
-static void machine_hppa_machine_init(MachineClass *mc)
+static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+    NMIClass *nc = NMI_CLASS(oc);
+
     mc->desc = "HPPA generic machine";
     mc->default_cpu_type = TYPE_HPPA_CPU;
     mc->init = machine_hppa_init;
@@ -459,14 +462,7 @@ static void machine_hppa_machine_init(MachineClass *mc)
     mc->default_ram_size = 512 * MiB;
     mc->default_boot_order = "cd";
     mc->default_ram_id = "ram";
-}
 
-static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data)
-{
-    MachineClass *mc = MACHINE_CLASS(oc);
-    machine_hppa_machine_init(mc);
-
-    NMIClass *nc = NMI_CLASS(oc);
     nc->nmi_monitor_handler = hppa_nmi;
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 50/50] hppa: simplify machine function names in machine.c
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (48 preceding siblings ...)
  2022-04-21 19:30 ` [PATCH 49/50] hppa: fold machine_hppa_machine_init() into machine_hppa_machine_init_class_init() Mark Cave-Ayland
@ 2022-04-21 19:31 ` Mark Cave-Ayland
  2022-04-28 16:58 ` [PATCH 00/50] hppa: general improvements and tidy-ups Helge Deller
  50 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-04-21 19:31 UTC (permalink / raw)
  To: richard.henderson, deller, qemu-devel

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/hppa/machine.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 3176c7897e..292867a063 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -446,7 +446,7 @@ static void hppa_nmi(NMIState *n, int cpu_index, Error **errp)
     }
 }
 
-static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data)
+static void hppa_machine_init_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
     NMIClass *nc = NMI_CLASS(oc);
@@ -466,19 +466,19 @@ static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data)
     nc->nmi_monitor_handler = hppa_nmi;
 }
 
-static const TypeInfo machine_hppa_machine_init_typeinfo = {
+static const TypeInfo hppa_machine_init_typeinfo = {
     .name = MACHINE_TYPE_NAME("hppa"),
     .parent = TYPE_MACHINE,
-    .class_init = machine_hppa_machine_init_class_init,
+    .class_init = hppa_machine_init_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_NMI },
         { }
     },
 };
 
-static void machine_hppa_machine_init_register_types(void)
+static void hppa_machine_init_register_types(void)
 {
-    type_register_static(&machine_hppa_machine_init_typeinfo);
+    type_register_static(&hppa_machine_init_typeinfo);
 }
 
-type_init(machine_hppa_machine_init_register_types)
+type_init(hppa_machine_init_register_types)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH 01/50] dino: checkpatch fixes
  2022-04-21 19:30 ` [PATCH 01/50] dino: checkpatch fixes Mark Cave-Ayland
@ 2022-04-21 22:19   ` Richard Henderson
  0 siblings, 0 replies; 56+ messages in thread
From: Richard Henderson @ 2022-04-21 22:19 UTC (permalink / raw)
  To: Mark Cave-Ayland, deller, qemu-devel

On 4/21/22 12:30, Mark Cave-Ayland wrote:
> Signed-off-by: Mark Cave-Ayland<mark.cave-ayland@ilande.co.uk>
> ---
>   hw/hppa/dino.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 00/50] hppa: general improvements and tidy-ups
  2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
                   ` (49 preceding siblings ...)
  2022-04-21 19:31 ` [PATCH 50/50] hppa: simplify machine function names in machine.c Mark Cave-Ayland
@ 2022-04-28 16:58 ` Helge Deller
  2022-05-03 12:11   ` Mark Cave-Ayland
  50 siblings, 1 reply; 56+ messages in thread
From: Helge Deller @ 2022-04-28 16:58 UTC (permalink / raw)
  To: Mark Cave-Ayland, richard.henderson, qemu-devel

On 4/21/22 21:30, Mark Cave-Ayland wrote:
> This patchset started off when I noticed that dino.c was accessing parent_obj
> directly rather than using a QOM cast. After fixing that I noticed quite a few
> other improvements that could be done to bring hppa up to our recommended
> coding standards.
>
> The main aim of this patchset is to de-couple the dino and lasi devices from
> the board using QOM to handle the initialisation instead of having global
> device init functions. Included in this is switching the onboard devices
> over to use qdev GPIOs for wiring instead of directly allocating QEMU IRQs.
>
> Along the way I've renamed the board config from CONFIG_DINO to
> CONFIG_HPPA_GENERIC since that better represents the machine type, and then
> used CONFIG_DINO and CONFIG_LASI for the appropriate devices which have been
> moved to hw/pci-host/dino.c and hw/misc/lasi.c respectively.
>
> After the reorganisation it was trivial to remove hppa_sys.h and the majority
> of pci.c which wasn't being used. Finally I tidied up the use of the QOM
> machine type macros in machine.c.
>
> The result has been lightly tested with a tiny Linux image I had lying around
> for testing my recent ESP changes, so more testing is welcome. There is a bit
> more work to be done sorting out the lasips2 device init and machine init, but
> since the patchset is already quite big I can follow up with that once this
> series has been merged.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

Marc, thanks a lot for this big cleanup!
I've reviewed and tested it with Linux and HP-UX guests.

Please add:
Acked-by: Helge Deller <deller@gmx.de>

Thanks!!
Helge

>
> Mark Cave-Ayland (50):
>   dino: checkpatch fixes
>   dino: move registers from dino_init() to DINO_PCI_BRIDGE init function
>   dino: move PCI bus initialisation to dino_pcihost_init()
>   dino: move PCI windows initialisation to dino_pcihost_init()
>   dino: add memory-as property containing a link to the memory address
>     space
>   dino: move pci_setup_iommu() to dino_pcihost_init()
>   dino: move PCI bus master address space setup to
>     dino_pcihost_realize()
>   dino: move initial register configuration to new dino_pcihost_reset()
>     function
>   dino: use QOM cast instead of directly referencing parent_obj
>   dino: return PCIBus from dino_init() using qdev_get_child_bus()
>   dino: split declarations from dino.c into dino.h
>   hppa: use new CONFIG_HPPA_GENERIC option instead of CONFIG_DINO to
>     build hppa machine
>   dino: change dino_init() to return the DINO device instead of PCIBus
>   machine.c: map DINO device during board configuration
>   dino.h: add defines for DINO IRQ numbers
>   dino: define IRQ inputs as qdev GPIOs
>   dino: wire up serial IRQ using a qdev GPIO in machine.c
>   dino: remove unused dino_set_timer_irq() IRQ handler
>   hppa: move dino_init() from dino.c to machine.c
>   dino: use numerical constant for iar0 and iar1 reset values
>   dino: move DINO HPA constants from hppa_hardware.h to dino.h
>   dino: move from hw/hppa to hw/pci-host
>   lasi: checkpatch fixes
>   lasi: move memory region initialisation to new lasi_init() function
>   lasi: move register memory mapping from lasi.c to machine.c
>   lasi: move initialisation of iar and rtc to new lasi_reset() function
>   lasi: move LASIState and associated QOM structures to lasi.h
>   lasi: replace lasi_get_irq() with defined constants
>   lasi: define IRQ inputs as qdev GPIOs
>   lasi: use qdev GPIOs to wire up IRQs in lasi_initfn()
>   lasi: fix serial port initialisation
>   lasi: update lasi_initfn() to return LASIState
>   lasi: move LAN initialisation to machine.c
>   lasi: move parallel port initialisation to machine.c
>   lasi: move second serial port initialisation to machine.c
>   lasi: move PS2 initialisation to machine.c
>   lasi: remove address space parameter from lasi_initfn()
>   lasi: move lasi_initfn() to machine.c
>   lasi: use constants for device register offsets
>   lasi: use numerical constant for iar reset value
>   hppa: move device headers from hppa_sys.h into individual .c files
>   lasi: move from hw/hppa to hw/misc
>   hppa: move hppa_pci_ignore_ops from pci.c to machine.c
>   hppa: remove hw/hppa/pci.c
>   hppa: remove unused trace-events from from hw/hppa
>   hppa: move enable_lan() define from hppa_sys.h to machine.c
>   hppa: remove the empty hppa_sys.h file
>   hppa: use MACHINE QOM macros for defining the hppa machine
>   hppa: fold machine_hppa_machine_init() into
>     machine_hppa_machine_init_class_init()
>   hppa: simplify machine function names in machine.c
>
>  MAINTAINERS                              |   4 +
>  configs/devices/hppa-softmmu/default.mak |   2 +-
>  hw/hppa/Kconfig                          |   5 +-
>  hw/hppa/hppa_hardware.h                  |   5 -
>  hw/hppa/hppa_sys.h                       |  24 ---
>  hw/hppa/machine.c                        | 122 +++++++++---
>  hw/hppa/meson.build                      |   2 +-
>  hw/hppa/pci.c                            |  88 ---------
>  hw/hppa/trace-events                     |  14 --
>  hw/misc/Kconfig                          |   3 +
>  hw/{hppa => misc}/lasi.c                 | 161 ++++------------
>  hw/misc/meson.build                      |   3 +
>  hw/misc/trace-events                     |   5 +
>  hw/pci-host/Kconfig                      |   4 +
>  hw/{hppa => pci-host}/dino.c             | 231 +++++++----------------
>  hw/pci-host/meson.build                  |   3 +
>  hw/pci-host/trace-events                 |   5 +
>  include/hw/misc/lasi.h                   |  78 ++++++++
>  include/hw/pci-host/dino.h               | 146 ++++++++++++++
>  meson.build                              |   1 -
>  20 files changed, 462 insertions(+), 444 deletions(-)
>  delete mode 100644 hw/hppa/hppa_sys.h
>  delete mode 100644 hw/hppa/pci.c
>  delete mode 100644 hw/hppa/trace-events
>  rename hw/{hppa => misc}/lasi.c (60%)
>  rename hw/{hppa => pci-host}/dino.c (71%)
>  create mode 100644 include/hw/misc/lasi.h
>  create mode 100644 include/hw/pci-host/dino.h
>



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 00/50] hppa: general improvements and tidy-ups
  2022-04-28 16:58 ` [PATCH 00/50] hppa: general improvements and tidy-ups Helge Deller
@ 2022-05-03 12:11   ` Mark Cave-Ayland
  2022-05-03 15:38     ` Richard Henderson
  0 siblings, 1 reply; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-05-03 12:11 UTC (permalink / raw)
  To: Helge Deller, richard.henderson, qemu-devel

On 28/04/2022 17:58, Helge Deller wrote:

> On 4/21/22 21:30, Mark Cave-Ayland wrote:
>> This patchset started off when I noticed that dino.c was accessing parent_obj
>> directly rather than using a QOM cast. After fixing that I noticed quite a few
>> other improvements that could be done to bring hppa up to our recommended
>> coding standards.
>>
>> The main aim of this patchset is to de-couple the dino and lasi devices from
>> the board using QOM to handle the initialisation instead of having global
>> device init functions. Included in this is switching the onboard devices
>> over to use qdev GPIOs for wiring instead of directly allocating QEMU IRQs.
>>
>> Along the way I've renamed the board config from CONFIG_DINO to
>> CONFIG_HPPA_GENERIC since that better represents the machine type, and then
>> used CONFIG_DINO and CONFIG_LASI for the appropriate devices which have been
>> moved to hw/pci-host/dino.c and hw/misc/lasi.c respectively.
>>
>> After the reorganisation it was trivial to remove hppa_sys.h and the majority
>> of pci.c which wasn't being used. Finally I tidied up the use of the QOM
>> machine type macros in machine.c.
>>
>> The result has been lightly tested with a tiny Linux image I had lying around
>> for testing my recent ESP changes, so more testing is welcome. There is a bit
>> more work to be done sorting out the lasips2 device init and machine init, but
>> since the patchset is already quite big I can follow up with that once this
>> series has been merged.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> 
> Marc, thanks a lot for this big cleanup!
> I've reviewed and tested it with Linux and HP-UX guests.
> 
> Please add:
> Acked-by: Helge Deller <deller@gmx.de>
> 
> Thanks!!
> Helge
> 
>>
>> Mark Cave-Ayland (50):
>>    dino: checkpatch fixes
>>    dino: move registers from dino_init() to DINO_PCI_BRIDGE init function
>>    dino: move PCI bus initialisation to dino_pcihost_init()
>>    dino: move PCI windows initialisation to dino_pcihost_init()
>>    dino: add memory-as property containing a link to the memory address
>>      space
>>    dino: move pci_setup_iommu() to dino_pcihost_init()
>>    dino: move PCI bus master address space setup to
>>      dino_pcihost_realize()
>>    dino: move initial register configuration to new dino_pcihost_reset()
>>      function
>>    dino: use QOM cast instead of directly referencing parent_obj
>>    dino: return PCIBus from dino_init() using qdev_get_child_bus()
>>    dino: split declarations from dino.c into dino.h
>>    hppa: use new CONFIG_HPPA_GENERIC option instead of CONFIG_DINO to
>>      build hppa machine
>>    dino: change dino_init() to return the DINO device instead of PCIBus
>>    machine.c: map DINO device during board configuration
>>    dino.h: add defines for DINO IRQ numbers
>>    dino: define IRQ inputs as qdev GPIOs
>>    dino: wire up serial IRQ using a qdev GPIO in machine.c
>>    dino: remove unused dino_set_timer_irq() IRQ handler
>>    hppa: move dino_init() from dino.c to machine.c
>>    dino: use numerical constant for iar0 and iar1 reset values
>>    dino: move DINO HPA constants from hppa_hardware.h to dino.h
>>    dino: move from hw/hppa to hw/pci-host
>>    lasi: checkpatch fixes
>>    lasi: move memory region initialisation to new lasi_init() function
>>    lasi: move register memory mapping from lasi.c to machine.c
>>    lasi: move initialisation of iar and rtc to new lasi_reset() function
>>    lasi: move LASIState and associated QOM structures to lasi.h
>>    lasi: replace lasi_get_irq() with defined constants
>>    lasi: define IRQ inputs as qdev GPIOs
>>    lasi: use qdev GPIOs to wire up IRQs in lasi_initfn()
>>    lasi: fix serial port initialisation
>>    lasi: update lasi_initfn() to return LASIState
>>    lasi: move LAN initialisation to machine.c
>>    lasi: move parallel port initialisation to machine.c
>>    lasi: move second serial port initialisation to machine.c
>>    lasi: move PS2 initialisation to machine.c
>>    lasi: remove address space parameter from lasi_initfn()
>>    lasi: move lasi_initfn() to machine.c
>>    lasi: use constants for device register offsets
>>    lasi: use numerical constant for iar reset value
>>    hppa: move device headers from hppa_sys.h into individual .c files
>>    lasi: move from hw/hppa to hw/misc
>>    hppa: move hppa_pci_ignore_ops from pci.c to machine.c
>>    hppa: remove hw/hppa/pci.c
>>    hppa: remove unused trace-events from from hw/hppa
>>    hppa: move enable_lan() define from hppa_sys.h to machine.c
>>    hppa: remove the empty hppa_sys.h file
>>    hppa: use MACHINE QOM macros for defining the hppa machine
>>    hppa: fold machine_hppa_machine_init() into
>>      machine_hppa_machine_init_class_init()
>>    hppa: simplify machine function names in machine.c
>>
>>   MAINTAINERS                              |   4 +
>>   configs/devices/hppa-softmmu/default.mak |   2 +-
>>   hw/hppa/Kconfig                          |   5 +-
>>   hw/hppa/hppa_hardware.h                  |   5 -
>>   hw/hppa/hppa_sys.h                       |  24 ---
>>   hw/hppa/machine.c                        | 122 +++++++++---
>>   hw/hppa/meson.build                      |   2 +-
>>   hw/hppa/pci.c                            |  88 ---------
>>   hw/hppa/trace-events                     |  14 --
>>   hw/misc/Kconfig                          |   3 +
>>   hw/{hppa => misc}/lasi.c                 | 161 ++++------------
>>   hw/misc/meson.build                      |   3 +
>>   hw/misc/trace-events                     |   5 +
>>   hw/pci-host/Kconfig                      |   4 +
>>   hw/{hppa => pci-host}/dino.c             | 231 +++++++----------------
>>   hw/pci-host/meson.build                  |   3 +
>>   hw/pci-host/trace-events                 |   5 +
>>   include/hw/misc/lasi.h                   |  78 ++++++++
>>   include/hw/pci-host/dino.h               | 146 ++++++++++++++
>>   meson.build                              |   1 -
>>   20 files changed, 462 insertions(+), 444 deletions(-)
>>   delete mode 100644 hw/hppa/hppa_sys.h
>>   delete mode 100644 hw/hppa/pci.c
>>   delete mode 100644 hw/hppa/trace-events
>>   rename hw/{hppa => misc}/lasi.c (60%)
>>   rename hw/{hppa => pci-host}/dino.c (71%)
>>   create mode 100644 include/hw/misc/lasi.h
>>   create mode 100644 include/hw/pci-host/dino.h

Thanks Helge! After a few brief experiments over the holiday weekend I'm going to 
send a v2 with your A-B tags, and also change the machine from "HPPA generic" to 
"HPPA BL160L". This will then match with both MAINTAINERS and also Linux which 
identifies the machine as "model 9000/778/B160L".

Richard, any other thoughts before sending out a v2? And who should be the best 
person to merge it?


ATB,

Mark.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 00/50] hppa: general improvements and tidy-ups
  2022-05-03 12:11   ` Mark Cave-Ayland
@ 2022-05-03 15:38     ` Richard Henderson
  2022-05-04 12:12       ` Mark Cave-Ayland
  0 siblings, 1 reply; 56+ messages in thread
From: Richard Henderson @ 2022-05-03 15:38 UTC (permalink / raw)
  To: Mark Cave-Ayland, Helge Deller, qemu-devel

On 5/3/22 05:11, Mark Cave-Ayland wrote:
> Thanks Helge! After a few brief experiments over the holiday weekend I'm going to send a 
> v2 with your A-B tags, and also change the machine from "HPPA generic" to "HPPA BL160L". 
> This will then match with both MAINTAINERS and also Linux which identifies the machine as 
> "model 9000/778/B160L".
> 
> Richard, any other thoughts before sending out a v2? And who should be the best person to 
> merge it?

I have no specific comments; most of the patch set is outside my area of expertise. As far 
as I'm concerned, it would be helpful if you sent the PR.


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 00/50] hppa: general improvements and tidy-ups
  2022-05-03 15:38     ` Richard Henderson
@ 2022-05-04 12:12       ` Mark Cave-Ayland
  0 siblings, 0 replies; 56+ messages in thread
From: Mark Cave-Ayland @ 2022-05-04 12:12 UTC (permalink / raw)
  To: Richard Henderson, Helge Deller, qemu-devel

On 03/05/2022 16:38, Richard Henderson wrote:

> On 5/3/22 05:11, Mark Cave-Ayland wrote:
>> Thanks Helge! After a few brief experiments over the holiday weekend I'm going to 
>> send a v2 with your A-B tags, and also change the machine from "HPPA generic" to 
>> "HPPA BL160L". This will then match with both MAINTAINERS and also Linux which 
>> identifies the machine as "model 9000/778/B160L".
>>
>> Richard, any other thoughts before sending out a v2? And who should be the best 
>> person to merge it?
> 
> I have no specific comments; most of the patch set is outside my area of expertise. 
> As far as I'm concerned, it would be helpful if you sent the PR.

No worries. I've sent the updated v2 and can send a PR at the end of the week 
assuming no-one has any further comments.


ATB,

Mark.


^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2022-05-04 12:14 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 19:30 [PATCH 00/50] hppa: general improvements and tidy-ups Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 01/50] dino: checkpatch fixes Mark Cave-Ayland
2022-04-21 22:19   ` Richard Henderson
2022-04-21 19:30 ` [PATCH 02/50] dino: move registers from dino_init() to DINO_PCI_BRIDGE init function Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 03/50] dino: move PCI bus initialisation to dino_pcihost_init() Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 04/50] dino: move PCI windows " Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 05/50] dino: add memory-as property containing a link to the memory address space Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 06/50] dino: move pci_setup_iommu() to dino_pcihost_init() Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 07/50] dino: move PCI bus master address space setup to dino_pcihost_realize() Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 08/50] dino: move initial register configuration to new dino_pcihost_reset() function Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 09/50] dino: use QOM cast instead of directly referencing parent_obj Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 10/50] dino: return PCIBus from dino_init() using qdev_get_child_bus() Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 11/50] dino: split declarations from dino.c into dino.h Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 12/50] hppa: use new CONFIG_HPPA_GENERIC option instead of CONFIG_DINO to build hppa machine Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 13/50] dino: change dino_init() to return the DINO device instead of PCIBus Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 14/50] machine.c: map DINO device during board configuration Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 15/50] dino.h: add defines for DINO IRQ numbers Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 16/50] dino: define IRQ inputs as qdev GPIOs Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 17/50] dino: wire up serial IRQ using a qdev GPIO in machine.c Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 18/50] dino: remove unused dino_set_timer_irq() IRQ handler Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 19/50] hppa: move dino_init() from dino.c to machine.c Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 20/50] dino: use numerical constant for iar0 and iar1 reset values Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 21/50] dino: move DINO HPA constants from hppa_hardware.h to dino.h Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 22/50] dino: move from hw/hppa to hw/pci-host Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 23/50] lasi: checkpatch fixes Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 24/50] lasi: move memory region initialisation to new lasi_init() function Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 25/50] lasi: move register memory mapping from lasi.c to machine.c Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 26/50] lasi: move initialisation of iar and rtc to new lasi_reset() function Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 27/50] lasi: move LASIState and associated QOM structures to lasi.h Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 28/50] lasi: replace lasi_get_irq() with defined constants Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 29/50] lasi: define IRQ inputs as qdev GPIOs Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 30/50] lasi: use qdev GPIOs to wire up IRQs in lasi_initfn() Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 31/50] lasi: fix serial port initialisation Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 32/50] lasi: update lasi_initfn() to return LASIState Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 33/50] lasi: move LAN initialisation to machine.c Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 34/50] lasi: move parallel port " Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 35/50] lasi: move second serial " Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 36/50] lasi: move PS2 " Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 37/50] lasi: remove address space parameter from lasi_initfn() Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 38/50] lasi: move lasi_initfn() to machine.c Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 39/50] lasi: use constants for device register offsets Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 40/50] lasi: use numerical constant for iar reset value Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 41/50] hppa: move device headers from hppa_sys.h into individual .c files Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 42/50] lasi: move from hw/hppa to hw/misc Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 43/50] hppa: move hppa_pci_ignore_ops from pci.c to machine.c Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 44/50] hppa: remove hw/hppa/pci.c Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 45/50] hppa: remove unused trace-events from from hw/hppa Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 46/50] hppa: move enable_lan() define from hppa_sys.h to machine.c Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 47/50] hppa: remove the empty hppa_sys.h file Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 48/50] hppa: use MACHINE QOM macros for defining the hppa machine Mark Cave-Ayland
2022-04-21 19:30 ` [PATCH 49/50] hppa: fold machine_hppa_machine_init() into machine_hppa_machine_init_class_init() Mark Cave-Ayland
2022-04-21 19:31 ` [PATCH 50/50] hppa: simplify machine function names in machine.c Mark Cave-Ayland
2022-04-28 16:58 ` [PATCH 00/50] hppa: general improvements and tidy-ups Helge Deller
2022-05-03 12:11   ` Mark Cave-Ayland
2022-05-03 15:38     ` Richard Henderson
2022-05-04 12:12       ` Mark Cave-Ayland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.