/** @file\r
Routines that access 8042 keyboard controller\r
\r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
//\r
// To let KB driver support Hot plug, here should skip the 'resend' command for the case that\r
// KB is not connected to system. If KB is not connected to system, driver will find there's something\r
- // error in the following code and wait for the input buffer empty, this waiting time shoulb be short enough since\r
+ // error in the following code and wait for the input buffer empty, this waiting time should be short enough since\r
// this is a NOTIFY TPL period function, or the system performance will degrade hardly when KB is not connected.\r
// Just skip the 'resend' process simply.\r
//\r
@param ConsoleIn - Pointer to instance of KEYBOARD_CONSOLE_IN_DEV\r
@param Data - Pointer to outof buffer for keeping key value\r
\r
- @retval EFI_TIMEOUT Status resigter time out\r
+ @retval EFI_TIMEOUT Status register time out\r
@retval EFI_SUCCESS Success to read keyboard\r
\r
**/\r
@param Data value wanted to be written\r
\r
@retval EFI_TIMEOUT The input buffer register is full for putting new value util timeout\r
- @retval EFI_SUCCESS The new value is sucess put into input buffer register.\r
+ @retval EFI_SUCCESS The new value is success put into input buffer register.\r
\r
**/\r
EFI_STATUS\r
return Status;\r
}\r
\r
+/**\r
+ Initialize the key state.\r
+\r
+ @param ConsoleIn The KEYBOARD_CONSOLE_IN_DEV instance.\r
+ @param KeyState A pointer to receive the key state information.\r
+**/\r
+VOID\r
+InitializeKeyState (\r
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,\r
+ OUT EFI_KEY_STATE *KeyState\r
+ )\r
+{\r
+ KeyState->KeyShiftState = EFI_SHIFT_STATE_VALID\r
+ | (ConsoleIn->LeftCtrl ? EFI_LEFT_CONTROL_PRESSED : 0)\r
+ | (ConsoleIn->RightCtrl ? EFI_RIGHT_CONTROL_PRESSED : 0)\r
+ | (ConsoleIn->LeftAlt ? EFI_LEFT_ALT_PRESSED : 0)\r
+ | (ConsoleIn->RightAlt ? EFI_RIGHT_ALT_PRESSED : 0)\r
+ | (ConsoleIn->LeftShift ? EFI_LEFT_SHIFT_PRESSED : 0)\r
+ | (ConsoleIn->RightShift ? EFI_RIGHT_SHIFT_PRESSED : 0)\r
+ | (ConsoleIn->LeftLogo ? EFI_LEFT_LOGO_PRESSED : 0)\r
+ | (ConsoleIn->RightLogo ? EFI_RIGHT_LOGO_PRESSED : 0)\r
+ | (ConsoleIn->Menu ? EFI_MENU_KEY_PRESSED : 0)\r
+ | (ConsoleIn->SysReq ? EFI_SYS_REQ_PRESSED : 0)\r
+ ;\r
+ KeyState->KeyToggleState = EFI_TOGGLE_STATE_VALID\r
+ | (ConsoleIn->CapsLock ? EFI_CAPS_LOCK_ACTIVE : 0)\r
+ | (ConsoleIn->NumLock ? EFI_NUM_LOCK_ACTIVE : 0)\r
+ | (ConsoleIn->ScrollLock ? EFI_SCROLL_LOCK_ACTIVE : 0)\r
+ | (ConsoleIn->IsSupportPartialKey ? EFI_KEY_STATE_EXPOSED : 0)\r
+ ;\r
+}\r
+\r
/**\r
Get scancode from scancode buffer and translate into EFI-scancode and unicode defined by EFI spec.\r
\r
//\r
// Save the Shift/Toggle state\r
//\r
- KeyData.KeyState.KeyShiftState = (UINT32) (EFI_SHIFT_STATE_VALID\r
- | (ConsoleIn->LeftCtrl ? EFI_LEFT_CONTROL_PRESSED : 0)\r
- | (ConsoleIn->RightCtrl ? EFI_RIGHT_CONTROL_PRESSED : 0)\r
- | (ConsoleIn->LeftAlt ? EFI_LEFT_ALT_PRESSED : 0)\r
- | (ConsoleIn->RightAlt ? EFI_RIGHT_ALT_PRESSED : 0)\r
- | (ConsoleIn->LeftShift ? EFI_LEFT_SHIFT_PRESSED : 0)\r
- | (ConsoleIn->RightShift ? EFI_RIGHT_SHIFT_PRESSED : 0)\r
- | (ConsoleIn->LeftLogo ? EFI_LEFT_LOGO_PRESSED : 0)\r
- | (ConsoleIn->RightLogo ? EFI_RIGHT_LOGO_PRESSED : 0)\r
- | (ConsoleIn->Menu ? EFI_MENU_KEY_PRESSED : 0)\r
- | (ConsoleIn->SysReq ? EFI_SYS_REQ_PRESSED : 0)\r
- );\r
- KeyData.KeyState.KeyToggleState = (EFI_KEY_TOGGLE_STATE) (EFI_TOGGLE_STATE_VALID\r
- | (ConsoleIn->CapsLock ? EFI_CAPS_LOCK_ACTIVE : 0)\r
- | (ConsoleIn->NumLock ? EFI_NUM_LOCK_ACTIVE : 0)\r
- | (ConsoleIn->ScrollLock ? EFI_SCROLL_LOCK_ACTIVE : 0)\r
- | (ConsoleIn->IsSupportPartialKey ? EFI_KEY_STATE_EXPOSED : 0)\r
- );\r
-\r
- KeyData.Key.ScanCode = SCAN_NULL;\r
- KeyData.Key.UnicodeChar = CHAR_NULL;\r
+ InitializeKeyState (ConsoleIn, &KeyData.KeyState);\r
+ KeyData.Key.ScanCode = SCAN_NULL;\r
+ KeyData.Key.UnicodeChar = CHAR_NULL;\r
\r
//\r
// Key Pad "/" shares the same scancode as that of "/" except Key Pad "/" has E0 prefix\r
}\r
\r
//\r
- // Invoke notification functions if exist\r
+ // Signal KeyNotify process event if this key pressed matches any key registered.\r
//\r
for (Link = GetFirstNode (&ConsoleIn->NotifyList); !IsNull (&ConsoleIn->NotifyList, Link); Link = GetNextNode (&ConsoleIn->NotifyList, Link)) {\r
CurrentNotify = CR (\r
KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
);\r
if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {\r
- CurrentNotify->KeyNotificationFn (&KeyData);\r
+ //\r
+ // The key notification function needs to run at TPL_CALLBACK\r
+ // while current TPL is TPL_NOTIFY. It will be invoked in\r
+ // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.\r
+ //\r
+ PushEfikeyBufTail (&ConsoleIn->EfiKeyQueueForNotify, &KeyData);\r
+ gBS->SignalEvent (ConsoleIn->KeyNotifyProcessEvent);\r
+ break;\r
}\r
}\r
\r
ConsoleIn->ScancodeQueue.Tail = 0;\r
ConsoleIn->EfiKeyQueue.Head = 0;\r
ConsoleIn->EfiKeyQueue.Tail = 0;\r
+ ConsoleIn->EfiKeyQueueForNotify.Head = 0;\r
+ ConsoleIn->EfiKeyQueueForNotify.Tail = 0;\r
\r
//\r
// Reset the status indicators\r
if (EFI_ERROR (Status)) {\r
KeyboardError (\r
ConsoleIn,\r
- L"Some specific value not aquired from 8042 controller!\n\r"\r
+ L"Some specific value not acquired from 8042 controller!\n\r"\r
);\r
goto Done;\r
}\r
\r
Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);\r
if (EFI_ERROR (Status)) {\r
- KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");\r
+ KeyboardError (ConsoleIn, L"Some specific value not acquired from 8042 controller!\n\r");\r
goto Done;\r
}\r
//\r
\r
Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);\r
if (EFI_ERROR (Status)) {\r
- KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");\r
+ KeyboardError (ConsoleIn, L"Some specific value not acquired from 8042 controller!\n\r");\r
goto Done;\r
}\r
\r
\r
Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);\r
if (EFI_ERROR (Status)) {\r
- KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");\r
+ KeyboardError (ConsoleIn, L"Some specific value not acquired from 8042 controller!\n\r");\r
goto Done;\r
}\r
\r
\r
Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);\r
if (EFI_ERROR (Status)) {\r
- KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");\r
+ KeyboardError (ConsoleIn, L"Some specific value not acquired from 8042 controller!\n\r");\r
goto Done;\r
}\r
//\r
\r
}\r
\r
-/**\r
- Disable the keyboard interface of the 8042 controller.\r
-\r
- @param ConsoleIn The device instance\r
-\r
- @return status of issuing disable command\r
-\r
-**/\r
-EFI_STATUS\r
-DisableKeyboard (\r
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Disable keyboard interface\r
- //\r
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);\r
- if (EFI_ERROR (Status)) {\r
- KeyboardError (ConsoleIn, L"\n\r");\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- return Status;\r
-}\r
\r
/**\r
Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command\r