}\r
\r
/**\r
- Starts the device with this driver.\r
+ Starts the keyboard device with this driver.\r
\r
This function produces Simple Text Input Protocol and Simple Text Input Ex Protocol,\r
initializes the keyboard device, and submit Asynchronous Interrupt Transfer to manage\r
//\r
REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
EFI_PROGRESS_CODE,\r
- PcdGet32 (PcdStatusCodeValueKeyboardEnable),\r
+ FixedPcdGet32 (PcdStatusCodeValueKeyboardEnable),\r
UsbKeyboardDevice->DevicePath\r
);\r
\r
//\r
REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
EFI_PROGRESS_CODE,\r
- PcdGet32 (PcdStatusCodeValueKeyboardPresenceDetect),\r
+ FixedPcdGet32 (PcdStatusCodeValueKeyboardPresenceDetect),\r
UsbKeyboardDevice->DevicePath\r
);\r
\r
EndpointNumber = UsbKeyboardDevice->InterfaceDescriptor.NumEndpoints;\r
\r
//\r
- // Traverse endpoints to find interrupt endpoints\r
+ // Traverse endpoints to find interrupt endpoint\r
//\r
Found = FALSE;\r
for (Index = 0; Index < EndpointNumber; Index++) {\r
&EndpointDescriptor\r
);\r
\r
- if ((EndpointDescriptor.Attributes & 0x03) == USB_ENDPOINT_INTERRUPT) {\r
+ if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) {\r
//\r
// We only care interrupt endpoint here\r
//\r
UsbKeyboardDevice->SimpleInputEx.ReadKeyStrokeEx = USBKeyboardReadKeyStrokeEx;\r
UsbKeyboardDevice->SimpleInputEx.SetState = USBKeyboardSetState;\r
UsbKeyboardDevice->SimpleInputEx.RegisterKeyNotify = USBKeyboardRegisterKeyNotify;\r
- UsbKeyboardDevice->SimpleInputEx.UnregisterKeyNotify = USBKeyboardUnregisterKeyNotify; \r
+ UsbKeyboardDevice->SimpleInputEx.UnregisterKeyNotify = USBKeyboardUnregisterKeyNotify;\r
\r
InitializeListHead (&UsbKeyboardDevice->NotifyList);\r
\r
UsbKeyboardDevice,\r
&(UsbKeyboardDevice->SimpleInput.WaitForKey)\r
);\r
-\r
- if (EFI_ERROR (Status)) {\r
- goto ErrorExit;\r
- }\r
-\r
- Status = InitKeyboardLayout (UsbKeyboardDevice);\r
if (EFI_ERROR (Status)) {\r
goto ErrorExit;\r
}\r
// Install Simple Text Input Protocol and Simple Text Input Ex Protocol\r
// for the USB keyboard device.\r
// USB keyboard is a hot plug device, and expected to work immediately\r
- // when plugging into system, so a HotPlugDeviceGuid is installed onto\r
- // the usb keyboard device handle, to distinguish it from other conventional\r
- // console devices.\r
+ // when plugging into system, other conventional console devices could\r
+ // distinguish it by its device path.\r
//\r
Status = gBS->InstallMultipleProtocolInterfaces (\r
&Controller,\r
&UsbKeyboardDevice->SimpleInput,\r
&gEfiSimpleTextInputExProtocolGuid,\r
&UsbKeyboardDevice->SimpleInputEx,\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
NULL\r
);\r
if (EFI_ERROR (Status)) {\r
goto ErrorExit;\r
}\r
\r
+ UsbKeyboardDevice->ControllerHandle = Controller;\r
+ Status = InitKeyboardLayout (UsbKeyboardDevice);\r
+ if (EFI_ERROR (Status)) {\r
+ gBS->UninstallMultipleProtocolInterfaces (\r
+ Controller,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ &UsbKeyboardDevice->SimpleInput,\r
+ &gEfiSimpleTextInputExProtocolGuid,\r
+ &UsbKeyboardDevice->SimpleInputEx,\r
+ NULL\r
+ );\r
+ goto ErrorExit;\r
+ }\r
+\r
+\r
//\r
// Reset USB Keyboard Device exhaustively.\r
//\r
&UsbKeyboardDevice->SimpleInput,\r
&gEfiSimpleTextInputExProtocolGuid,\r
&UsbKeyboardDevice->SimpleInputEx,\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
NULL\r
);\r
goto ErrorExit;\r
&UsbKeyboardDevice->SimpleInput,\r
&gEfiSimpleTextInputExProtocolGuid,\r
&UsbKeyboardDevice->SimpleInputEx,\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
NULL\r
);\r
goto ErrorExit;\r
if (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx != NULL) {\r
gBS->CloseEvent (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx);\r
}\r
- gBS->FreePool (UsbKeyboardDevice);\r
+ if (UsbKeyboardDevice->KeyboardLayoutEvent != NULL) {\r
+ gBS->CloseEvent (UsbKeyboardDevice->KeyboardLayoutEvent);\r
+ }\r
+ if (UsbKeyboardDevice->KeyConvertionTable != NULL) {\r
+ FreePool (UsbKeyboardDevice->KeyConvertionTable);\r
+ }\r
+ FreePool (UsbKeyboardDevice);\r
UsbKeyboardDevice = NULL;\r
}\r
gBS->CloseProtocol (\r
//\r
REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
EFI_PROGRESS_CODE,\r
- PcdGet32 (PcdStatusCodeValueKeyboardDisable),\r
+ FixedPcdGet32 (PcdStatusCodeValueKeyboardDisable),\r
UsbKeyboardDevice->DevicePath\r
);\r
\r
&UsbKeyboardDevice->SimpleInput,\r
&gEfiSimpleTextInputExProtocolGuid,\r
&UsbKeyboardDevice->SimpleInputEx,\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
NULL\r
);\r
//\r
FreeUnicodeStringTable (UsbKeyboardDevice->ControllerNameTable);\r
}\r
\r
- gBS->FreePool (UsbKeyboardDevice);\r
+ FreePool (UsbKeyboardDevice);\r
\r
return Status;\r
}\r
EFI_STATUS Status;\r
UINT8 KeyCode; \r
LIST_ENTRY *Link;\r
+ LIST_ENTRY *NotifyList;\r
KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify; \r
EFI_KEY_DATA OriginalKeyData;\r
\r
//\r
// Invoke notification functions if the key is registered.\r
//\r
- for (Link = GetFirstNode (&UsbKeyboardDevice->NotifyList);\r
- !IsNull (&UsbKeyboardDevice->NotifyList, Link);\r
- Link = GetNextNode (&UsbKeyboardDevice->NotifyList, Link)) {\r
+ NotifyList = &UsbKeyboardDevice->NotifyList;\r
+ for (Link = GetFirstNode (NotifyList);\r
+ !IsNull (NotifyList, Link);\r
+ Link = GetNextNode (NotifyList, Link)) {\r
CurrentNotify = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE);\r
if (IsKeyRegistered (&CurrentNotify->KeyData, &OriginalKeyData)) { \r
CurrentNotify->KeyNotificationFn (&OriginalKeyData);\r
}\r
\r
/**\r
- Reset the input device and optionaly run diagnostics\r
+ Reset the input device and optionally run diagnostics\r
\r
There are 2 types of reset for USB keyboard.\r
For non-exhaustive reset, only keyboard buffer is cleared.\r
\r
REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
EFI_PROGRESS_CODE,\r
- PcdGet32 (PcdStatusCodeValueKeyboardReset),\r
+ FixedPcdGet32 (PcdStatusCodeValueKeyboardReset),\r
UsbKeyboardDevice->DevicePath\r
);\r
\r
if (!ExtendedVerification) {\r
REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
EFI_PROGRESS_CODE,\r
- PcdGet32 (PcdStatusCodeValueKeyboardClearBuffer),\r
+ FixedPcdGet32 (PcdStatusCodeValueKeyboardClearBuffer),\r
UsbKeyboardDevice->DevicePath\r
);\r
//\r
\r
@retval EFI_SUCCESS The keystroke information was returned.\r
@retval EFI_NOT_READY There was no keystroke data availiable.\r
- @retval EFI_DEVICE_ERROR The keydtroke information was not returned due to\r
+ @retval EFI_DEVICE_ERROR The keystroke information was not returned due to\r
hardware errors.\r
\r
**/\r
Link = GetFirstNode (NotifyList);\r
NotifyNode = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE);\r
RemoveEntryList (Link);\r
- gBS->FreePool (NotifyNode);\r
+ FreePool (NotifyNode);\r
}\r
\r
return EFI_SUCCESS;\r
@param InputData A pointer to keystroke data for the key that was pressed.\r
\r
@retval TRUE Key pressed matches a registered key.\r
- @retval FLASE Key pressed does not matche a registered key.\r
+ @retval FLASE Key pressed does not matches a registered key.\r
\r
**/\r
BOOLEAN\r
@param NotifyHandle Points to the unique handle assigned to the registered notification.\r
\r
@retval EFI_SUCCESS The notification function was registered successfully.\r
- @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.\r
+ @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necessary data structures.\r
@retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or KeyNotificationFunction is NULL.\r
\r
**/\r
)\r
{\r
USB_KB_DEV *UsbKeyboardDevice;\r
- EFI_STATUS Status;\r
KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;\r
LIST_ENTRY *Link;\r
+ LIST_ENTRY *NotifyList;\r
KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify; \r
\r
if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {\r
//\r
// Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.\r
//\r
- for (Link = GetFirstNode (&UsbKeyboardDevice->NotifyList);\r
- !IsNull (&UsbKeyboardDevice->NotifyList, Link);\r
- Link = GetNextNode (&UsbKeyboardDevice->NotifyList, Link)) {\r
+ NotifyList = &UsbKeyboardDevice->NotifyList;\r
+ \r
+ for (Link = GetFirstNode (NotifyList);\r
+ !IsNull (NotifyList, Link);\r
+ Link = GetNextNode (NotifyList, Link)) {\r
CurrentNotify = CR (\r
Link, \r
KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
\r
NewNotify->Signature = USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE; \r
NewNotify->KeyNotificationFn = KeyNotificationFunction;\r
+ NewNotify->NotifyHandle = (EFI_HANDLE) NewNotify;\r
CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));\r
InsertTailList (&UsbKeyboardDevice->NotifyList, &NewNotify->NotifyEntry);\r
\r
- //\r
- // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE\r
- // \r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &NewNotify->NotifyHandle,\r
- &gSimpleTextInExNotifyGuid,\r
- NULL,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- \r
+\r
*NotifyHandle = NewNotify->NotifyHandle; \r
\r
return EFI_SUCCESS;\r
\r
@retval EFI_SUCCESS The notification function was unregistered successfully.\r
@retval EFI_INVALID_PARAMETER The NotificationHandle is invalid\r
- @retval EFI_NOT_FOUND Cannot find the matching entry in database.\r
\r
**/\r
EFI_STATUS\r
)\r
{\r
USB_KB_DEV *UsbKeyboardDevice;\r
- EFI_STATUS Status;\r
KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;\r
LIST_ENTRY *Link;\r
+ LIST_ENTRY *NotifyList;\r
\r
if (NotificationHandle == NULL) {\r
return EFI_INVALID_PARAMETER;\r
} \r
+\r
+ if (((KEYBOARD_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature != USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {\r
+ return EFI_INVALID_PARAMETER;\r
+ } \r
\r
UsbKeyboardDevice = TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS (This);\r
\r
- //\r
- // Check if NotificationHandle is returned from RegisterKeyNotify().\r
- //\r
- Status = gBS->OpenProtocol (\r
- NotificationHandle,\r
- &gSimpleTextInExNotifyGuid,\r
- NULL,\r
- NULL,\r
- NULL,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
//\r
// Traverse notify list of USB keyboard and remove the entry of NotificationHandle.\r
//\r
- for (Link = GetFirstNode (&UsbKeyboardDevice->NotifyList);\r
- !IsNull (&UsbKeyboardDevice->NotifyList, Link);\r
- Link = GetNextNode (&UsbKeyboardDevice->NotifyList, Link)) {\r
+ NotifyList = &UsbKeyboardDevice->NotifyList;\r
+ for (Link = GetFirstNode (NotifyList);\r
+ !IsNull (NotifyList, Link);\r
+ Link = GetNextNode (NotifyList, Link)) {\r
CurrentNotify = CR (\r
Link, \r
KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
// Remove the notification function from NotifyList and free resources\r
//\r
RemoveEntryList (&CurrentNotify->NotifyEntry); \r
- Status = gBS->UninstallMultipleProtocolInterfaces (\r
- CurrentNotify->NotifyHandle,\r
- &gSimpleTextInExNotifyGuid,\r
- NULL,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- gBS->FreePool (CurrentNotify); \r
+\r
+ FreePool (CurrentNotify); \r
return EFI_SUCCESS;\r
}\r
}\r
\r
- return EFI_NOT_FOUND; \r
+ //\r
+ // Cannot find the matching entry in database.\r
+ //\r
+ return EFI_INVALID_PARAMETER; \r
}\r
\r