mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
Kernel: Re-organize the abstractions around i8042, PS2 and HID concepts
The HIDController class is removed 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.
This commit is contained in:
parent
a14dc9b569
commit
d276cac82c
Notes:
sideshowbarker
2024-07-17 09:48:50 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/d276cac82c Pull-request: https://github.com/SerenityOS/serenity/pull/18654 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/BertalanD Reviewed-by: https://github.com/Panky-codes Reviewed-by: https://github.com/kleinesfilmroellchen ✅
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Bus/SerialIO/Controller.h>
|
||||
#include <Kernel/Devices/HID/Controller.h>
|
||||
#include <Kernel/Devices/HID/KeyboardDevice.h>
|
||||
#include <Kernel/Devices/HID/MouseDevice.h>
|
||||
@ -96,7 +97,7 @@ protected:
|
||||
class PS2KeyboardDevice;
|
||||
class PS2MouseDevice;
|
||||
class HIDManagement;
|
||||
class I8042Controller final : public HIDController {
|
||||
class I8042Controller final : public SerialIOController {
|
||||
friend class PS2KeyboardDevice;
|
||||
friend class PS2MouseDevice;
|
||||
|
||||
|
32
Kernel/Bus/SerialIO/Controller.h
Normal file
32
Kernel/Bus/SerialIO/Controller.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class HIDManagement;
|
||||
class SerialIOController : public AtomicRefCounted<SerialIOController> {
|
||||
friend class HIDManagement;
|
||||
|
||||
public:
|
||||
virtual ~SerialIOController() = default;
|
||||
|
||||
protected:
|
||||
SerialIOController() = default;
|
||||
|
||||
private:
|
||||
IntrusiveListNode<SerialIOController, NonnullRefPtr<SerialIOController>> m_list_node;
|
||||
};
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class HIDManagement;
|
||||
class HIDController : public AtomicRefCounted<HIDController> {
|
||||
friend class HIDManagement;
|
||||
|
||||
public:
|
||||
virtual ~HIDController() = default;
|
||||
|
||||
protected:
|
||||
HIDController() = default;
|
||||
|
||||
private:
|
||||
IntrusiveListNode<HIDController, NonnullRefPtr<HIDController>> m_list_node;
|
||||
};
|
||||
|
||||
}
|
@ -155,7 +155,7 @@ UNMAP_AFTER_INIT ErrorOr<void> HIDManagement::enumerate()
|
||||
return {};
|
||||
if (auto result_or_error = i8042_controller->detect_devices(); result_or_error.is_error())
|
||||
return {};
|
||||
m_hid_controllers.with([&](auto& list) {
|
||||
m_hid_serial_io_controllers.with([&](auto& list) {
|
||||
list.append(i8042_controller);
|
||||
});
|
||||
#endif
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/API/KeyCode.h>
|
||||
#include <Kernel/Devices/HID/Controller.h>
|
||||
#include <Kernel/Bus/SerialIO/Controller.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
#include <Kernel/Locking/SpinlockProtected.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
@ -60,7 +60,7 @@ private:
|
||||
size_t m_keyboard_minor_number { 0 };
|
||||
KeyboardClient* m_client { nullptr };
|
||||
|
||||
SpinlockProtected<IntrusiveList<&HIDController::m_list_node>, LockRank::None> m_hid_controllers;
|
||||
SpinlockProtected<IntrusiveList<&SerialIOController::m_list_node>, LockRank::None> m_hid_serial_io_controllers;
|
||||
Spinlock<LockRank::None> m_client_lock;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user