diff --git a/sys/isa/atkbd.c b/sys/isa/atkbd.c index ec94c61..f47b61c 100644 --- a/sys/isa/atkbd.c +++ b/sys/isa/atkbd.c @@ -44,15 +44,15 @@ static int atkbd_scan(); -static unsigned int keyMap = 0x0; -static unsigned int ledStatus = 0x0; -static char stdinBuffer[512]; -static uInt16 stdinSize; -static uInt32 controlKeys = 0x0; +static unsigned int keyMap = 0x0; +static unsigned int ledStatus = 0x0; +static char stdinBuffer[512]; +static uInt16 stdinSize; +static uInt32 controlKeys = 0x0; -static struct spinLock atkbdSpinLock = SPIN_LOCK_INITIALIZER; +static struct spinLock atkbdSpinLock = SPIN_LOCK_INITIALIZER; -static unsigned int keyboardMap[255][8] = { +static unsigned int keyboardMap[255][8] = { /* Ascii, Shift, Ctrl, Alt, Num, Caps, Shift Caps, Shift Num */ { 0, 0, 0, 0, 0, 0, 0, 0 }, /* ESC */{ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B }, @@ -70,41 +70,41 @@ /* =,+ */{ 0x3D, 0x2B, 0, 0, 0x3D, 0x3D, 0x2B, 0x2B }, /* 14 */{ 0x08, 0x08, 0x8, 0x8, 0x08, 0x08, 0x08, 0x08 }, /* 15 */{ 0x09, 0, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x71, 0x51, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x77, 0x57, 0, 0, 0, 0, 0, 0 }, +/* q,Q */{ 0x71, 0x51, 0x11, 0, 0, 0, 0, 0 }, +/* w,W */{ 0x77, 0x57, 0x17, 0, 0, 0, 0, 0 }, /* e,E */{ 0x65, 0x45, 0x05, 0, 0, 0, 0, 0 }, -/* */{ 0x72, 0x52, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x74, 0x54, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x79, 0x59, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x75, 0x55, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x69, 0x49, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x6F, 0x4F, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x70, 0x50, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x5B, 0x7B, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x5D, 0x7D, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x0A, 0, 0, 0, 0, 0, 0, 0 }, +/* r,R */{ 0x72, 0x52, 0x18, 0, 0, 0, 0, 0 }, +/* t,T */{ 0x74, 0x54, 0x14, 0, 0, 0, 0, 0 }, +/* y,Y */{ 0x79, 0x59, 0x19, 0, 0, 0, 0, 0 }, +/* u,U */{ 0x75, 0x55, 0x15, 0, 0, 0, 0, 0 }, +/* i,I */{ 0x69, 0x49, 0x09, 0, 0, 0, 0, 0 }, +/* o,O */{ 0x6F, 0x4F, 0x0F, 0, 0, 0, 0, 0 }, +/* p,P */{ 0x70, 0x50, 0x10, 0, 0, 0, 0, 0 }, +/* [,{ */{ 0x5B, 0x7B, 0x1B, 0, 0, 0, 0, 0 }, +/* ],} */{ 0x5D, 0x7D, 0x1D, 0, 0, 0, 0, 0 }, +/* LF */{ 0x0A, 0, 0, 0, 0, 0, 0, 0 }, /* */{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* a,A */{ 0x61, 0x41, 0x01, 0, 0, 0, 0, 0 }, -/* */{ 0x73, 0x53, 0, 0, 0, 0, 0, 0 }, +/* s,S */{ 0x73, 0x53, 0x13, 0, 0, 0, 0, 0 }, /* d,D */{ 0x64, 0x44, 0x04, 0, 0, 0, 0, 0 }, /* f,F */{ 0x66, 0x46, 0x06, 0, 0, 0, 0, 0 }, /* g,G */{ 0x67, 0x47, 0x07, 0, 0, 0, 0, 0 }, /* h,H */{ 0x68, 0x48, 0x08, 0, 0, 0, 0, 0 }, -/* */{ 0x6A, 0x4A, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x6B, 0x4B, 0, 0, 0, 0, 0, 0 }, -/* */{ 0x6C, 0x4C, 0, 0, 0,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*/{ 0x2E, 0x3E, 0, 0, 0, 0, 0, 0 }, /* */{ 0x2F, 0x3F, 0, 0, 0, 0, 0, 0 }, @@ -215,53 +215,83 @@ return (code); } -void keyboardHandler(struct trapframe *frame) { - int key = 0x0; +void keyboardHandler( struct trapframe *frame ) { - if (spinTryLock(&atkbdSpinLock)) - return; + int key = 0x0; - key = atkbd_scan(); + if( spinTryLock( &atkbdSpinLock ) ) + return; - if (key > 255) - return; + key = atkbd_scan( ); - /* Control Key */ - if (key == 0x1D && !(controlKeys & controlKey)) { - controlKeys |= controlKey; - } - if (key == 0x80 + 0x1D) { - controlKeys &= (0xFF - controlKey); - } - /* ALT Key */ - if (key == 0x38 && !(controlKeys & altKey)) { - controlKeys |= altKey; - } - if (key == 0x80 + 0x38) { - controlKeys &= (0xFF - altKey); - } - /* Shift Key */ - if ((key == 0x2A || key == 0x36) && !(controlKeys & shiftKey)) { - controlKeys |= shiftKey; - } - if ((key == 0x80 + 0x2A) || (key == 0x80 + 0x36)) { - controlKeys &= (0xFF - shiftKey); - } - /* Caps Lock */ - if (key == 0x3A) { - ledStatus ^= ledCapslock; - setLED(); - } - /* Num Lock */ - if (key == 0x45) { - ledStatus ^= ledNumlock; - setLED(); - } - /* Scroll Lock */ - if (key == 0x46) { - ledStatus ^= ledScrolllock; - setLED(); - } + if( key > 255 ) + return; + + // Control Key + if( key == 0x1D && !( controlKeys & controlKey ) ) { + + controlKeys |= controlKey; + + } + + if( key == 0x80 + 0x1D ) { + + controlKeys &= (0xFF - controlKey); + + } + + // ALT Key + if( key == 0x38 && !( controlKeys & altKey ) ) { + + controlKeys |= altKey; + + } + + if( key == 0x80 + 0x38 ) { + + controlKeys &= (0xFF - altKey); + + } + + // Shift Key + if( ( key == 0x2A || key == 0x36 ) && !( controlKeys & shiftKey ) ) { + + controlKeys |= shiftKey; + + } + + if( ( key == 0x80 + 0x2A ) || ( key == 0x80 + 0x36 ) ) { + + controlKeys &= ( 0xFF - shiftKey ); + + } + + // Caps Lock + if( key == 0x3A ) { + + ledStatus ^= ledCapslock; + + setLED(); + + } + + // Num Lock + if( key == 0x45 ) { + + ledStatus ^= ledNumlock; + + setLED(); + + } + + // Scroll Lock + if( key == 0x46 ) { + + ledStatus ^= ledScrolllock; + + setLED(); + + } /* Pick Which Key Map */ if (controlKeys == 0) { keyMap = 0; @@ -275,6 +305,7 @@ else if (controlKeys == 4) { keyMap = 3; } + /* If Key Is Not Null Add It To Handler */ if (((uInt) (keyboardMap[key][keyMap]) > 0) && ((uInt32) (keyboardMap[key][keyMap]) < 0xFF)) { switch ((uInt32) keyboardMap[key][keyMap]) { @@ -296,6 +327,10 @@ kprintf("FreePages: [0x%X]\n", systemVitals->freePages); sched_setStatus(tty_foreground->owner, DEAD); break; + + case 0x0D: + kprintf( "FreePages: [0x%X]\n", systemVitals->freePages ); + break; case 0x9: sys_shutdown(REBOOT); break;