serenity icon indicating copy to clipboard operation
serenity copied to clipboard

Kernel: Re-organize the abstractions around i8042, PS2 and HID concepts

Open supercomputer7 opened this issue 2 years ago • 1 comments
trafficstars

This is another preparation to ensure that the I8042Controller code is agnostic to what the actual PS2 devices are attached to it. We do that with the following changes:

  • Removing HIDController class and instead adding SerialIOController class. The HIDController class was a mistake - there's no such thing in real hardware as host controller only for human interface devices (VirtIO PCI input controller being the exception here, but it could be technically treated as serial IO controller too). Instead, we simply add a new abstraction layer - the SerialIO "bus", which will hold all the code that is related to serial communications with other devices. A PS2 controller is simply a serial IO controller, and the Intel 8042 Controller is simply a specific implementation of a PS2 controller.
  • PS2KeyboardDevice and PS2MouseDevice classes are no longer inheriting from the IRQHandler class. Instead we have specific IRQHandler derived class for the I8042 controller implementation, which is used to ensure that we don't end up mixing PS2 code with low-level interrupt handling functionality. In the future this means that we could add a driver for other PS2 controllers that might have only one interrupt handler but multiple PS2 devices are attached, therefore, making it easier to put the right propagation flow from the controller driver all the way to the HID core code.

A side note - this is just a step before implementing device detection in the I8042 controller code. The goal here is to ensure that we don't assume that a certain type of device is attached to any port, as real hardware doesn't restrict a user from connecting a keyboard to PS2 green port and a mouse to the PS2 purple port, for example. This might help us with detection of an emulated i8042 controller too (because BIOS might emulate a certain type of a device being attached), ofc, with some helping code on the USB controller side too.

supercomputer7 avatar May 05 '23 11:05 supercomputer7

Rebased after CI flakes occurred.

supercomputer7 avatar May 14 '23 17:05 supercomputer7