kernel

hobby kernel
git clone git://git.evenfri.duckdns.org/kernel.git
Log | Files | Refs | README | LICENSE

commit d4f6abb9a55834c28d95bb2c6d951ec897606c0d
parent d6d3327785708026b67e49a0e674f9c48c10a9e4
Author: evenfri <evenfri256@gmail.com>
Date:   Sun,  2 Aug 2026 21:27:41 +0800

fix keyboard scancodes

Diffstat:
Minit.c | 1-
Mkeyboard/keyboard.c | 25+++++++++++++------------
Mtty.c | 2--
3 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/init.c b/init.c @@ -1,4 +1,3 @@ -#include <stdint.h> #include <multiboot.h> #include <fns.h> #include <keyboard/keyboard.h> diff --git a/keyboard/keyboard.c b/keyboard/keyboard.c @@ -1,7 +1,7 @@ #include <fns.h> #include "keyboard.h" -unsigned int shift_state = 0;; +unsigned int shift_state = 0; unsigned char buf[buf_size]; unsigned int buf_head = 0; @@ -16,23 +16,24 @@ const char lower_scancodes[128] = { const char upper_scancodes[128] = { 0, 0, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', - '+', '\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', - '{', '}', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', - ':', '\"', '~', 0, '|', 'z', 'x', 'c', 'v', 'b', 'n', 'm', '<', + '+', '\b', '\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', + '{', '}', '\n', 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', + ':', '\"', '~', 0, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0}; extern void keyboard_asm(void); char keyboard_read(void) { - while (buf_head == buf_tail) { - asm volatile("hlt"); + while (1) { + asm volatile("cli"); + if (buf_head != buf_tail) { + char ch = buf[buf_head]; + buf_head = (buf_head + 1) % buf_size; + asm volatile("sti"); + return ch; + } + asm volatile("sti; hlt"); } - - char ch = buf[buf_head]; - - buf_head = (buf_head + 1) % buf_size; - - return ch; } void keyboard_handler(void) { diff --git a/tty.c b/tty.c @@ -1,5 +1,3 @@ -#include <stdint.h> -#include <stddef.h> #include <dat.h> #include <fns.h>