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
+ 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
&UsbKeyboardDevice->SimpleInput,\r
&gEfiSimpleTextInputExProtocolGuid,\r
&UsbKeyboardDevice->SimpleInputEx,\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
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
\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
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
// 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
+\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