kern

annotate src/main.c @ 29:8ea6debe4265

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