kern

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