kern

view src/main.c @ 40:710739e33da8

- now read_rtc doesn't try to read weekday as it's probably wrong anyway, and doesn't set yearday either - mktime now fixes yearday and weekday - moved init_timer and init_rtc just before enabling the interrupts in main
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 12 Jun 2011 15:45:21 +0300
parents e70b1ab9613e
children 928b0ebfff4d
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 /* 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 /* initialize the physical memory manager */
59 init_mem(mbinf);
60 /* initialize paging and the virtual memory manager */
61 init_vm();
63 /* initialize the timer and RTC */
64 init_timer();
65 init_rtc();
67 /* initialization complete, enable interrupts */
68 enable_intr();
70 for(;;) {
71 char c, keypress;
72 do {
73 inb(keypress, 0x64);
74 } while(!(keypress & 1));
75 inb(c, 0x60);
76 if(!(c & 0x80)) {
77 putchar(keycodes[(int)c]);
78 }
79 }
80 }