forked from Bananymous/banan-os
update main #1
|
@ -12,6 +12,8 @@ namespace Kernel::Input
|
|||
PS2Device();
|
||||
virtual ~PS2Device() {}
|
||||
|
||||
virtual void send_initialize() = 0;
|
||||
|
||||
virtual BAN::StringView name() const override { return m_name; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -28,13 +28,13 @@ namespace Kernel::Input
|
|||
|
||||
public:
|
||||
static BAN::ErrorOr<PS2Keyboard*> create(PS2Controller&);
|
||||
virtual void send_initialize() override;
|
||||
|
||||
virtual void handle_irq() override;
|
||||
virtual void update() override;
|
||||
|
||||
private:
|
||||
PS2Keyboard(PS2Controller& controller);
|
||||
BAN::ErrorOr<void> initialize();
|
||||
|
||||
void append_command_queue(uint8_t);
|
||||
void append_command_queue(uint8_t, uint8_t);
|
||||
|
|
|
@ -180,18 +180,24 @@ namespace Kernel::Input
|
|||
m_devices[0]->set_irq(PS2::IRQ::DEVICE0);
|
||||
m_devices[0]->enable_interrupt();
|
||||
config |= PS2::Config::INTERRUPT_FIRST_PORT;
|
||||
DevFileSystem::get().add_device(m_devices[0]);
|
||||
}
|
||||
if (m_devices[1])
|
||||
{
|
||||
m_devices[1]->set_irq(PS2::IRQ::DEVICE1);
|
||||
m_devices[1]->enable_interrupt();
|
||||
config |= PS2::Config::INTERRUPT_SECOND_PORT;
|
||||
DevFileSystem::get().add_device(m_devices[1]);
|
||||
}
|
||||
|
||||
controller_send_command(PS2::Command::WRITE_CONFIG, config);
|
||||
|
||||
|
||||
for (uint8_t device = 0; device < 2; device++)
|
||||
{
|
||||
if (m_devices[device] == nullptr)
|
||||
continue;
|
||||
m_devices[device]->send_initialize();
|
||||
DevFileSystem::get().add_device(m_devices[device]);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@ namespace Kernel::Input
|
|||
PS2Keyboard* keyboard = new PS2Keyboard(controller);
|
||||
if (keyboard == nullptr)
|
||||
return BAN::Error::from_errno(ENOMEM);
|
||||
BAN::ScopeGuard guard([keyboard] { delete keyboard; });
|
||||
TRY(keyboard->initialize());
|
||||
guard.disable();
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
|
@ -69,12 +66,11 @@ namespace Kernel::Input
|
|||
}
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> PS2Keyboard::initialize()
|
||||
void PS2Keyboard::send_initialize()
|
||||
{
|
||||
append_command_queue(Command::SET_LEDS, 0x00);
|
||||
append_command_queue(Command::SCANCODE, PS2::KBScancode::SET_SCANCODE_SET2);
|
||||
append_command_queue(Command::ENABLE_SCANNING);
|
||||
return {};
|
||||
}
|
||||
|
||||
void PS2Keyboard::update()
|
||||
|
|
Loading…
Reference in New Issue