summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-06-19 06:18:09 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-06-19 06:18:09 +0000
commitb6763e03bd36207ba0a61a7376e4f085fa18f29f (patch)
tree205b16becb4623e06276e487ef5b42f7f6d8e81f /IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe
parent273d2d3f088219044b9b7813ad10c476b7766024 (diff)
downloadedk2-platforms-b6763e03bd36207ba0a61a7376e4f085fa18f29f.tar.xz
Clean up the Ps2keyboardDxe module
1) Use MicroSecondDelay() produced by TimerLib to replace gBS->Stall 2) Add more command/register/status definition for 8042/8048 chipset and remove hard code value used in driver's source code; 3) Remove some unused function declaration before function implementation. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8604 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe')
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c154
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c256
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c2
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h27
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf3
5 files changed, 179 insertions, 263 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
index 04571c2f95..eb03c0c836 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
@@ -1,5 +1,4 @@
/**@file
- PS/2 Keyboard driver
Routines that access 8042 keyboard controller
Copyright (c) 2006 - 2007, Intel Corporation
@@ -567,64 +566,6 @@ UINTN mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
BOOLEAN mEnableMouseInterface;
-//
-// Function declarations
-//
-UINT8
-KeyReadDataRegister (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- );
-
-VOID
-KeyWriteDataRegister (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Data
- );
-
-VOID
-KeyWriteCommandRegister (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Data
- );
-
-VOID
-KeyboardError (
- IN KEYBOARD_CONSOLE_IN_DEV*ConsoleIn,
- IN CHAR16 *ErrMsg // should be a unicode string
- );
-
-EFI_STATUS
-GetScancodeBufHead (
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT32 Count,
- OUT UINT8 *Buf
- );
-
-EFI_STATUS
-PopScancodeBufHead (
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT32 Count,
- OUT UINT8 *Buf
- );
-
-EFI_STATUS
-KeyboardWrite (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Data
- );
-
-EFI_STATUS
-KeyboardCommand (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Data
- );
-
-EFI_STATUS
-KeyboardWaitForValue (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Value
- );
-
/**
Read data register
@@ -687,9 +628,6 @@ KeyWriteDataRegister (
&Data
);
- //
- // outp(ConsoleIn->DataRegisterAddress, Data);
- //
}
/**
@@ -770,11 +708,6 @@ KeyboardError (
)
{
ConsoleIn->KeyboardErr = TRUE;
-
- //
- // gST -> ConOut -> OutputString (gST -> ConOut, L"Keyboard Driver: ");
- // gST -> ConOut -> OutputString (gST -> ConOut, ErrMsg);
- //
}
/**
@@ -784,8 +717,8 @@ KeyboardError (
the memory buffer or empty the keyboard buffer.
It is registered as running under TPL_NOTIFY
- @param Event - The timer event
- @param Context - A KEYBOARD_CONSOLE_IN_DEV pointer
+ @param Event The timer event
+ @param Context A KEYBOARD_CONSOLE_IN_DEV pointer
**/
VOID
@@ -814,6 +747,7 @@ KeyboardTimerHandler (
gBS->RestoreTPL (OldTpl);
return ;
}
+
//
// To let KB driver support Hot plug, here should skip the 'resend' command for the case that
// KB is not connected to system. If KB is not connected to system, driver will find there's something
@@ -827,7 +761,7 @@ KeyboardTimerHandler (
//
// if there is no key present, just return
//
- if ((KeyReadStatusRegister (Context) & 0x21) != 0x1) {
+ if ((KeyReadStatusRegister (Context) & (KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT|KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA)) != KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA) {
//
// Leave critical section and return
//
@@ -1019,13 +953,13 @@ KeyboardRead (
// wait till output buffer full then perform the read
//
for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
- if (KeyReadStatusRegister (ConsoleIn) & 0x01) {
+ if (KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA) {
RegFilled = 1;
*Data = KeyReadDataRegister (ConsoleIn);
break;
}
- gBS->Stall (30);
+ MicroSecondDelay (30);
}
if (!RegFilled) {
@@ -1041,8 +975,8 @@ KeyboardRead (
@param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
@param Data value wanted to be written
- @retval EFI_TIMEOUT - GC_TODO: Add description for return value
- @retval EFI_SUCCESS - GC_TODO: Add description for return value
+ @retval EFI_TIMEOUT The input buffer register is full for putting new value util timeout
+ @retval EFI_SUCCESS The new value is sucess put into input buffer register.
**/
EFI_STATUS
@@ -1066,7 +1000,7 @@ KeyboardWrite (
break;
}
- gBS->Stall (30);
+ MicroSecondDelay (30);
}
if (!RegEmptied) {
@@ -1111,7 +1045,7 @@ KeyboardCommand (
break;
}
- gBS->Stall (30);
+ MicroSecondDelay (30);
}
if (!RegEmptied) {
@@ -1132,7 +1066,7 @@ KeyboardCommand (
break;
}
- gBS->Stall (30);
+ MicroSecondDelay (30);
}
if (!RegEmptied) {
@@ -1191,7 +1125,7 @@ KeyboardWaitForValue (
break;
}
- gBS->Stall (30);
+ MicroSecondDelay (30);
}
SumTimeOut += TimeOut;
@@ -1208,7 +1142,7 @@ KeyboardWaitForValue (
//
// Check results
//
- if (GotIt) {
+ if (GotIt == 1) {
return EFI_SUCCESS;
} else {
return EFI_TIMEOUT;
@@ -1222,7 +1156,7 @@ KeyboardWaitForValue (
@param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
- @return status
+ @return status of updating keyboard register
**/
EFI_STATUS
@@ -1276,8 +1210,8 @@ UpdateStatusLights (
@param ConsoleIn KEYBOARD_CONSOLE_IN_DEV instance pointer
- @retval EFI_NOT_READY - Input from console not ready yet.
- @retval EFI_SUCCESS - Function executed successfully.
+ @retval EFI_NOT_READY Input from console not ready yet.
+ @retval EFI_SUCCESS Function executed successfully.
**/
EFI_STATUS
@@ -1365,7 +1299,7 @@ KeyGetchar (
// Check if there are enough bytes of scancode representing a single key
// available in the buffer
//
- while (1) {
+ while (TRUE) {
Status = GetScancodeBufHead (ConsoleIn, 1, ScancodeArr);
ScancodeArrPos = 0;
@@ -1516,7 +1450,7 @@ KeyGetchar (
//
if (Extended && ScanCode == 0x35) {
ConsoleIn->Key.ScanCode = SCAN_NULL;
- ConsoleIn->Key.UnicodeChar = '/';
+ ConsoleIn->Key.UnicodeChar = L'/';
return EFI_SUCCESS;
}
//
@@ -1531,7 +1465,7 @@ KeyGetchar (
// Need not return associated shift state if a class of printable characters that
// are normally adjusted by shift modifiers. e.g. Shift Key + 'f' key = 'F'
//
- if (ConsoleIn->Key.UnicodeChar >= 'A' && ConsoleIn->Key.UnicodeChar <= 'Z') {
+ if (ConsoleIn->Key.UnicodeChar >= L'A' && ConsoleIn->Key.UnicodeChar <= L'Z') {
ConsoleIn->LeftShift = FALSE;
ConsoleIn->RightShift = FALSE;
}
@@ -1542,9 +1476,9 @@ KeyGetchar (
// alphabetic key is affected by CapsLock State
//
if (ConsoleIn->CapsLock) {
- if (ConsoleIn->Key.UnicodeChar >= 'a' && ConsoleIn->Key.UnicodeChar <= 'z') {
+ if (ConsoleIn->Key.UnicodeChar >= L'a' && ConsoleIn->Key.UnicodeChar <= L'z') {
ConsoleIn->Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar;
- } else if (ConsoleIn->Key.UnicodeChar >= 'A' && ConsoleIn->Key.UnicodeChar <= 'Z') {
+ } else if (ConsoleIn->Key.UnicodeChar >= L'A' && ConsoleIn->Key.UnicodeChar <= L'Z') {
ConsoleIn->Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar;
}
}
@@ -1552,10 +1486,10 @@ KeyGetchar (
// Translate the CTRL-Alpha characters to their corresponding control value (ctrl-a = 0x0001 through ctrl-Z = 0x001A)
//
if (ConsoleIn->Ctrled) {
- if (ConsoleIn->Key.UnicodeChar >= 'a' && ConsoleIn->Key.UnicodeChar <= 'z') {
- ConsoleIn->Key.UnicodeChar = (UINT16) (ConsoleIn->Key.UnicodeChar - 'a' + 1);
- } else if (ConsoleIn->Key.UnicodeChar >= 'A' && ConsoleIn->Key.UnicodeChar <= 'Z') {
- ConsoleIn->Key.UnicodeChar = (UINT16) (ConsoleIn->Key.UnicodeChar - 'A' + 1);
+ if (ConsoleIn->Key.UnicodeChar >= L'a' && ConsoleIn->Key.UnicodeChar <= L'z') {
+ ConsoleIn->Key.UnicodeChar = (UINT16) (ConsoleIn->Key.UnicodeChar - L'a' + 1);
+ } else if (ConsoleIn->Key.UnicodeChar >= L'A' && ConsoleIn->Key.UnicodeChar <= L'Z') {
+ ConsoleIn->Key.UnicodeChar = (UINT16) (ConsoleIn->Key.UnicodeChar - L'A' + 1);
}
}
@@ -1571,13 +1505,13 @@ KeyGetchar (
if (ConsoleIn->NumLock && !ConsoleIn->Shift && !Extended) {
ConsoleIn->Key.ScanCode = SCAN_NULL;
} else if (ScanCode != 0x4a && ScanCode != 0x4e) {
- ConsoleIn->Key.UnicodeChar = 0x00;
+ ConsoleIn->Key.UnicodeChar = 0x0000;
}
}
//
// If the key can not be converted then just return.
//
- if (ConsoleIn->Key.ScanCode == SCAN_NULL && ConsoleIn->Key.UnicodeChar == 0x00) {
+ if (ConsoleIn->Key.ScanCode == SCAN_NULL && ConsoleIn->Key.UnicodeChar == 0x0000) {
return EFI_NOT_READY;
}
@@ -1690,7 +1624,7 @@ InitKeyboard (
// Test the system flag in to determine whether this is the first
// time initialization
//
- if ((KeyReadStatusRegister (ConsoleIn) & 0x04)) {
+ if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG)) {
//
// 8042 controller is already setup (by myself or by mouse driver):
// See whether mouse interface is already enabled
@@ -1699,7 +1633,7 @@ InitKeyboard (
//
// Read the command byte of 8042 controller
//
- Status = KeyboardCommand (ConsoleIn, 0x20);
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_READ);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"\n\r");
goto Done;
@@ -1728,13 +1662,13 @@ InitKeyboard (
//
// Disable keyboard and mouse interfaces
//
- Status = KeyboardCommand (ConsoleIn, 0xad);
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"\n\r");
goto Done;
}
- Status = KeyboardCommand (ConsoleIn, 0xa7);
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"\n\r");
goto Done;
@@ -1748,7 +1682,7 @@ InitKeyboard (
//
// 8042 Controller Self Test
//
- Status = KeyboardCommand (ConsoleIn, 0xaa);
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
goto Done;
@@ -1787,7 +1721,7 @@ InitKeyboard (
// 1: Enable Auxiliary device interrupt
// 0: Enable Keyboard interrupt )
//
- Status = KeyboardCommand (ConsoleIn, 0x60);
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_WRITE);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
goto Done;
@@ -1837,7 +1771,7 @@ InitKeyboard (
//
// Keyboard Interface Test
//
- Status = KeyboardCommand (ConsoleIn, 0xab);
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_KEYBOARD_INTERFACE_SELF_TEST);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
goto Done;
@@ -1854,13 +1788,13 @@ InitKeyboard (
//
// Keyboard reset with a BAT(Basic Assurance Test)
//
- Status = KeyboardWrite (ConsoleIn, 0xff);
+ Status = KeyboardWrite (ConsoleIn, KEYBOARD_8048_COMMAND_RESET);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
goto Done;
}
- Status = KeyboardWaitForValue (ConsoleIn, 0xfa);
+ Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
goto Done;
@@ -1870,7 +1804,7 @@ InitKeyboard (
//
mWaitForValueTimeOut = KEYBOARD_BAT_TIMEOUT;
- Status = KeyboardWaitForValue (ConsoleIn, 0xaa);
+ Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_BAT_SUCCESS);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"Keyboard self test failed!\n\r");
goto Done;
@@ -1881,13 +1815,13 @@ InitKeyboard (
//
// Set Keyboard to use Scan Code Set 2
//
- Status = KeyboardWrite (ConsoleIn, 0xf0);
+ Status = KeyboardWrite (ConsoleIn, KEYBOARD_8048_COMMAND_SELECT_SCAN_CODE_SET);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
goto Done;
}
- Status = KeyboardWaitForValue (ConsoleIn, 0xfa);
+ Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
goto Done;
@@ -1899,7 +1833,7 @@ InitKeyboard (
goto Done;
}
- Status = KeyboardWaitForValue (ConsoleIn, 0xfa);
+ Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
goto Done;
@@ -1908,13 +1842,13 @@ InitKeyboard (
//
// Clear Keyboard Scancode Buffer
//
- Status = KeyboardWrite (ConsoleIn, 0xf4);
+ Status = KeyboardWrite (ConsoleIn, KEYBOARD_8048_COMMAND_CLEAR_OUTPUT_DATA);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
goto Done;
}
- Status = KeyboardWaitForValue (ConsoleIn, 0xfa);
+ Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
goto Done;
@@ -1951,7 +1885,7 @@ Done:
//
// Enable mouse interface
//
- Status1 = KeyboardCommand (ConsoleIn, 0xa8);
+ Status1 = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_ENABLE_MOUSE_INTERFACE);
if (EFI_ERROR (Status1)) {
KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
return EFI_DEVICE_ERROR;
@@ -1984,7 +1918,7 @@ DisableKeyboard (
//
// Disable keyboard interface
//
- Status = KeyboardCommand (ConsoleIn, 0xad);
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"\n\r");
return EFI_DEVICE_ERROR;
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
index cc4ce812f1..49245c6496 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
@@ -1,6 +1,6 @@
/**@file
- PS/2 Keyboard driver
- Routines that support SIMPLE_TEXT_IN protocol
+ Routines implements SIMPLE_TEXT_IN protocol's interfaces based on 8042 interfaces
+ provided by Ps2KbdCtrller.c.
Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
@@ -16,66 +16,89 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Ps2Keyboard.h"
-//
-// function declarations
-//
+/**
+ Check keyboard for given key value
+
+ @param This Point to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
+
+ @retval EFI_SUCCESS success check keyboard value
+ @retval !EFI_SUCCESS Fail to get char from keyboard
+**/
EFI_STATUS
-EFIAPI
-KeyboardEfiReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
+KeyboardCheckForKey (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
+ )
+{
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
-EFI_STATUS
-EFIAPI
-KeyboardReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
- );
+ ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
-VOID
-EFIAPI
-KeyboardWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
+ //
+ // If ready to read next key, check it
+ //
+ if (ConsoleIn->Key.ScanCode == SCAN_NULL && ConsoleIn->Key.UnicodeChar == 0x00) {
+ return KeyGetchar (ConsoleIn);
+ }
-EFI_STATUS
-KeyboardCheckForKey (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
- );
+ return EFI_SUCCESS;
+}
/**
- @param RegsiteredData - A pointer to a buffer that is filled in with the keystroke
- state data for the key that was registered.
- @param InputData - A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
+ Judge whether is a registed key
+
+ @param RegsiteredData A pointer to a buffer that is filled in with the keystroke
+ state data for the key that was registered.
+ @param InputData A pointer to a buffer that is filled in with the keystroke
+ state data for the key that was pressed.
- @retval TRUE - Key be pressed matches a registered key.
- @retval FALSE - Match failed.
+ @retval TRUE Key be pressed matches a registered key.
+ @retval FLASE Match failed.
**/
BOOLEAN
IsKeyRegistered (
IN EFI_KEY_DATA *RegsiteredData,
IN EFI_KEY_DATA *InputData
- );
+ )
+
+{
+ ASSERT (RegsiteredData != NULL && InputData != NULL);
+
+ if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
+ (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
+ return FALSE;
+ }
+
+ //
+ // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
+ //
+ if (RegsiteredData->KeyState.KeyShiftState != 0 &&
+ RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
+ return FALSE;
+ }
+ if (RegsiteredData->KeyState.KeyToggleState != 0 &&
+ RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existance of a keystroke via WaitForEvent () call.
-
- @param ConsoleInDev - Ps2 Keyboard private structure
- @param KeyData - A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
+ @param ConsoleInDev Ps2 Keyboard private structure
+ @param KeyData A pointer to a buffer that is filled in with the keystroke
+ state data for the key that was pressed.
- @retval EFI_SUCCESS - The keystroke information was returned.
- @retval EFI_NOT_READY - There was no keystroke data availiable.
- @retval EFI_DEVICE_ERROR - The keystroke information was not returned due to
- hardware errors.
- @retval EFI_INVALID_PARAMETER - KeyData is NULL.
+ @retval EFI_SUCCESS The keystroke information was returned.
+ @retval EFI_NOT_READY There was no keystroke data availiable.
+ @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
+ hardware errors.
+ @retval EFI_INVALID_PARAMETER KeyData is NULL.
**/
EFI_STATUS
@@ -90,6 +113,7 @@ KeyboardReadKeyStrokeWorker (
LIST_ENTRY *Link;
KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
EFI_KEY_DATA OriginalKeyData;
+
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -111,6 +135,7 @@ KeyboardReadKeyStrokeWorker (
gBS->RestoreTPL (OldTpl);
return EFI_NOT_READY;
}
+
CopyMem (&KeyData->Key, &ConsoleInDev->Key, sizeof (EFI_INPUT_KEY));
ConsoleInDev->Key.ScanCode = SCAN_NULL;
@@ -128,9 +153,9 @@ KeyboardReadKeyStrokeWorker (
if (ConsoleInDev->Ctrled) {
if (OriginalKeyData.Key.UnicodeChar >= 0x01 && OriginalKeyData.Key.UnicodeChar <= 0x1A) {
if (ConsoleInDev->CapsLock) {
- OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'A' - 1);
+ OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + L'A' - 1);
} else {
- OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'a' - 1);
+ OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + L'a' - 1);
}
}
}
@@ -153,11 +178,9 @@ KeyboardReadKeyStrokeWorker (
}
/**
- logic reset keyboard
- Implement SIMPLE_TEXT_IN.Reset()
- Perform 8042 controller and keyboard initialization
+ Perform 8042 controller and keyboard initialization which implement SIMPLE_TEXT_IN.Reset()
- @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
+ @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
@param ExtendedVerification Indicate that the driver may perform a more
exhaustive verification operation of the device during
reset, now this par is ignored in this driver
@@ -237,8 +260,7 @@ KeyboardEfiReset (
}
/**
- Implement SIMPLE_TEXT_IN.ReadKeyStroke().
- Retrieve key values for driver user.
+ Retrieve key values for driver user which implement SIMPLE_TEXT_IN.ReadKeyStroke().
@param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
@param Key The output buffer for key value
@@ -315,74 +337,6 @@ KeyboardWaitForKey (
}
/**
- Check keyboard for given key value
-
- @param This Point to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
-
- @retval EFI_SUCCESS success check keyboard value
-**/
-EFI_STATUS
-KeyboardCheckForKey (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
- )
-{
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
-
- ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
-
- //
- // If ready to read next key, check it
- //
- if (ConsoleIn->Key.ScanCode == SCAN_NULL && ConsoleIn->Key.UnicodeChar == 0x00) {
- return KeyGetchar (ConsoleIn);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Judge whether is a registed key
-
- @param RegsiteredData - A pointer to a buffer that is filled in with the keystroke
- state data for the key that was registered.
- @param InputData - A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
-
- @retval TRUE - Key be pressed matches a registered key.
- @retval FLASE - Match failed.
-
-**/
-BOOLEAN
-IsKeyRegistered (
- IN EFI_KEY_DATA *RegsiteredData,
- IN EFI_KEY_DATA *InputData
- )
-
-{
- ASSERT (RegsiteredData != NULL && InputData != NULL);
-
- if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
- (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
- return FALSE;
- }
-
- //
- // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
- //
- if (RegsiteredData->KeyState.KeyShiftState != 0 &&
- RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
- return FALSE;
- }
- if (RegsiteredData->KeyState.KeyToggleState != 0 &&
- RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
- return FALSE;
- }
-
- return TRUE;
-
-}
-
-/**
Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event
Signal the event if there is key available
@@ -408,11 +362,11 @@ KeyboardWaitForKeyEx (
/**
Reset the input device and optionaly run diagnostics
- @param This - Protocol instance pointer.
- @param ExtendedVerification - Driver may perform diagnostics on reset.
+ @param This Protocol instance pointer.
+ @param ExtendedVerification Driver may perform diagnostics on reset.
- @retval EFI_SUCCESS - The device was reset.
- @retval EFI_DEVICE_ERROR - The device is not functioning properly and could
+ @retval EFI_SUCCESS The device was reset.
+ @retval EFI_DEVICE_ERROR The device is not functioning properly and could
not be reset.
**/
@@ -456,15 +410,15 @@ KeyboardEfiResetEx (
be used to test for existance of a keystroke via WaitForEvent () call.
- @param This - Protocol instance pointer.
- @param KeyData - A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
+ @param This Protocol instance pointer.
+ @param KeyData A pointer to a buffer that is filled in with the keystroke
+ state data for the key that was pressed.
- @retval EFI_SUCCESS - The keystroke information was returned.
- @retval EFI_NOT_READY - There was no keystroke data availiable.
- @retval EFI_DEVICE_ERROR - The keystroke information was not returned due to
- hardware errors.
- @retval EFI_INVALID_PARAMETER - KeyData is NULL.
+ @retval EFI_SUCCESS The keystroke information was returned.
+ @retval EFI_NOT_READY There was no keystroke data availiable.
+ @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
+ hardware errors.
+ @retval EFI_INVALID_PARAMETER KeyData is NULL.
**/
EFI_STATUS
@@ -489,15 +443,15 @@ KeyboardReadKeyStrokeEx (
/**
Set certain state for the input device.
- @param This - Protocol instance pointer.
- @param KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the
- state for the input device.
+ @param This Protocol instance pointer.
+ @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
+ state for the input device.
- @retval EFI_SUCCESS - The device state was set successfully.
- @retval EFI_DEVICE_ERROR - The device is not functioning correctly and could
- not have the setting adjusted.
- @retval EFI_UNSUPPORTED - The device does not have the ability to set its state.
- @retval EFI_INVALID_PARAMETER - KeyToggleState is NULL.
+ @retval EFI_SUCCESS The device state was set successfully.
+ @retval EFI_DEVICE_ERROR The device is not functioning correctly and could
+ not have the setting adjusted.
+ @retval EFI_UNSUPPORTED The device does not have the ability to set its state.
+ @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
**/
EFI_STATUS
@@ -571,16 +525,16 @@ Exit:
/**
Register a notification function for a particular keystroke for the input device.
- @param This - Protocol instance pointer.
- @param KeyData - A pointer to a buffer that is filled in with the keystroke
- information data for the key that was pressed.
- @param KeyNotificationFunction - Points to the function to be called when the key
- sequence is typed specified by KeyData.
- @param NotifyHandle - Points to the unique handle assigned to the registered notification.
+ @param This Protocol instance pointer.
+ @param KeyData A pointer to a buffer that is filled in with the keystroke
+ information data for the key that was pressed.
+ @param KeyNotificationFunction Points to the function to be called when the key
+ sequence is typed specified by KeyData.
+ @param NotifyHandle Points to the unique handle assigned to the registered notification.
- @retval EFI_SUCCESS - The notification function was registered successfully.
- @retval EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
- @retval EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
+ @retval EFI_SUCCESS The notification function was registered successfully.
+ @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.
+ @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or KeyNotificationFunction is NULL.
**/
EFI_STATUS
@@ -659,12 +613,12 @@ Exit:
/**
Remove a registered notification function from a particular keystroke.
- @param This - Protocol instance pointer.
- @param NotificationHandle - The handle of the notification function being unregistered.
+ @param This Protocol instance pointer.
+ @param NotificationHandle The handle of the notification function being unregistered.
- @retval EFI_SUCCESS - The notification function was unregistered successfully.
- @retval EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
+ @retval EFI_SUCCESS The notification function was unregistered successfully.
+ @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
**/
EFI_STATUS
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
index 7c7c0bf27a..060a172ddf 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
@@ -555,7 +555,7 @@ KbdFreeNotifyList (
}
/**
- The user Entry Point for module Ps2Keyboard. The user code starts with this function.
+ The module Entry Point for module Ps2Keyboard.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
index fd97f28d2e..5bf3a6eefc 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
@@ -33,6 +33,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/TimerLib.h>
//
// Global Variables
@@ -180,6 +181,32 @@ InstallPs2KeyboardDriver (
#define SCANCODE_SYS_REQ_MAKE 0x37
#define SCANCODE_MAX_MAKE 0x60
+#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
+#define KEYBOARD_STATUS_REGISTER_INPUT_DATA_TYPE BIT3 ///< 0 - Data in input register is data; 1 - Data in input register is command
+#define KEYBOARD_STATUS_REGISTER_ENABLE_FLAG BIT4 ///< 0 - Keyboard is disable; 1 - Keyboard is enable
+#define KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT BIT5 ///< 0 - Transmit is complete without timeout; 1 - Transmit is timeout without complete
+#define KEYBOARD_STATUS_REGISTER_RECEIVE_TIMEOUT BIT6 ///< 0 - Receive is complete without timeout; 1 - Receive is timeout without complete
+#define KEYBOARD_STATUS_REGISTER_PARITY BIT7 ///< 0 - Odd parity; 1 - Even parity
+
+#define KEYBOARD_8042_COMMAND_READ 0x20
+#define KEYBOARD_8042_COMMAND_WRITE 0x60
+#define KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE 0xA7
+#define KEYBOARD_8042_COMMAND_ENABLE_MOUSE_INTERFACE 0xA8
+#define KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST 0xAA
+#define KEYBOARD_8042_COMMAND_KEYBOARD_INTERFACE_SELF_TEST 0xAB
+#define KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE 0xAD
+
+#define KEYBOARD_8048_COMMAND_CLEAR_OUTPUT_DATA 0xF4
+#define KEYBOARD_8048_COMMAND_RESET 0xFF
+#define KEYBOARD_8048_COMMAND_SELECT_SCAN_CODE_SET 0xF0
+
+#define KEYBOARD_8048_RETURN_8042_BAT_SUCCESS 0xAA
+#define KEYBOARD_8048_RETURN_8042_BAT_ERROR 0xFC
+#define KEYBOARD_8048_RETURN_8042_ACK 0xFA
+
+
//
// Keyboard Controller Status
//
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
index 01d01df48d..2f0b46b6f6 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
@@ -54,7 +54,8 @@
UefiDriverEntryPoint
BaseLib
BaseMemoryLib
-
+ TimerLib
+
[Protocols]
gEfiPs2PolicyProtocolGuid # PROTOCOL TO_START
gEfiIsaIoProtocolGuid # PROTOCOL TO_START