Skip to contentSkip to conversation

HPPA: i82596, PS/2 and graphics emulation

PATCH Superseded Sven Schnelle 2 participants 9 messages Oct 22, 2019

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover HPPA: i82596, PS/2 and graphics emulation

Hi,

these series adds quite a lot to the HPPA emulation in QEMU:
i82596 emulation from Helge, PS/2 and Artist graphics emulation.

See https://parisc.wiki.kernel.org/index.php/Qemu for a few screenshots of QEMU running a X11/CDE session in HP-UX.

Changes in v2:
- dropped 'hppa: remove ISA region' as that patch requires some more work
- added shortlog to seabios update
- use const and MAKE_64BIT_MASK in dino.c

Regards,
Sven

Helge Deller (2):
hw/hppa/dino.c: Improve emulation of Dino PCI chip
hppa: Add support for LASI chip with i82596 NIC

Sven Schnelle (4):
ps2: accept 'Set Key Make and Break' commands
hppa: add emulation of LASI PS2 controllers
hppa: Add emulation of Artist graphics
seabios-hppa: update to latest version

 MAINTAINERS                 |    4 +-
 hw/display/Kconfig          |    3 +
 hw/display/Makefile.objs    |    1 +
 hw/display/artist.c         | 1336 +++++++++++++++++++++++++++++++++++
 hw/display/trace-events     |    9 +
 hw/hppa/Kconfig             |    3 +
 hw/hppa/Makefile.objs       |    2 +-
 hw/hppa/dino.c              |   94 ++-
 hw/hppa/hppa_hardware.h     |    1 +
 hw/hppa/hppa_sys.h          |    2 +
 hw/hppa/lasi.c              |  368 ++++++++++
 hw/hppa/machine.c           |   18 +-
 hw/hppa/trace-events        |   10 +
 hw/input/Kconfig            |    3 +
 hw/input/Makefile.objs      |    1 +
 hw/input/lasips2.c          |  289 ++++++++
 hw/input/ps2.c              |   11 +
 hw/input/trace-events       |    5 +
 hw/net/Kconfig              |    7 +
 hw/net/Makefile.objs        |    2 +
 hw/net/i82596.c             |  734 +++++++++++++++++++
 hw/net/i82596.h             |   55 ++
 hw/net/lasi_i82596.c        |  188 +++++
 hw/net/trace-events         |   13 +
 include/hw/input/lasips2.h  |   16 +
 include/hw/input/ps2.h      |    1 +
 include/hw/net/lasi_82596.h |   29 +
 pc-bios/hppa-firmware.img   |  Bin 783724 -> 772876 bytes
 roms/seabios-hppa           |    2 +-
 29 files changed, 3191 insertions(+), 16 deletions(-)
 create mode 100644 hw/display/artist.c
 create mode 100644 hw/hppa/lasi.c
 create mode 100644 hw/input/lasips2.c
 create mode 100644 hw/net/i82596.c
 create mode 100644 hw/net/i82596.h
 create mode 100644 hw/net/lasi_i82596.c
 create mode 100644 include/hw/input/lasips2.h
 create mode 100644 include/hw/net/lasi_82596.h
Signature · 1 line
2.23.0
#4 lore raw

PATCH v2 3/6 ps2: accept 'Set Key Make and Break' commands

HP-UX sends both the 'Set key make and break (0xfc) and 'Set all key typematic make and break' (0xfa). QEMU response with 'Resend' as it doesn't handle these commands. HP-UX than reports an PS/2 max retransmission exceeded error. Add these commands and just reply with ACK.

---
 hw/input/ps2.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/input/ps2.c +6 -0
index 67f92f6112..6c2c7066a6 100644
@@ -49,6 +49,8 @@
 #define KBD_CMD_RESET_DISABLE	0xF5	/* reset and disable scanning */
 #define KBD_CMD_RESET_ENABLE   	0xF6    /* reset and enable scanning */
 #define KBD_CMD_RESET		0xFF	/* Reset */
+#define KBD_CMD_SET_MAKE_BREAK  0xFC    /* Set Make and Break mode */
+#define KBD_CMD_SET_TYPEMATIC   0xFA    /* Set Typematic Make and Break mode */
 
 /* Keyboard Replies */
 #define KBD_REPLY_POR		0xAA	/* Power on reset */
@@ -592,6 +594,10 @@ void ps2_write_keyboard(void *opaque, int val)
                 KBD_REPLY_ACK,
                 KBD_REPLY_POR);
             break;
+        case KBD_CMD_SET_TYPEMATIC:
+        case KBD_CMD_SET_MAKE_BREAK:
+            ps2_queue(&s->common, KBD_REPLY_ACK);
+            break;
         default:
             ps2_queue(&s->common, KBD_REPLY_RESEND);
             break;
Signature · 1 line
2.23.0
#8 lore raw

PATCH v2 5/6 hppa: Add emulation of Artist graphics

In reply to Sven Schnelle

This adds emulation of Artist graphics good enough to get a Text console on both Linux and HP-UX. The X11 server from HP-UX also works.

---
 hw/display/Kconfig       |    3 +
 hw/display/Makefile.objs |    1 +
 hw/display/artist.c      | 1336 ++++++++++++++++++++++++++++++++++++++
 hw/display/trace-events  |    9 +
 hw/hppa/Kconfig          |    1 +
 hw/hppa/hppa_hardware.h  |    1 +
 hw/hppa/machine.c        |   10 +
 7 files changed, 1361 insertions(+)
 create mode 100644 hw/display/artist.c
hw/display/Kconfig +3 -0
index cbdf7b1a67..953631afb6 100644
@@ -91,6 +91,9 @@ config TCX
 config CG3
     bool
 
+config ARTIST
+    bool
+
 config VGA
     bool
 
hw/display/Makefile.objs +1 -0
index 5a4066383b..5f63294149 100644
@@ -39,6 +39,7 @@ common-obj-$(CONFIG_SM501) += sm501.o
 common-obj-$(CONFIG_TCX) += tcx.o
 common-obj-$(CONFIG_CG3) += cg3.o
 common-obj-$(CONFIG_NEXTCUBE) += next-fb.o
+common-obj-$(CONFIG_ARTIST) += artist.o
 
 obj-$(CONFIG_VGA) += vga.o
 
hw/display/artist.c new file +1336 -0

1,336 lines not on this page · raw message

hw/display/trace-events +9 -0
index ba7787b180..e6e22bef88 100644
@@ -142,3 +142,12 @@ sii9022_switch_mode(const char *mode) "mode: %s"
 # ati.c
 ati_mm_read(unsigned int size, uint64_t addr, const char *name, uint64_t val) "%u 0x%"PRIx64 " %s -> 0x%"PRIx64
 ati_mm_write(unsigned int size, uint64_t addr, const char *name, uint64_t val) "%u 0x%"PRIx64 " %s <- 0x%"PRIx64
+
+# artist.c
+artist_reg_read(unsigned int size, uint64_t addr, const char *name, uint64_t val) "%u 0x%"PRIx64 "%s -> 0x%"PRIx64
+artist_reg_write(unsigned int size, uint64_t addr, const char *name, uint64_t val) "%u 0x%"PRIx64 "%s <- 0x%"PRIx64
+artist_vram_read(unsigned int size, uint64_t addr, int posx, int posy, uint64_t val) "%u 0x%"PRIx64 " %ux%u-> 0x%"PRIx64
+artist_vram_write(unsigned int size, uint64_t addr, uint64_t val) "%u 0x%"PRIx64 " <- 0x%"PRIx64
+artist_fill_window(unsigned int start_x, unsigned int start_y, unsigned int width, unsigned int height, uint32_t op, uint32_t ctlpln) "start=%ux%u length=%ux%u op=0x%08x ctlpln=0x%08x"
+artist_block_move(unsigned int start_x, unsigned int start_y, unsigned int dest_x, unsigned int dest_y, unsigned int width, unsigned int height) "source %ux%u -> dest %ux%u size %ux%u"
+artist_draw_line(unsigned int start_x, unsigned int start_y, unsigned int end_x, unsigned int end_y) "%ux%u %ux%u"
hw/hppa/Kconfig +1 -0
index 7f9be7f25c..82178c7dcb 100644
@@ -12,3 +12,4 @@ config DINO
     select LSI_SCSI_PCI
     select LASI_82596
     select LASIPS2
+    select ARTIST
hw/hppa/hppa_hardware.h +1 -0
index 507f91e05d..4a2fe2df60 100644
@@ -22,6 +22,7 @@
 #define LASI_PS2KBD_HPA 0xffd08000
 #define LASI_PS2MOU_HPA 0xffd08100
 #define LASI_GFX_HPA    0xf8000000
+#define ARTIST_FB_ADDR  0xf9000000
 #define CPU_HPA         0xfffb0000
 #define MEMORY_HPA      0xfffbf000
 
hw/hppa/machine.c +10 -0
index 65fc20ebed..39bd5f1834 100644
@@ -21,6 +21,7 @@
 #include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/log.h"
+#include "hw/usb.h"
 
 #define MAX_IDE_BUS 2
 
@@ -74,6 +75,7 @@ static void machine_hppa_init(MachineState *machine)
     MemoryRegion *cpu_region;
     long i;
     unsigned int smp_cpus = machine->smp.cpus;
+    SysBusDevice *s;
 
     ram_size = machine->ram_size;
 
@@ -126,6 +128,14 @@ static void machine_hppa_init(MachineState *machine)
     dev = DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a"));
     lsi53c8xx_handle_legacy_cmdline(dev);
 
+    if (vga_interface_type != VGA_NONE) {
+        dev = qdev_create(NULL, "artist");
+        qdev_init_nofail(dev);
+        s = SYS_BUS_DEVICE(dev);
+        sysbus_mmio_map(s, 0, LASI_GFX_HPA);
+        sysbus_mmio_map(s, 1, ARTIST_FB_ADDR);
+    }
+
     /* Network setup.  e1000 is good enough, failing Tulip support.  */
     for (i = 0; i < nb_nics; i++) {
         if (!enable_lasi_lan()) {
Signature · 1 line
2.23.0
#3 lore raw

PATCH v2 2/6 hppa: Add support for LASI chip with i82596 NIC

In reply to Sven Schnelle

From: Helge Deller <[email protected]>

LASI is a built-in multi-I/O chip which supports serial, parallel, network (Intel i82596 Apricot), sound and other functionalities. LASI has been used in many HP PARISC machines.
This patch adds the necessary parts to allow Linux and HP-UX to detect LASI and the network card.

---
 MAINTAINERS                 |   2 +
 hw/hppa/Kconfig             |   1 +
 hw/hppa/Makefile.objs       |   2 +-
 hw/hppa/hppa_sys.h          |   2 +
 hw/hppa/lasi.c              | 360 ++++++++++++++++++
 hw/hppa/machine.c           |   8 +-
 hw/hppa/trace-events        |   5 +
 hw/net/Kconfig              |   7 +
 hw/net/Makefile.objs        |   2 +
 hw/net/i82596.c             | 734 ++++++++++++++++++++++++++++++++++++
 hw/net/i82596.h             |  55 +++
 hw/net/lasi_i82596.c        | 188 +++++++++
 hw/net/trace-events         |  13 +
 include/hw/net/lasi_82596.h |  29 ++
 14 files changed, 1406 insertions(+), 2 deletions(-)
 create mode 100644 hw/hppa/lasi.c
 create mode 100644 hw/net/i82596.c
 create mode 100644 hw/net/i82596.h
 create mode 100644 hw/net/lasi_i82596.c
 create mode 100644 include/hw/net/lasi_82596.h
MAINTAINERS +2 -0
index f9541c3305..91e9e8ceac 100644
@@ -178,6 +178,8 @@ S: Maintained
 F: target/hppa/
 F: hw/hppa/
 F: disas/hppa.c
+F: hw/net/*i82596*
+F: include/hw/net/lasi_82596.h
 
 LM32 TCG CPUs
 M: Michael Walle <[email protected]>
hw/hppa/Kconfig +1 -0
index 6e5d74a825..2a7b38d6d6 100644
@@ -10,3 +10,4 @@ config DINO
     select IDE_CMD646
     select MC146818RTC
     select LSI_SCSI_PCI
+    select LASI_82596
hw/hppa/Makefile.objs +1 -1
index 67838f50a3..eac3467d8a 100644
@@ -1 +1 @@
-obj-$(CONFIG_DINO) += pci.o machine.o dino.o
+obj-$(CONFIG_DINO) += pci.o machine.o dino.o lasi.o
hw/hppa/hppa_sys.h +2 -0
index 43d25d21fc..d99b5dd87b 100644
@@ -11,6 +11,8 @@
 #include "hppa_hardware.h"
 
 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"
 
hw/hppa/lasi.c new file +360 -0

360 lines not on this page · raw message

hw/hppa/machine.c +7 -1
index 7e23675429..65fc20ebed 100644
@@ -16,6 +16,7 @@
 #include "hw/ide.h"
 #include "hw/timer/i8254.h"
 #include "hw/char/serial.h"
+#include "hw/net/lasi_82596.h"
 #include "hppa_sys.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
@@ -100,6 +101,9 @@ static void machine_hppa_init(MachineState *machine)
                                          "ram", ram_size);
     memory_region_add_subregion(addr_space, 0, ram_region);
 
+    /* Init Lasi chip */
+    lasi_init(addr_space);
+
     /* Init Dino (PCI host bus chip).  */
     pci_bus = dino_init(addr_space, &rtc_irq, &serial_irq);
     assert(pci_bus);
@@ -124,7 +128,9 @@ static void machine_hppa_init(MachineState *machine)
 
     /* Network setup.  e1000 is good enough, failing Tulip support.  */
     for (i = 0; i < nb_nics; i++) {
-        pci_nic_init_nofail(&nd_table[i], pci_bus, "e1000", NULL);
+        if (!enable_lasi_lan()) {
+            pci_nic_init_nofail(&nd_table[i], pci_bus, "e1000", NULL);
+        }
     }
 
     /* Load firmware.  Given that this is not "real" firmware,
hw/hppa/trace-events +5 -0
index f943b16c4e..3ff620319a 100644
@@ -7,3 +7,8 @@ hppa_pci_iack_write(void) ""
 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"
+lasi_chip_write(uint64_t addr, uint32_t val) "addr 0x%"PRIx64" val 0x%08x"
hw/net/Kconfig +7 -0
index 4ef86dc3a5..a38f9adaeb 100644
@@ -24,6 +24,9 @@ config PCNET_PCI
 config PCNET_COMMON
     bool
 
+config I82596_COMMON
+    bool
+
 config E1000_PCI
     bool
     default y if PCI_DEVICES
@@ -82,6 +85,10 @@ config LANCE
     bool
     select PCNET_COMMON
 
+config LASI_82596
+    bool
+    select I82596_COMMON
+
 config SUNHME
     bool
 
hw/net/Makefile.objs +2 -0
index 9904273b06..f3ef9ffe9b 100644
@@ -27,6 +27,8 @@ common-obj-$(CONFIG_IMX_FEC) += imx_fec.o
 common-obj-$(CONFIG_CADENCE) += cadence_gem.o
 common-obj-$(CONFIG_STELLARIS_ENET) += stellaris_enet.o
 common-obj-$(CONFIG_LANCE) += lance.o
+common-obj-$(CONFIG_LASI_82596) += lasi_i82596.o
+common-obj-$(CONFIG_I82596_COMMON) += i82596.o
 common-obj-$(CONFIG_SUNHME) += sunhme.o
 common-obj-$(CONFIG_FTGMAC100) += ftgmac100.o
 common-obj-$(CONFIG_SUNGEM) += sungem.o
hw/net/i82596.c new file +734 -0

734 lines not on this page · raw message

hw/net/i82596.h new file +55 -0

55 lines not on this page · raw message

hw/net/lasi_i82596.c new file +188 -0

188 lines not on this page · raw message

hw/net/trace-events +13 -0
index 58665655cc..abb71a6a9a 100644
@@ -367,3 +367,16 @@ virtio_net_announce_notify(void) ""
 virtio_net_announce_timer(int round) "%d"
 virtio_net_handle_announce(int round) "%d"
 virtio_net_post_load_device(void)
+
+# lasi_i82596.c
+lasi_82596_mem_readw(uint64_t addr, uint32_t ret) "addr=0x%"PRIx64" val=0x%04x"
+lasi_82596_mem_writew(uint64_t addr, uint32_t val) "addr=0x%"PRIx64" val=0x%04x"
+
+# i82596.c
+i82596_s_reset(void *s) "%p Reset chip"
+i82596_transmit(uint32_t size, uint32_t addr) "size %u from addr 0x%04x"
+i82596_receive_analysis(const char *s) "%s"
+i82596_receive_packet(size_t sz) "len=%zu"
+i82596_new_mac(const char *id_with_mac) "New MAC for: %s"
+i82596_set_multicast(uint16_t count) "Added %d multicast entries"
+i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION"
include/hw/net/lasi_82596.h new file +29 -0
new file mode 100644
index 0000000000..e76ef8308e
@@ -0,0 +1,29 @@
+/*
+ * QEMU LASI i82596 device emulation
+ *
+ * Copyright (c) 201 Helge Deller <[email protected]>
+ *
+ */
+
+#ifndef LASI_82596_H
+#define LASI_82596_H
+
+#include "net/net.h"
+#include "hw/net/i82596.h"
+
+#define TYPE_LASI_82596 "lasi_82596"
+#define SYSBUS_I82596(obj) \
+    OBJECT_CHECK(SysBusI82596State, (obj), TYPE_LASI_82596)
+
+typedef struct {
+    SysBusDevice parent_obj;
+
+    I82596State state;
+    uint16_t last_val;
+    int val_index:1;
+} SysBusI82596State;
+
+SysBusI82596State *lasi_82596_init(MemoryRegion *addr_space,
+                                    hwaddr hpa, qemu_irq irq);
+
+#endif
Signature · 1 line
2.23.0
#1 lore raw

PATCH v2 1/6 hw/hppa/dino.c: Improve emulation of Dino PCI chip

In reply to Sven Schnelle

From: Helge Deller <[email protected]>

The tests of the dino chip with the Online-diagnostics CD ("ODE DINOTEST") now succeeds.
Additionally add some qemu trace events.

---
 MAINTAINERS          |  2 +-
 hw/hppa/dino.c       | 94 ++++++++++++++++++++++++++++++++++++++------
 hw/hppa/trace-events |  5 +++
 3 files changed, 88 insertions(+), 13 deletions(-)
MAINTAINERS +1 -1
index 250ce8e7a1..f9541c3305 100644
@@ -874,7 +874,7 @@ F: hw/*/etraxfs_*.c
 
 HP-PARISC Machines
 ------------------
-Dino
+HP B160L
 M: Richard Henderson <[email protected]>
 R: Helge Deller <[email protected]>
 S: Odd Fixes
hw/hppa/dino.c +82 -12

223 lines not on this page · raw message

hw/hppa/trace-events +5 -0
index 4e2acb6176..f943b16c4e 100644
@@ -2,3 +2,8 @@
 
 # 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"
Signature · 1 line
2.23.0
#7 lore raw

PATCH v2 4/6 hppa: add emulation of LASI PS2 controllers

In reply to Sven Schnelle
---
 hw/hppa/Kconfig            |   1 +
 hw/hppa/lasi.c             |  10 +-
 hw/input/Kconfig           |   3 +
 hw/input/Makefile.objs     |   1 +
 hw/input/lasips2.c         | 289 +++++++++++++++++++++++++++++++++++++
 hw/input/ps2.c             |   5 +
 hw/input/trace-events      |   5 +
 include/hw/input/lasips2.h |  16 ++
 include/hw/input/ps2.h     |   1 +
 9 files changed, 330 insertions(+), 1 deletion(-)
 create mode 100644 hw/input/lasips2.c
 create mode 100644 include/hw/input/lasips2.h
hw/hppa/Kconfig +1 -0
index 2a7b38d6d6..7f9be7f25c 100644
@@ -11,3 +11,4 @@ config DINO
     select MC146818RTC
     select LSI_SCSI_PCI
     select LASI_82596
+    select LASIPS2
hw/hppa/lasi.c +9 -1
index 51752589f3..d8d03f95c0 100644
@@ -22,6 +22,7 @@
 #include "hw/net/lasi_82596.h"
 #include "hw/char/parallel.h"
 #include "hw/char/serial.h"
+#include "hw/input/lasips2.h"
 #include "exec/address-spaces.h"
 #include "migration/vmstate.h"
 
@@ -324,6 +325,7 @@ DeviceState *lasi_init(MemoryRegion *address_space)
                      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;
 
@@ -333,8 +335,14 @@ DeviceState *lasi_init(MemoryRegion *address_space)
                 lasi_get_irq(LASI_UART_HPA));
         serial_mm_init(address_space, LASI_UART_HPA + 0x800, 0,
                 serial_irq, 8000000 / 16,
-                serial_hd(1), DEVICE_NATIVE_ENDIAN);
+                serial_hd(0), DEVICE_NATIVE_ENDIAN);
     }
+
+    /* PS/2 Keyboard/Mouse */
+    qemu_irq ps2kbd_irq = qemu_allocate_irq(lasi_set_irq, s,
+            lasi_get_irq(LASI_PS2KBD_HPA));
+    lasips2_init(address_space, LASI_PS2KBD_HPA,  ps2kbd_irq);
+
     return dev;
 }
 
hw/input/Kconfig +3 -0
index 287f08887b..25c77a1b87 100644
@@ -41,3 +41,6 @@ config VHOST_USER_INPUT
 
 config TSC210X
     bool
+
+config LASIPS2
+    select PS2
hw/input/Makefile.objs +1 -0
index a1bc502ed0..f98f635685 100644
@@ -15,3 +15,4 @@ common-obj-$(CONFIG_VHOST_USER_INPUT) += vhost-user-input.o
 obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
 obj-$(CONFIG_PXA2XX) += pxa2xx_keypad.o
 obj-$(CONFIG_TSC210X) += tsc210x.o
+obj-$(CONFIG_LASIPS2) += lasips2.o
hw/input/lasips2.c new file +289 -0

289 lines not on this page · raw message

hw/input/ps2.c +5 -0
index 6c2c7066a6..7b0739aa7f 100644
@@ -192,6 +192,11 @@ static void ps2_reset_queue(PS2State *s)
     q->count = 0;
 }
 
+int ps2_queue_empty(PS2State *s)
+{
+    return s->queue.count == 0;
+}
+
 void ps2_queue_noirq(PS2State *s, int b)
 {
     PS2Queue *q = &s->queue;
hw/input/trace-events +5 -0
index cf072fa2f8..a2888fd10c 100644
@@ -53,3 +53,8 @@ tsc2005_sense(const char *state) "touchscreen sense %s"
 
 # virtio-input.c
 virtio_input_queue_full(void) "queue full"
+
+# lasips2.c
+lasips2_reg_read(unsigned int size, int id, uint64_t addr, const char *name, uint64_t val) "%u %d addr 0x%"PRIx64 "%s -> 0x%"PRIx64
+lasips2_reg_write(unsigned int size, int id, uint64_t addr, const char *name, uint64_t val) "%u %d addr 0x%"PRIx64 "%s <- 0x%"PRIx64
+lasips2_intr(unsigned int val) "%d"
include/hw/input/lasips2.h new file +16 -0
new file mode 100644
index 0000000000..0cd7b59064
@@ -0,0 +1,16 @@
+/*
+ * QEMU LASI PS/2 emulation
+ *
+ * Copyright (c) 2019 Sven Schnelle
+ *
+ */
+#ifndef HW_INPUT_LASIPS2_H
+#define HW_INPUT_LASIPS2_H
+
+#include "exec/hwaddr.h"
+
+#define TYPE_LASIPS2 "lasips2"
+
+void lasips2_init(MemoryRegion *address_space, hwaddr base, qemu_irq irq);
+
+#endif /* HW_INPUT_LASIPS2_H */
include/hw/input/ps2.h +1 -0
index b60455d4f6..35d983897a 100644
@@ -47,5 +47,6 @@ void ps2_queue_3(PS2State *s, int b1, int b2, int b3);
 void ps2_queue_4(PS2State *s, int b1, int b2, int b3, int b4);
 void ps2_keyboard_set_translation(void *opaque, int mode);
 void ps2_mouse_fake_event(void *opaque);
+int ps2_queue_empty(PS2State *s);
 
 #endif /* HW_PS2_H */
Signature · 1 line
2.23.0
#5 lore raw

Re: [PATCH v2 3/6] ps2: accept 'Set Key Make and Break' commands

In reply to Sven Schnelle
Quoted 25 lines · Sven Schnelle

HP-UX sends both the 'Set key make and break (0xfc) and 'Set all key typematic make and break' (0xfa). QEMU response with 'Resend' as it doesn't handle these commands. HP-UX than reports an PS/2 max retransmission exceeded error. Add these commands and just reply with ACK.

---
  hw/input/ps2.c | 6 ++++++
  1 file changed, 6 insertions(+)
hw/input/ps2.c +2 -0
index 67f92f6112..6c2c7066a6 100644
@@ -49,6 +49,8 @@
  #define KBD_CMD_RESET_DISABLE	0xF5	/* reset and disable scanning */
  #define KBD_CMD_RESET_ENABLE   	0xF6    /* reset and enable scanning */
  #define KBD_CMD_RESET		0xFF	/* Reset */
+#define KBD_CMD_SET_MAKE_BREAK  0xFC    /* Set Make and Break mode */
+#define KBD_CMD_SET_TYPEMATIC   0xFA    /* Set Typematic Make and Break mode */
 
  /* Keyboard Replies */
  #define KBD_REPLY_POR		0xAA	/* Power on reset */

hw/input/ps2.c void ps2_write_keyboard(void *opaque, int val) · line 598

Quoted 5 lines
hw/input/ps2.c +2 -0
@@ -592,6 +594,10 @@ void ps2_write_keyboard(void *opaque, int val)
                  KBD_REPLY_ACK,
                  KBD_REPLY_POR);
              break;
+        case KBD_CMD_SET_TYPEMATIC:
+        case KBD_CMD_SET_MAKE_BREAK:

Shouldn't we reset the write state machine too? I'm not sure.

               s->common.write_cmd = -1;
Quoted 6 lines
hw/input/ps2.c +2 -0
+            ps2_queue(&s->common, KBD_REPLY_ACK);
+            break;
          default:
              ps2_queue(&s->common, KBD_REPLY_RESEND);
              break;
Reviewed-by on v2 1/6
#2 lore raw

Re: [PATCH v2 1/6] hw/hppa/dino.c: Improve emulation of Dino PCI chip

In reply to Sven Schnelle
Quoted 101 lines · Sven Schnelle

From: Helge Deller <[email protected]>

The tests of the dino chip with the Online-diagnostics CD ("ODE DINOTEST") now succeeds.
Additionally add some qemu trace events.

---
  MAINTAINERS          |  2 +-
  hw/hppa/dino.c       | 94 ++++++++++++++++++++++++++++++++++++++------
  hw/hppa/trace-events |  5 +++
  3 files changed, 88 insertions(+), 13 deletions(-)
MAINTAINERS +1 -1
index 250ce8e7a1..f9541c3305 100644
@@ -874,7 +874,7 @@ F: hw/*/etraxfs_*.c
 
  HP-PARISC Machines
  ------------------
-Dino
+HP B160L
  M: Richard Henderson <[email protected]>
  R: Helge Deller <[email protected]>
  S: Odd Fixes
hw/hppa/dino.c +24 -4
index ab6969b45f..ec5a71a831 100644
@@ -1,7 +1,7 @@
  /*
- * HP-PARISC Dino PCI chipset emulation.
+ * HP-PARISC Dino PCI chipset emulation, as in B160L and similiar machines
   *
- * (C) 2017 by Helge Deller <[email protected]>
+ * (C) 2017-2019 by Helge Deller <[email protected]>
   *
   * This work is licensed under the GNU GPL license version 2 or later.
   *
@@ -21,6 +21,7 @@
  #include "migration/vmstate.h"
  #include "hppa_sys.h"
  #include "exec/address-spaces.h"
+#include "trace.h"
 
 
  #define TYPE_DINO_PCI_HOST_BRIDGE "dino-pcihost"
@@ -82,11 +83,28 @@
  #define DINO_PCI_HOST_BRIDGE(obj) \
      OBJECT_CHECK(DinoState, (obj), TYPE_DINO_PCI_HOST_BRIDGE)
 
+#define DINO800_REGS ((DINO_TLTIM - DINO_GMASK) / 4)
+static const uint32_t reg800_keep_bits[DINO800_REGS] = {
+            MAKE_64BIT_MASK(0, 1),
+            MAKE_64BIT_MASK(0, 7),
+            MAKE_64BIT_MASK(0, 7),
+            MAKE_64BIT_MASK(0, 8),
+            MAKE_64BIT_MASK(0, 7),
+            MAKE_64BIT_MASK(0, 9),
+            MAKE_64BIT_MASK(0, 32),
+            MAKE_64BIT_MASK(0, 8),
+            MAKE_64BIT_MASK(0, 30),
+            MAKE_64BIT_MASK(0, 25),
+            MAKE_64BIT_MASK(0, 22),
+            MAKE_64BIT_MASK(0, 9),
+};
+
  typedef 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;
@@ -94,8 +112,12 @@ typedef struct DinoState {
      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;
@@ -106,8 +128,6 @@ typedef struct DinoState {
      MemoryRegion bm_ram_alias;
      MemoryRegion bm_pci_alias;
      MemoryRegion bm_cpu_alias;
-
-    MemoryRegion cpu0_eir_mem;
  } DinoState;
 
  /*

hw/hppa/dino.c static void gsc_to_pci_forwarding(DinoState *s) · line 146

Quoted 5 lines
hw/hppa/dino.c +2 -0
@@ -122,6 +142,8 @@ static void gsc_to_pci_forwarding(DinoState *s)
      tmp = extract32(s->io_control, 7, 2);
      enabled = (tmp == 0x01);
      io_addr_en = s->io_addr_en;
+    /* Mask out first (=firmware) and last (=Dino) areas. */
+    io_addr_en &= 0x7ffffffe;

Or

       io_addr_en &= ~((1 << 31) | (1 << 0));

hw/hppa/dino.c static const VMStateDescription vmstate_dino = {

Quoted 127 lines
hw/hppa/dino.c +48 -6
      memory_region_transaction_begin();
      for (i = 1; i < 31; i++) {
@@ -142,6 +164,8 @@ static bool dino_chip_mem_valid(void *opaque, hwaddr addr,
                                  unsigned size, bool is_write,
                                  MemTxAttrs attrs)
  {
+    bool ret = false;
+
      switch (addr) {
      case DINO_IAR0:
      case DINO_IAR1:
@@ -152,16 +176,22 @@ static bool dino_chip_mem_valid(void *opaque, hwaddr addr,
      case DINO_ICR:
      case DINO_ILR:
      case DINO_IO_CONTROL:
+    case DINO_IO_FBB_EN:
      case DINO_IO_ADDR_EN:
      case DINO_PCI_IO_DATA:
-        return true;
+    case DINO_TOC_ADDR:
+    case DINO_GMASK ... DINO_TLTIM:
+        ret = true;
+        break;
      case DINO_PCI_IO_DATA + 2:
-        return size <= 2;
+        ret = (size <= 2);
+        break;
      case DINO_PCI_IO_DATA + 1:
      case DINO_PCI_IO_DATA + 3:
-        return size == 1;
+        ret = (size == 1);
      }
-    return false;
+    trace_dino_chip_mem_valid(addr, ret);
+    return ret;
  }
 
  static MemTxResult dino_chip_read_with_attrs(void *opaque, hwaddr addr,
@@ -194,6 +224,9 @@ static MemTxResult dino_chip_read_with_attrs(void *opaque, hwaddr addr,
          }
          break;
 
+    case DINO_IO_FBB_EN:
+        val = s->io_fbb_en;
+        break;
      case DINO_IO_ADDR_EN:
          val = s->io_addr_en;
          break;
@@ -227,12 +260,28 @@ static MemTxResult dino_chip_read_with_attrs(void *opaque, hwaddr addr,
      case DINO_IRR1:
          val = s->ilr & s->imr & s->icr;
          break;
+    case DINO_TOC_ADDR:
+        val = s->toc_addr;
+        break;
+    case DINO_GMASK ... DINO_TLTIM:
+        val = s->reg800[(addr - DINO_GMASK) / 4];
+        if (addr == DINO_PAMR) {
+            val &= ~0x01;  /* LSB is hardwired to 0 */
+        }
+        if (addr == DINO_MLTIM) {
+            val &= ~0x07;  /* 3 LSB are hardwired to 0 */
+        }
+        if (addr == DINO_BRDG_FEAT) {
+            val &= ~(0x10710E0ul | 8); /* bits 5-7, 24 & 15 reserved */
+        }
+        break;
 
      default:
          /* Controlled by dino_chip_mem_valid above.  */
          g_assert_not_reached();
      }
 
+    trace_dino_chip_read(addr, val);
      *data = val;
      return ret;
  }
@@ -245,6 +294,9 @@ static MemTxResult dino_chip_write_with_attrs(void *opaque, hwaddr addr,
      AddressSpace *io;
      MemTxResult ret;
      uint16_t ioaddr;
+    int i;
+
+    trace_dino_chip_write(addr, val);
 
      switch (addr) {
      case DINO_IO_DATA ... DINO_PCI_IO_DATA + 3:
@@ -266,9 +318,11 @@ static MemTxResult dino_chip_write_with_attrs(void *opaque, hwaddr addr,
          }
          return ret;
 
+    case DINO_IO_FBB_EN:
+        s->io_fbb_en = val & 0x03;
+        break;
      case DINO_IO_ADDR_EN:
-        /* Never allow first (=firmware) and last (=Dino) areas.  */
-        s->io_addr_en = val & 0x7ffffffe;
+        s->io_addr_en = val;
          gsc_to_pci_forwarding(s);
          break;
      case DINO_IO_CONTROL:
@@ -292,6 +346,10 @@ static MemTxResult dino_chip_write_with_attrs(void *opaque, hwaddr addr,
          /* Any write to IPR clears the register.  */
          s->ipr = 0;
          break;
+    case DINO_TOC_ADDR:
+        /* IO_COMMAND of CPU with client_id bits */
+        s->toc_addr = 0xFFFA0030 | (val & 0x1e000);
+        break;
 
      case DINO_ILR:
      case DINO_IRR0:
@@ -299,6 +357,12 @@ static MemTxResult dino_chip_write_with_attrs(void *opaque, hwaddr addr,
          /* These registers are read-only.  */
          break;
 
+    case DINO_GMASK ... DINO_TLTIM:
+        i = (addr - DINO_GMASK) / 4;
+        val &= reg800_keep_bits[i];
+        s->reg800[i] = val;
+        break;
+
      default:
          /* Controlled by dino_chip_mem_valid above.  */
          g_assert_not_reached();
@@ -332,8 +396,10 @@ static const VMStateDescription vmstate_dino = {

You changed the migration state, shouldn't you update its version?

           .version_id = 2,

Except this question,

Quoted 52 lines
hw/hppa/dino.c +8 -2
          VMSTATE_UINT32(ipr, DinoState),
          VMSTATE_UINT32(icr, DinoState),
          VMSTATE_UINT32(ilr, DinoState),
+        VMSTATE_UINT32(io_fbb_en, DinoState),
          VMSTATE_UINT32(io_addr_en, DinoState),
          VMSTATE_UINT32(io_control, DinoState),
+        VMSTATE_UINT32(toc_addr, DinoState),
          VMSTATE_END_OF_LIST()
      }
  };
@@ -362,14 +428,16 @@ static const MemoryRegionOps dino_config_data_ops = {
 
  static uint64_t dino_config_addr_read(void *opaque, hwaddr addr, unsigned len)
  {
-    PCIHostState *s = opaque;
-    return s->config_reg;
+    DinoState *s = opaque;
+    return s->config_reg_dino;
  }
 
  static void dino_config_addr_write(void *opaque, hwaddr addr,
                                     uint64_t val, unsigned len)
  {
      PCIHostState *s = opaque;
+    DinoState *ds = opaque;
+    ds->config_reg_dino = val; /* keep a copy of original value */
      s->config_reg = val & ~3U;
  }
 
@@ -453,6 +521,8 @@ PCIBus *dino_init(MemoryRegion *addr_space,
 
      dev = qdev_create(NULL, TYPE_DINO_PCI_HOST_BRIDGE);
      s = DINO_PCI_HOST_BRIDGE(dev);
+    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,
hw/hppa/trace-events +5 -0
index 4e2acb6176..f943b16c4e 100644
@@ -2,3 +2,8 @@
 
  # 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"
#6 lore raw

Re: [PATCH v2 3/6] ps2: accept 'Set Key Make and Break' commands

In reply to Philippe Mathieu-Daudé

Hi Philippe,

Quoted 33 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Sven Schnelle

HP-UX sends both the 'Set key make and break (0xfc) and 'Set all key typematic make and break' (0xfa). QEMU response with 'Resend' as it doesn't handle these commands. HP-UX than reports an PS/2 max retransmission exceeded error. Add these commands and just reply with ACK.

---
  hw/input/ps2.c | 6 ++++++
  1 file changed, 6 insertions(+)
hw/input/ps2.c +2 -0
index 67f92f6112..6c2c7066a6 100644
@@ -49,6 +49,8 @@
  #define KBD_CMD_RESET_DISABLE	0xF5	/* reset and disable scanning */
  #define KBD_CMD_RESET_ENABLE   	0xF6    /* reset and enable scanning */
  #define KBD_CMD_RESET		0xFF	/* Reset */
+#define KBD_CMD_SET_MAKE_BREAK  0xFC    /* Set Make and Break mode */
+#define KBD_CMD_SET_TYPEMATIC   0xFA    /* Set Typematic Make and Break mode */
  /* Keyboard Replies */
  #define KBD_REPLY_POR		0xAA	/* Power on reset */

hw/input/ps2.c void ps2_write_keyboard(void *opaque, int val) · line 598

Quoted 5 lines
hw/input/ps2.c +2 -0
@@ -592,6 +594,10 @@ void ps2_write_keyboard(void *opaque, int val)
                  KBD_REPLY_ACK,
                  KBD_REPLY_POR);
              break;
+        case KBD_CMD_SET_TYPEMATIC:
+        case KBD_CMD_SET_MAKE_BREAK:

Shouldn't we reset the write state machine too? I'm not sure.

Quoted 1 line
               s->common.write_cmd = -1;

Looking at this again i think the KBD_CMD_SET_TYPEMATIC case needs to assign common.write_cmd to properly handle the addtional data byte. For KBD_CMD_SET_MAKE_BREAK i think that's not neccessary. I'll fix that up.

Quoted 8 lines

hw/input/ps2.c void ps2_write_keyboard(void *opaque, int val) · line 603

Quoted 7 lines
hw/input/ps2.c +2 -0
+            ps2_queue(&s->common, KBD_REPLY_ACK);
+            break;
          default:
              ps2_queue(&s->common, KBD_REPLY_RESEND);
              break;

Thanks
Sven