kern
view src/main.c @ 6:7e40f14617ed
forgot to add stdarg.h and stdlib.c
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 13 Jan 2011 20:24:10 +0200 |
parents | ebe5e0e44a9d |
children | 611b2d66420b |
line source
1 #include <stdio.h>
2 #include "vid.h"
3 #include "term.h"
4 #include <asmops.h>
6 /* special keys */
7 enum {
8 LALT, RALT,
9 LCTRL, RCTRL,
10 LSHIFT, RSHIFT,
11 F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
12 CAPSLK, NUMLK, SCRLK, SYSRQ,
13 ESC = 27,
14 INSERT, DEL, HOME, END, PGUP, PGDN, LEFT, RIGHT, UP, DOWN,
15 NUM_DOT, NUM_ENTER, NUM_PLUS, NUM_MINUS, NUM_MUL, NUM_DIV,
16 NUM_0, NUM_1, NUM_2, NUM_3, NUM_4, NUM_5, NUM_6, NUM_7, NUM_8, NUM_9,
17 BACKSP = 127
18 };
20 /* table with rough translations from set 1 scancodes to ASCII-ish */
21 static int keycodes[] = {
22 0, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', /* 0 - e */
23 '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* f - 1c */
24 LCTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', /* 1d - 29 */
25 LSHIFT, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', RSHIFT, /* 2a - 36 */
26 NUM_MUL, LALT, ' ', CAPSLK, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, /* 37 - 44 */
27 NUMLK, SCRLK, NUM_7, NUM_8, NUM_9, NUM_MINUS, NUM_4, NUM_5, NUM_6, NUM_PLUS, /* 45 - 4e */
28 NUM_1, NUM_2, NUM_3, NUM_0, NUM_DOT, SYSRQ, 0, 0, F11, F12, /* 4d - 58 */
29 0, 0, 0, 0, 0, 0, 0, /* 59 - 5f */
30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6f */
31 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 70 - 7f */
32 };
35 void kmain(void)
36 {
37 clear_scr();
38 puts("kernel starting up");
40 set_text_color(YELLOW);
41 puts("<initialization code goes here>");
42 set_text_color(LTGRAY);
43 puts("hello world!");
45 for(;;) {
46 char c, keypress;
47 do {
48 inb(keypress, 0x64);
49 } while(!(keypress & 1));
50 inb(c, 0x60);
51 if(!(c & 0x80)) {
52 putchar(keycodes[c]);
53 }
54 }
55 }