Skip to contentSkip to conversation

HPPA Patches for qemu-v11

PATCH In review Helge Deller 3 participants 22 messages Mar 30 – Mar 31

lore
Share & tools
lore
#0 lore raw

cover HPPA Patches for qemu-v11

From: Helge Deller <[email protected]>

A few late fixes for the HPPA architecture:
- graphics support was broken for 64-bit machines. This series adds support for VGA graphics for Linux guests
- the various memory ranges were not correctly implemented
- TOC/NMI was not working on 64-bit machines
- minor 64-bit HP-UX boot fixes (but it still crashes)
- minor fixes regarding weblinks and various Astro registers

Please review and consider to pull for qemu-v11.

Thanks!
Helge

Helge Deller (11):
hw/pci-host/astro: Update copyright and documentation link hw/hppa: Disable Artist graphics card on 64-bit machines hw/pci-host/astro: Make astro address arrays accessible for other
users
hw/pci-host/astro: Fix initial addresses in IOC hw/pci-host/astro: Implement LMMIO registers hw/pci-host/astro: Fix LMMIO DIRECT mappings hw/pci-host/astro: Add GMMIO mapping hw/pci-host/astro: Add comment about Astro version numbers target/hppa: Fix TOC handler for 64-bit CPUs
hw/hppa: Implement memory ranges
target/hppa: Update SeaBIOS-hppa to version 24

 hw/hppa/hppa_hardware.h     |   3 +-
 hw/hppa/machine.c           |  61 +++++++---
 hw/pci-host/astro.c         | 215 ++++++++++++++++++++++++++++++------
 include/hw/pci-host/astro.h |  12 +-
 pc-bios/hppa-firmware.img   | Bin 631968 -> 632416 bytes
 pc-bios/hppa-firmware64.img | Bin 714440 -> 664768 bytes
 roms/seabios-hppa           |   2 +-
 target/hppa/int_helper.c    |   3 +-
 8 files changed, 239 insertions(+), 57 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/11 hw/pci-host/astro: Update copyright and documentation link

From: Helge Deller <[email protected]>

Update the link to the documentation, which was still pointing to the Wiki page. In the meantime the PA-RISC wiki was converted to a read-the-docs website.

---
 hw/pci-host/astro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/astro.c +2 -2
index 6cc0b35070..59d8007a1a 100644
@@ -3,12 +3,12 @@
  * with Elroy PCI bus (LBA) adapter emulation
  * Found in C3000 and similar machines
  *
- * (C) 2023 by Helge Deller <[email protected]>
+ * (C) 2023-2026 by Helge Deller <[email protected]>
  *
  * This work is licensed under the GNU GPL license version 2 or later.
  *
  * Chip documentation is available at:
- * https://parisc.wiki.kernel.org/index.php/Technical_Documentation
+ * https://parisc.docs.kernel.org/en/latest/technical_documentation.html
  *
  * TODO:
  * - All user-added devices are currently attached to the first
Signature · 1 line
2.53.0
Reviewed-by Tested-by on v1 1/11
#2 lore raw

Re: [PATCH 01/11] hw/pci-host/astro: Update copyright and documentation link

Quoted 10 lines · Helge Deller

From: Helge Deller <[email protected]>

Update the link to the documentation, which was still pointing to the Wiki page. In the meantime the PA-RISC wiki was converted to a read-the-docs website.

---
  hw/pci-host/astro.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
#3 lore raw

PATCH 2/11 hw/hppa: Disable Artist graphics card on 64-bit machines

In reply to Helge Deller

From: Helge Deller <[email protected]>

The original Artist graphics used the GSC bus, was often installed in old 32-bit machines (e.g. 715) and can not be used on 64-bit machines. This is why this patch makes the artist driver dependend on the Lasi chip, which was never used in a 64-bit machine.

Note that there exists a variant of Artist for the PCI-bus (Visualize-EG PCI). It has quite some differences in the registers, and would require that we write a PCI ROM for it, so that Linux and HP-UX would be able to use it.

Instead, for now, users can simply use a standard VGA or ATI PCI graphics card on Linux. This can be enabled on the command line with "-device ati-vga" or "-device VGA". If the "-nographic" option is omitted, a PCI OCHI controller with USB keyboard and USB mouse will be added automatically.

This fixes graphics support on 64-bit hppa machines and allows us to boot up a 64-bit Linux installation with VGA graphics.

---
 hw/hppa/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/hppa/machine.c +2 -1
index 3663bac53b..58e76bee2e 100644
@@ -384,7 +384,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
     SysBusDevice *s;
 
     /* Graphics setup. */
-    if (machine->enable_graphics && vga_interface_type != VGA_NONE) {
+    if (lasi_dev && machine->enable_graphics &&
+        vga_interface_type != VGA_NONE) {
         dev = qdev_new("artist");
         s = SYS_BUS_DEVICE(dev);
         bool disabled = object_property_get_bool(OBJECT(dev), "disable", NULL);
Signature · 1 line
2.53.0
Reviewed-by on v1 2/11
#4 lore raw

Re: [PATCH 02/11] hw/hppa: Disable Artist graphics card on 64-bit machines

Quoted 29 lines · Helge Deller

From: Helge Deller <[email protected]>

The original Artist graphics used the GSC bus, was often installed in old 32-bit machines (e.g. 715) and can not be used on 64-bit machines. This is why this patch makes the artist driver dependend on the Lasi chip, which was never used in a 64-bit machine.

Note that there exists a variant of Artist for the PCI-bus (Visualize-EG PCI). It has quite some differences in the registers, and would require that we write a PCI ROM for it, so that Linux and HP-UX would be able to use it.

Instead, for now, users can simply use a standard VGA or ATI PCI graphics card on Linux. This can be enabled on the command line with "-device ati-vga" or "-device VGA". If the "-nographic" option is omitted, a PCI OCHI controller with USB keyboard and USB mouse will be added automatically.

This fixes graphics support on 64-bit hppa machines and allows us to boot up a 64-bit Linux installation with VGA graphics.

---
  hw/hppa/machine.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
hw/hppa/machine.c +0 -0
index 3663bac53b..58e76bee2e 100644

hw/hppa/machine.c static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus, · line 388

Quoted 6 lines
hw/hppa/machine.c +2 -1
@@ -384,7 +384,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
      SysBusDevice *s;
 
      /* Graphics setup. */
-    if (machine->enable_graphics && vga_interface_type != VGA_NONE) {
+    if (lasi_dev && machine->enable_graphics &&
+        vga_interface_type != VGA_NONE) {

Pre-existing, 'lasi_dev' being a static variable isn't really helpful.

Back to this patch:

Although a distinct descriptive boolean variable could be used instead for clarity, rather than testing LASI presence.

#5 lore raw

Re: [PATCH 02/11] hw/hppa: Disable Artist graphics card on 64-bit machines

Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Helge Deller

From: Helge Deller <[email protected]>

The original Artist graphics used the GSC bus, was often installed in old 32-bit machines (e.g. 715) and can not be used on 64-bit machines. This is why this patch makes the artist driver dependend on the Lasi chip, which was never used in a 64-bit machine.

Note that there exists a variant of Artist for the PCI-bus (Visualize-EG PCI). It has quite some differences in the registers, and would require that we write a PCI ROM for it, so that Linux and HP-UX would be able to use it.

Instead, for now, users can simply use a standard VGA or ATI PCI graphics card on Linux.  This can be enabled on the command line with "-device ati-vga" or "-device VGA".  If the "-nographic" option is omitted, a PCI OCHI controller with USB keyboard and USB mouse will be added automatically.

This fixes graphics support on 64-bit hppa machines and allows us to boot up a 64-bit Linux installation with VGA graphics.

---
  hw/hppa/machine.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/hppa/machine.c static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus, · line 387

Quoted 10 lines
hw/hppa/machine.c +2 -1
index 3663bac53b..58e76bee2e 100644
@@ -384,7 +384,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
       SysBusDevice *s;
       /* Graphics setup. */
-    if (machine->enable_graphics && vga_interface_type != VGA_NONE) {
+    if (lasi_dev && machine->enable_graphics &&
+        vga_interface_type != VGA_NONE) {

Pre-existing, 'lasi_dev' being a static variable isn't really helpful.

Yes, can be done post-v11.
Where would it belong? Into MachineState?

Quoted 2 lines

Back to this patch:

Thanks!

Quoted 2 lines

Although a distinct descriptive boolean variable could be used instead for clarity, rather than testing LASI presence.

Helge

#6 lore raw

Re: [PATCH 02/11] hw/hppa: Disable Artist graphics card on 64-bit machines

Quoted 40 lines · Helge Deller
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Helge Deller

From: Helge Deller <[email protected]>

The original Artist graphics used the GSC bus, was often installed in old 32-bit machines (e.g. 715) and can not be used on 64-bit machines. This is why this patch makes the artist driver dependend on the Lasi chip, which was never used in a 64-bit machine.

Note that there exists a variant of Artist for the PCI-bus (Visualize-EG PCI). It has quite some differences in the registers, and would require that we write a PCI ROM for it, so that Linux and HP-UX would be able to use it.

Instead, for now, users can simply use a standard VGA or ATI PCI graphics card on Linux.  This can be enabled on the command line with "-device ati- vga" or "-device VGA".  If the "-nographic" option is omitted, a PCI OCHI controller with USB keyboard and USB mouse will be added automatically.

This fixes graphics support on 64-bit hppa machines and allows us to boot up a 64-bit Linux installation with VGA graphics.

---
  hw/hppa/machine.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 13 lines

hw/hppa/machine.c static void · line 388

Quoted 11 lines
hw/hppa/machine.c +2 -1
index 3663bac53b..58e76bee2e 100644
@@ -384,7 +384,8 @@ static void 
 machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
       SysBusDevice *s;
       /* Graphics setup. */
-    if (machine->enable_graphics && vga_interface_type != VGA_NONE) {
+    if (lasi_dev && machine->enable_graphics &&
+        vga_interface_type != VGA_NONE) {

Pre-existing, 'lasi_dev' being a static variable isn't really helpful.

Quoted 2 lines

Yes, can be done post-v11.
Where would it belong? Into MachineState?

HppaMachineState that would encapsulate MachineState. (hint: git grep ' MachineState parent_obj')

Quoted 10 lines
Quoted 3 lines

Back to this patch:

Thanks!

Quoted 2 lines

Although a distinct descriptive boolean variable could be used instead for clarity, rather than testing LASI presence.

Helge

#7 lore raw

PATCH 3/11 hw/pci-host/astro: Make astro address arrays accessible for other users

In reply to Helge Deller

From: Helge Deller <[email protected]>

Move the tables out of astro_realize(). This is needed because follow-up patches will need those tables.

---
 hw/pci-host/astro.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/pci-host/astro.c +5 -4
index 59d8007a1a..6a09dc15e7 100644
@@ -37,6 +37,11 @@
 #include "qom/object.h"
 #include "exec/target_page.h"
 
+static const int elroy_hpa_offsets[ELROY_NUM] = {
+            0x30000, 0x32000, 0x38000, 0x3c000 };
+static const char elroy_rope_nr[ELROY_NUM] = {
+            0, 1, 4, 6 }; /* busnum path, e.g. [10:6] */
+
 /*
  * Helper functions
  */
@@ -843,10 +848,6 @@ static void astro_realize(DeviceState *obj, Error **errp)
 
     /* Create Elroys (PCI host bus chips).  */
     for (i = 0; i < ELROY_NUM; i++) {
-        static const int elroy_hpa_offsets[ELROY_NUM] = {
-                    0x30000, 0x32000, 0x38000, 0x3c000 };
-        static const char elroy_rope_nr[ELROY_NUM] = {
-                    0, 1, 4, 6 }; /* busnum path, e.g. [10:6] */
         int addr_offset;
         ElroyState *elroy;
         hwaddr map_addr;
Signature · 1 line
2.53.0
#8 lore raw

PATCH 4/11 hw/pci-host/astro: Fix initial addresses in IOC

In reply to Helge Deller

From: Helge Deller <[email protected]>

F-Extend the LMMIO and IOS distributed addresses. Use the 44-bit address for the IOS distributed address.

---
 hw/pci-host/astro.c         | 6 +++---
 include/hw/pci-host/astro.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
hw/pci-host/astro.c +3 -3
index 6a09dc15e7..87bc98f553 100644
@@ -804,13 +804,13 @@ static void astro_reset(DeviceState *dev)
      * The LBA BASE/MASK registers control IO -> System routing (in Elroy)
      */
     memset(&s->ioc_ranges, 0, sizeof(s->ioc_ranges));
-    s->ioc_ranges[(0x360 - 0x300) / 8] = LMMIO_DIST_BASE_ADDR | 0x01; /* LMMIO_DIST_BASE (SBA) */
+    s->ioc_ranges[(0x360 - 0x300) / 8] = F_EXTEND(LMMIO_DIST_BASE_ADDR) | 0x01;
     s->ioc_ranges[(0x368 - 0x300) / 8] = 0xfc000000;          /* LMMIO_DIST_MASK */
     s->ioc_ranges[(0x370 - 0x300) / 8] = 0;                   /* LMMIO_DIST_ROUTE */
-    s->ioc_ranges[(0x390 - 0x300) / 8] = IOS_DIST_BASE_ADDR | 0x01; /* IOS_DIST_BASE */
+    s->ioc_ranges[(0x390 - 0x300) / 8] = F_EXTEND(IOS_DIST_BASE_ADDR) | 0x01;
     s->ioc_ranges[(0x398 - 0x300) / 8] = 0xffffff0000;        /* IOS_DIST_MASK    */
     s->ioc_ranges[(0x3a0 - 0x300) / 8] = 0x3400000000000000ULL; /* IOS_DIST_ROUTE */
-    s->ioc_ranges[(0x3c0 - 0x300) / 8] = 0xfffee00000;        /* IOS_DIRECT_BASE  */
+    s->ioc_ranges[(0x3c0 - 0x300) / 8] = IOS_DIST_BASE_ADDR;  /* IOS_DIRECT_BASE  */
     s->ioc_ranges[(0x3c8 - 0x300) / 8] = 0xffffff0000;        /* IOS_DIRECT_MASK  */
     s->ioc_ranges[(0x3d0 - 0x300) / 8] = 0x0;                 /* IOS_DIRECT_ROUTE */
 
include/hw/pci-host/astro.h +2 -2
index fce052c9f8..5eb1fa57c1 100644
@@ -26,8 +26,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(ElroyState, ELROY_PCI_HOST_BRIDGE)
 
 #define LMMIO_DIRECT_RANGES     4
 
-#define IOS_DIST_BASE_ADDR      0xfffee00000ULL
-#define IOS_DIST_BASE_SIZE           0x10000ULL
+#define IOS_DIST_BASE_ADDR      0xffffee00000ULL
+#define IOS_DIST_BASE_SIZE            0x10000ULL
 
 #define HF_ENABLE       0x40    /* enable HF mode (default is -1 mode) */
 
Signature · 1 line
2.53.0
#9 lore raw

PATCH 5/11 hw/pci-host/astro: Implement LMMIO registers

In reply to Helge Deller

From: Helge Deller <[email protected]>

Add code to adjust the memory mapping windows according to the LMMIO registers in Astro. This allows SeaBIOS-hppa to configure Astro depending on existing PCI cards, and especially makes it possible to enable a VGA PCI card.

---
 hw/pci-host/astro.c         | 84 +++++++++++++++++++++++++++++++++----
 include/hw/pci-host/astro.h |  8 +++-
 2 files changed, 81 insertions(+), 11 deletions(-)
hw/pci-host/astro.c +75 -9
index 87bc98f553..4af35ea92f 100644
@@ -530,6 +530,78 @@ static ElroyState *elroy_init(int num)
  * Astro Runway chip.
  */
 
+static void adjust_LMMIO_mapping(AstroState *s)
+{
+    MemoryRegion *lmmio;
+    uint64_t map_addr, map_size, align_mask;
+    uint32_t map_route, map_enabled, i;
+
+    lmmio = &s->lmmio;
+
+    /* read LMMIO distributed route and calculate size */
+    map_route = s->ioc_ranges[(0x370 - 0x300) / 8] >> 58;
+    map_route = MIN(MAX(map_route, 20), 23);
+
+    /* calculate size of each mapping, sum of all is 8-64 MB */
+    map_size  = 1ULL << map_route;
+    align_mask = ~(map_size - 1);
+
+    /* read LMMIO_DIST_BASE for mapping address */
+    map_addr  = s->ioc_ranges[(0x360 - 0x300) / 8];
+    map_enabled = map_addr & 1;
+    map_addr  &= MAKE_64BIT_MASK(24, 5);
+    map_addr  |= MAKE_64BIT_MASK(29, 36);
+    map_addr  &= align_mask;
+    s->ioc_ranges[(0x360 - 0x300) / 8] = map_addr | map_enabled;
+
+    /* make sure the lmmio region is initially turned off */
+    if (lmmio->enabled) {
+        memory_region_set_enabled(lmmio, false);
+    }
+
+    /* exit if range is not enabled */
+    if (!map_enabled) {
+        return;
+    }
+
+    if (!lmmio->name) {
+        memory_region_init_io(lmmio, OBJECT(s), &unassigned_io_ops, s,
+                    "LMMIO", ROPES_PER_IOC * map_size);
+        memory_region_add_subregion_overlap(get_system_memory(),
+                    map_addr, lmmio, 1);
+    }
+
+    memory_region_set_address(lmmio, map_addr);
+    memory_region_set_size(lmmio, ROPES_PER_IOC * map_size);
+    memory_region_set_enabled(lmmio, true);
+
+    for (i = 0; i < ELROY_NUM; i++) {
+        MemoryRegion *alias;
+        ElroyState *elroy;
+        int rope;
+
+        elroy = s->elroy[i];
+        alias = &elroy->lmmio_alias;
+        rope = elroy_rope_nr[i];
+        if (alias->enabled) {
+            memory_region_set_enabled(alias, false);
+        }
+
+        if (!alias->name) {
+            memory_region_init_alias(alias, OBJECT(elroy),
+                 "lmmio-alias", &elroy->pci_mmio, 0, map_size);
+            memory_region_add_subregion_overlap(lmmio, rope * map_size,
+                 alias, 2);
+        }
+
+        memory_region_set_address(alias, rope * map_size);
+        memory_region_set_alias_offset(alias,
+                (uint32_t) (map_addr + rope * map_size));
+        memory_region_set_size(alias, map_size);
+        memory_region_set_enabled(alias, true);
+    }
+}
+
 static void adjust_LMMIO_DIRECT_mapping(AstroState *s, unsigned int reg_index)
 {
     MemoryRegion *lmmio_alias;
@@ -689,6 +761,9 @@ static MemTxResult astro_chip_write_with_attrs(void *opaque, hwaddr addr,
         if (index < LMMIO_DIRECT_RANGES * 3) {
             adjust_LMMIO_DIRECT_mapping(s, index);
         }
+        if (addr >= 0x360 && addr <= 0x370 + 7) {
+            adjust_LMMIO_mapping(s);
+        }
         break;
     case 0x10200:
     case 0x10220:
@@ -892,15 +967,6 @@ static void astro_realize(DeviceState *obj, Error **errp)
         elroy->mmio_base[(0x0240 - 0x200) / 8] = rope * map_size | 0x01;
         elroy->mmio_base[(0x0248 - 0x200) / 8] = 0x0000e000;
 
-        /* map elroys mmio */
-        map_size = LMMIO_DIST_BASE_SIZE / ROPES_PER_IOC;
-        map_addr = F_EXTEND(LMMIO_DIST_BASE_ADDR + rope * map_size);
-        memory_region_init_alias(&elroy->pci_mmio_alias, OBJECT(elroy),
-                                 "pci-mmio-alias",
-                                 &elroy->pci_mmio, (uint32_t) map_addr, map_size);
-        memory_region_add_subregion(get_system_memory(), map_addr,
-                                 &elroy->pci_mmio_alias);
-
         /* map elroys io */
         map_size = IOS_DIST_BASE_SIZE / ROPES_PER_IOC;
         map_addr = F_EXTEND(IOS_DIST_BASE_ADDR + rope * map_size);
include/hw/pci-host/astro.h +6 -2
index 5eb1fa57c1..0cd384bceb 100644
@@ -61,9 +61,10 @@ struct ElroyState {
     MemoryRegion this_mem;
 
     MemoryRegion pci_mmio;
-    MemoryRegion pci_mmio_alias;
-    MemoryRegion pci_hole;
     MemoryRegion pci_io;
+
+    MemoryRegion gmmio_alias;
+    MemoryRegion lmmio_alias;
 };
 
 struct AstroState {
@@ -89,6 +90,9 @@ struct AstroState {
     MemoryRegion this_mem;
     MemoryRegion lmmio_direct[LMMIO_DIRECT_RANGES];
 
+    MemoryRegion lmmio;
+    MemoryRegion gmmio;
+
     IOMMUMemoryRegion iommu;
     AddressSpace iommu_as;
 };
Signature · 1 line
2.53.0
#10 lore raw

PATCH 6/11 hw/pci-host/astro: Fix LMMIO DIRECT mappings

In reply to Helge Deller

From: Helge Deller <[email protected]>

Fix the existing code which has the mask wrong.
Implement the direct mapping via overlapping subregion with priority 3 to make sure the direct mapping gets precedence over the LMMIO region.

---
 hw/pci-host/astro.c | 39 +++++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 14 deletions(-)
hw/pci-host/astro.c +25 -14
index 4af35ea92f..e1d73258c4 100644
@@ -607,9 +607,13 @@ static void adjust_LMMIO_DIRECT_mapping(AstroState *s, unsigned int reg_index)
     MemoryRegion *lmmio_alias;
     unsigned int lmmio_index, map_route;
     hwaddr map_addr;
-    uint32_t map_size;
+    uint32_t map_size, map_enabled;
     struct ElroyState *elroy;
 
+    /* each LMMIO may access from 1 MB up to 64 MB */
+    const unsigned int lmmio_mask = ~(1 * MiB - 1);
+    const unsigned int lmmio_max_size = 64 * MiB;
+
     /* pointer to LMMIO_DIRECT entry */
     lmmio_index = reg_index / 3;
     lmmio_alias = &s->lmmio_direct[lmmio_index];
@@ -622,31 +626,38 @@ static void adjust_LMMIO_DIRECT_mapping(AstroState *s, unsigned int reg_index)
     map_route &= (ELROY_NUM - 1);
     elroy = s->elroy[map_route];
 
+    /* make sure the lmmio region is initially turned off */
     if (lmmio_alias->enabled) {
         memory_region_set_enabled(lmmio_alias, false);
     }
 
+    /* do sanity checks and calculate mmio size */
+    map_enabled = map_addr & 1;
+    map_addr &= lmmio_mask;
+    map_size &= lmmio_mask;
+    map_size = MIN(map_size, lmmio_max_size);
     map_addr = F_EXTEND(map_addr);
-    map_addr &= TARGET_PAGE_MASK;
-    map_size = (~map_size) + 1;
-    map_size &= TARGET_PAGE_MASK;
 
-    /* exit if disabled or zero map size */
-    if (!(map_addr & 1) || !map_size) {
+    /* exit if disabled or has zero size. */
+    if (!map_enabled || !map_size) {
         return;
     }
 
-    if (!memory_region_size(lmmio_alias)) {
+    if (!lmmio_alias->name) {
+        char lmmio_name[32];
+        snprintf(lmmio_name, sizeof(lmmio_name),
+                 "LMMIO-DIRECT-%u", lmmio_index);
         memory_region_init_alias(lmmio_alias, OBJECT(elroy),
-                        "pci-lmmmio-alias", &elroy->pci_mmio,
+                        lmmio_name, &elroy->pci_mmio,
                         (uint32_t) map_addr, map_size);
-        memory_region_add_subregion(get_system_memory(), map_addr,
-                                 lmmio_alias);
-    } else {
-        memory_region_set_alias_offset(lmmio_alias, map_addr);
-        memory_region_set_size(lmmio_alias, map_size);
-        memory_region_set_enabled(lmmio_alias, true);
+        memory_region_add_subregion_overlap(get_system_memory(),
+                        map_addr, lmmio_alias, 3);
     }
+
+    memory_region_set_address(lmmio_alias, map_addr);
+    memory_region_set_alias_offset(lmmio_alias, (uint32_t) map_addr);
+    memory_region_set_size(lmmio_alias, map_size);
+    memory_region_set_enabled(lmmio_alias, true);
 }
 
 static MemTxResult astro_chip_read_with_attrs(void *opaque, hwaddr addr,
Signature · 1 line
2.53.0
#11 lore raw

PATCH 7/11 hw/pci-host/astro: Add GMMIO mapping

In reply to Helge Deller

From: Helge Deller <[email protected]>

Implement the GMMIO mapping.

---
 hw/pci-host/astro.c | 71 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)
hw/pci-host/astro.c +70 -1
index e1d73258c4..8c61c696bd 100644
@@ -14,7 +14,6 @@
  * - All user-added devices are currently attached to the first
  *   Elroy (PCI bus) only for now. To fix this additional work in
  *   SeaBIOS and this driver is needed. See "user_creatable" flag below.
- * - GMMIO (Greater than 4 GB MMIO) register
  */
 
 #define TYPE_ASTRO_IOMMU_MEMORY_REGION "astro-iommu-memory-region"
@@ -660,6 +659,73 @@ static void adjust_LMMIO_DIRECT_mapping(AstroState *s, unsigned int reg_index)
     memory_region_set_enabled(lmmio_alias, true);
 }
 
+static void adjust_GMMIO_mapping(AstroState *s)
+{
+    MemoryRegion *gmmio;
+    uint64_t map_addr, map_size, align_mask;
+    uint32_t map_route, map_enabled, i;
+
+    gmmio = &s->gmmio;
+    map_addr  = s->ioc_ranges[(0x378 - 0x300) / 8];       /* GMMIO_DIST_BASE */
+    map_enabled = map_addr & 1;
+    map_addr  &= MAKE_64BIT_MASK(32, 8);
+    s->ioc_ranges[(0x378 - 0x300) / 8] = map_addr | map_enabled;
+
+    map_route = s->ioc_ranges[(0x388 - 0x300) / 8] >> 58; /* GMMIO_DIST_ROUTE */
+    map_route = MIN(MAX(map_route, 29), 33); /* between 4-16 GB total */
+    map_size  = 1ULL << map_route;      /* size of each mapping */
+    align_mask = ~(map_size - 1);
+
+    /* make sure the lmmio region is initially turned off */
+    if (gmmio->enabled) {
+        memory_region_set_enabled(gmmio, false);
+    }
+
+    /* do sanity checks and calculate mmio size */
+    map_addr &= align_mask;
+
+    /* exit if disabled */
+    if (!map_enabled) {
+        return;
+    }
+
+    if (!gmmio->name) {
+        memory_region_init_io(gmmio, OBJECT(s), &unassigned_io_ops, s,
+                "GMMIO", ROPES_PER_IOC * map_size);
+        memory_region_add_subregion_overlap(get_system_memory(),
+                map_addr, gmmio, 1);
+    }
+
+    memory_region_set_address(gmmio, map_addr);
+    memory_region_set_size(gmmio, ROPES_PER_IOC * map_size);
+    memory_region_set_enabled(gmmio, true);
+
+    for (i = 0; i < ELROY_NUM; i++) {
+        MemoryRegion *alias;
+        ElroyState *elroy;
+        int rope;
+
+        elroy = s->elroy[i];
+        alias = &elroy->gmmio_alias;
+        rope = elroy_rope_nr[i];
+        if (alias->enabled) {
+            memory_region_set_enabled(alias, false);
+        }
+
+        if (!alias->name) {
+            memory_region_init_alias(alias, OBJECT(elroy),
+                 "gmmio-alias", &elroy->pci_mmio, 0, map_size);
+            memory_region_add_subregion_overlap(gmmio, rope * map_size,
+                 alias, 2);
+        }
+
+        memory_region_set_address(alias, rope * map_size);
+        memory_region_set_alias_offset(alias, map_addr + rope * map_size);
+        memory_region_set_size(alias, map_size);
+        memory_region_set_enabled(alias, true);
+    }
+}
+
 static MemTxResult astro_chip_read_with_attrs(void *opaque, hwaddr addr,
                                              uint64_t *data, unsigned size,
                                              MemTxAttrs attrs)
@@ -775,6 +841,9 @@ static MemTxResult astro_chip_write_with_attrs(void *opaque, hwaddr addr,
         if (addr >= 0x360 && addr <= 0x370 + 7) {
             adjust_LMMIO_mapping(s);
         }
+        if (addr >= 0x378 && addr <= 0x388 + 7) {
+            adjust_GMMIO_mapping(s);
+        }
         break;
     case 0x10200:
     case 0x10220:
Signature · 1 line
2.53.0
#12 lore raw

Re: [PATCH 07/11] hw/pci-host/astro: Add GMMIO mapping

Quoted 3 lines · Helge Deller

From: Helge Deller <[email protected]>

Implement the GMMIO mapping.

As this point in the release process, this is a bit out of scope IMHO.

Quoted 4 lines
---
  hw/pci-host/astro.c | 71 ++++++++++++++++++++++++++++++++++++++++++++-
  1 file changed, 70 insertions(+), 1 deletion(-)
#13 lore raw

Re: [PATCH 07/11] hw/pci-host/astro: Add GMMIO mapping

Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Helge Deller

From: Helge Deller <[email protected]>

Implement the GMMIO mapping.

As this point in the release process, this is a bit out of scope IMHO.

Well, no...
SeaBIOS has to initialize GMMIO at the same time and report it along with LMMIO and IOS to the operating system.

Helge

Quoted 6 lines
Quoted 5 lines

---
  hw/pci-host/astro.c | 71 ++++++++++++++++++++++++++++++++++++++++++++-

  1 file changed, 70 insertions(+), 1 deletion(-)
#14 lore raw

Re: [PATCH 07/11] hw/pci-host/astro: Add GMMIO mapping

Quoted 11 lines · Helge Deller
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Helge Deller

From: Helge Deller <[email protected]>

Implement the GMMIO mapping.

As this point in the release process, this is a bit out of scope IMHO.

Well, no...
SeaBIOS has to initialize GMMIO at the same time and report it along with LMMIO and IOS to the operating system.

Then it is an incomplete/broken feature, not something buggy that can be fixed in time. Anyway, not my judgement call, so feel free to ignore me, just I don't feel confidement enough to review and test that implementation for the release.

Quoted 10 lines

Helge

Quoted 6 lines
Quoted 5 lines

---
  hw/pci-host/astro.c | 71 ++++++++++++++++++++++++++++++++++++++++++++-

  1 file changed, 70 insertions(+), 1 deletion(-)
#15 lore raw

PATCH 8/11 hw/pci-host/astro: Add comment about Astro version numbers

In reply to Helge Deller

From: Helge Deller <[email protected]>

---
 hw/pci-host/astro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-host/astro.c +1 -1
index 8c61c696bd..776267e150 100644
@@ -738,7 +738,7 @@ static MemTxResult astro_chip_read_with_attrs(void *opaque, hwaddr addr,
     switch ((addr >> 3) << 3) {
     /* R2I registers */
     case 0x0000:        /* ID */
-        val = (0x01 << 3) | 0x01ULL;
+        val = (0x01 << 3) | 0x01ULL; /* 0=Astro 1.0, 9=Astro 2.1, 2=Astro 3.0 */
         break;
     case 0x0008:        /* IOC_CTRL */
         val = s->ioc_ctrl;
Signature · 1 line
2.53.0
#16 lore raw

Re: [PATCH 08/11] hw/pci-host/astro: Add comment about Astro version numbers

Quoted 12 lines · Helge Deller

From: Helge Deller <[email protected]>

---
  hw/pci-host/astro.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-host/astro.c +0 -0
index 8c61c696bd..776267e150 100644

hw/pci-host/astro.c static MemTxResult astro_chip_read_with_attrs(void *opaque, hwaddr addr, · line 741

Quoted 5 lines
hw/pci-host/astro.c +1 -1
@@ -738,7 +738,7 @@ static MemTxResult astro_chip_read_with_attrs(void *opaque, hwaddr addr,
      switch ((addr >> 3) << 3) {
      /* R2I registers */
      case 0x0000:        /* ID */
-        val = (0x01 << 3) | 0x01ULL;
+        val = (0x01 << 3) | 0x01ULL; /* 0=Astro 1.0, 9=Astro 2.1, 2=Astro 3.0 */

Using enum:

enum { ID_ASTRO_1_0 = 0, ID_ASTRO_2_1 = 9, ID_ASTRO_3_0 = 2 };

            val = ID_ASTRO_2_1;
Quoted 3 lines
hw/pci-host/astro.c +0 -0
          break;
      case 0x0008:        /* IOC_CTRL */
          val = s->ioc_ctrl;
#17 lore raw

Re: [PATCH 08/11] hw/pci-host/astro: Add comment about Astro version numbers

Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Helge Deller

From: Helge Deller <[email protected]>

---
  hw/pci-host/astro.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-host/astro.c +0 -0
index 8c61c696bd..776267e150 100644
@@ -738,7 +738,7 @@ static MemTxResult astro_chip_read_with_attrs(void *opaque, hwaddr addr,
       switch ((addr >> 3) << 3) {
       /* R2I registers */
Quoted 3 lines

      case 0x0000:        /* ID */
-        val = (0x01 << 3) | 0x01ULL;
+        val = (0x01 << 3) | 0x01ULL; /* 0=Astro 1.0, 9=Astro 2.1, 2=Astro 3.0 */

Using enum:

Quoted 3 lines

enum { ID_ASTRO_1_0 = 0, ID_ASTRO_2_1 = 9, ID_ASTRO_3_0 = 2 };

            val = ID_ASTRO_2_1;

Good idea.
I've fixed it up and queued this patch for post qemu-v11.

Thanks!
Helge

Quoted 4 lines
Quoted 3 lines

          break;
      case 0x0008:        /* IOC_CTRL */
          val = s->ioc_ctrl;

#18 lore raw

PATCH 9/11 target/hppa: Fix TOC handler for 64-bit CPUs

In reply to Helge Deller

From: Helge Deller <[email protected]>

When the TOC handler is triggered, e.g. by using the "NMI" command in the QEMU monitor, make sure to call the full 64-bit TOC handler address in SeaBIOS-hppa firmware.
This fixes the TOC handler on 64-bit CPUs (and 64-bit SeaBIOS).

---
 target/hppa/int_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/hppa/int_helper.c +2 -1
index d5a20cd549..fd4b99069e 100644
@@ -203,7 +203,8 @@ void hppa_cpu_do_interrupt(CPUState *cs)
 
     /* step 7 */
     if (i == EXCP_TOC) {
-        env->iaoq_f = hppa_form_gva(env, 0, FIRMWARE_START);
+        env->iaoq_f = hppa_form_gva(env, 0,
+                ((uint64_t) FIRMWARE_HIGH) << 32 | FIRMWARE_START);
         /* help SeaBIOS and provide iaoq_b and iasq_back in shadow regs */
         env->gr[24] = env->cr_back[0];
         env->gr[25] = env->cr_back[1];
Signature · 1 line
2.53.0
#19 lore raw

Re: [PATCH 09/11] target/hppa: Fix TOC handler for 64-bit CPUs

Quoted 17 lines · Helge Deller

From: Helge Deller <[email protected]>

When the TOC handler is triggered, e.g. by using the "NMI" command in the QEMU monitor, make sure to call the full 64-bit TOC handler address in SeaBIOS-hppa firmware.
This fixes the TOC handler on 64-bit CPUs (and 64-bit SeaBIOS).

---
  target/hppa/int_helper.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
target/hppa/int_helper.c +0 -0
index d5a20cd549..fd4b99069e 100644

target/hppa/int_helper.c void hppa_cpu_do_interrupt(CPUState *cs) · line 207

Quoted 6 lines
target/hppa/int_helper.c +2 -1
@@ -203,7 +203,8 @@ void hppa_cpu_do_interrupt(CPUState *cs)
 
      /* step 7 */
      if (i == EXCP_TOC) {
-        env->iaoq_f = hppa_form_gva(env, 0, FIRMWARE_START);
+        env->iaoq_f = hppa_form_gva(env, 0,
+                ((uint64_t) FIRMWARE_HIGH) << 32 | FIRMWARE_START);

Maybe we can define that directly and use? Such PDC_FIRMWARE_START?

Or have some hppa_pdc_addr() helper?

Quoted 3 lines
target/hppa/int_helper.c +0 -0
          /* help SeaBIOS and provide iaoq_b and iasq_back in shadow regs */
          env->gr[24] = env->cr_back[0];
          env->gr[25] = env->cr_back[1];
#20 lore raw

PATCH 10/11 hw/hppa: Implement memory ranges

In reply to Helge Deller

From: Helge Deller <[email protected]>

All 64-bit PA-RISC machines split the memory into (up to 3) different memory ranges, which are mapped at specific addresses. This patch mimics the mapping as it's done on physical machines, which includes the 3.75 GB split for C3700, and 1 GB split for newer 64-bit PAT machines like the A400.

SeaBIOS-hppa needs to know how the memory split is done, so add a new memsplit_addr variable which stores the specific split address and hand this over to SeaBIOS-hppa via fwcfg.

---
 hw/hppa/hppa_hardware.h |  3 ++-
 hw/hppa/machine.c       | 58 ++++++++++++++++++++++++++++++-----------
 2 files changed, 45 insertions(+), 16 deletions(-)
hw/hppa/hppa_hardware.h +2 -1
index 006aae63b9..e2b2faa4a3 100644
@@ -8,7 +8,8 @@
 #define FIRMWARE_END    0xf0100000
 #define FIRMWARE_HIGH   0xfffffff0  /* upper 32-bits of 64-bit firmware address */
 
-#define RAM_MAP_HIGH  0x0100000000  /* memory above 3.75 GB is mapped here */
+#define RAM_MAP_HIGH1 0x0100000000  /* memory above 4 GB */
+#define RAM_MAP_HIGH2 0x4040000000  /* memory between 1 G and 3.75 GB */
 
 #define MEM_PDC_ENTRY       0x4800  /* PDC entry address */
 
hw/hppa/machine.c +43 -15

101 lines not on this page · raw message

Signature · 1 line
2.53.0
#21 lore raw
In reply to Helge Deller
Quoted 3 lines · Helge Deller

Helge Deller (11):
hw/pci-host/astro: Update copyright and documentation link hw/hppa: Disable Artist graphics card on 64-bit machines

Queuing the first 2 patches via hw-misc tree, thanks.