diff --git a/iso/boot/kernel.elf b/iso/boot/kernel.elf index a95472e..3b8ed7b 100755 Binary files a/iso/boot/kernel.elf and b/iso/boot/kernel.elf differ diff --git a/kb.c b/kb.c new file mode 100644 index 0000000..23e75ca --- /dev/null +++ b/kb.c @@ -0,0 +1,63 @@ +#include "io.h" +#include "stdio.h" +#include "system.h" + +unsigned char kbdus[128] = +{ + 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */ + '9', '0', '-', '=', '\b', /* Backspace */ + '\t', /* Tab */ + 'q', 'w', 'e', 'r', /* 19 */ + 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* Enter key */ + 0, /* 29 - Control */ + 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */ + '\'', '`', 0, /* Left shift */ + '\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */ + 'm', ',', '.', '/', 0, /* Right shift */ + '*', + 0, /* Alt */ + ' ', /* Space bar */ + 0, /* Caps lock */ + 0, /* 59 - F1 key ... > */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, /* < ... F10 */ + 0, /* 69 - Num lock*/ + 0, /* Scroll Lock */ + 0, /* Home key */ + 0, /* Up Arrow */ + 0, /* Page Up */ + '-', + 0, /* Left Arrow */ + 0, + 0, /* Right Arrow */ + '+', + 0, /* 79 - End key*/ + 0, /* Down Arrow */ + 0, /* Page Down */ + 0, /* Insert Key */ + 0, /* Delete Key */ + 0, 0, 0, + 0, /* F11 Key */ + 0, /* F12 Key */ + 0, /* All other keys are undefined */ +}; + +void keyboard_handler() +{ + unsigned char scancode; + + scancode = inb(0x60); + + if (scancode & 0x80) + { + } + else + { + putc(kbdus[scancode]); + } +} + +void keyboard_install() +{ + irq_install_handler(1, keyboard_handler); +} diff --git a/kernel.elf b/kernel.elf index a95472e..3b8ed7b 100755 Binary files a/kernel.elf and b/kernel.elf differ diff --git a/kmain.c b/kmain.c index 82e269e..413814b 100644 --- a/kmain.c +++ b/kmain.c @@ -25,11 +25,13 @@ int kmain(int retvalue) colorputs("Blank OS version 1 iteration 3 minor 20\n", 10); - // TODO: Framebuffer upgrade: color output // TODO: Serial printf to dump registers on kernel panic // TODO: Fix scrolling bug (framebuffer driver) + // TODO: Fix keyboard driver bug (some keys mapped weirdly) + add suport for SHIFT and backspace (deleting character) + // TODO: Grub modules to load programs + // TODO: Folder and build process restructuration - timer_install(); - + //timer_install(); + keyboard_install(); return retvalue; } diff --git a/makefile b/makefile index db6ae9a..fff7463 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -OBJECTS = loader.o kmain.o stdio.o io.o string.o serial.o gdt.o idt.o system.o isr.o irq.o timer.o +OBJECTS = loader.o kmain.o stdio.o io.o string.o serial.o gdt.o idt.o system.o isr.o irq.o timer.o kb.o CC = gcc CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -Wall -Wextra -c LDFLAGS = -T link.ld -melf_i386 diff --git a/os.iso b/os.iso deleted file mode 100644 index 347513c..0000000 Binary files a/os.iso and /dev/null differ diff --git a/system.h b/system.h index 6104e5b..fc459fc 100644 --- a/system.h +++ b/system.h @@ -19,5 +19,6 @@ void irq_install_handler(int irq, void (*handler)(struct regs *r)); void irq_uninstall_handler(int irq); void timer_install(); void delay(int ticks); +void keyboard_install(); #endif