kern
view src/main.c @ 27:7795225808b3
moved enable_intr out of init_intr and after the kernel initialization is completed
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 09 Apr 2011 07:22:27 +0300 |
parents | 387078ef5c0d |
children | 3ed041d07ae1 |
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 "mem.h"
9 #include "vm.h"
11 static void do_nothing();
13 /* special keys */
14 enum {
15 LALT, RALT,
16 LCTRL, RCTRL,
17 LSHIFT, RSHIFT,
18 F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
19 CAPSLK, NUMLK, SCRLK, SYSRQ,
20 ESC = 27,
21 INSERT, DEL, HOME, END, PGUP, PGDN, LEFT, RIGHT, UP, DOWN,
22 NUM_DOT, NUM_ENTER, NUM_PLUS, NUM_MINUS, NUM_MUL, NUM_DIV,
23 NUM_0, NUM_1, NUM_2, NUM_3, NUM_4, NUM_5, NUM_6, NUM_7, NUM_8, NUM_9,
24 BACKSP = 127
25 };
27 /* table with rough translations from set 1 scancodes to ASCII-ish */
28 static int keycodes[] = {
29 0, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', /* 0 - e */
30 '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* f - 1c */
31 LCTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', /* 1d - 29 */
32 LSHIFT, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', RSHIFT, /* 2a - 36 */
33 NUM_MUL, LALT, ' ', CAPSLK, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, /* 37 - 44 */
34 NUMLK, SCRLK, NUM_7, NUM_8, NUM_9, NUM_MINUS, NUM_4, NUM_5, NUM_6, NUM_PLUS, /* 45 - 4e */
35 NUM_1, NUM_2, NUM_3, NUM_0, NUM_DOT, SYSRQ, 0, 0, F11, F12, /* 4d - 58 */
36 0, 0, 0, 0, 0, 0, 0, /* 59 - 5f */
37 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6f */
38 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 70 - 7f */
39 };
41 void kmain(struct mboot_info *mbinf)
42 {
43 clear_scr();
45 /* pointless verbal diarrhea */
46 if(mbinf->flags & MB_LDRNAME) {
47 printf("loaded by: %s\n", mbinf->boot_loader_name);
48 }
49 if(mbinf->flags & MB_CMDLINE) {
50 printf("kernel command line: %s\n", mbinf->cmdline);
51 }
53 puts("kernel starting up");
55 init_segm();
56 init_intr();
58 /* silence the blasted timer interrupt */
59 interrupt(32, do_nothing);
61 /* initialize the physical memory manager */
62 init_mem(mbinf);
63 /* initialize paging and the virtual memory manager */
64 init_vm();
66 /* initialization complete, enable interrupts */
67 enable_intr();
69 dbg_print_vm(MEM_USER);
70 dbg_print_vm(MEM_KERNEL);
72 for(;;) {
73 char c, keypress;
74 do {
75 inb(keypress, 0x64);
76 } while(!(keypress & 1));
77 inb(c, 0x60);
78 if(!(c & 0x80)) {
79 putchar(keycodes[(int)c]);
80 }
81 }
82 }
84 static void do_nothing()
85 {
86 }