Update PS/2 keyboard driver to return scan code for Pause key.

Signed-off-by: vanjeff
Reviewed-by: niruiyu

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11657 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2011-05-16 02:00:34 +00:00
parent 4ff492c312
commit e812318638
2 changed files with 121 additions and 107 deletions

View File

@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Ps2Keyboard.h"
struct {
UINT8 ScanCode; ///< follows value defined in Scan Code Set1
UINT16 ScanCode; ///< follows value defined in Scan Code Set1
UINT16 EfiScanCode;
CHAR16 UnicodeChar;
CHAR16 ShiftUnicodeChar;
@ -550,6 +550,12 @@ ConvertKeyboardScanCodeToEfiKey[] = {
0x0000,
0x0000
},
{
0x1D45, //Pause key
SCAN_PAUSE,
0x0000,
0x0000
},
{
TABLE_END,
TABLE_END,
@ -1152,8 +1158,9 @@ KeyGetchar (
)
{
EFI_STATUS Status;
UINT8 ScanCode;
UINT16 ScanCode;
BOOLEAN Extended;
BOOLEAN Extended1;
UINTN Index;
EFI_KEY_DATA KeyData;
LIST_ENTRY *Link;
@ -1163,20 +1170,18 @@ KeyGetchar (
//
UINT8 ScancodeArr[4];
UINT32 ScancodeArrPos;
//
// point to the current position in ScancodeArr
//
Extended = FALSE;
ScancodeArrPos = 0;
//
// Check if there are enough bytes of scancode representing a single key
// available in the buffer
//
while (TRUE) {
Extended = FALSE;
Extended1 = FALSE;
Status = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, 1, ScancodeArr);
//
// point to the current position in ScancodeArr
//
ScancodeArrPos = 0;
if (EFI_ERROR (Status)) {
return ;
@ -1195,7 +1200,7 @@ KeyGetchar (
// if present, ignore them
//
if (ScancodeArr[ScancodeArrPos] == SCANCODE_EXTENDED1) {
Extended1 = TRUE;
Status = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, 2, ScancodeArr);
ScancodeArrPos = 1;
@ -1209,9 +1214,6 @@ KeyGetchar (
if (EFI_ERROR (Status)) {
return ;
}
PopScancodeBufHead (&ConsoleIn->ScancodeQueue, 3, ScancodeArr);
return ;
}
//
// if we reach this position, scancodes for a key is in buffer now,pop them
@ -1220,6 +1222,8 @@ KeyGetchar (
if (EFI_ERROR (Status)) {
return ;
}
if (!Extended1) {
//
// store the last available byte, this byte of scancode will be checked
//
@ -1296,29 +1300,37 @@ KeyGetchar (
if (Extended) {
ConsoleIn->SysReq = TRUE;
}
break;
case SCANCODE_CAPS_LOCK_MAKE:
ConsoleIn->CapsLock = (BOOLEAN)!ConsoleIn->CapsLock;
UpdateStatusLights (ConsoleIn);
break;
case SCANCODE_NUM_LOCK_MAKE:
ConsoleIn->NumLock = (BOOLEAN)!ConsoleIn->NumLock;
UpdateStatusLights (ConsoleIn);
break;
case SCANCODE_SCROLL_LOCK_MAKE:
ConsoleIn->ScrollLock = (BOOLEAN)!ConsoleIn->ScrollLock;
UpdateStatusLights (ConsoleIn);
break;
}
//
// If this is a BREAK Key or above the valid range, ignore it
// If this is above the valid range, ignore it
//
if (ScanCode >= SCANCODE_MAX_MAKE) {
continue;
} else {
break;
}
} else {
//
// Store the last 2 available byte to check if it is Pause key
//
ScanCode = (UINT16) (ScancodeArr[ScancodeArrPos] + (ScancodeArr[ScancodeArrPos - 1] << 8));
if (ScanCode == SCANCODE_PAUSE_MAKE) {
break;
}
}
}
//

View File

@ -182,6 +182,8 @@ InstallPs2KeyboardDriver (
#define SCANCODE_SYS_REQ_MAKE 0x37
#define SCANCODE_MAX_MAKE 0x60
#define SCANCODE_PAUSE_MAKE 0x1D45
#define KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA BIT0 ///< 0 - Output register has no data; 1 - Output register has data
#define KEYBOARD_STATUS_REGISTER_HAS_INPUT_DATA BIT1 ///< 0 - Input register has no data; 1 - Input register has data
#define KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG BIT2 ///< Set to 0 after power on reset