Xv6 with picoc & Linkage editor
v1.0
The project delineate mutual cohesion between c library, linkage editor ( linker), interpreter and operating system by porting the same on xv6 kernel
|
00001 // PC keyboard interface constants 00002 00003 #define KBSTATP 0x64 // kbd controller status port(I) 00004 #define KBS_DIB 0x01 // kbd data in buffer 00005 #define KBDATAP 0x60 // kbd data port(I) 00006 00007 #define NO 0 00008 00009 #define SHIFT (1<<0) 00010 #define CTL (1<<1) 00011 #define ALT (1<<2) 00012 00013 #define CAPSLOCK (1<<3) 00014 #define NUMLOCK (1<<4) 00015 #define SCROLLLOCK (1<<5) 00016 00017 #define E0ESC (1<<6) 00018 00019 // Special keycodes 00020 #define KEY_HOME 0xE0 00021 #define KEY_END 0xE1 00022 #define KEY_UP 0xE2 00023 #define KEY_DN 0xE3 00024 #define KEY_LF 0xE4 00025 #define KEY_RT 0xE5 00026 #define KEY_PGUP 0xE6 00027 #define KEY_PGDN 0xE7 00028 #define KEY_INS 0xE8 00029 #define KEY_DEL 0xE9 00030 00031 // C('A') == Control-A 00032 #define C(x) (x - '@') 00033 00034 static uchar shiftcode[256] = 00035 { 00036 [0x1D] CTL, 00037 [0x2A] SHIFT, 00038 [0x36] SHIFT, 00039 [0x38] ALT, 00040 [0x9D] CTL, 00041 [0xB8] ALT 00042 }; 00043 00044 static uchar togglecode[256] = 00045 { 00046 [0x3A] CAPSLOCK, 00047 [0x45] NUMLOCK, 00048 [0x46] SCROLLLOCK 00049 }; 00050 00051 static uchar normalmap[256] = 00052 { 00053 NO, 0x1B, '1', '2', '3', '4', '5', '6', // 0x00 00054 '7', '8', '9', '0', '-', '=', '\b', '\t', 00055 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', // 0x10 00056 'o', 'p', '[', ']', '\n', NO, 'a', 's', 00057 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', // 0x20 00058 '\'', '`', NO, '\\', 'z', 'x', 'c', 'v', 00059 'b', 'n', 'm', ',', '.', '/', NO, '*', // 0x30 00060 NO, ' ', NO, NO, NO, NO, NO, NO, 00061 NO, NO, NO, NO, NO, NO, NO, '7', // 0x40 00062 '8', '9', '-', '4', '5', '6', '+', '1', 00063 '2', '3', '0', '.', NO, NO, NO, NO, // 0x50 00064 [0x9C] '\n', // KP_Enter 00065 [0xB5] '/', // KP_Div 00066 [0xC8] KEY_UP, [0xD0] KEY_DN, 00067 [0xC9] KEY_PGUP, [0xD1] KEY_PGDN, 00068 [0xCB] KEY_LF, [0xCD] KEY_RT, 00069 [0x97] KEY_HOME, [0xCF] KEY_END, 00070 [0xD2] KEY_INS, [0xD3] KEY_DEL 00071 }; 00072 00073 static uchar shiftmap[256] = 00074 { 00075 NO, 033, '!', '@', '#', '$', '%', '^', // 0x00 00076 '&', '*', '(', ')', '_', '+', '\b', '\t', 00077 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', // 0x10 00078 'O', 'P', '{', '}', '\n', NO, 'A', 'S', 00079 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', // 0x20 00080 '"', '~', NO, '|', 'Z', 'X', 'C', 'V', 00081 'B', 'N', 'M', '<', '>', '?', NO, '*', // 0x30 00082 NO, ' ', NO, NO, NO, NO, NO, NO, 00083 NO, NO, NO, NO, NO, NO, NO, '7', // 0x40 00084 '8', '9', '-', '4', '5', '6', '+', '1', 00085 '2', '3', '0', '.', NO, NO, NO, NO, // 0x50 00086 [0x9C] '\n', // KP_Enter 00087 [0xB5] '/', // KP_Div 00088 [0xC8] KEY_UP, [0xD0] KEY_DN, 00089 [0xC9] KEY_PGUP, [0xD1] KEY_PGDN, 00090 [0xCB] KEY_LF, [0xCD] KEY_RT, 00091 [0x97] KEY_HOME, [0xCF] KEY_END, 00092 [0xD2] KEY_INS, [0xD3] KEY_DEL 00093 }; 00094 00095 static uchar ctlmap[256] = 00096 { 00097 NO, NO, NO, NO, NO, NO, NO, NO, 00098 NO, NO, NO, NO, NO, NO, NO, NO, 00099 C('Q'), C('W'), C('E'), C('R'), C('T'), C('Y'), C('U'), C('I'), 00100 C('O'), C('P'), NO, NO, '\r', NO, C('A'), C('S'), 00101 C('D'), C('F'), C('G'), C('H'), C('J'), C('K'), C('L'), NO, 00102 NO, NO, NO, C('\\'), C('Z'), C('X'), C('C'), C('V'), 00103 C('B'), C('N'), C('M'), NO, NO, C('/'), NO, NO, 00104 [0x9C] '\r', // KP_Enter 00105 [0xB5] C('/'), // KP_Div 00106 [0xC8] KEY_UP, [0xD0] KEY_DN, 00107 [0xC9] KEY_PGUP, [0xD1] KEY_PGDN, 00108 [0xCB] KEY_LF, [0xCD] KEY_RT, 00109 [0x97] KEY_HOME, [0xCF] KEY_END, 00110 [0xD2] KEY_INS, [0xD3] KEY_DEL 00111 }; 00112