kern
view src/main.c @ 10:b11a86695493
interrupt handling
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 18 Feb 2011 08:42:32 +0200 |
parents | 611b2d66420b |
children | eaec918de072 |
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 for(;;) {
50 char c, keypress;
51 do {
52 inb(keypress, 0x64);
53 } while(!(keypress & 1));
54 inb(c, 0x60);
55 if(!(c & 0x80)) {
56 putchar(keycodes[(int)c]);
57 }
58 }
59 }