mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-08 23:42:53 +03:00
89a8920764
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.
51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/AtomicRefCounted.h>
|
|
#include <AK/DistinctNumeric.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:
|
|
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;
|
|
|
|
private:
|
|
IntrusiveListNode<SerialIOController, NonnullRefPtr<SerialIOController>> m_list_node;
|
|
};
|
|
|
|
}
|