1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 17:27:34 +00:00

Kernel: Add I8042Controller to detect and manage PS/2 devices

Rework the PS/2 keyboard and mouse drivers to use a common 8042
controller driver. Also, reset and reconfigure the 8042 controller
as they are not guaranteed to be in the state that we expect.
This commit is contained in:
Tom 2020-11-07 12:09:28 -07:00 committed by Andreas Kling
parent e1c27c16d8
commit 91db31880f
8 changed files with 617 additions and 261 deletions

View file

@ -31,6 +31,7 @@
#include <AK/Types.h>
#include <Kernel/API/KeyCode.h>
#include <Kernel/Devices/CharacterDevice.h>
#include <Kernel/Devices/I8042Controller.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Random.h>
#include <LibKeyboard/CharacterMap.h>
@ -40,17 +41,19 @@ namespace Kernel {
class KeyboardClient;
class KeyboardDevice final : public IRQHandler
, public CharacterDevice {
, public CharacterDevice
, public I8042Device {
AK_MAKE_ETERNAL
public:
using Event = KeyEvent;
static void initialize();
static KeyboardDevice& the();
virtual ~KeyboardDevice() override;
KeyboardDevice();
bool initialize();
void set_client(KeyboardClient* client) { m_client = client; }
void set_maps(const Keyboard::CharacterMapData& character_map, const String& character_map_name);
@ -64,6 +67,13 @@ public:
virtual const char* purpose() const override { return class_name(); }
// ^I8042Device
virtual void irq_handle_byte_read(u8 byte) override;
virtual void enable_interrupts() override
{
enable_irq();
}
private:
// ^IRQHandler
virtual void handle_irq(const RegisterState&) override;
@ -80,7 +90,9 @@ private:
m_modifiers &= ~modifier;
}
I8042Controller& m_controller;
KeyboardClient* m_client { nullptr };
mutable SpinLock<u8> m_queue_lock;
CircularQueue<Event, 16> m_queue;
u8 m_modifiers { 0 };
bool m_caps_lock_on { false };