kern

view src/main.c @ 14:a5176aa334c3

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