diff options
author | Marvin Borner | 2020-11-14 22:27:59 +0100 |
---|---|---|
committer | Marvin Borner | 2020-11-14 22:27:59 +0100 |
commit | 0621c44e439bedf034399e1bff139ef506039eba (patch) | |
tree | 68e69323391e5c4725fa6ef2d16e17e6664011b4 /kernel/drivers | |
parent | 1af60d64fb97cfadab39b9d3e86248473cac0693 (diff) |
Some fixes
I WAS BUG-SEARCHING FOR SEVERAL HOURS
WHYYYY, WHEEERE, AAAAAH
Diffstat (limited to 'kernel/drivers')
-rw-r--r-- | kernel/drivers/interrupts.c | 3 | ||||
-rw-r--r-- | kernel/drivers/keyboard.c | 40 | ||||
-rw-r--r-- | kernel/drivers/mouse.c | 25 | ||||
-rw-r--r-- | kernel/drivers/rtl8139.c | 4 |
4 files changed, 23 insertions, 49 deletions
diff --git a/kernel/drivers/interrupts.c b/kernel/drivers/interrupts.c index b0751d6..dd10ac6 100644 --- a/kernel/drivers/interrupts.c +++ b/kernel/drivers/interrupts.c @@ -13,6 +13,9 @@ * IDT */ +struct idt_entry idt[256] = { 0 }; +struct idt_ptr idt_ptr = { 0 }; + void idt_set_gate(u8 num, u32 base, u16 sel, u8 flags) { // Specify the interrupt routine's base address diff --git a/kernel/drivers/keyboard.c b/kernel/drivers/keyboard.c index 67e0a72..ac97d36 100644 --- a/kernel/drivers/keyboard.c +++ b/kernel/drivers/keyboard.c @@ -8,11 +8,10 @@ #include <print.h> #include <sys.h> -char keymap[128]; -struct event_keyboard *event; +static struct event_keyboard *event = NULL; -int state = 0; -int merged = 0; +static int state = 0; +static int merged = 0; void keyboard_handler() { int scancode = inb(0x60); @@ -29,7 +28,8 @@ void keyboard_handler() // TODO: "Merge" scancode to linux keycode? /* printf("%x %x = %x\n", scancode, state ? 0xe0 : 0, merged); */ - free(event); + if (event) + free(event); event = malloc(sizeof(*event)); event->magic = KEYBOARD_MAGIC; event->press = (scancode & 0x80) == 0; @@ -58,33 +58,3 @@ void keyboard_install(void) //keyboard_rate(); TODO: Fix keyboard rate? irq_install_handler(1, keyboard_handler); } - -char keymap[128] = { - 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', - '\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', - '\n', 17, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', - 14, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 14, '*', - 0, // Alt key - ' ', // Space bar - 15, // Caps lock - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // F keys - 0, // Num lock - 0, // Scroll lock - 0, // Home key - 0, // Up arrow - 0, // Page up - '-', - 0, // Left arrow - 0, - 0, // Right arrow - '+', - 0, // End key - 0, // Down arrow - 0, // Page down - 0, // Insert key - 0, // Delete key - 0, 0, 0, - 0, // F11 - 0, // F12 - 0, // Other keys -}; diff --git a/kernel/drivers/mouse.c b/kernel/drivers/mouse.c index 9b34b0a..d58fbfc 100644 --- a/kernel/drivers/mouse.c +++ b/kernel/drivers/mouse.c @@ -8,10 +8,10 @@ #include <print.h> #include <sys.h> -char mouse_cycle = 0; -char mouse_byte[3]; +static char mouse_cycle = 0; +static char mouse_byte[3] = { 0 }; -struct event_mouse *event; +static struct event_mouse *event = NULL; void mouse_handler() { @@ -30,7 +30,8 @@ void mouse_handler() case 2: mouse_byte[2] = (char)inb(0x60); - free(event); + if (event) + free(event); event = malloc(sizeof(*event)); event->magic = MOUSE_MAGIC; event->diff_x = mouse_byte[1]; @@ -140,14 +141,14 @@ void mouse_install(void) printf("4th and 5th mouse button support!\n"); /* TODO: Fix mouse laggyness - mouse_write(0xE8); - mouse_read(); - mouse_write(0x03); - mouse_read(); - mouse_write(0xF3); - mouse_read(); - mouse_write(200); - mouse_read(); */ + mouse_write(0xE8); + mouse_read(); + mouse_write(0x03); + mouse_read(); + mouse_write(0xF3); + mouse_read(); + mouse_write(200); + mouse_read(); */ // Enable mouse mouse_write(0xF4); diff --git a/kernel/drivers/rtl8139.c b/kernel/drivers/rtl8139.c index b870825..fb60865 100644 --- a/kernel/drivers/rtl8139.c +++ b/kernel/drivers/rtl8139.c @@ -12,9 +12,9 @@ #include <rtl8139.h> static int rtl_irq = 0; -static u8 mac[6]; +static u8 mac[6] = { 0 }; static u8 *last_packet = NULL; -static u8 *rtl_rx_buffer; +static u8 *rtl_rx_buffer = NULL; static u32 rtl_device_pci = 0; static u32 rtl_iobase = 0; static u32 cur_rx = 0; |