kern

view src/main.c @ 23:5454cee245a3

- fixed tragic mistake in the initial kernel image mapping - page table modifications by disabling paging first - page allocation completed
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 04 Apr 2011 23:34:06 +0300
parents 8be069e6bb05
children 387078ef5c0d
line source
1 #include <stdio.h>
2 #include "mboot.h"
3 #include "vid.h"
4 #include "term.h"
5 #include "asmops.h"
6 #include "segm.h"
7 #include "intr.h"
8 #include "vm.h"
10 static void do_nothing();
12 /* special keys */
13 enum {
14 LALT, RALT,
15 LCTRL, RCTRL,
16 LSHIFT, RSHIFT,
17 F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
18 CAPSLK, NUMLK, SCRLK, SYSRQ,
19 ESC = 27,
20 INSERT, DEL, HOME, END, PGUP, PGDN, LEFT, RIGHT, UP, DOWN,
21 NUM_DOT, NUM_ENTER, NUM_PLUS, NUM_MINUS, NUM_MUL, NUM_DIV,
22 NUM_0, NUM_1, NUM_2, NUM_3, NUM_4, NUM_5, NUM_6, NUM_7, NUM_8, NUM_9,
23 BACKSP = 127
24 };
26 /* table with rough translations from set 1 scancodes to ASCII-ish */
27 static int keycodes[] = {
28 0, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', /* 0 - e */
29 '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* f - 1c */
30 LCTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', /* 1d - 29 */
31 LSHIFT, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', RSHIFT, /* 2a - 36 */
32 NUM_MUL, LALT, ' ', CAPSLK, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, /* 37 - 44 */
33 NUMLK, SCRLK, NUM_7, NUM_8, NUM_9, NUM_MINUS, NUM_4, NUM_5, NUM_6, NUM_PLUS, /* 45 - 4e */
34 NUM_1, NUM_2, NUM_3, NUM_0, NUM_DOT, SYSRQ, 0, 0, F11, F12, /* 4d - 58 */
35 0, 0, 0, 0, 0, 0, 0, /* 59 - 5f */
36 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6f */
37 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 70 - 7f */
38 };
40 void kmain(struct mboot_info *mbinf)
41 {
42 clear_scr();
44 /* pointless verbal diarrhea */
45 if(mbinf->flags & MB_LDRNAME) {
46 printf("loaded by: %s\n", mbinf->boot_loader_name);
47 }
48 if(mbinf->flags & MB_CMDLINE) {
49 printf("kernel command line: %s\n", mbinf->cmdline);
50 }
52 puts("kernel starting up");
54 init_segm();
55 init_intr();
57 /* silence the blasted timer interrupt */
58 interrupt(32, do_nothing);
60 init_vm(mbinf);
62 dbg_print_vm(MEM_USER);
63 dbg_print_vm(MEM_KERNEL);
65 for(;;) {
66 char c, keypress;
67 do {
68 inb(keypress, 0x64);
69 } while(!(keypress & 1));
70 inb(c, 0x60);
71 if(!(c & 0x80)) {
72 putchar(keycodes[(int)c]);
73 }
74 }
75 }
77 static void do_nothing()
78 {
79 }