PS/2 Keyboard driver. Routines that interacts with callers,\r
conforming to EFI driver model\r
\r
-Copyright (c) 2006 - 2011, 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
/**\r
Test controller is a keyboard Controller.\r
- \r
+\r
@param This Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
@param Controller driver's controller\r
@param RemainingDevicePath children device path\r
- \r
+\r
@retval EFI_UNSUPPORTED controller is not floppy disk\r
@retval EFI_SUCCESS controller is floppy disk\r
**/\r
\r
/**\r
Create KEYBOARD_CONSOLE_IN_DEV instance on controller.\r
- \r
+\r
@param This Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
@param Controller driver controller handle\r
@param RemainingDevicePath Children's device path\r
- \r
+\r
@retval whether success to create floppy control instance.\r
**/\r
EFI_STATUS\r
);\r
\r
/**\r
- Stop this driver on ControllerHandle. Support stoping any child handles\r
+ Stop this driver on ControllerHandle. Support stopping any child handles\r
created by this driver.\r
\r
@param This Protocol instance pointer.\r
\r
/**\r
Free the waiting key notify list.\r
- \r
+\r
@param ListHead Pointer to list head\r
- \r
+\r
@retval EFI_INVALID_PARAMETER ListHead is NULL\r
@retval EFI_SUCCESS Sucess to free NotifyList\r
**/\r
EFI_STATUS\r
KbdFreeNotifyList (\r
IN OUT LIST_ENTRY *ListHead\r
- ); \r
+ );\r
\r
//\r
// DriverBinding Protocol Instance\r
\r
/**\r
Test controller is a keyboard Controller.\r
- \r
+\r
@param This Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
@param Controller driver's controller\r
@param RemainingDevicePath children device path\r
- \r
+\r
@retval EFI_UNSUPPORTED controller is not floppy disk\r
@retval EFI_SUCCESS controller is floppy disk\r
**/\r
\r
/**\r
Create KEYBOARD_CONSOLE_IN_DEV instance on controller.\r
- \r
+\r
@param This Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
@param Controller driver controller handle\r
@param RemainingDevicePath Children's device path\r
- \r
+\r
@retval whether success to create floppy control instance.\r
**/\r
EFI_STATUS\r
ConsoleIn->ConInEx.ReadKeyStrokeEx = KeyboardReadKeyStrokeEx;\r
ConsoleIn->ConInEx.SetState = KeyboardSetState;\r
ConsoleIn->ConInEx.RegisterKeyNotify = KeyboardRegisterKeyNotify;\r
- ConsoleIn->ConInEx.UnregisterKeyNotify = KeyboardUnregisterKeyNotify; \r
- \r
+ ConsoleIn->ConInEx.UnregisterKeyNotify = KeyboardUnregisterKeyNotify;\r
+\r
InitializeListHead (&ConsoleIn->NotifyList);\r
\r
//\r
// Fix for random hangs in System waiting for the Key if no KBC is present in BIOS.\r
- // When KBC decode (IO port 0x60/0x64 decode) is not enabled, \r
+ // When KBC decode (IO port 0x60/0x64 decode) is not enabled,\r
// KeyboardRead will read back as 0xFF and return status is EFI_SUCCESS.\r
// So instead we read status register to detect after read if KBC decode is enabled.\r
//\r
- \r
+\r
//\r
// Return code is ignored on purpose.\r
//\r
- KeyboardRead (ConsoleIn, &Data);\r
- if ((KeyReadStatusRegister (ConsoleIn) & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {\r
- //\r
- // If nobody decodes KBC I/O port, it will read back as 0xFF.\r
- // Check the Time-Out and Parity bit to see if it has an active KBC in system\r
- //\r
- Status = EFI_DEVICE_ERROR;\r
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;\r
- goto ErrorExit;\r
+ if (!PcdGetBool (PcdFastPS2Detection)) {\r
+ KeyboardRead (ConsoleIn, &Data);\r
+ if ((KeyReadStatusRegister (ConsoleIn) & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {\r
+ //\r
+ // If nobody decodes KBC I/O port, it will read back as 0xFF.\r
+ // Check the Time-Out and Parity bit to see if it has an active KBC in system\r
+ //\r
+ Status = EFI_DEVICE_ERROR;\r
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;\r
+ goto ErrorExit;\r
+ }\r
}\r
- \r
+\r
//\r
// Setup the WaitForKey event\r
//\r
}\r
//\r
// Setup the WaitForKeyEx event\r
- // \r
+ //\r
Status = gBS->CreateEvent (\r
EVT_NOTIFY_WAIT,\r
TPL_NOTIFY,\r
StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
goto ErrorExit;\r
}\r
+\r
// Setup a periodic timer, used for reading keystrokes at a fixed interval\r
//\r
Status = gBS->CreateEvent (\r
goto ErrorExit;\r
}\r
\r
+ Status = gBS->CreateEvent (\r
+ EVT_NOTIFY_SIGNAL,\r
+ TPL_CALLBACK,\r
+ KeyNotifyProcessHandler,\r
+ ConsoleIn,\r
+ &ConsoleIn->KeyNotifyProcessEvent\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
+ goto ErrorExit;\r
+ }\r
+\r
REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
EFI_PROGRESS_CODE,\r
EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_PRESENCE_DETECT,\r
goto ErrorExit;\r
}\r
\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_DETECTED,\r
+ ParentDevicePath\r
+ );\r
+\r
ConsoleIn->ControllerNameTable = NULL;\r
AddUnicodeString2 (\r
"eng",\r
if ((ConsoleIn != NULL) && (ConsoleIn->ConInEx.WaitForKeyEx != NULL)) {\r
gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
}\r
+ if ((ConsoleIn != NULL) && (ConsoleIn->KeyNotifyProcessEvent != NULL)) {\r
+ gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);\r
+ }\r
KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
if ((ConsoleIn != NULL) && (ConsoleIn->ControllerNameTable != NULL)) {\r
FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
Status1 = KeyboardRead (ConsoleIn, &Data);;\r
}\r
}\r
- \r
+\r
if (ConsoleIn != NULL) {\r
gBS->FreePool (ConsoleIn);\r
}\r
}\r
\r
/**\r
- Stop this driver on ControllerHandle. Support stoping any child handles\r
+ Stop this driver on ControllerHandle. Support stopping any child handles\r
created by this driver.\r
\r
@param This Protocol instance pointer.\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
- \r
+\r
ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);\r
\r
//\r
gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
ConsoleIn->ConInEx.WaitForKeyEx = NULL;\r
}\r
+ if (ConsoleIn->KeyNotifyProcessEvent != NULL) {\r
+ gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);\r
+ ConsoleIn->KeyNotifyProcessEvent = NULL;\r
+ }\r
KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
gBS->FreePool (ConsoleIn);\r
\r
/**\r
Free the waiting key notify list.\r
- \r
+\r
@param ListHead Pointer to list head\r
- \r
+\r
@retval EFI_INVALID_PARAMETER ListHead is NULL\r
@retval EFI_SUCCESS Sucess to free NotifyList\r
**/\r
}\r
while (!IsListEmpty (ListHead)) {\r
NotifyNode = CR (\r
- ListHead->ForwardLink, \r
- KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
- NotifyEntry, \r
+ ListHead->ForwardLink,\r
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY,\r
+ NotifyEntry,\r
KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
);\r
RemoveEntryList (ListHead->ForwardLink);\r
gBS->FreePool (NotifyNode);\r
}\r
- \r
+\r
return EFI_SUCCESS;\r
}\r
\r
/**\r
- The module Entry Point for module Ps2Keyboard. \r
+ The module Entry Point for module Ps2Keyboard.\r
\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
@param[in] SystemTable A pointer to the EFI System Table.\r
- \r
+\r
@retval EFI_SUCCESS The entry point is executed successfully.\r
@retval other Some error occurs when executing this entry point.\r
\r