summaryrefslogtreecommitdiff
path: root/kernel/keyboard.c
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-07-08 19:09:31 +0200
committerMichal Idziorek <m.i@gmx.at>2014-07-08 19:09:31 +0200
commitc4cc22b897fed06d040d8fdcc0b40b0f0dcf5bcf (patch)
treeb5be597050a2511841473d0ef2b13308640b9ea6 /kernel/keyboard.c
parent48bdc0e58fa036d6551fe216daaa6dbb390b8c82 (diff)
Further celanup and a little modularization
Diffstat (limited to 'kernel/keyboard.c')
-rw-r--r--kernel/keyboard.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/kernel/keyboard.c b/kernel/keyboard.c
new file mode 100644
index 0000000..d1175c1
--- /dev/null
+++ b/kernel/keyboard.c
@@ -0,0 +1,118 @@
+
+#include "kernel.h"
+#include "console.h"
+
+/// keyboard driver ////
+
+static uint8_t kb_in;
+static int cursor=0;
+static char last_code=0;
+
+void int0(uint8_t in)
+{
+ int i=0;
+ //
+ //print_hex(int_count);
+
+ uint8_t make_codes[]={
+ 0x1e, // A
+ 0x30, // B
+ 0x2e, // C
+ 0x20, // D
+ 0x12, // E
+ 0x21, // F
+ 0x22, // G
+ 0x23, // H
+ 0x17, // I
+ 0x24, // J
+ 0x25, // K
+ 0x26, // L
+ 0x32, // M
+ 0x31, // N
+ 0x18, // O
+ 0x19, // P
+ 0x10, // Q
+ 0x13, // R
+ 0x1F, // S
+ 0x14, // T
+ 0x16, // U
+ 0x2F, // V
+ 0x11, // W
+ 0x2D, // X
+ 0x15, // Y
+ 0x2c, // Z
+ };
+
+ uint8_t break_codes[]={
+ 0x9e, // A
+ 0xb0, // B
+ 0xae, // C
+ 0xa0, // D
+ 0x92, // E
+ 0xa1, // F
+ 0xa2, // G
+ 0xa3, // H
+ 0x97, // I
+ 0xa4, // J
+ 0xa5, // K
+ 0xa6, // L
+ 0xb2, // M
+ 0xb1, // N
+ 0x98, // O
+ 0x99, // P
+ 0x90, // Q
+ 0x93, // R
+ 0x9F, // S
+ 0x94, // T
+ 0x96, // U
+ 0xaF, // V
+ 0x91, // W
+ 0xaD, // X
+ 0x95, // Y
+ 0xac, // Z
+ };
+
+ //if(last_code==*int_count)return;
+
+ for(i=0;i<26;i++)
+ {
+ if(make_codes[i]==in)
+ {
+ print_char_col(cursor,20,'A'+i,0xf);
+ }
+ }
+
+ for(i=0;i<26;i++)
+ {
+ if(break_codes[i]==in)
+ {
+ print_char_col(cursor++,20,'a'+i,SCR_RED);
+ }
+ }
+
+ last_code=in;
+
+}
+
+void int_kb_handler()
+{
+ __asm__("pusha");
+
+ __asm__("in $0x60, %al");
+ __asm__("mov %%al, %0"::"m" (kb_in));
+
+ // scr_nextline();
+ //scr_put_string("irq 1 -> kb scancodes : ");
+ //scr_put_hex(kb_in);
+
+ int0(kb_in); //TODO!!
+
+ __asm__("mov $0x20, %al");
+ __asm__("out %al, $0x20");
+
+ __asm__("popa");
+ __asm__("leave");
+ __asm__("iret");
+
+}
+