summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-01-24 19:45:53 -0500
committerBenji Dial <benji6283@gmail.com>2021-01-24 19:46:51 -0500
commit782cfaa0e3f44f8c8089a7c6a148149bece0a515 (patch)
tree51d186e253736b93d8632a2efdfaf2af16dca9d1 /src
parentbce944d1498eaa3b6940ee234c863b3548a66b37 (diff)
downloadportland-os-782cfaa0e3f44f8c8089a7c6a148149bece0a515.tar.gz
making keyboard driver spin by checking if scanbyte has changed rather than by a decrement loop
Diffstat (limited to 'src')
-rw-r--r--src/kernel/kbd.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/kernel/kbd.c b/src/kernel/kbd.c
index 29c0350..f7158bb 100644
--- a/src/kernel/kbd.c
+++ b/src/kernel/kbd.c
@@ -78,11 +78,15 @@ void init_kbd() {
drives->free_file(drives, stf);
}
+static uint8_t last_code_byte = 0;
static inline uint8_t get_next_code_byte() {
- for (uint32_t spin = 0; spin < 10000000; ++spin)
- ;
- return inb(PS2_DATA);
+ uint8_t cb;
+ do
+ cb = inb(PS2_DATA);
+ while (cb == last_code_byte);
+ last_code_byte = cb;
+ return cb;
}
static enum key_modifiers_t keymods = 0;
@@ -90,6 +94,7 @@ static enum key_modifiers_t keymods = 0;
void on_kbd_isr() {
//logf(LOG_INFO, "on_kbd_isr()");
while (inb(PS2_CMD) & PS2S_CODE_READY) {
+ last_code_byte = 0;
uint8_t code[256];
uint8_t code_i = 0;
sub_table: