From 02a703e8dca690780d6e00198274a2139e89f01a Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 3 Mar 2021 11:43:43 +0200 Subject: Add some comments to keyboard driver --- drivers/keyboard.cc | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'drivers/keyboard.cc') diff --git a/drivers/keyboard.cc b/drivers/keyboard.cc index 268ce2b..09fd4e9 100644 --- a/drivers/keyboard.cc +++ b/drivers/keyboard.cc @@ -1,15 +1,28 @@ #include "keyboard.h" #include +/* + * https://wiki.osdev.org/%228042%22_PS/2_Controller + * https://wiki.osdev.org/PS/2_Keyboard + */ + +constexpr uint8_t comm_enable_first_ps2 = 0xae; +constexpr uint8_t comm_read_ctrl_config = 0x20; +constexpr uint8_t comm_write_ctrl_config = 0x60; + +constexpr uint8_t dat_enable_scanning = 0xf4; + Keyboard::Keyboard() : InterruptHandler(0x01) { // eat all previous keystrikes - while (commandport.read() & 0x1) dataport.read(); - commandport.write(0xae); // ??? - commandport.write(0x20); // get state ??? - auto status = (dataport.read() | 1) & ~0x10; - commandport.write(0x60); // set state ??? - dataport.write(status); // ??? - dataport.write(0xf4); // ??? + while (commstatport.read() & 0x1) { + [[maybe_unused]] auto _c = dataport.read(); + } + commstatport.write(comm_enable_first_ps2); + commstatport.write(comm_read_ctrl_config); + const uint8_t conf = (dataport.read() | 1) & ~0x10; + commstatport.write(comm_write_ctrl_config); + dataport.write(conf); + dataport.write(dat_enable_scanning); } void Keyboard::trigger() { -- cgit v1.2.1