diff options
Diffstat (limited to 'drivers/keyboard.cc')
-rw-r--r-- | drivers/keyboard.cc | 27 |
1 files changed, 20 insertions, 7 deletions
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 <stdlib.h> +/* + * 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() { |