1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:27:44 +00:00

Kernel: Untie PS2 mouse and keyboard devices from i8042 implementation

To ensure actual PS2 code is not tied to the i8042 code, we make them
separated in the following ways:
- 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 simple abstraction layer is added between the PS2 command set which
  devices could use and the actual implementation low-level commands.
  This means that the code in PS2MouseDevice and PS2KeyboardDevice
  classes is no longer tied to i8042 implementation-specific commands,
  so now these objects could send PS2 commands to their PS2 controller
  and get a PS2Response which abstracts the given response too.
This commit is contained in:
Liav A 2023-05-12 18:04:01 +03:00 committed by Andrew Kaster
parent d276cac82c
commit 89a8920764
13 changed files with 392 additions and 272 deletions

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/AtomicRefCounted.h>
#include <AK/DistinctNumeric.h>
#include <AK/Error.h>
#include <AK/IntrusiveList.h>
#include <AK/NonnullRefPtr.h>
@ -20,8 +21,25 @@ class SerialIOController : public AtomicRefCounted<SerialIOController> {
friend class HIDManagement;
public:
enum class DeviceCommand : u8 {
GetDeviceID,
SetSampleRate,
EnablePacketStreaming,
DisablePacketStreaming,
SetDefaults,
};
AK_TYPEDEF_DISTINCT_ORDERED_ID(size_t, PortIndex);
virtual ~SerialIOController() = default;
virtual ErrorOr<void> reset_device(PortIndex) = 0;
virtual ErrorOr<void> send_command(PortIndex, DeviceCommand command) = 0;
virtual ErrorOr<void> send_command(PortIndex, DeviceCommand command, u8 data) = 0;
virtual ErrorOr<u8> read_from_device(PortIndex) = 0;
virtual ErrorOr<void> prepare_for_input(PortIndex) = 0;
protected:
SerialIOController() = default;