Code Scrub for UsbKbDxe module.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7028 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xli24 2008-12-15 07:17:47 +00:00
parent 619c3f0826
commit b4e73a6373
6 changed files with 715 additions and 663 deletions

View File

@ -1,6 +1,5 @@
/** @file /** @file
UEFI Component Name(2) protocol implementation for USB Keyboard driver.
UEFI Component Name(2) protocol implementation for Usb Keyboard driver.
Copyright (c) 2004 - 2008, Intel Corporation Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
@ -16,136 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "KeyBoard.h" #include "KeyBoard.h"
//
// EFI Component Name Functions
//
/**
Retrieves a Unicode string that is the user readable name of the driver.
This function retrieves the user readable name of a driver in the form of a
Unicode string. If the driver specified by This has a user readable name in
the language specified by Language, then a pointer to the driver name is
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified
in RFC 3066 or ISO 639-2 language code format.
@param DriverName[out] A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by
This and the language specified by Language was
returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
UsbKeyboardComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
This function retrieves the user readable name of the controller specified by
ControllerHandle and ChildHandle in the form of a Unicode string. If the
driver specified by This has a user readable name in the language specified by
Language, then a pointer to the controller name is returned in ControllerName,
and EFI_SUCCESS is returned. If the driver specified by This is not currently
managing the controller specified by ControllerHandle and ChildHandle,
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle[in] The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param ChildHandle[in] The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
that wish to retrieve the name of the bus
controller. It will not be NULL for a bus
driver that wishes to retrieve the name of a
child controller.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified in
RFC 3066 or ISO 639-2 language code format.
@param ControllerName[out] A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
Language from the point of view of the driver
specified by This.
@retval EFI_SUCCESS The Unicode string for the user readable name in
the language specified by Language for the
driver specified by This was returned in
DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently
managing the controller specified by
ControllerHandle and ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
UsbKeyboardComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
// //
// EFI Component Name Protocol // EFI Component Name Protocol
// //
@ -170,7 +39,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTab
{ NULL , NULL } { NULL , NULL }
}; };
/** /**
Retrieves a Unicode string that is the user readable name of the driver. Retrieves a Unicode string that is the user readable name of the driver.
@ -181,10 +49,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTab
by This does not support the language specified by Language, by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned. then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance. EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language A pointer to a Null-terminated ASCII string
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the array indicating the language. This is the
language of the driver name that the caller is language of the driver name that the caller is
requesting, and it must match one of the requesting, and it must match one of the
@ -192,8 +59,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTab
number of languages supported by a driver is up number of languages supported by a driver is up
to the driver writer. Language is specified to the driver writer. Language is specified
in RFC 3066 or ISO 639-2 language code format. in RFC 3066 or ISO 639-2 language code format.
@param DriverName A pointer to the Unicode string to return.
@param DriverName[out] A pointer to the Unicode string to return.
This Unicode string is the name of the This Unicode string is the name of the
driver specified by This in the language driver specified by This in the language
specified by Language. specified by Language.
@ -201,11 +67,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTab
@retval EFI_SUCCESS The Unicode string for the Driver specified by @retval EFI_SUCCESS The Unicode string for the Driver specified by
This and the language specified by Language was This and the language specified by Language was
returned in DriverName. returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL. @retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL. @retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support @retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language. the language specified by Language.
@ -240,15 +103,13 @@ UsbKeyboardComponentNameGetDriverName (
then EFI_UNSUPPORTED is returned. If the driver specified by This does not then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned. support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance. EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle The handle of a controller that the driver
@param ControllerHandle[in] The handle of a controller that the driver
specified by This is managing. This handle specified by This is managing. This handle
specifies the controller whose name is to be specifies the controller whose name is to be
returned. returned.
@param ChildHandle The handle of the child controller to retrieve
@param ChildHandle[in] The handle of the child controller to retrieve
the name of. This is an optional parameter that the name of. This is an optional parameter that
may be NULL. It will be NULL for device may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers drivers. It will also be NULL for a bus drivers
@ -256,8 +117,7 @@ UsbKeyboardComponentNameGetDriverName (
controller. It will not be NULL for a bus controller. It will not be NULL for a bus
driver that wishes to retrieve the name of a driver that wishes to retrieve the name of a
child controller. child controller.
@param Language A pointer to a Null-terminated ASCII string
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the array indicating the language. This is the
language of the driver name that the caller is language of the driver name that the caller is
requesting, and it must match one of the requesting, and it must match one of the
@ -265,8 +125,7 @@ UsbKeyboardComponentNameGetDriverName (
number of languages supported by a driver is up number of languages supported by a driver is up
to the driver writer. Language is specified in to the driver writer. Language is specified in
RFC 3066 or ISO 639-2 language code format. RFC 3066 or ISO 639-2 language code format.
@param ControllerName A pointer to the Unicode string to return.
@param ControllerName[out] A pointer to the Unicode string to return.
This Unicode string is the name of the This Unicode string is the name of the
controller specified by ControllerHandle and controller specified by ControllerHandle and
ChildHandle in the language specified by ChildHandle in the language specified by
@ -277,20 +136,14 @@ UsbKeyboardComponentNameGetDriverName (
the language specified by Language for the the language specified by Language for the
driver specified by This was returned in driver specified by This was returned in
DriverName. DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE. EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL. @retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently @retval EFI_UNSUPPORTED The driver specified by This is not currently
managing the controller specified by managing the controller specified by
ControllerHandle and ChildHandle. ControllerHandle and ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support @retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language. the language specified by Language.

View File

@ -1,5 +1,6 @@
/** @file /** @file
USB Keyboard Driver that includes the implementation of interface. USB Keyboard Driver that manages USB keyboard and produces Simple Text Input
Protocol and Simple Text Input Ex Protocol.
Copyright (c) 2004 - 2008, Intel Corporation Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
@ -99,8 +100,8 @@ USBKeyboardDriverBindingSupported (
} }
// //
// Use the USB I/O Protocol interface to check whether the Controller is // Use the USB I/O Protocol interface to check whether Controller is
// the Keyboard controller that can be managed by this driver. // a keyboard device that can be managed by this driver.
// //
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -119,7 +120,11 @@ USBKeyboardDriverBindingSupported (
} }
/** /**
Start running driver on the controller. Starts the device with this driver.
This function produces Simple Text Input Protocol and Simple Text Input Ex Protocol,
initializes the keyboard device, and submit Asynchronous Interrupt Transfer to manage
this keyboard device.
@param This The USB keyboard driver binding instance. @param This The USB keyboard driver binding instance.
@param Controller Handle of device to bind driver to. @param Controller Handle of device to bind driver to.
@ -128,7 +133,7 @@ USBKeyboardDriverBindingSupported (
@retval EFI_SUCCESS The controller is controlled by the usb keyboard driver. @retval EFI_SUCCESS The controller is controlled by the usb keyboard driver.
@retval EFI_UNSUPPORTED No interrupt endpoint can be found. @retval EFI_UNSUPPORTED No interrupt endpoint can be found.
@retval Other The keyboard driver cannot support this controller. @retval Other This controller cannot be started.
**/ **/
EFI_STATUS EFI_STATUS
@ -201,9 +206,6 @@ USBKeyboardDriverBindingStart (
UsbKeyboardDevice->DevicePath UsbKeyboardDevice->DevicePath
); );
//
// Initialize UsbKeyboardDevice
//
UsbKeyboardDevice->UsbIo = UsbIo; UsbKeyboardDevice->UsbIo = UsbIo;
// //
@ -405,17 +407,18 @@ ErrorExit:
/** /**
Stop handling the controller by this USB keyboard driver. Stop the USB keyboard device handled by this driver.
@param This The USB keyboard driver binding protocol. @param This The USB keyboard driver binding protocol.
@param Controller The controller to release. @param Controller The controller to release.
@param NumberOfChildren The number of handles in ChildHandleBuffer. @param NumberOfChildren The number of handles in ChildHandleBuffer.
@param ChildHandleBuffer The array of child handle. @param ChildHandleBuffer The array of child handle.
@retval EFI_SUCCESS The controller or children are stopped. @retval EFI_SUCCESS The device was stopped.
@retval EFI_UNSUPPORTED Simple Text In Protocol or Simple Text In Ex Protocol @retval EFI_UNSUPPORTED Simple Text In Protocol or Simple Text In Ex Protocol
is not installed on Controller. is not installed on Controller.
@retval EFI_DEVICE_ERROR Failed to stop the driver. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
@retval Others Fail to uninstall protocols attached on the device.
**/ **/
EFI_STATUS EFI_STATUS
@ -454,9 +457,7 @@ USBKeyboardDriverBindingStop (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
//
// Get USB_KB_DEV instance.
//
UsbKeyboardDevice = USB_KB_DEV_FROM_THIS (SimpleInput); UsbKeyboardDevice = USB_KB_DEV_FROM_THIS (SimpleInput);
// //
@ -520,28 +521,29 @@ USBKeyboardDriverBindingStop (
} }
/** /**
Internal function to read the next keystroke from the input device. Internal function to read the next keystroke from the keyboard buffer.
@param UsbKeyboardDevice Usb keyboard's private structure. @param UsbKeyboardDevice USB keyboard's private structure.
@param KeyData A pointer to a buffer that is filled in with the keystroke @param KeyData A pointer to buffer to hold the keystroke
state data for the key that was pressed. data for the key that was pressed.
@return EFI_SUCCESS The keystroke information was returned. @retval EFI_SUCCESS The keystroke information was returned.
@return EFI_NOT_READY There was no keystroke data availiable. @retval EFI_NOT_READY There was no keystroke data availiable.
@return EFI_DEVICE_ERROR The keystroke information was not returned due to @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
hardware errors. hardware errors.
@return EFI_INVALID_PARAMETER KeyData is NULL. @retval EFI_INVALID_PARAMETER KeyData is NULL.
@retval Others Fail to translate keycode into EFI_INPUT_KEY
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
USBKeyboardReadKeyStrokeWorker ( USBKeyboardReadKeyStrokeWorker (
IN USB_KB_DEV *UsbKeyboardDevice, IN OUT USB_KB_DEV *UsbKeyboardDevice,
OUT EFI_KEY_DATA *KeyData OUT EFI_KEY_DATA *KeyData
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT8 KeyChar; UINT8 KeyCode;
LIST_ENTRY *Link; LIST_ENTRY *Link;
KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify; KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
EFI_KEY_DATA OriginalKeyData; EFI_KEY_DATA OriginalKeyData;
@ -551,10 +553,10 @@ USBKeyboardReadKeyStrokeWorker (
} }
// //
// If there is no saved ASCII byte, fetch it // If there is no saved USB keycode, fetch it
// by calling USBKeyboardCheckForKey(). // by calling USBKeyboardCheckForKey().
// //
if (UsbKeyboardDevice->CurKeyChar == 0) { if (UsbKeyboardDevice->CurKeyCode == 0) {
Status = USBKeyboardCheckForKey (UsbKeyboardDevice); Status = USBKeyboardCheckForKey (UsbKeyboardDevice);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_NOT_READY; return EFI_NOT_READY;
@ -565,15 +567,15 @@ USBKeyboardReadKeyStrokeWorker (
KeyData->Key.ScanCode = SCAN_NULL; KeyData->Key.ScanCode = SCAN_NULL;
// //
// Store the key char read by USBKeyboardCheckForKey() and clear it. // Store the current keycode and clear it.
// //
KeyChar = UsbKeyboardDevice->CurKeyChar; KeyCode = UsbKeyboardDevice->CurKeyCode;
UsbKeyboardDevice->CurKeyChar = 0; UsbKeyboardDevice->CurKeyCode = 0;
// //
// Translate saved ASCII byte into EFI_INPUT_KEY // Translate saved USB keycode into EFI_INPUT_KEY
// //
Status = UsbKeyCodeToEfiInputKey (UsbKeyboardDevice, KeyChar, &KeyData->Key); Status = UsbKeyCodeToEfiInputKey (UsbKeyboardDevice, KeyCode, &KeyData->Key);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -594,9 +596,9 @@ USBKeyboardReadKeyStrokeWorker (
// here switch them back for notification function. // here switch them back for notification function.
// //
CopyMem (&OriginalKeyData, KeyData, sizeof (EFI_KEY_DATA)); CopyMem (&OriginalKeyData, KeyData, sizeof (EFI_KEY_DATA));
if (UsbKeyboardDevice->CtrlOn != 0) { if (UsbKeyboardDevice->CtrlOn) {
if (OriginalKeyData.Key.UnicodeChar >= 0x01 && OriginalKeyData.Key.UnicodeChar <= 0x1A) { if (OriginalKeyData.Key.UnicodeChar >= 0x01 && OriginalKeyData.Key.UnicodeChar <= 0x1A) {
if (UsbKeyboardDevice->CapsOn != 0) { if (UsbKeyboardDevice->CapsOn) {
OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'A' - 1); OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'A' - 1);
} else { } else {
OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'a' - 1); OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'a' - 1);
@ -617,24 +619,21 @@ USBKeyboardReadKeyStrokeWorker (
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Reset USB Keyboard. Reset the input device and optionaly run diagnostics
There are 2 types of reset for USB keyboard. There are 2 types of reset for USB keyboard.
For non-exhaustive reset, only keyboard buffer is cleared. For non-exhaustive reset, only keyboard buffer is cleared.
For exhaustive reset, in addition to clearance of keyboard buffer, the hardware status For exhaustive reset, in addition to clearance of keyboard buffer, the hardware status
is also re-initialized. is also re-initialized.
@param This The protocol instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL. @param This Protocol instance pointer.
@param ExtendedVerification Indicates if exhaustive reset is used. @param ExtendedVerification Driver may perform diagnostics on reset.
TRUE for exhaustive reset.
FALSE for non-exhaustive reset.
@retval EFI_SUCCESS Keyboard is reset successfully. @retval EFI_SUCCESS The device was reset.
@retval EFI_DEVICE_ERROR Failed to reset keyboard. @retval EFI_DEVICE_ERROR The device is not functioning properly and could not be reset.
**/ **/
EFI_STATUS EFI_STATUS
@ -669,7 +668,7 @@ USBKeyboardReset (
// Clear the key buffer of this USB keyboard // Clear the key buffer of this USB keyboard
// //
InitUSBKeyBuffer (&(UsbKeyboardDevice->KeyboardBuffer)); InitUSBKeyBuffer (&(UsbKeyboardDevice->KeyboardBuffer));
UsbKeyboardDevice->CurKeyChar = 0; UsbKeyboardDevice->CurKeyCode = 0;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -678,7 +677,7 @@ USBKeyboardReset (
// Exhaustive reset // Exhaustive reset
// //
Status = InitUSBKeyboard (UsbKeyboardDevice); Status = InitUSBKeyboard (UsbKeyboardDevice);
UsbKeyboardDevice->CurKeyChar = 0; UsbKeyboardDevice->CurKeyCode = 0;
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -688,14 +687,16 @@ USBKeyboardReset (
/** /**
Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke() function. Reads the next keystroke from the input device.
@param This The EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance. @param This The EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance.
@param Key A pointer to a buffer that is filled in with the keystroke @param Key A pointer to a buffer that is filled in with the keystroke
information for the key that was pressed. information for the key that was pressed.
@retval EFI_SUCCESS Read key stroke successfully. @retval EFI_SUCCESS The keystroke information was returned.
@retval Other Read key stroke failed. @retval EFI_NOT_READY There was no keystroke data availiable.
@retval EFI_DEVICE_ERROR The keydtroke information was not returned due to
hardware errors.
**/ **/
EFI_STATUS EFI_STATUS
@ -719,12 +720,12 @@ USBKeyboardReadKeyStroke (
CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY)); CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Handler function for WaitForKey event. Event notification function registered for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx
and EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey.
@param Event Event to be signaled when a key is pressed. @param Event Event to be signaled when a key is pressed.
@param Context Points to USB_KB_DEV instance. @param Context Points to USB_KB_DEV instance.
@ -741,7 +742,7 @@ USBKeyboardWaitForKey (
UsbKeyboardDevice = (USB_KB_DEV *) Context; UsbKeyboardDevice = (USB_KB_DEV *) Context;
if (UsbKeyboardDevice->CurKeyChar == 0) { if (UsbKeyboardDevice->CurKeyCode == 0) {
if (EFI_ERROR (USBKeyboardCheckForKey (UsbKeyboardDevice))) { if (EFI_ERROR (USBKeyboardCheckForKey (UsbKeyboardDevice))) {
// //
// If no pending key, simply return. // If no pending key, simply return.
@ -757,7 +758,7 @@ USBKeyboardWaitForKey (
/** /**
Check whether there is key pending. Check whether there is key pending in the keyboard buffer.
@param UsbKeyboardDevice The USB_KB_DEV instance. @param UsbKeyboardDevice The USB_KB_DEV instance.
@ -768,53 +769,50 @@ USBKeyboardWaitForKey (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
USBKeyboardCheckForKey ( USBKeyboardCheckForKey (
IN USB_KB_DEV *UsbKeyboardDevice IN OUT USB_KB_DEV *UsbKeyboardDevice
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINT8 KeyChar; UINT8 KeyCode;
// //
// Fetch raw data from the USB keyboard input, // Fetch raw data from the USB keyboard buffer,
// and translate it into ASCII data. // and translate it into USB keycode.
// //
Status = USBParseKey (UsbKeyboardDevice, &KeyChar); Status = USBParseKey (UsbKeyboardDevice, &KeyCode);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_NOT_READY; return EFI_NOT_READY;
} }
UsbKeyboardDevice->CurKeyChar = KeyChar; UsbKeyboardDevice->CurKeyCode = KeyCode;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Free keyboard notify list. Free keyboard notify list.
@param ListHead The list head. @param NotifyList The keyboard notify list to free.
@retval EFI_SUCCESS Free the notify list successfully. @retval EFI_SUCCESS Free the notify list successfully.
@retval EFI_INVALID_PARAMETER ListHead is invalid. @retval EFI_INVALID_PARAMETER NotifyList is NULL.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
KbdFreeNotifyList ( KbdFreeNotifyList (
IN OUT LIST_ENTRY *ListHead IN OUT LIST_ENTRY *NotifyList
) )
{ {
KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode; KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
LIST_ENTRY *Link;
if (ListHead == NULL) { if (NotifyList == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
while (!IsListEmpty (ListHead)) { while (!IsListEmpty (NotifyList)) {
NotifyNode = CR ( Link = GetFirstNode (NotifyList);
ListHead->ForwardLink, NotifyNode = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
KEYBOARD_CONSOLE_IN_EX_NOTIFY, RemoveEntryList (Link);
NotifyEntry,
USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE
);
RemoveEntryList (ListHead->ForwardLink);
gBS->FreePool (NotifyNode); gBS->FreePool (NotifyNode);
} }
@ -822,15 +820,13 @@ KbdFreeNotifyList (
} }
/** /**
Whether the pressed key matches a registered key or not. Check whether the pressed key matches a registered key or not.
@param RegsiteredData A pointer to a buffer that is filled in with the keystroke @param RegsiteredData A pointer to keystroke data for the key that was registered.
state data for the key that was registered. @param InputData A pointer to keystroke data for the key that was pressed.
@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 pressed matches a registered key. @retval TRUE Key pressed matches a registered key.
@retval FLASE Match failed. @retval FLASE Key pressed does not matche a registered key.
**/ **/
BOOLEAN BOOLEAN
@ -860,21 +856,31 @@ IsKeyRegistered (
} }
return TRUE; return TRUE;
} }
// //
// Simple Text Input Ex protocol functions // Simple Text Input Ex protocol functions
// //
/** /**
The extension routine to reset the input device. Resets the input device hardware.
@param This Protocol instance pointer. The Reset() function resets the input device hardware. As part
@param ExtendedVerification Driver may perform diagnostics on reset. of initialization process, the firmware/device will make a quick
but reasonable attempt to verify that the device is functioning.
If the ExtendedVerification flag is TRUE the firmware may take
an extended amount of time to verify the device is operating on
reset. Otherwise the reset operation is to occur as quickly as
possible. The hardware verification process is not defined by
this specification and is left up to the platform firmware or
driver to implement.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param ExtendedVerification Indicates that the driver may perform a more exhaustive
verification operation of the device during reset.
@retval EFI_SUCCESS The device was reset. @retval EFI_SUCCESS The device was reset.
@retval EFI_DEVICE_ERROR The device is not functioning properly and could @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.
not be reset.
**/ **/
EFI_STATUS EFI_STATUS
@ -906,16 +912,17 @@ USBKeyboardResetEx (
} }
/** /**
Reads the next keystroke from the input device. The WaitForKey Event can Reads the next keystroke from the input device.
be used to test for existance of a keystroke via WaitForEvent () call.
@param This Protocol instance pointer. @param This Protocol instance pointer.
@param KeyData A pointer to a buffer that is filled in with the keystroke @param KeyData A pointer to a buffer that is filled in with the keystroke
state data for the key that was pressed. state data for the key that was pressed.
@return EFI_SUCCESS The keystroke information was returned successfully. @retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data available.
@retval EFI_DEVICE_ERROR The keystroke information was not returned due to
hardware errors.
@retval EFI_INVALID_PARAMETER KeyData is NULL. @retval EFI_INVALID_PARAMETER KeyData is NULL.
@retval Other Read key stroke information failed.
**/ **/
EFI_STATUS EFI_STATUS
@ -944,8 +951,10 @@ USBKeyboardReadKeyStrokeEx (
@param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
state for the input device. state for the input device.
@retval EFI_SUCCESS The device state was set successfully. @retval EFI_SUCCESS The device state was set appropriately.
@retval EFI_UNSUPPORTED The device does not have the ability to set its state. @retval EFI_DEVICE_ERROR The device is not functioning correctly and could
not have the setting adjusted.
@retval EFI_UNSUPPORTED The device does not support the ability to have its state set.
@retval EFI_INVALID_PARAMETER KeyToggleState is NULL. @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
**/ **/
@ -973,18 +982,18 @@ USBKeyboardSetState (
// Update the status light // Update the status light
// //
UsbKeyboardDevice->ScrollOn = 0; UsbKeyboardDevice->ScrollOn = FALSE;
UsbKeyboardDevice->NumLockOn = 0; UsbKeyboardDevice->NumLockOn = FALSE;
UsbKeyboardDevice->CapsOn = 0; UsbKeyboardDevice->CapsOn = FALSE;
if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) { if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {
UsbKeyboardDevice->ScrollOn = 1; UsbKeyboardDevice->ScrollOn = TRUE;
} }
if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) { if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {
UsbKeyboardDevice->NumLockOn = 1; UsbKeyboardDevice->NumLockOn = TRUE;
} }
if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) { if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {
UsbKeyboardDevice->CapsOn = 1; UsbKeyboardDevice->CapsOn = TRUE;
} }
SetKeyLED (UsbKeyboardDevice); SetKeyLED (UsbKeyboardDevice);
@ -1007,7 +1016,7 @@ USBKeyboardSetState (
@retval EFI_SUCCESS The notification function was registered successfully. @retval EFI_SUCCESS The notification function was registered successfully.
@retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures. @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.
@retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL. @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or KeyNotificationFunction is NULL.
**/ **/
EFI_STATUS EFI_STATUS
@ -1088,9 +1097,8 @@ USBKeyboardRegisterKeyNotify (
@param NotificationHandle The handle of the notification function being unregistered. @param NotificationHandle The handle of the notification function being unregistered.
@retval EFI_SUCCESS The notification function was unregistered successfully. @retval EFI_SUCCESS The notification function was unregistered successfully.
@retval EFI_INVALID_PARAMETER The NotificationHandle is invalid or opening gSimpleTextInExNotifyGuid @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid
on NotificationHandle fails. @retval EFI_NOT_FOUND Cannot find the matching entry in database.
@retval EFI_NOT_FOUND Can not find the matching entry in database.
**/ **/
EFI_STATUS EFI_STATUS

View File

@ -54,7 +54,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define REPORT_PROTOCOL 1 #define REPORT_PROTOCOL 1
typedef struct { typedef struct {
UINT8 Down; BOOLEAN Down;
UINT8 KeyCode; UINT8 KeyCode;
} USB_KEY; } USB_KEY;
@ -110,31 +110,31 @@ typedef struct {
EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor; EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
USB_KB_BUFFER KeyboardBuffer; USB_KB_BUFFER KeyboardBuffer;
UINT8 CtrlOn; BOOLEAN CtrlOn;
UINT8 AltOn; BOOLEAN AltOn;
UINT8 ShiftOn; BOOLEAN ShiftOn;
UINT8 NumLockOn; BOOLEAN NumLockOn;
UINT8 CapsOn; BOOLEAN CapsOn;
UINT8 ScrollOn; BOOLEAN ScrollOn;
UINT8 LastKeyCodeArray[8]; UINT8 LastKeyCodeArray[8];
UINT8 CurKeyChar; UINT8 CurKeyCode;
UINT8 RepeatKey; UINT8 RepeatKey;
EFI_EVENT RepeatTimer; EFI_EVENT RepeatTimer;
EFI_UNICODE_STRING_TABLE *ControllerNameTable; EFI_UNICODE_STRING_TABLE *ControllerNameTable;
UINT8 LeftCtrlOn; BOOLEAN LeftCtrlOn;
UINT8 LeftAltOn; BOOLEAN LeftAltOn;
UINT8 LeftShiftOn; BOOLEAN LeftShiftOn;
UINT8 LeftLogoOn; BOOLEAN LeftLogoOn;
UINT8 RightCtrlOn; BOOLEAN RightCtrlOn;
UINT8 RightAltOn; BOOLEAN RightAltOn;
UINT8 RightShiftOn; BOOLEAN RightShiftOn;
UINT8 RightLogoOn; BOOLEAN RightLogoOn;
UINT8 MenuKeyOn; BOOLEAN MenuKeyOn;
UINT8 SysReqOn; BOOLEAN SysReqOn;
UINT8 AltGrOn; BOOLEAN AltGrOn;
EFI_KEY_STATE KeyState; EFI_KEY_STATE KeyState;
// //
@ -164,24 +164,20 @@ extern EFI_GUID gSimpleTextInExNotifyGuid;
#define TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS(a) \ #define TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS(a) \
CR(a, USB_KB_DEV, SimpleInputEx, USB_KB_DEV_SIGNATURE) CR(a, USB_KB_DEV, SimpleInputEx, USB_KB_DEV_SIGNATURE)
//
#define MOD_CONTROL_L 0x01 // According to Universal Serial Bus HID Usage Tables document ver 1.12,
#define MOD_CONTROL_R 0x10 // a Boot Keyboard should support the keycode range from 0x0 to 0x65 and 0xE0 to 0xE7.
#define MOD_SHIFT_L 0x02 // 0xE0 to 0xE7 are for modifier keys, and 0x0 to 0x3 are reserved for typical
#define MOD_SHIFT_R 0x20 // keyboard status or keyboard errors.
#define MOD_ALT_L 0x04 // So the number of valid non-modifier USB keycodes is 0x62, and the number of
#define MOD_ALT_R 0x40 // valid keycodes is 0x6A.
#define MOD_WIN_L 0x08 //
#define MOD_WIN_R 0x80 #define NUMBER_OF_VALID_NON_MODIFIER_USB_KEYCODE 0x62
#define NUMBER_OF_VALID_USB_KEYCODE 0x6A
typedef struct { //
UINT8 Mask; // 0x0 to 0x3 are reserved for typical keyboard status or keyboard errors.
UINT8 Key; //
} KB_MODIFIER; #define USBKBD_VALID_KEYCODE(Key) ((UINT8) (Key) > 3)
#define USB_KEYCODE_MAX_MAKE 0x62
#define USBKBD_VALID_KEYCODE(key) ((UINT8) (key) > 3)
typedef struct { typedef struct {
UINT8 NumLock : 1; UINT8 NumLock : 1;
@ -213,7 +209,11 @@ USBKeyboardDriverBindingSupported (
); );
/** /**
Start running driver on the controller. Starts the device with this driver.
This function produces Simple Text Input Protocol and Simple Text Input Ex Protocol,
initializes the keyboard device, and submit Asynchronous Interrupt Transfer to manage
this keyboard device.
@param This The USB keyboard driver binding instance. @param This The USB keyboard driver binding instance.
@param Controller Handle of device to bind driver to. @param Controller Handle of device to bind driver to.
@ -222,7 +222,7 @@ USBKeyboardDriverBindingSupported (
@retval EFI_SUCCESS The controller is controlled by the usb keyboard driver. @retval EFI_SUCCESS The controller is controlled by the usb keyboard driver.
@retval EFI_UNSUPPORTED No interrupt endpoint can be found. @retval EFI_UNSUPPORTED No interrupt endpoint can be found.
@retval Other The keyboard driver cannot support this controller. @retval Other This controller cannot be started.
**/ **/
EFI_STATUS EFI_STATUS
@ -234,17 +234,18 @@ USBKeyboardDriverBindingStart (
); );
/** /**
Stop handling the controller by this USB keyboard driver. Stop the USB keyboard device handled by this driver.
@param This The USB keyboard driver binding protocol. @param This The USB keyboard driver binding protocol.
@param Controller The controller to release. @param Controller The controller to release.
@param NumberOfChildren The number of handles in ChildHandleBuffer. @param NumberOfChildren The number of handles in ChildHandleBuffer.
@param ChildHandleBuffer The array of child handle. @param ChildHandleBuffer The array of child handle.
@retval EFI_SUCCESS The controller or children are stopped. @retval EFI_SUCCESS The device was stopped.
@retval EFI_UNSUPPORTED Simple Text In Protocol or Simple Text In Ex Protocol @retval EFI_UNSUPPORTED Simple Text In Protocol or Simple Text In Ex Protocol
is not installed on Controller. is not installed on Controller.
@retval EFI_DEVICE_ERROR Failed to stop the driver. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
@retval Others Fail to uninstall protocols attached on the device.
**/ **/
EFI_STATUS EFI_STATUS
@ -256,24 +257,135 @@ USBKeyboardDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer IN EFI_HANDLE *ChildHandleBuffer
); );
//
// EFI Component Name Functions
//
/**
Retrieves a Unicode string that is the user readable name of the driver.
This function retrieves the user readable name of a driver in the form of a
Unicode string. If the driver specified by This has a user readable name in
the language specified by Language, then a pointer to the driver name is
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified
in RFC 3066 or ISO 639-2 language code format.
@param DriverName A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by
This and the language specified by Language was
returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
UsbKeyboardComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
This function retrieves the user readable name of the controller specified by
ControllerHandle and ChildHandle in the form of a Unicode string. If the
driver specified by This has a user readable name in the language specified by
Language, then a pointer to the controller name is returned in ControllerName,
and EFI_SUCCESS is returned. If the driver specified by This is not currently
managing the controller specified by ControllerHandle and ChildHandle,
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param ChildHandle The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
that wish to retrieve the name of the bus
controller. It will not be NULL for a bus
driver that wishes to retrieve the name of a
child controller.
@param Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified in
RFC 3066 or ISO 639-2 language code format.
@param ControllerName A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
Language from the point of view of the driver
specified by This.
@retval EFI_SUCCESS The Unicode string for the user readable name in
the language specified by Language for the
driver specified by This was returned in
DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently
managing the controller specified by
ControllerHandle and ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
UsbKeyboardComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
// //
// Functions of Simple Text Input Protocol // Functions of Simple Text Input Protocol
// //
/** /**
Reset USB Keyboard. Reset the input device and optionaly run diagnostics
There are 2 types of reset for USB keyboard. There are 2 types of reset for USB keyboard.
For non-exhaustive reset, only keyboard buffer is cleared. For non-exhaustive reset, only keyboard buffer is cleared.
For exhaustive reset, in addition to clearance of keyboard buffer, the hardware status For exhaustive reset, in addition to clearance of keyboard buffer, the hardware status
is also re-initialized. is also re-initialized.
@param This The protocol instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL. @param This Protocol instance pointer.
@param ExtendedVerification Indicates if exhaustive reset is used. @param ExtendedVerification Driver may perform diagnostics on reset.
TRUE for exhaustive reset.
FALSE for non-exhaustive reset.
@retval EFI_SUCCESS Keyboard is reset successfully. @retval EFI_SUCCESS The device was reset.
@retval EFI_DEVICE_ERROR Failed to reset keyboard. @retval EFI_DEVICE_ERROR The device is not functioning properly and could not be reset.
**/ **/
EFI_STATUS EFI_STATUS
@ -284,14 +396,16 @@ USBKeyboardReset (
); );
/** /**
Implements EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke() function. Reads the next keystroke from the input device.
@param This The EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance. @param This The EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance.
@param Key A pointer to a buffer that is filled in with the keystroke @param Key A pointer to a buffer that is filled in with the keystroke
information for the key that was pressed. information for the key that was pressed.
@retval EFI_SUCCESS Read key stroke successfully. @retval EFI_SUCCESS The keystroke information was returned.
@retval Other Read key stroke failed. @retval EFI_NOT_READY There was no keystroke data availiable.
@retval EFI_DEVICE_ERROR The keydtroke information was not returned due to
hardware errors.
**/ **/
EFI_STATUS EFI_STATUS
@ -305,14 +419,25 @@ USBKeyboardReadKeyStroke (
// Simple Text Input Ex protocol functions // Simple Text Input Ex protocol functions
// //
/** /**
The extension routine to reset the input device. Resets the input device hardware.
@param This Protocol instance pointer. The Reset() function resets the input device hardware. As part
@param ExtendedVerification Driver may perform diagnostics on reset. of initialization process, the firmware/device will make a quick
but reasonable attempt to verify that the device is functioning.
If the ExtendedVerification flag is TRUE the firmware may take
an extended amount of time to verify the device is operating on
reset. Otherwise the reset operation is to occur as quickly as
possible. The hardware verification process is not defined by
this specification and is left up to the platform firmware or
driver to implement.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param ExtendedVerification Indicates that the driver may perform a more exhaustive
verification operation of the device during reset.
@retval EFI_SUCCESS The device was reset. @retval EFI_SUCCESS The device was reset.
@retval EFI_DEVICE_ERROR The device is not functioning properly and could @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.
not be reset.
**/ **/
EFI_STATUS EFI_STATUS
@ -323,16 +448,17 @@ USBKeyboardResetEx (
); );
/** /**
Reads the next keystroke from the input device. The WaitForKey Event can Reads the next keystroke from the input device.
be used to test for existance of a keystroke via WaitForEvent () call.
@param This Protocol instance pointer. @param This Protocol instance pointer.
@param KeyData A pointer to a buffer that is filled in with the keystroke @param KeyData A pointer to a buffer that is filled in with the keystroke
state data for the key that was pressed. state data for the key that was pressed.
@return EFI_SUCCESS The keystroke information was returned successfully. @retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data available.
@retval EFI_DEVICE_ERROR The keystroke information was not returned due to
hardware errors.
@retval EFI_INVALID_PARAMETER KeyData is NULL. @retval EFI_INVALID_PARAMETER KeyData is NULL.
@retval Other Read key stroke information failed.
**/ **/
EFI_STATUS EFI_STATUS
@ -349,8 +475,10 @@ USBKeyboardReadKeyStrokeEx (
@param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
state for the input device. state for the input device.
@retval EFI_SUCCESS The device state was set successfully. @retval EFI_SUCCESS The device state was set appropriately.
@retval EFI_UNSUPPORTED The device does not have the ability to set its state. @retval EFI_DEVICE_ERROR The device is not functioning correctly and could
not have the setting adjusted.
@retval EFI_UNSUPPORTED The device does not support the ability to have its state set.
@retval EFI_INVALID_PARAMETER KeyToggleState is NULL. @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
**/ **/
@ -373,7 +501,7 @@ USBKeyboardSetState (
@retval EFI_SUCCESS The notification function was registered successfully. @retval EFI_SUCCESS The notification function was registered successfully.
@retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures. @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.
@retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL. @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or KeyNotificationFunction is NULL.
**/ **/
EFI_STATUS EFI_STATUS
@ -392,9 +520,8 @@ USBKeyboardRegisterKeyNotify (
@param NotificationHandle The handle of the notification function being unregistered. @param NotificationHandle The handle of the notification function being unregistered.
@retval EFI_SUCCESS The notification function was unregistered successfully. @retval EFI_SUCCESS The notification function was unregistered successfully.
@retval EFI_INVALID_PARAMETER The NotificationHandle is invalid or opening gSimpleTextInExNotifyGuid @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid
on NotificationHandle fails. @retval EFI_NOT_FOUND Cannot find the matching entry in database.
@retval EFI_NOT_FOUND Can not find the matching entry in database.
**/ **/
EFI_STATUS EFI_STATUS
@ -405,7 +532,8 @@ USBKeyboardUnregisterKeyNotify (
); );
/** /**
Handler function for WaitForKey event. Event notification function registered for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx
and EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey.
@param Event Event to be signaled when a key is pressed. @param Event Event to be signaled when a key is pressed.
@param Context Points to USB_KB_DEV instance. @param Context Points to USB_KB_DEV instance.
@ -421,20 +549,20 @@ USBKeyboardWaitForKey (
/** /**
Free keyboard notify list. Free keyboard notify list.
@param ListHead The list head. @param NotifyList The keyboard notify list to free.
@retval EFI_SUCCESS Free the notify list successfully. @retval EFI_SUCCESS Free the notify list successfully.
@retval EFI_INVALID_PARAMETER ListHead is invalid. @retval EFI_INVALID_PARAMETER NotifyList is NULL.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
KbdFreeNotifyList ( KbdFreeNotifyList (
IN OUT LIST_ENTRY *ListHead IN OUT LIST_ENTRY *NotifyList
); );
/** /**
Check whether there is key pending. Check whether there is key pending in the keyboard buffer.
@param UsbKeyboardDevice The USB_KB_DEV instance. @param UsbKeyboardDevice The USB_KB_DEV instance.
@ -445,19 +573,17 @@ KbdFreeNotifyList (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
USBKeyboardCheckForKey ( USBKeyboardCheckForKey (
IN USB_KB_DEV *UsbKeyboardDevice IN OUT USB_KB_DEV *UsbKeyboardDevice
); );
/** /**
Whether the pressed key matches a registered key or not. Check whether the pressed key matches a registered key or not.
@param RegsiteredData A pointer to a buffer that is filled in with the keystroke @param RegsiteredData A pointer to keystroke data for the key that was registered.
state data for the key that was registered. @param InputData A pointer to keystroke data for the key that was pressed.
@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 pressed matches a registered key. @retval TRUE Key pressed matches a registered key.
@retval FLASE Match failed. @retval FLASE Key pressed does not matche a registered key.
**/ **/
BOOLEAN BOOLEAN

File diff suppressed because it is too large Load Diff

View File

@ -19,10 +19,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "EfiKey.h" #include "EfiKey.h"
/** /**
Uses USB I/O to check whether the device is a USB Keyboard device. Uses USB I/O to check whether the device is a USB keyboard device.
@param UsbIo Points to a USB I/O protocol instance. @param UsbIo Pointer to a USB I/O protocol instance.
@retval None
@retval TRUE Device is a USB keyboard device.
@retval FALSE Device is a not USB keyboard device.
**/ **/
BOOLEAN BOOLEAN
@ -32,37 +34,43 @@ IsUSBKeyboard (
); );
/** /**
Initialize USB Keyboard device and all private data structures. Initialize USB keyboard device and all private data structures.
@param UsbKeyboardDevice The USB_KB_DEV instance. @param UsbKeyboardDevice The USB_KB_DEV instance.
@retval EFI_SUCCESS Initialization is successful. @retval EFI_SUCCESS Initialization is successful.
@retval EFI_DEVICE_ERROR Configure hardware failed. @retval EFI_DEVICE_ERROR Keyboard initialization failed.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitUSBKeyboard ( InitUSBKeyboard (
IN USB_KB_DEV *UsbKeyboardDevice IN OUT USB_KB_DEV *UsbKeyboardDevice
); );
/** /**
Initialize USB Keyboard layout. Initialize USB keyboard layout.
This function initializes Key Convertion Table for the USB keyboard device.
It first tries to retrieve layout from HII database. If failed and default
layout is enabled, then it just uses the default layout.
@param UsbKeyboardDevice The USB_KB_DEV instance. @param UsbKeyboardDevice The USB_KB_DEV instance.
@retval EFI_SUCCESS Initialization Success. @retval EFI_SUCCESS Initialization succeeded.
@retval Other Keyboard layout initial failed. @retval EFI_NOT_READY Keyboard layout cannot be retrieve from HII
database, and default layout is disabled.
@retval Other Fail to register event to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitKeyboardLayout ( InitKeyboardLayout (
IN USB_KB_DEV *UsbKeyboardDevice OUT USB_KB_DEV *UsbKeyboardDevice
); );
/** /**
Destroy resources for Keyboard layout. Destroy resources for keyboard layout.
@param UsbKeyboardDevice The USB_KB_DEV instance. @param UsbKeyboardDevice The USB_KB_DEV instance.
@ -70,11 +78,16 @@ InitKeyboardLayout (
VOID VOID
EFIAPI EFIAPI
ReleaseKeyboardLayoutResources ( ReleaseKeyboardLayoutResources (
IN USB_KB_DEV *UsbKeyboardDevice IN OUT USB_KB_DEV *UsbKeyboardDevice
); );
/** /**
Handler function for USB Keyboard's asynchronous interrupt transfer. Handler function for USB keyboard's asynchronous interrupt transfer.
This function is the handler function for USB keyboard's asynchronous interrupt transfer
to manage the keyboard. It parses the USB keyboard input report, and inserts data to
keyboard buffer according to state of modifer keys and normal keys. Timer for repeat key
is also set accordingly.
@param Data A pointer to a buffer that is filled with key data which is @param Data A pointer to a buffer that is filled with key data which is
retrieved via asynchronous interrupt transfer. retrieved via asynchronous interrupt transfer.
@ -82,8 +95,8 @@ ReleaseKeyboardLayoutResources (
@param Context Pointing to USB_KB_DEV instance. @param Context Pointing to USB_KB_DEV instance.
@param Result Indicates the result of the asynchronous interrupt transfer. @param Result Indicates the result of the asynchronous interrupt transfer.
@retval EFI_SUCCESS Handler is successful. @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
@retval EFI_DEVICE_ERROR Hardware Error @retval EFI_DEVICE_ERROR Hardware error occurs.
**/ **/
EFI_STATUS EFI_STATUS
@ -96,12 +109,17 @@ KeyboardHandler (
); );
/** /**
Timer handler for Delayed Recovery timer. Handler for Delayed Recovery event.
This function is the handler for Delayed Recovery event triggered
by timer.
After a device error occurs, the event would be triggered
with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
is defined in USB standard for error handling.
@param Event The Delayed Recovery event. @param Event The Delayed Recovery event.
@param Context Points to the USB_KB_DEV instance. @param Context Points to the USB_KB_DEV instance.
**/ **/
VOID VOID
EFIAPI EFIAPI
@ -111,62 +129,67 @@ USBKeyboardRecoveryHandler (
); );
/** /**
Retrieves a key character after parsing the raw data in keyboard buffer. Retrieves a USB keycode after parsing the raw data in keyboard buffer.
This function parses keyboard buffer. It updates state of modifier key for
USB_KB_DEV instancem, and returns keycode for output.
@param UsbKeyboardDevice The USB_KB_DEV instance. @param UsbKeyboardDevice The USB_KB_DEV instance.
@param KeyChar Points to the Key character after key parsing. @param KeyCode Pointer to the USB keycode for output.
@retval EFI_SUCCESS Parse key is successful. @retval EFI_SUCCESS Keycode successfully parsed.
@retval EFI_NOT_READY Device is not ready. @retval EFI_NOT_READY Keyboard buffer is not ready for a valid keycode
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
USBParseKey ( USBParseKey (
IN OUT USB_KB_DEV *UsbKeyboardDevice, IN OUT USB_KB_DEV *UsbKeyboardDevice,
OUT UINT8 *KeyChar OUT UINT8 *KeyCode
); );
/** /**
Converts USB Keyboard code to EFI Scan Code. Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.
@param UsbKeyboardDevice The USB_KB_DEV instance. @param UsbKeyboardDevice The USB_KB_DEV instance.
@param KeyChar Indicates the key code that will be interpreted. @param KeyCode Indicates the key code that will be interpreted.
@param Key A pointer to a buffer that is filled in with @param Key A pointer to a buffer that is filled in with
the keystroke information for the key that the keystroke information for the key that
was pressed. was pressed.
@retval EFI_NOT_READY Device is not ready
@retval EFI_SUCCESS Success. @retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.
@retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.
@retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
UsbKeyCodeToEfiInputKey ( UsbKeyCodeToEfiInputKey (
IN USB_KB_DEV *UsbKeyboardDevice, IN USB_KB_DEV *UsbKeyboardDevice,
IN UINT8 KeyChar, IN UINT8 KeyCode,
OUT EFI_INPUT_KEY *Key OUT EFI_INPUT_KEY *Key
); );
/** /**
Resets USB Keyboard Buffer. Resets USB keyboard buffer.
@param KeyboardBuffer Points to the USB Keyboard Buffer. @param KeyboardBuffer Points to the USB keyboard buffer.
**/ **/
VOID VOID
EFIAPI EFIAPI
InitUSBKeyBuffer ( InitUSBKeyBuffer (
IN OUT USB_KB_BUFFER *KeyboardBuffer OUT USB_KB_BUFFER *KeyboardBuffer
); );
/** /**
Check whether USB Keyboard buffer is empty. Check whether USB keyboard buffer is empty.
@param KeyboardBuffer USB Keyboard Buffer. @param KeyboardBuffer USB keyboard buffer
@retval TRUE Key buffer is empty. @retval TRUE Keyboard buffer is empty.
@retval FALSE Key buffer is not empty. @retval FALSE Keyboard buffer is not empty.
**/ **/
BOOLEAN BOOLEAN
@ -176,12 +199,12 @@ IsUSBKeyboardBufferEmpty (
); );
/** /**
Check whether USB Keyboard buffer is full. Check whether USB keyboard buffer is full.
@param KeyboardBuffer USB Keyboard Buffer. @param KeyboardBuffer USB keyboard buffer
@retval TRUE Key buffer is full. @retval TRUE Keyboard buffer is full.
@retval FALSE Key buffer is not full. @retval FALSE Keyboard buffer is not full.
**/ **/
BOOLEAN BOOLEAN
@ -191,11 +214,12 @@ IsUSBKeyboardBufferFull (
); );
/** /**
Inserts a key code into keyboard buffer. Inserts a keycode into keyboard buffer.
@param KeyboardBuffer Points to the USB Keyboard Buffer. @param KeyboardBuffer Points to the USB keyboard buffer.
@param Key Key code @param Key Keycode to insert.
@param Down Special key @param Down TRUE means key is pressed.
FALSE means key is released.
**/ **/
VOID VOID
@ -207,13 +231,13 @@ InsertKeyCode (
); );
/** /**
Pops a key code off from keyboard buffer. Remove a keycode from keyboard buffer and return it.
@param KeyboardBuffer Points to the USB Keyboard Buffer. @param KeyboardBuffer Points to the USB keyboard buffer.
@param UsbKey Points to the buffer that contains a usb key code. @param UsbKey Points to the buffer that contains keycode for output.
@retval EFI_SUCCESS Success @retval EFI_SUCCESS Keycode successfully removed from keyboard buffer.
@retval EFI_DEVICE_ERROR Hardware Error @retval EFI_DEVICE_ERROR Keyboard buffer is empty.
**/ **/
EFI_STATUS EFI_STATUS
@ -224,12 +248,17 @@ RemoveKeyCode (
); );
/** /**
Timer handler for Repeat Key timer. Handler for Repeat Key event.
This function is the handler for Repeat Key event triggered
by timer.
After a repeatable key is pressed, the event would be triggered
with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,
following trigger will come with interval of USBKBD_REPEAT_RATE.
@param Event The Repeat Key event. @param Event The Repeat Key event.
@param Context Points to the USB_KB_DEV instance. @param Context Points to the USB_KB_DEV instance.
**/ **/
VOID VOID
EFIAPI EFIAPI
@ -239,7 +268,7 @@ USBKeyboardRepeatHandler (
); );
/** /**
Sets USB Keyboard LED state. Sets USB keyboard LED state.
@param UsbKeyboardDevice The USB_KB_DEV instance. @param UsbKeyboardDevice The USB_KB_DEV instance.

View File

@ -1,8 +1,8 @@
#/** @file #/** @file
# Component name for module UsbKb # USB Keyboard Driver that manages USB keyboard and produces Simple Text Input
# Protocol and Simple Text Input Ex Protocol.
# #
# FIX ME! # Copyright (c) 2006 - 2008, Intel Corporation.
# Copyright (c) 2006, Intel Corporation.
# #
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License