kern

view src/main.c @ 12:eaec918de072

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