kern
diff src/main.c @ 2:86781ef20689
added hardware scrolling, memset16 and temporary keyboard input for testing
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 04 Dec 2010 08:04:43 +0200 |
parents | ebe5e0e44a9d |
children | 611b2d66420b |
line diff
1.1 --- a/src/main.c Thu Dec 02 08:45:41 2010 +0200 1.2 +++ b/src/main.c Sat Dec 04 08:04:43 2010 +0200 1.3 @@ -1,10 +1,55 @@ 1.4 #include <stdio.h> 1.5 #include "vid.h" 1.6 #include "term.h" 1.7 +#include <asmops.h> 1.8 + 1.9 +/* special keys */ 1.10 +enum { 1.11 + LALT, RALT, 1.12 + LCTRL, RCTRL, 1.13 + LSHIFT, RSHIFT, 1.14 + F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, 1.15 + CAPSLK, NUMLK, SCRLK, SYSRQ, 1.16 + ESC = 27, 1.17 + INSERT, DEL, HOME, END, PGUP, PGDN, LEFT, RIGHT, UP, DOWN, 1.18 + NUM_DOT, NUM_ENTER, NUM_PLUS, NUM_MINUS, NUM_MUL, NUM_DIV, 1.19 + NUM_0, NUM_1, NUM_2, NUM_3, NUM_4, NUM_5, NUM_6, NUM_7, NUM_8, NUM_9, 1.20 + BACKSP = 127 1.21 +}; 1.22 + 1.23 +/* table with rough translations from set 1 scancodes to ASCII-ish */ 1.24 +static int keycodes[] = { 1.25 + 0, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', /* 0 - e */ 1.26 + '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* f - 1c */ 1.27 + LCTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', /* 1d - 29 */ 1.28 + LSHIFT, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', RSHIFT, /* 2a - 36 */ 1.29 + NUM_MUL, LALT, ' ', CAPSLK, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, /* 37 - 44 */ 1.30 + NUMLK, SCRLK, NUM_7, NUM_8, NUM_9, NUM_MINUS, NUM_4, NUM_5, NUM_6, NUM_PLUS, /* 45 - 4e */ 1.31 + NUM_1, NUM_2, NUM_3, NUM_0, NUM_DOT, SYSRQ, 0, 0, F11, F12, /* 4d - 58 */ 1.32 + 0, 0, 0, 0, 0, 0, 0, /* 59 - 5f */ 1.33 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6f */ 1.34 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 70 - 7f */ 1.35 +}; 1.36 + 1.37 1.38 void kmain(void) 1.39 { 1.40 - clear_scr(0); 1.41 - set_text_color(LTRED); 1.42 + clear_scr(); 1.43 + puts("kernel starting up"); 1.44 + 1.45 + set_text_color(YELLOW); 1.46 + puts("<initialization code goes here>"); 1.47 + set_text_color(LTGRAY); 1.48 puts("hello world!"); 1.49 + 1.50 + for(;;) { 1.51 + char c, keypress; 1.52 + do { 1.53 + inb(keypress, 0x64); 1.54 + } while(!(keypress & 1)); 1.55 + inb(c, 0x60); 1.56 + if(!(c & 0x80)) { 1.57 + putchar(keycodes[c]); 1.58 + } 1.59 + } 1.60 }