kern

view src/main.c @ 41:928b0ebfff4d

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