[RFC 0/1] hw/input: add basic support for a PCI PS/2 controller

Liav Albani posted 1 patch 11 months, 3 weeks ago
Failed in applying to current master (apply log)
hw/i386/Kconfig           |   1 +
hw/input/Kconfig          |   5 +
hw/input/meson.build      |   2 +
hw/input/ps2pci.c         | 282 ++++++++++++++++++++++++++++++++++++++
include/hw/input/ps2pci.h |  52 +++++++
5 files changed, 342 insertions(+)
create mode 100644 hw/input/ps2pci.c
create mode 100644 include/hw/input/ps2pci.h
[RFC 0/1] hw/input: add basic support for a PCI PS/2 controller
Posted by Liav Albani 11 months, 3 weeks ago
This small patch I wrote might raise few questions on the motivation to
why someone would write such thing like this - I'll try my best to be
descriptive about this.

I am SerenityOS developer. In that project I mainly work on kernel stuff
for the most part.
Recently I started to fix issues with the HID code in the SerenityOS
kernel and I stumbled upon fixing some issues with our PS/2 abstractions
in relation to hardware implementations (such as the i8042) and the rest
of the HID subsystem. I figured that it would be nice that with strong
abstractions in place that I could write more drivers for other PS2
serial IO controllers.

That's where I started to look into the Linux source code and I found
that sometime in the past, someone wrote a driver for PS/2 controller,
which is connected over the PCI bus. This driver is called pcips2 and
almost nobody touched it since its initial write in 2003 (by now it's 20
years old, so getting hardware to test it might be even harder today!).

Therefore, my goal was to see if I could actually use that driver, and
so I wrote this small patch for letting QEMU to emulate that very old
PS/2 PCI card. If this ever goes into the tree, a SerenityOS kernel
driver could be written too, and will probably be used someday in our
upcoming aarch64 port (probably for the virt machine as it supports the
PCI bus).

As for what it gives, keyboard works perfectly fine. I had some struggle
with interrupts initially (mainly getting "bogus" interrupts).
As for the mouse support - I tried to boot Manjaro live-CD on QEMU with
either both of the "pci-ps2-keyboard" and "pci-ps2-mouse" devices and
also with only "pci-ps2-mouse" - both options resulted in a kernel panic
a few seconds after booting. The panic seemed to be some sort of nullptr
dereference in the linux PS/2 core code, which I still need to debug.

In general, this potentially could benefit multiple projects, which is
the best case I'd imagine - more emulation options for QEMU, more
drivers for SerenityOS, and maybe even fixing issues in PS/2 core (in
Linux) and improving the pcips2 driver code in Linux as well.

Liav Albani (1):
  hw/input: add basic support for a PCI PS/2 controller

 hw/i386/Kconfig           |   1 +
 hw/input/Kconfig          |   5 +
 hw/input/meson.build      |   2 +
 hw/input/ps2pci.c         | 282 ++++++++++++++++++++++++++++++++++++++
 include/hw/input/ps2pci.h |  52 +++++++
 5 files changed, 342 insertions(+)
 create mode 100644 hw/input/ps2pci.c
 create mode 100644 include/hw/input/ps2pci.h

-- 
2.40.1