Skip to contentSkip to conversation

hppa power button support, graphics updates and firmware fixes

PATCH Superseded Helge Deller 3 participants 27 messages Sep 1, 2020 – Sep 3, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover hppa power button support, graphics updates and firmware fixes

Add emulation for a power button on hppa,
fix quite some bugs in seabios-hppa firmware for artist graphics card fix boot with old Linux installation CDs.

Helge Deller (7):
seabios-hppa: Update SeaBIOS to hppa-qemu-5.2-2 tag hw/hppa: Make number of TLB and BTLB entries configurable hw/hppa: Store boot device in fw_cfg section hw/hppa: Inform SeaBIOS about fw_cfg port address hw/hppa: Add power button emulation hw/display/artist: Fix artist screen resolution target/hppa: Fix boot with old Linux installation CDs

 hw/display/artist.c       |  37 +++++++++++++++----------
 hw/hppa/hppa_hardware.h   |   3 +-
 hw/hppa/machine.c         |  56 +++++++++++++++++++++++++++++++++++++-
 pc-bios/hppa-firmware.img | Bin 783192 -> 785696 bytes
 roms/seabios-hppa         |   2 +-
 target/hppa/cpu.h         |   5 +++-
 target/hppa/insns.decode  |  10 +++----
 7 files changed, 89 insertions(+), 24 deletions(-)

--
2.21.3

#1 lore raw

PATCH 1/7 seabios-hppa: Update SeaBIOS to hppa-qemu-5.2-2 tag

Changes:
* If only one bootable device is available, boot from it.
* Silence PDC warnings with HP-UX 11.11
* Inform Linux about fw_cfg port addresses
* Make power switch button configurable from qemu
* Clear screen on machine reset
* Add fw_cfg option to enable runtime debug info
* Fix panic on OpenBSD/6.7 regarding STI console
* Set text planes and used_bits in STI fields
* Fix mon_tbl entries
* Convert sti_region_list to an initialized struct

---
 pc-bios/hppa-firmware.img | Bin 783192 -> 785696 bytes
 roms/seabios-hppa         |   2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
pc-bios/hppa-firmware.img binary +0 -0
index f0f8d0e164898cd3a19406ce24d1bbfc036a4667..4ba8c7f8b8d4187271e958f5b1f6d7f2a099e0d8 100644
GIT binary patch
roms/seabios-hppa +1 -1
index 4ff7639e2b..73b740f771 160000
@@ -1 +1 @@
-Subproject commit 4ff7639e2b86d5775fa7d5cd0dbfa4d3a385a701
+Subproject commit 73b740f77190643b2ada5ee97a9a108c6ef2a37b

--
2.21.3

#2 lore raw

PATCH 2/7 hw/hppa: Make number of TLB and BTLB entries configurable

In reply to Helge Deller

Until now the TLB size was fixed at 256 entries. To allow operating systems to utilize more TLB entries in the future, we need to tell firmware how many TLB entries we actually support in the emulation. Firmware then reports this to the operating system via the PDC_CACHE_INFO call.

This patch simply does the preparation to allow more TLB entries.

---
 hw/hppa/machine.c | 8 ++++++++
 target/hppa/cpu.h | 5 ++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
hw/hppa/machine.c +8 -0
index 90aeefe2a4..e9d84d0f03 100644
@@ -72,6 +72,14 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     fw_cfg_add_file(fw_cfg, "/etc/firmware-min-version",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
+    val = cpu_to_le64(HPPA_TLB_ENTRIES);
+    fw_cfg_add_file(fw_cfg, "/etc/cpu/tlb_entries",
+                    g_memdup(&val, sizeof(val)), sizeof(val));
+
+    val = cpu_to_le64(HPPA_BTLB_ENTRIES);
+    fw_cfg_add_file(fw_cfg, "/etc/cpu/btlb_entries",
+                    g_memdup(&val, sizeof(val)), sizeof(val));
+
     return fw_cfg;
 }
 
target/hppa/cpu.h +4 -1
index 801a4fb1ba..440104dc3c 100644
@@ -196,9 +196,12 @@ struct CPUHPPAState {
     target_ureg shadow[7];   /* shadow registers */
 
     /* ??? The number of entries isn't specified by the architecture.  */
+    #define HPPA_TLB_ENTRIES        256
+    #define HPPA_BTLB_ENTRIES       0
+
     /* ??? Implement a unified itlb/dtlb for the moment.  */
     /* ??? We should use a more intelligent data structure.  */
-    hppa_tlb_entry tlb[256];
+    hppa_tlb_entry tlb[HPPA_TLB_ENTRIES];
     uint32_t tlb_last;
 };
 

--
2.21.3

#3 lore raw

Re: [PATCH 2/7] hw/hppa: Make number of TLB and BTLB entries configurable

hw/hppa/machine.c static FWCfgState *create_fw_cfg(MachineState *ms) · line 75

Quoted 9 lines · Helge Deller
hw/hppa/machine.c +1 -0
index 90aeefe2a4..e9d84d0f03 100644
@@ -72,6 +72,14 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     fw_cfg_add_file(fw_cfg, "/etc/firmware-min-version",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
+    val = cpu_to_le64(HPPA_TLB_ENTRIES);

I guess you don't have a cpu structure here against which you could apply ARRAY_SIZE?

hw/hppa/machine.c static FWCfgState *create_fw_cfg(MachineState *ms) · line 78

Quoted 3 lines
hw/hppa/machine.c +2 -0
     /* ??? The number of entries isn't specified by the architecture.  */
+    #define HPPA_TLB_ENTRIES        256
+    #define HPPA_BTLB_ENTRIES       0

What's a btlb entry?
The indented defines are weird.

r~

#4 lore raw

Re: [PATCH 2/7] hw/hppa: Make number of TLB and BTLB entries configurable

Quoted 9 lines · Richard Henderson
Quoted 8 lines · Helge Deller
hw/hppa/machine.c +0 -0
index 90aeefe2a4..e9d84d0f03 100644
@@ -72,6 +72,14 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     fw_cfg_add_file(fw_cfg, "/etc/firmware-min-version",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
Quoted 4 lines

hw/hppa/machine.c static FWCfgState *create_fw_cfg(MachineState *ms) · line 75

Quoted 1 line
hw/hppa/machine.c +1 -0
+    val = cpu_to_le64(HPPA_TLB_ENTRIES);

I guess you don't have a cpu structure here against which you could apply ARRAY_SIZE?

You mean to calculate the number of TLB entries based on the static size of an array, e.g. ARRAY_SIZE(struct CPUHPPAState.tlb[256]) ? I've replaced it intentionally by a constant, because in a follow-up patch to improve the TLB-lookup speed, the array gets replaced by a GTree. You can see a working version of the patch here:
https://github.com/hdeller/qemu-hppa/commit/644790132b91cdb835c8dd38198e6f6ed0b533a1

In this patch:

-   hppa_tlb_entry tlb[HPPA_TLB_ENTRIES];
+   GTree *tlb;
+   GList *tlb_list;
+   int tlb_entries;
Quoted 5 lines

hw/hppa/machine.c static FWCfgState *create_fw_cfg(MachineState *ms) · line 78

Quoted 3 lines
hw/hppa/machine.c +2 -0
     /* ??? The number of entries isn't specified by the architecture.  */
+    #define HPPA_TLB_ENTRIES        256
+    #define HPPA_BTLB_ENTRIES       0

The indented defines are weird.

How/Why?

Quoted 1 line

What's a btlb entry?

Block-TLB entries. Most PA1.1-machines have 16 such BTLBs which can address a range of 4k pages with a single entry.
In a follow-up qemu patch it makes sense to add those TLBs.

Helge

#5 lore raw

Re: [PATCH 2/7] hw/hppa: Make number of TLB and BTLB entries configurable

Quoted 9 lines · Helge Deller
Quoted 4 lines
Quoted 1 line

+ val = cpu_to_le64(HPPA_TLB_ENTRIES);

I guess you don't have a cpu structure here against which you could apply ARRAY_SIZE?

You mean to calculate the number of TLB entries based on the static size of an array, e.g. ARRAY_SIZE(struct CPUHPPAState.tlb[256]) ? I've replaced it intentionally by a constant, because in a follow-up patch to improve the TLB-lookup speed, the array gets replaced by a GTree.

Ok.

Quoted 3 lines
Quoted 1 line

The indented defines are weird.

How/Why?

Because usually the # is at column 1.

r~

#6 lore raw

Re: [PATCH 2/7] hw/hppa: Make number of TLB and BTLB entries configurable

Quoted 11 lines · Richard Henderson
Quoted 9 lines · Helge Deller
Quoted 4 lines
Quoted 1 line

+ val = cpu_to_le64(HPPA_TLB_ENTRIES);

I guess you don't have a cpu structure here against which you could apply ARRAY_SIZE?

You mean to calculate the number of TLB entries based on the static size of an array, e.g. ARRAY_SIZE(struct CPUHPPAState.tlb[256]) ? I've replaced it intentionally by a constant, because in a follow-up patch to improve the TLB-lookup speed, the array gets replaced by a GTree.

Quoted 7 lines

Ok.

Quoted 3 lines
Quoted 1 line

The indented defines are weird.

How/Why?

Because usually the # is at column 1.

I fixed that up in the last v3 version I just sent.

Helge

#7 lore raw

PATCH 3/7 hw/hppa: Store boot device in fw_cfg section

In reply to Helge Deller
---
 hw/hppa/machine.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/hppa/machine.c +9 -0
index e9d84d0f03..4b35afc9d5 100644
@@ -58,6 +58,12 @@ static uint64_t cpu_hppa_to_phys(void *opaque, uint64_t addr)
 static HPPACPU *cpu[HPPA_MAX_CPUS];
 static uint64_t firmware_entry;
 
+static void fw_cfg_boot_set(void *opaque, const char *boot_device,
+                            Error **errp)
+{
+    fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
+}
+
 static FWCfgState *create_fw_cfg(MachineState *ms)
 {
     FWCfgState *fw_cfg;
@@ -80,6 +86,9 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     fw_cfg_add_file(fw_cfg, "/etc/cpu/btlb_entries",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
+    fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_order[0]);
+    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
+
     return fw_cfg;
 }
 

--
2.21.3

#9 lore raw

PATCH 4/7 hw/hppa: Inform SeaBIOS about fw_cfg port address

In reply to Helge Deller
---
 hw/hppa/hppa_hardware.h | 3 +--
 hw/hppa/machine.c       | 7 ++++++-
 2 files changed, 7 insertions(+), 3 deletions(-)
hw/hppa/hppa_hardware.h +1 -2
index cdb7fa6240..bc258895c9 100644
@@ -38,8 +38,7 @@
 #define PORT_PCI_CMD    (PCI_HPA + DINO_PCI_ADDR)
 #define PORT_PCI_DATA   (PCI_HPA + DINO_CONFIG_DATA)
 
-/* QEMU fw_cfg interface port */
-#define QEMU_FW_CFG_IO_BASE     (MEMORY_HPA + 0x80)
+#define FW_CFG_IO_BASE  0xfffa0000
 
 #define PORT_SERIAL1    (DINO_UART_HPA + 0x800)
 #define PORT_SERIAL2    (LASI_UART_HPA + 0x800)
hw/hppa/machine.c +6 -1
index 4b35afc9d5..2bed49807b 100644
@@ -69,7 +69,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     FWCfgState *fw_cfg;
     uint64_t val;
 
-    fw_cfg = fw_cfg_init_mem(QEMU_FW_CFG_IO_BASE, QEMU_FW_CFG_IO_BASE + 4);
+    fw_cfg = fw_cfg_init_mem(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4);
     fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, ms->smp.cpus);
     fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, HPPA_MAX_CPUS);
     fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, ram_size);
@@ -290,6 +290,9 @@ static void machine_hppa_init(MachineState *machine)
 
     /* tell firmware how many SMP CPUs to present in inventory table */
     cpu[0]->env.gr[21] = smp_cpus;
+
+    /* tell firmware fw_cfg port */
+    cpu[0]->env.gr[19] = FW_CFG_IO_BASE;
 }
 
 static void hppa_machine_reset(MachineState *ms)
@@ -317,6 +320,8 @@ static void hppa_machine_reset(MachineState *ms)
     cpu[0]->env.gr[24] = 'c';
     /* gr22/gr23 unused, no initrd while reboot. */
     cpu[0]->env.gr[21] = smp_cpus;
+    /* tell firmware fw_cfg port */
+    cpu[0]->env.gr[19] = FW_CFG_IO_BASE;
 }
 
 

--
2.21.3

#10 lore raw

Re: [PATCH 4/7] hw/hppa: Inform SeaBIOS about fw_cfg port address

hw/hppa/hppa_hardware.h line 41

Quoted 3 lines · Helge Deller
hw/hppa/hppa_hardware.h +1 -2
-/* QEMU fw_cfg interface port */
-#define QEMU_FW_CFG_IO_BASE     (MEMORY_HPA + 0x80)
+#define FW_CFG_IO_BASE  0xfffa0000

Why is this value changing?

r~

#11 lore raw

Re: [PATCH 4/7] hw/hppa: Inform SeaBIOS about fw_cfg port address

Quoted 6 lines · Richard Henderson

hw/hppa/hppa_hardware.h line 41

Quoted 3 lines · Helge Deller
hw/hppa/hppa_hardware.h +1 -2
-/* QEMU fw_cfg interface port */
-#define QEMU_FW_CFG_IO_BASE     (MEMORY_HPA + 0x80)
+#define FW_CFG_IO_BASE  0xfffa0000

Why is this value changing?

Devices on hppa occupy at least 4k starting at the HPA, so MEMORY_HPA+4k is blocked (by Linux) for the memory module. I noticed this when testing the new Linux kernel patch to let the fw_cfg entries show up in Linux under /proc:
https://patchwork.kernel.org/patch/11715133/
The Linux kernel driver could not allocate the region for fw_cfg. This new base address seems to not conflict.

Helge

#12 lore raw

Re: [PATCH 4/7] hw/hppa: Inform SeaBIOS about fw_cfg port address

Quoted 8 lines · Helge Deller
Quoted 6 lines · Richard Henderson

hw/hppa/hppa_hardware.h line 41

Quoted 3 lines · Helge Deller
hw/hppa/hppa_hardware.h +1 -2
-/* QEMU fw_cfg interface port */
-#define QEMU_FW_CFG_IO_BASE     (MEMORY_HPA + 0x80)
+#define FW_CFG_IO_BASE  0xfffa0000

Why is this value changing?

Quoted 7 lines

Devices on hppa occupy at least 4k starting at the HPA, so MEMORY_HPA+4k is blocked (by Linux) for the memory module. I noticed this when testing the new Linux kernel patch to let the fw_cfg entries show up in Linux under /proc:
https://patchwork.kernel.org/patch/11715133/
The Linux kernel driver could not allocate the region for fw_cfg. This new base address seems to not conflict.

Then that information should be in a patch description, and the change should be a completely separate patch.

r~

#13 lore raw

Re: [PATCH 4/7] hw/hppa: Inform SeaBIOS about fw_cfg port address

Quoted 17 lines · Richard Henderson
Quoted 8 lines · Helge Deller
Quoted 6 lines · Richard Henderson

hw/hppa/hppa_hardware.h line 41

Quoted 3 lines · Helge Deller
hw/hppa/hppa_hardware.h +1 -2
-/* QEMU fw_cfg interface port */
-#define QEMU_FW_CFG_IO_BASE     (MEMORY_HPA + 0x80)
+#define FW_CFG_IO_BASE  0xfffa0000

Why is this value changing?

Quoted 7 lines

Devices on hppa occupy at least 4k starting at the HPA, so MEMORY_HPA+4k is blocked (by Linux) for the memory module. I noticed this when testing the new Linux kernel patch to let the fw_cfg entries show up in Linux under /proc:
https://patchwork.kernel.org/patch/11715133/
The Linux kernel driver could not allocate the region for fw_cfg. This new base address seems to not conflict.

Quoted 2 lines

Then that information should be in a patch description, and the change should be a completely separate patch.

Ok, I've splitted that patch up and added the description in the last v3 version I just sent.

Helge

#14 lore raw

PATCH 5/7 hw/hppa: Add power button emulation

In reply to Helge Deller

Emulate a power button switch, tell SeaBIOS the address via fw_cfg and bind the power button to the qemu UI.

---
 hw/hppa/machine.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
hw/hppa/machine.c +32 -0
index 2bed49807b..d5164457ee 100644
@@ -12,6 +12,7 @@
 #include "qemu/error-report.h"
 #include "sysemu/reset.h"
 #include "sysemu/sysemu.h"
+#include "sysemu/runstate.h"
 #include "hw/rtc/mc146818rtc.h"
 #include "hw/timer/i8254.h"
 #include "hw/char/serial.h"
@@ -27,6 +28,30 @@
 
 #define MIN_SEABIOS_HPPA_VERSION 1 /* require at least this fw version */
 
+#define HPA_POWER_BUTTON (FIRMWARE_END - 0x10)
+
+static void hppa_powerdown_req(Notifier *n, void *opaque)
+{
+    hwaddr soft_power_reg = HPA_POWER_BUTTON;
+    uint32_t val;
+
+    val = ldl_be_phys(&address_space_memory, soft_power_reg);
+    if ((val >> 8) == 0) {
+        /* immediately shut down when under hardware control */
+        qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
+        return;
+    }
+
+    /* clear bit 31 to indicate that the power switch was pressed. */
+    val &= ~1;
+    stl_be_phys(&address_space_memory, soft_power_reg, val);
+}
+
+static Notifier hppa_system_powerdown_notifier = {
+    .notify = hppa_powerdown_req
+};
+
+
 static ISABus *hppa_isa_bus(void)
 {
     ISABus *isa_bus;
@@ -86,6 +111,10 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     fw_cfg_add_file(fw_cfg, "/etc/cpu/btlb_entries",
                     g_memdup(&val, sizeof(val)), sizeof(val));
 
+    val = cpu_to_le64(HPA_POWER_BUTTON);
+    fw_cfg_add_file(fw_cfg, "/etc/power-button-addr",
+                    g_memdup(&val, sizeof(val)), sizeof(val));
+
     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_order[0]);
     qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
 
@@ -177,6 +206,9 @@ static void machine_hppa_init(MachineState *machine)
         }
     }
 
+    /* register power switch emulation */
+    qemu_register_powerdown_notifier(&hppa_system_powerdown_notifier);
+
     /* Load firmware.  Given that this is not "real" firmware,
        but one explicitly written for the emulation, we might as
        well load it directly from an ELF image.  */

--
2.21.3

#16 lore raw

PATCH 6/7 hw/display/artist: Fix artist screen resolution

In reply to Helge Deller

Artist screen size is limited to 2048 x 2048 pixels and x/y coordination addressing needs to be done by OS via an uint32 value which is based on a 2048 byte line length, independend of the real screen size.

Since HP-UX seems to ideally need at least 640 pixels in width, this patch ensures that the screen size stays between 640x480 and 2048x2048 pixels and fixes some pixel glitches were visible before on STI text consoles due to the 2048 line length limitation.

---
 hw/display/artist.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)
hw/display/artist.c +23 -14
index 71982559c6..98bee6d61c 100644
@@ -192,6 +192,10 @@ static const char *artist_reg_name(uint64_t addr)
 }
 #undef REG_NAME
 
+/* artist has a fixed line length of 2048 bytes. */
+#define ADDR_TO_Y(addr) (((addr) >> 11) & 0x7ff)
+#define ADDR_TO_X(addr) ((addr) & 0x7ff)
+
 static int16_t artist_get_x(uint32_t reg)
 {
     return reg >> 16;
@@ -348,13 +352,13 @@ static void artist_invalidate_cursor(ARTISTState *s)
                             y, s->cursor_height);
 }
 
-static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
+static void vram_bit_write(ARTISTState *s, int posy, bool incr_x,
                            int size, uint32_t data)
 {
     struct vram_buffer *buf;
     uint32_t vram_bitmask = s->vram_bitmask;
     int mask, i, pix_count, pix_length;
-    unsigned int offset, width;
+    unsigned int posx, offset, width;
     uint8_t *data8, *p;
 
     pix_count = vram_write_pix_per_transfer(s);
@@ -366,6 +370,8 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
     if (s->cmap_bm_access) {
         offset = s->vram_pos;
     } else {
+        posx = ADDR_TO_X(s->vram_pos >> 2);
+        posy += ADDR_TO_Y(s->vram_pos >> 2);
         offset = posy * width + posx;
     }
 
@@ -858,7 +864,6 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val,
                              unsigned size)
 {
     ARTISTState *s = opaque;
-    int posx, posy;
     int width, height;
 
     trace_artist_reg_write(size, addr, artist_reg_name(addr & ~3ULL), val);
@@ -881,16 +886,12 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val,
         break;
 
     case VRAM_WRITE_INCR_Y:
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;
-        vram_bit_write(s, posx, posy + s->vram_char_y++, false, size, val);
+        vram_bit_write(s, s->vram_char_y++, false, size, val);
         break;
 
     case VRAM_WRITE_INCR_X:
     case VRAM_WRITE_INCR_X2:
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;
-        vram_bit_write(s, posx, posy + s->vram_char_y, true, size, val);
+        vram_bit_write(s, s->vram_char_y, true, size, val);
         break;
 
     case VRAM_IDX:
@@ -1156,8 +1157,7 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
 {
     ARTISTState *s = opaque;
     struct vram_buffer *buf;
-    int posy = (addr >> 11) & 0x3ff;
-    int posx = addr & 0x7ff;
+    unsigned int posy, posx;
     unsigned int offset;
     trace_artist_vram_write(size, addr, val);
 
@@ -1170,6 +1170,9 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
     }
 
     buf = vram_write_buffer(s);
+    posy = ADDR_TO_Y(addr);
+    posx = ADDR_TO_X(addr);
+
     if (!buf->size) {
         return;
     }
@@ -1212,7 +1215,7 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
     ARTISTState *s = opaque;
     struct vram_buffer *buf;
     uint64_t val;
-    int posy, posx;
+    unsigned int posy, posx;
 
     if (s->cmap_bm_access) {
         buf = &s->vram_buffer[ARTIST_BUFFER_CMAP];
@@ -1229,8 +1232,8 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
         return 0;
     }
 
-    posy = (addr >> 13) & 0x3ff;
-    posx = (addr >> 2) & 0x7ff;
+    posy = ADDR_TO_Y(addr);
+    posx = ADDR_TO_X(addr);
 
     if (posy > buf->height || posx > buf->width) {
         return 0;
@@ -1374,6 +1377,12 @@ static void artist_realizefn(DeviceState *dev, Error **errp)
     struct vram_buffer *buf;
     hwaddr offset = 0;
 
+    /* Screen on artist can not be greater than 2048x2048 pixels. */
+    s->width = MAX(s->width, 640);
+    s->width = MIN(s->width, 2048);
+    s->height = MAX(s->height, 480);
+    s->height = MIN(s->height, 2048);
+
     memory_region_init(&s->mem_as_root, OBJECT(dev), "artist", ~0ull);
     address_space_init(&s->as, &s->mem_as_root, "artist");
 

--
2.21.3

#17 lore raw

Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution

Quoted 20 lines · Helge Deller

Artist screen size is limited to 2048 x 2048 pixels and x/y coordination addressing needs to be done by OS via an uint32 value which is based on a 2048 byte line length, independend of the real screen size.

Since HP-UX seems to ideally need at least 640 pixels in width, this patch ensures that the screen size stays between 640x480 and 2048x2048 pixels and fixes some pixel glitches were visible before on STI text consoles due to the 2048 line length limitation.

---
 hw/display/artist.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)
hw/display/artist.c +0 -0
index 71982559c6..98bee6d61c 100644

hw/display/artist.c static const char *artist_reg_name(uint64_t addr) · line 197

Quoted 6 lines
hw/display/artist.c +3 -0
@@ -192,6 +192,10 @@ static const char *artist_reg_name(uint64_t addr)
 }
 #undef REG_NAME
 
+/* artist has a fixed line length of 2048 bytes. */
+#define ADDR_TO_Y(addr) (((addr) >> 11) & 0x7ff)
+#define ADDR_TO_X(addr) ((addr) & 0x7ff)

extract32()

Quoted 21 lines
hw/display/artist.c +3 -2
+
 static int16_t artist_get_x(uint32_t reg)
 {
     return reg >> 16;
@@ -348,13 +352,13 @@ static void artist_invalidate_cursor(ARTISTState *s)
                             y, s->cursor_height);
 }
 
-static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
+static void vram_bit_write(ARTISTState *s, int posy, bool incr_x,
                            int size, uint32_t data)
 {
     struct vram_buffer *buf;
     uint32_t vram_bitmask = s->vram_bitmask;
     int mask, i, pix_count, pix_length;
-    unsigned int offset, width;
+    unsigned int posx, offset, width;
     uint8_t *data8, *p;
 
     pix_count = vram_write_pix_per_transfer(s);

hw/display/artist.c static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, · line 374

Quoted 5 lines
hw/display/artist.c +2 -0
@@ -366,6 +370,8 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
     if (s->cmap_bm_access) {
         offset = s->vram_pos;
     } else {
+        posx = ADDR_TO_X(s->vram_pos >> 2);
+        posy += ADDR_TO_Y(s->vram_pos >> 2);

Do you in fact want to fold the >> 2 into the ADDR_TO_X/Y, like

#define ADDR_TO_X(POS) extract32(POS, 2, 11)

?

Quoted 6 lines
hw/display/artist.c +0 -2
@@ -881,16 +886,12 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val,
         break;
 
     case VRAM_WRITE_INCR_Y:
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;

...

Quoted 4 lines

case VRAM_WRITE_INCR_X:
case VRAM_WRITE_INCR_X2:

hw/display/artist.c +0 -2
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;

...

Quoted 1 line

- int posy = (addr >> 11) & 0x3ff;

Is it a bug that these Y were using 0x3ff and not 0x7ff? Because it's pretty consistent...

You should make that a separate change, for sure.

hw/display/artist.c static void artist_realizefn(DeviceState *dev, Error **errp) · line 1384

Quoted 9 lines
hw/display/artist.c +5 -0
@@ -1374,6 +1377,12 @@ static void artist_realizefn(DeviceState *dev, Error **errp)
     struct vram_buffer *buf;
     hwaddr offset = 0;
 
+    /* Screen on artist can not be greater than 2048x2048 pixels. */
+    s->width = MAX(s->width, 640);
+    s->width = MIN(s->width, 2048);
+    s->height = MAX(s->height, 480);
+    s->height = MIN(s->height, 2048);

Was the original values chosen by the user? Should we be giving some sort of error for out-of-range values?

r~

#18 lore raw

Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution

* Richard Henderson <[email protected]>:

Quoted 24 lines · Helge Deller
Quoted 23 lines

Artist screen size is limited to 2048 x 2048 pixels and x/y coordination addressing needs to be done by OS via an uint32 value which is based on a 2048 byte line length, independend of the real screen size.

Since HP-UX seems to ideally need at least 640 pixels in width, this patch ensures that the screen size stays between 640x480 and 2048x2048 pixels and fixes some pixel glitches were visible before on STI text consoles due to the 2048 line length limitation.

---
 hw/display/artist.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)
hw/display/artist.c +0 -0
index 71982559c6..98bee6d61c 100644
@@ -192,6 +192,10 @@ static const char *artist_reg_name(uint64_t addr)
 }
 #undef REG_NAME
 
Quoted 5 lines

hw/display/artist.c static const char *artist_reg_name(uint64_t addr) · line 197

Quoted 3 lines
hw/display/artist.c +3 -0
+/* artist has a fixed line length of 2048 bytes. */
+#define ADDR_TO_Y(addr) (((addr) >> 11) & 0x7ff)
+#define ADDR_TO_X(addr) ((addr) & 0x7ff)

extract32()

fixed.

Quoted 9 lines

hw/display/artist.c static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, · line 374

Quoted 6 lines
hw/display/artist.c +2 -0
@@ -366,6 +370,8 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
     if (s->cmap_bm_access) {
         offset = s->vram_pos;
     } else {
+        posx = ADDR_TO_X(s->vram_pos >> 2);
+        posy += ADDR_TO_Y(s->vram_pos >> 2);

Do you in fact want to fold the >> 2 into the ADDR_TO_X/Y, like #define ADDR_TO_X(POS) extract32(POS, 2, 11)

Yes.
Basically this block was simply moved up to inside the function. See in removed chunk below, there is the "s->vram_pos >> 2".

Quoted 11 lines
Quoted 6 lines
hw/display/artist.c +0 -2
@@ -881,16 +886,12 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val,
         break;
 
     case VRAM_WRITE_INCR_Y:
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;

...

hw/display/artist.c

Quoted 4 lines

case VRAM_WRITE_INCR_X:
case VRAM_WRITE_INCR_X2:

hw/display/artist.c +0 -2
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;
Quoted 5 lines

...

Quoted 1 line

- int posy = (addr >> 11) & 0x3ff;

Is it a bug that these Y were using 0x3ff and not 0x7ff? Because it's pretty consistent...

I'm not sure if was intentional, a bug or just initial coding by Sven. The old code was limiting to 1024 lines.
I assume that there doesn't exist any real hardware with > 1024 lines, so it's more theoretical.
I tested the code, and it seems to work with > 1024 at least. So, I think to use 0x7ff is probably more correct - at least if we allow more lines.

Quoted 1 line

You should make that a separate change, for sure.

I'd prefer to keep it in one patch.
It's simply moving code around and reuse a macro.

Quoted 11 lines

hw/display/artist.c static void artist_realizefn(DeviceState *dev, Error **errp) · line 1384

Quoted 9 lines
hw/display/artist.c +5 -0
@@ -1374,6 +1377,12 @@ static void artist_realizefn(DeviceState *dev, Error **errp)
     struct vram_buffer *buf;
     hwaddr offset = 0;
 
+    /* Screen on artist can not be greater than 2048x2048 pixels. */
+    s->width = MAX(s->width, 640);
+    s->width = MIN(s->width, 2048);
+    s->height = MAX(s->height, 480);
+    s->height = MIN(s->height, 2048);

Was the original values chosen by the user?

Yes, can bet set by user via
-global -global artist.width=800 -global artist.height=600

Quoted 1 line

Should we be giving some sort of error for out-of-range values?

I had a warning there, but then removed it again. Most users will probably use the default values anyway. If you really want, I will add a warning. I'm not a fan of errors. Errors usually abort, but we can adjust and simply continue here.

Updated patch below.

Helge

----------------------------------

[PATCH] hw/display/artist: Fix artist screen resolution

Artist screen size is limited to 2048 x 2048 pixels and x/y coordination addressing needs to be done by OS via an uint32 value which is based on a 2048 byte line length, independend of the real screen size.

Since HP-UX seems to ideally need at least 640 pixels in width, this patch ensures that the screen size stays between 640x480 and 2048x2048 pixels and fixes some pixel glitches were visible before on STI text consoles due to the 2048 line length limitation.

hw/display/artist.c +23 -14
index 71982559c6..71f527c0e1 100644
@@ -192,6 +192,10 @@ static const char *artist_reg_name(uint64_t addr)
 }
 #undef REG_NAME
 
+/* artist has a fixed line length of 2048 bytes. */
+#define ADDR_TO_Y(addr) extract32(addr, 11, 11)
+#define ADDR_TO_X(addr) extract32(addr, 0, 11)
+
 static int16_t artist_get_x(uint32_t reg)
 {
     return reg >> 16;
@@ -348,13 +352,13 @@ static void artist_invalidate_cursor(ARTISTState *s)
                             y, s->cursor_height);
 }
 
-static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
+static void vram_bit_write(ARTISTState *s, int posy, bool incr_x,
                            int size, uint32_t data)
 {
     struct vram_buffer *buf;
     uint32_t vram_bitmask = s->vram_bitmask;
     int mask, i, pix_count, pix_length;
-    unsigned int offset, width;
+    unsigned int posx, offset, width;
     uint8_t *data8, *p;
 
     pix_count = vram_write_pix_per_transfer(s);
@@ -366,6 +370,8 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
     if (s->cmap_bm_access) {
         offset = s->vram_pos;
     } else {
+        posx = ADDR_TO_X(s->vram_pos >> 2);
+        posy += ADDR_TO_Y(s->vram_pos >> 2);
         offset = posy * width + posx;
     }
 
@@ -858,7 +864,6 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val,
                              unsigned size)
 {
     ARTISTState *s = opaque;
-    int posx, posy;
     int width, height;
 
     trace_artist_reg_write(size, addr, artist_reg_name(addr & ~3ULL), val);
@@ -881,16 +886,12 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val,
         break;
 
     case VRAM_WRITE_INCR_Y:
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;
-        vram_bit_write(s, posx, posy + s->vram_char_y++, false, size, val);
+        vram_bit_write(s, s->vram_char_y++, false, size, val);
         break;
 
     case VRAM_WRITE_INCR_X:
     case VRAM_WRITE_INCR_X2:
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;
-        vram_bit_write(s, posx, posy + s->vram_char_y, true, size, val);
+        vram_bit_write(s, s->vram_char_y, true, size, val);
         break;
 
     case VRAM_IDX:
@@ -1156,8 +1157,7 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
 {
     ARTISTState *s = opaque;
     struct vram_buffer *buf;
-    int posy = (addr >> 11) & 0x3ff;
-    int posx = addr & 0x7ff;
+    unsigned int posy, posx;
     unsigned int offset;
     trace_artist_vram_write(size, addr, val);
 
@@ -1170,6 +1170,9 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
     }
 
     buf = vram_write_buffer(s);
+    posy = ADDR_TO_Y(addr);
+    posx = ADDR_TO_X(addr);
+
     if (!buf->size) {
         return;
     }
@@ -1212,7 +1215,7 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
     ARTISTState *s = opaque;
     struct vram_buffer *buf;
     uint64_t val;
-    int posy, posx;
+    unsigned int posy, posx;
 
     if (s->cmap_bm_access) {
         buf = &s->vram_buffer[ARTIST_BUFFER_CMAP];
@@ -1229,8 +1232,8 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
         return 0;
     }
 
-    posy = (addr >> 13) & 0x3ff;
-    posx = (addr >> 2) & 0x7ff;
+    posy = ADDR_TO_Y(addr);
+    posx = ADDR_TO_X(addr);
 
     if (posy > buf->height || posx > buf->width) {
         return 0;
@@ -1374,6 +1377,12 @@ static void artist_realizefn(DeviceState *dev, Error **errp)
     struct vram_buffer *buf;
     hwaddr offset = 0;
 
+    /* Screen on artist can not be greater than 2048x2048 pixels. */
+    s->width = MAX(s->width, 640);
+    s->width = MIN(s->width, 2048);
+    s->height = MAX(s->height, 480);
+    s->height = MIN(s->height, 2048);
+
     memory_region_init(&s->mem_as_root, OBJECT(dev), "artist", ~0ull);
     address_space_init(&s->as, &s->mem_as_root, "artist");
 
#19 lore raw

Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution

Quoted 11 lines · Helge Deller
Quoted 2 lines

Is it a bug that these Y were using 0x3ff and not 0x7ff? Because it's pretty consistent...

I'm not sure if was intentional, a bug or just initial coding by Sven. The old code was limiting to 1024 lines.
I assume that there doesn't exist any real hardware with > 1024 lines, so it's more theoretical.
I tested the code, and it seems to work with > 1024 at least. So, I think to use 0x7ff is probably more correct - at least if we allow more lines.

Quoted 4 lines
Quoted 1 line

You should make that a separate change, for sure.

I'd prefer to keep it in one patch.
It's simply moving code around and reuse a macro.

It's more than that, it's a behaviour change.

Code refactoring should be separate from feature changes, when at all possible.
And here, its certainly possible.

Quoted 11 lines
Quoted 1 line

Was the original values chosen by the user?

Yes, can bet set by user via
-global -global artist.width=800 -global artist.height=600

Quoted 1 line

Should we be giving some sort of error for out-of-range values?

I had a warning there, but then removed it again. Most users will probably use the default values anyway. If you really want, I will add a warning. I'm not a fan of errors. Errors usually abort, but we can adjust and simply continue here.

It's exactly the same error as -smp 1234, when only 8 cpus are supported. An error is more than appropriate.

r~

#20 lore raw

Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution

New patch #1:

From 80ad61c2ba25ca608b7c1c1cf701ae8164219cf6 Mon Sep 17 00:00:00 2001
From: Helge Deller <[email protected]>
Subject: [PATCH] hw/display/artist: Verify artist screen resolution

Artist hardware is limited to 2048 x 2048 pixels.
STI ROMs allow at minimum 640 x 480 pixels.

Qemu users can adjust the screen size on the command line with:
-global artist.width=800 -global artist.height=600
but we need to ensure that the screen size stays inside the given boundaries, otherwise print an error message and adjust.

hw/display/artist.c +12 -0
index 71982559c6..ff1532fdc1 100644
@@ -1374,6 +1374,18 @@ static void artist_realizefn(DeviceState *dev, Error **errp)
     struct vram_buffer *buf;
     hwaddr offset = 0;
 
+    if (s->width > 2048 || s->height > 2048) {
+        error_report("artist: screen size can not exceed 2048 x 2048 pixel.");
+        s->width = MIN(s->width, 2048);
+        s->height = MIN(s->height, 2048);
+    }
+
+    if (s->width < 640 || s->height < 480) {
+        error_report("artist: minimum screen size is 640 x 480 pixel.");
+        s->width = MAX(s->width, 640);
+        s->height = MAX(s->height, 480);
+    }
+
     memory_region_init(&s->mem_as_root, OBJECT(dev), "artist", ~0ull);
     address_space_init(&s->as, &s->mem_as_root, "artist");
 
#21 lore raw

Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution

In reply to Richard Henderson

New patch #2:

From b0f0d24563df504b8221fbc934d25c5a896e0a49 Mon Sep 17 00:00:00 2001
From: Helge Deller <[email protected]>
Subject: [PATCH] hw/display/artist: Refactor x/y coordination extraction

Simplify the code by using new introduced ADDR_TO_Y() and ADDR_TO_X() macros. Those macros extract the x/y-coordinate from the given uint32.

As further simplification the extraction of the x/y coordinates for VRAM_WRITE_INCR_Y and VRAM_WRITE_INCR_X can be done centrally in vram_bit_write(), so move this code up into the function.

ADDR_TO_Y() is still limited to 10 bits which allow to address up to of 1024 lines - this will be increased in a follow-up patch.

hw/display/artist.c +17 -14
index ff1532fdc1..16d85c65f8 100644
@@ -192,6 +192,10 @@ static const char *artist_reg_name(uint64_t addr)
 }
 #undef REG_NAME
 
+/* artist has a fixed line length of 2048 bytes. */
+#define ADDR_TO_Y(addr) extract32(addr, 11, 10)
+#define ADDR_TO_X(addr) extract32(addr, 0, 11)
+
 static int16_t artist_get_x(uint32_t reg)
 {
     return reg >> 16;
@@ -348,13 +352,13 @@ static void artist_invalidate_cursor(ARTISTState *s)
                             y, s->cursor_height);
 }
 
-static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
+static void vram_bit_write(ARTISTState *s, int posy, bool incr_x,
                            int size, uint32_t data)
 {
     struct vram_buffer *buf;
     uint32_t vram_bitmask = s->vram_bitmask;
     int mask, i, pix_count, pix_length;
-    unsigned int offset, width;
+    unsigned int posx, offset, width;
     uint8_t *data8, *p;
 
     pix_count = vram_write_pix_per_transfer(s);
@@ -366,6 +370,8 @@ static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
     if (s->cmap_bm_access) {
         offset = s->vram_pos;
     } else {
+        posx = ADDR_TO_X(s->vram_pos >> 2);
+        posy += ADDR_TO_Y(s->vram_pos >> 2);
         offset = posy * width + posx;
     }
 
@@ -858,7 +864,6 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val,
                              unsigned size)
 {
     ARTISTState *s = opaque;
-    int posx, posy;
     int width, height;
 
     trace_artist_reg_write(size, addr, artist_reg_name(addr & ~3ULL), val);
@@ -881,16 +886,12 @@ static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val,
         break;
 
     case VRAM_WRITE_INCR_Y:
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;
-        vram_bit_write(s, posx, posy + s->vram_char_y++, false, size, val);
+        vram_bit_write(s, s->vram_char_y++, false, size, val);
         break;
 
     case VRAM_WRITE_INCR_X:
     case VRAM_WRITE_INCR_X2:
-        posx = (s->vram_pos >> 2) & 0x7ff;
-        posy = (s->vram_pos >> 13) & 0x3ff;
-        vram_bit_write(s, posx, posy + s->vram_char_y, true, size, val);
+        vram_bit_write(s, s->vram_char_y, true, size, val);
         break;
 
     case VRAM_IDX:
@@ -1156,8 +1157,7 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
 {
     ARTISTState *s = opaque;
     struct vram_buffer *buf;
-    int posy = (addr >> 11) & 0x3ff;
-    int posx = addr & 0x7ff;
+    unsigned int posy, posx;
     unsigned int offset;
     trace_artist_vram_write(size, addr, val);
 
@@ -1170,6 +1170,9 @@ static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val,
     }
 
     buf = vram_write_buffer(s);
+    posy = ADDR_TO_Y(addr);
+    posx = ADDR_TO_X(addr);
+
     if (!buf->size) {
         return;
     }
@@ -1212,7 +1215,7 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
     ARTISTState *s = opaque;
     struct vram_buffer *buf;
     uint64_t val;
-    int posy, posx;
+    unsigned int posy, posx;
 
     if (s->cmap_bm_access) {
         buf = &s->vram_buffer[ARTIST_BUFFER_CMAP];
@@ -1229,8 +1232,8 @@ static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size)
         return 0;
     }
 
-    posy = (addr >> 13) & 0x3ff;
-    posx = (addr >> 2) & 0x7ff;
+    posy = ADDR_TO_Y(addr);
+    posx = ADDR_TO_X(addr);
 
     if (posy > buf->height || posx > buf->width) {
         return 0;
#22 lore raw

Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution

In reply to Richard Henderson

New patch #3/3:

From 476aeb9b832ae172a9d6a28aa9e43300dedd419b Mon Sep 17 00:00:00 2001
Subject: [PATCH] hw/display/artist: Allow screen size up to 2048 lines

Adjust the ADDR_TO_Y() macro to extract 11 bits, which allows userspace to address screen sizes up to 2048 lines (instead of 1024 before).

hw/display/artist.c +1 -1
index 16d85c65f8..955296d3d8 100644
@@ -193,7 +193,7 @@ static const char *artist_reg_name(uint64_t addr)
 #undef REG_NAME
 
 /* artist has a fixed line length of 2048 bytes. */
-#define ADDR_TO_Y(addr) extract32(addr, 11, 10)
+#define ADDR_TO_Y(addr) extract32(addr, 11, 11)
 #define ADDR_TO_X(addr) extract32(addr, 0, 11)
 
 static int16_t artist_get_x(uint32_t reg)
Reviewed-by
#23 lore raw

Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution

Quoted 16 lines · Helge Deller

New patch #3/3:

From 476aeb9b832ae172a9d6a28aa9e43300dedd419b Mon Sep 17 00:00:00 2001
Subject: [PATCH] hw/display/artist: Allow screen size up to 2048 lines

Adjust the ADDR_TO_Y() macro to extract 11 bits, which allows userspace to address screen sizes up to 2048 lines (instead of 1024 before).

hw/display/artist.c +0 -0
index 16d85c65f8..955296d3d8 100644

hw/display/artist.c static const char *artist_reg_name(uint64_t addr) · line 199

Quoted 8 lines
hw/display/artist.c +1 -1
@@ -193,7 +193,7 @@ static const char *artist_reg_name(uint64_t addr)
 #undef REG_NAME
 
 /* artist has a fixed line length of 2048 bytes. */
-#define ADDR_TO_Y(addr) extract32(addr, 11, 10)
+#define ADDR_TO_Y(addr) extract32(addr, 11, 11)
 #define ADDR_TO_X(addr) extract32(addr, 0, 11)
 
 static int16_t artist_get_x(uint32_t reg)

Thanks. All 3 can have a

r~

#24 lore raw

PATCH 7/7 target/hppa: Fix boot with old Linux installation CDs

In reply to Helge Deller

The current qemu hppa emulation emulates a PA1.1 CPU, which can only execute the 32-bit instruction set. For unknown 64-bit instructions, a instruction trap is sent to the virtual CPU.
This behaviour is correct in the sense that we emulate what the PA1.1 specification says.

But when trying to boot older Linux installation images, e.g. ftp://parisc.parisc-linux.org/debian-cd/debian-5.0/lenny-5.0.10-hppa-iso-cd/cdimage.debian.org/debian-5010-hppa-netinst.iso one finds that qemu fails to boot those images.
The problem is, that in the Linux kernel (e.g. 2.6.26) of those old images
64-bit instructions were used by mistake in the fault handlers. The relevant
instructions (the ",*" indicates that it's a 64-bit instruction) I see are:

   0:   09 3e 04 29     sub,* sp,r9,r9
   0:   08 3d 06 3d     add,* ret1,r1,ret1
   0:   0a 09 02 61     or,* r9,r16,r1
   0:   0a ba 00 3a     andcm,* r26,r21,r26
   0:   08 33 02 33     and,* r19,r1,r19

The interesting part is, that real physical 32-bit machines (like the 700/64 and B160L - which is the one we emulate) do boot those images and thus seem to simply ignore the 64-bit flag on those instructions.

The patch below modifies the qemu instruction decoder to ignore the 64-bit flag too - which is what real 32-bit hardware seems to do. With this modification qemu now successfully boots those older images too.

I suggest to apply the patch below - even if it does not reflect what the SPEC says. Instead it increases the compatibility to really existing hardware and seem to not create problems if we add real PA2.0 support anytime later.

---
 target/hppa/insns.decode | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
target/hppa/insns.decode +5 -5
index f0dd71dd08..dceaad65e9 100644
@@ -149,9 +149,9 @@ lci             000001 ----- ----- -- 01001100 0 t:5
 # Arith/Log
 ####
 
-andcm           000010 ..... ..... .... 000000 0 .....  @rrr_cf
-and             000010 ..... ..... .... 001000 0 .....  @rrr_cf
-or              000010 ..... ..... .... 001001 0 .....  @rrr_cf
+andcm           000010 ..... ..... .... 000000 - .....  @rrr_cf
+and             000010 ..... ..... .... 001000 - .....  @rrr_cf
+or              000010 ..... ..... .... 001001 - .....  @rrr_cf
 xor             000010 ..... ..... .... 001010 0 .....  @rrr_cf
 uxor            000010 ..... ..... .... 001110 0 .....  @rrr_cf
 ds              000010 ..... ..... .... 010001 0 .....  @rrr_cf
@@ -161,13 +161,13 @@ uaddcm_tc       000010 ..... ..... .... 100111 0 .....  @rrr_cf
 dcor            000010 ..... 00000 .... 101110 0 .....  @rr_cf
 dcor_i          000010 ..... 00000 .... 101111 0 .....  @rr_cf
 
-add             000010 ..... ..... .... 0110.. 0 .....  @rrr_cf_sh
+add             000010 ..... ..... .... 0110.. - .....  @rrr_cf_sh
 add_l           000010 ..... ..... .... 1010.. 0 .....  @rrr_cf_sh
 add_tsv         000010 ..... ..... .... 1110.. 0 .....  @rrr_cf_sh
 add_c           000010 ..... ..... .... 011100 0 .....  @rrr_cf_sh0
 add_c_tsv       000010 ..... ..... .... 111100 0 .....  @rrr_cf_sh0
 
-sub             000010 ..... ..... .... 010000 0 .....  @rrr_cf
+sub             000010 ..... ..... .... 010000 - .....  @rrr_cf
 sub_tsv         000010 ..... ..... .... 110000 0 .....  @rrr_cf
 sub_tc          000010 ..... ..... .... 010011 0 .....  @rrr_cf
 sub_tsv_tc      000010 ..... ..... .... 110011 0 .....  @rrr_cf

--
2.21.3

#25 lore raw
In reply to Helge Deller

Hi Helge,

Quoted 3 lines · Helge Deller

Add emulation for a power button on hppa,
fix quite some bugs in seabios-hppa firmware for artist graphics card fix boot with old Linux installation CDs.

I started to review the version you sent last week and took few notes, are there big changes in this version (is it a REPOST or a v2)? (I think you just appended 2 extra patches posted separately).

Thanks,

Phil.

Quoted 23 lines

Helge Deller (7):
seabios-hppa: Update SeaBIOS to hppa-qemu-5.2-2 tag hw/hppa: Make number of TLB and BTLB entries configurable hw/hppa: Store boot device in fw_cfg section hw/hppa: Inform SeaBIOS about fw_cfg port address hw/hppa: Add power button emulation hw/display/artist: Fix artist screen resolution target/hppa: Fix boot with old Linux installation CDs

 hw/display/artist.c       |  37 +++++++++++++++----------
 hw/hppa/hppa_hardware.h   |   3 +-
 hw/hppa/machine.c         |  56 +++++++++++++++++++++++++++++++++++++-
 pc-bios/hppa-firmware.img | Bin 783192 -> 785696 bytes
 roms/seabios-hppa         |   2 +-
 target/hppa/cpu.h         |   5 +++-
 target/hppa/insns.decode  |  10 +++----
 7 files changed, 89 insertions(+), 24 deletions(-)

--
2.21.3

#26 lore raw

Hi Philippe,

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

Add emulation for a power button on hppa,
fix quite some bugs in seabios-hppa firmware for artist graphics card fix boot with old Linux installation CDs.

I started to review the version you sent last week and took few notes,

Thanks!

Quoted 2 lines

are there big changes in this version (is it a REPOST or a v2)? (I think you just appended 2 extra patches posted separately).

Yes, it's a v2 version with the two patches appended.
Otherwise no real changes to qemu, but some more fixes in the included Seabios.

Helge

Quoted 29 lines

Thanks,

Phil.

Quoted 23 lines

Helge Deller (7):
seabios-hppa: Update SeaBIOS to hppa-qemu-5.2-2 tag hw/hppa: Make number of TLB and BTLB entries configurable hw/hppa: Store boot device in fw_cfg section hw/hppa: Inform SeaBIOS about fw_cfg port address hw/hppa: Add power button emulation hw/display/artist: Fix artist screen resolution target/hppa: Fix boot with old Linux installation CDs

 hw/display/artist.c       |  37 +++++++++++++++----------
 hw/hppa/hppa_hardware.h   |   3 +-
 hw/hppa/machine.c         |  56 +++++++++++++++++++++++++++++++++++++-
 pc-bios/hppa-firmware.img | Bin 783192 -> 785696 bytes
 roms/seabios-hppa         |   2 +-
 target/hppa/cpu.h         |   5 +++-
 target/hppa/insns.decode  |  10 +++----
 7 files changed, 89 insertions(+), 24 deletions(-)

--
2.21.3