kern

annotate src/main.c @ 13:6c9138a87e02

added register dump in panic()
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 23 Feb 2011 00:12:36 +0200
parents eaec918de072
children 2cbc2b922e49
rev   line source
nuclear@1 1 #include <stdio.h>
nuclear@0 2 #include "vid.h"
nuclear@1 3 #include "term.h"
nuclear@2 4 #include <asmops.h>
nuclear@7 5 #include "segm.h"
nuclear@10 6 #include "intr.h"
nuclear@13 7 #include "panic.h"
nuclear@2 8
nuclear@2 9 /* special keys */
nuclear@2 10 enum {
nuclear@2 11 LALT, RALT,
nuclear@2 12 LCTRL, RCTRL,
nuclear@2 13 LSHIFT, RSHIFT,
nuclear@2 14 F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
nuclear@2 15 CAPSLK, NUMLK, SCRLK, SYSRQ,
nuclear@2 16 ESC = 27,
nuclear@2 17 INSERT, DEL, HOME, END, PGUP, PGDN, LEFT, RIGHT, UP, DOWN,
nuclear@2 18 NUM_DOT, NUM_ENTER, NUM_PLUS, NUM_MINUS, NUM_MUL, NUM_DIV,
nuclear@2 19 NUM_0, NUM_1, NUM_2, NUM_3, NUM_4, NUM_5, NUM_6, NUM_7, NUM_8, NUM_9,
nuclear@2 20 BACKSP = 127
nuclear@2 21 };
nuclear@2 22
nuclear@2 23 /* table with rough translations from set 1 scancodes to ASCII-ish */
nuclear@2 24 static int keycodes[] = {
nuclear@2 25 0, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', /* 0 - e */
nuclear@2 26 '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* f - 1c */
nuclear@2 27 LCTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', /* 1d - 29 */
nuclear@2 28 LSHIFT, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', RSHIFT, /* 2a - 36 */
nuclear@2 29 NUM_MUL, LALT, ' ', CAPSLK, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, /* 37 - 44 */
nuclear@2 30 NUMLK, SCRLK, NUM_7, NUM_8, NUM_9, NUM_MINUS, NUM_4, NUM_5, NUM_6, NUM_PLUS, /* 45 - 4e */
nuclear@2 31 NUM_1, NUM_2, NUM_3, NUM_0, NUM_DOT, SYSRQ, 0, 0, F11, F12, /* 4d - 58 */
nuclear@2 32 0, 0, 0, 0, 0, 0, 0, /* 59 - 5f */
nuclear@2 33 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6f */
nuclear@2 34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 70 - 7f */
nuclear@2 35 };
nuclear@2 36
nuclear@0 37 void kmain(void)
nuclear@0 38 {
nuclear@2 39 clear_scr();
nuclear@2 40 puts("kernel starting up");
nuclear@2 41
nuclear@7 42 init_segm();
nuclear@10 43 init_intr();
nuclear@7 44
nuclear@2 45 set_text_color(YELLOW);
nuclear@2 46 puts("<initialization code goes here>");
nuclear@2 47 set_text_color(LTGRAY);
nuclear@1 48 puts("hello world!");
nuclear@2 49
nuclear@12 50 asm volatile("int $0x80");
nuclear@12 51
nuclear@13 52 panic("foo\n");
nuclear@13 53
nuclear@2 54 for(;;) {
nuclear@2 55 char c, keypress;
nuclear@2 56 do {
nuclear@2 57 inb(keypress, 0x64);
nuclear@2 58 } while(!(keypress & 1));
nuclear@2 59 inb(c, 0x60);
nuclear@2 60 if(!(c & 0x80)) {
nuclear@7 61 putchar(keycodes[(int)c]);
nuclear@2 62 }
nuclear@2 63 }
nuclear@0 64 }