nuclear@1: #include nuclear@16: #include "mboot.h" nuclear@0: #include "vid.h" nuclear@1: #include "term.h" nuclear@16: #include "asmops.h" nuclear@7: #include "segm.h" nuclear@10: #include "intr.h" nuclear@33: #include "timer.h" nuclear@27: #include "mem.h" nuclear@16: #include "vm.h" nuclear@16: nuclear@2: /* special keys */ nuclear@2: enum { nuclear@2: LALT, RALT, nuclear@2: LCTRL, RCTRL, nuclear@2: LSHIFT, RSHIFT, nuclear@2: F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, nuclear@2: CAPSLK, NUMLK, SCRLK, SYSRQ, nuclear@2: ESC = 27, nuclear@2: INSERT, DEL, HOME, END, PGUP, PGDN, LEFT, RIGHT, UP, DOWN, nuclear@2: NUM_DOT, NUM_ENTER, NUM_PLUS, NUM_MINUS, NUM_MUL, NUM_DIV, nuclear@2: NUM_0, NUM_1, NUM_2, NUM_3, NUM_4, NUM_5, NUM_6, NUM_7, NUM_8, NUM_9, nuclear@2: BACKSP = 127 nuclear@2: }; nuclear@2: nuclear@2: /* table with rough translations from set 1 scancodes to ASCII-ish */ nuclear@2: static int keycodes[] = { nuclear@2: 0, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', /* 0 - e */ nuclear@2: '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* f - 1c */ nuclear@2: LCTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', /* 1d - 29 */ nuclear@2: LSHIFT, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', RSHIFT, /* 2a - 36 */ nuclear@2: NUM_MUL, LALT, ' ', CAPSLK, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, /* 37 - 44 */ nuclear@2: NUMLK, SCRLK, NUM_7, NUM_8, NUM_9, NUM_MINUS, NUM_4, NUM_5, NUM_6, NUM_PLUS, /* 45 - 4e */ nuclear@2: NUM_1, NUM_2, NUM_3, NUM_0, NUM_DOT, SYSRQ, 0, 0, F11, F12, /* 4d - 58 */ nuclear@2: 0, 0, 0, 0, 0, 0, 0, /* 59 - 5f */ nuclear@2: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6f */ nuclear@2: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 70 - 7f */ nuclear@2: }; nuclear@2: nuclear@16: void kmain(struct mboot_info *mbinf) nuclear@0: { nuclear@2: clear_scr(); nuclear@16: nuclear@16: /* pointless verbal diarrhea */ nuclear@16: if(mbinf->flags & MB_LDRNAME) { nuclear@16: printf("loaded by: %s\n", mbinf->boot_loader_name); nuclear@16: } nuclear@16: if(mbinf->flags & MB_CMDLINE) { nuclear@16: printf("kernel command line: %s\n", mbinf->cmdline); nuclear@16: } nuclear@16: nuclear@2: puts("kernel starting up"); nuclear@2: nuclear@7: init_segm(); nuclear@10: init_intr(); nuclear@7: nuclear@33: init_timer(); nuclear@13: nuclear@26: /* initialize the physical memory manager */ nuclear@26: init_mem(mbinf); nuclear@26: /* initialize paging and the virtual memory manager */ nuclear@26: init_vm(); nuclear@19: nuclear@27: /* initialization complete, enable interrupts */ nuclear@27: enable_intr(); nuclear@27: nuclear@2: for(;;) { nuclear@2: char c, keypress; nuclear@2: do { nuclear@2: inb(keypress, 0x64); nuclear@2: } while(!(keypress & 1)); nuclear@2: inb(c, 0x60); nuclear@2: if(!(c & 0x80)) { nuclear@7: putchar(keycodes[(int)c]); nuclear@2: } nuclear@2: } nuclear@0: }