TianoCore EDK2 master
Loading...
Searching...
No Matches
EfiKey.c File Reference
#include "EfiKey.h"
#include "KeyBoard.h"

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI USBKeyboardDriverBindingEntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI USBKeyboardDriverBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI USBKeyboardDriverBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI USBKeyboardDriverBindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS USBKeyboardReadKeyStrokeWorker (IN OUT USB_KB_DEV *UsbKeyboardDevice, OUT EFI_KEY_DATA *KeyData)
 
EFI_STATUS EFIAPI USBKeyboardReset (IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
 
EFI_STATUS EFIAPI USBKeyboardReadKeyStroke (IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, OUT EFI_INPUT_KEY *Key)
 
VOID EFIAPI USBKeyboardWaitForKey (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI USBKeyboardTimerHandler (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS KbdFreeNotifyList (IN OUT LIST_ENTRY *NotifyList)
 
BOOLEAN IsKeyRegistered (IN EFI_KEY_DATA *RegsiteredData, IN EFI_KEY_DATA *InputData)
 
EFI_STATUS EFIAPI USBKeyboardResetEx (IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
 
EFI_STATUS EFIAPI USBKeyboardReadKeyStrokeEx (IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, OUT EFI_KEY_DATA *KeyData)
 
EFI_STATUS EFIAPI USBKeyboardSetState (IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_TOGGLE_STATE *KeyToggleState)
 
EFI_STATUS EFIAPI USBKeyboardRegisterKeyNotify (IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_DATA *KeyData, IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, OUT VOID **NotifyHandle)
 
EFI_STATUS EFIAPI USBKeyboardUnregisterKeyNotify (IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN VOID *NotificationHandle)
 
VOID EFIAPI KeyNotifyProcessHandler (IN EFI_EVENT Event, IN VOID *Context)
 

Variables

EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding
 

Detailed Description

USB Keyboard Driver that manages USB keyboard and produces Simple Text Input Protocol and Simple Text Input Ex Protocol.

Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file EfiKey.c.

Function Documentation

◆ IsKeyRegistered()

BOOLEAN IsKeyRegistered ( IN EFI_KEY_DATA RegsiteredData,
IN EFI_KEY_DATA InputData 
)

Check whether the pressed key matches a registered key or not.

Parameters
RegsiteredDataA pointer to keystroke data for the key that was registered.
InputDataA pointer to keystroke data for the key that was pressed.
Return values
TRUEKey pressed matches a registered key.
FALSEKey pressed does not matches a registered key.

Definition at line 887 of file EfiKey.c.

◆ KbdFreeNotifyList()

EFI_STATUS KbdFreeNotifyList ( IN OUT LIST_ENTRY NotifyList)

Free keyboard notify list.

Parameters
NotifyListThe keyboard notify list to free.
Return values
EFI_SUCCESSFree the notify list successfully.
EFI_INVALID_PARAMETERNotifyList is NULL.

Definition at line 855 of file EfiKey.c.

◆ KeyNotifyProcessHandler()

VOID EFIAPI KeyNotifyProcessHandler ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Process key notify.

Parameters
EventIndicates the event that invoke this function.
ContextIndicates the calling context.

Definition at line 1215 of file EfiKey.c.

◆ USBKeyboardDriverBindingEntryPoint()

EFI_STATUS EFIAPI USBKeyboardDriverBindingEntryPoint ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Entrypoint of USB Keyboard Driver.

This function is the entrypoint of USB Keyboard Driver. It installs Driver Binding Protocols together with Component Name Protocols.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.

Definition at line 39 of file EfiKey.c.

◆ USBKeyboardDriverBindingStart()

EFI_STATUS EFIAPI USBKeyboardDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Starts the keyboard 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.

Parameters
ThisThe USB keyboard driver binding instance.
ControllerHandle of device to bind driver to.
RemainingDevicePathOptional parameter use to pick a specific child device to start.
Return values
EFI_SUCCESSThe controller is controlled by the usb keyboard driver.
EFI_UNSUPPORTEDNo interrupt endpoint can be found.
OtherThis controller cannot be started.

Definition at line 135 of file EfiKey.c.

◆ USBKeyboardDriverBindingStop()

EFI_STATUS EFIAPI USBKeyboardDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Stop the USB keyboard device handled by this driver.

Parameters
ThisThe USB keyboard driver binding protocol.
ControllerThe controller to release.
NumberOfChildrenThe number of handles in ChildHandleBuffer.
ChildHandleBufferThe array of child handle.
Return values
EFI_SUCCESSThe device was stopped.
EFI_UNSUPPORTEDSimple Text In Protocol or Simple Text In Ex Protocol is not installed on Controller.
EFI_DEVICE_ERRORThe device could not be stopped due to a device error.
OthersFail to uninstall protocols attached on the device.

Definition at line 483 of file EfiKey.c.

◆ USBKeyboardDriverBindingSupported()

EFI_STATUS EFIAPI USBKeyboardDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Check whether USB keyboard driver supports this device.

Parameters
ThisThe USB keyboard driver binding protocol.
ControllerThe controller handle to check.
RemainingDevicePathThe remaining device path.
Return values
EFI_SUCCESSThe driver supports this controller.
otherThis device isn't supported.

Definition at line 72 of file EfiKey.c.

◆ USBKeyboardReadKeyStroke()

EFI_STATUS EFIAPI USBKeyboardReadKeyStroke ( IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL This,
OUT EFI_INPUT_KEY Key 
)

Reads the next keystroke from the input device.

Parameters
ThisThe EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance.
KeyA pointer to a buffer that is filled in with the keystroke information for the key that was pressed.
Return values
EFI_SUCCESSThe keystroke information was returned.
EFI_NOT_READYThere was no keystroke data available.
EFI_DEVICE_ERRORThe keystroke information was not returned due to hardware errors.
EFI_UNSUPPORTEDThe device does not support the ability to read keystroke data.

Definition at line 700 of file EfiKey.c.

◆ USBKeyboardReadKeyStrokeEx()

EFI_STATUS EFIAPI USBKeyboardReadKeyStrokeEx ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL This,
OUT EFI_KEY_DATA KeyData 
)

Reads the next keystroke from the input device.

Parameters
ThisProtocol instance pointer.
KeyDataA pointer to a buffer that is filled in with the keystroke state data for the key that was pressed.
Return values
EFI_SUCCESSThe keystroke information was returned.
EFI_NOT_READYThere was no keystroke data available.
EFI_DEVICE_ERRORThe keystroke information was not returned due to hardware errors.
EFI_INVALID_PARAMETERKeyData is NULL.
EFI_UNSUPPORTEDThe device does not support the ability to read keystroke data.

Definition at line 984 of file EfiKey.c.

◆ USBKeyboardReadKeyStrokeWorker()

EFI_STATUS USBKeyboardReadKeyStrokeWorker ( IN OUT USB_KB_DEV UsbKeyboardDevice,
OUT EFI_KEY_DATA KeyData 
)

Internal function to read the next keystroke from the keyboard buffer.

Parameters
UsbKeyboardDeviceUSB keyboard's private structure.
KeyDataA pointer to buffer to hold the keystroke data for the key that was pressed.
Return values
EFI_SUCCESSThe keystroke information was returned.
EFI_NOT_READYThere was no keystroke data available.
EFI_DEVICE_ERRORThe keystroke information was not returned due to hardware errors.
EFI_INVALID_PARAMETERKeyData is NULL.
OthersFail to translate keycode into EFI_INPUT_KEY

Definition at line 600 of file EfiKey.c.

◆ USBKeyboardRegisterKeyNotify()

EFI_STATUS EFIAPI USBKeyboardRegisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL This,
IN EFI_KEY_DATA KeyData,
IN EFI_KEY_NOTIFY_FUNCTION  KeyNotificationFunction,
OUT VOID **  NotifyHandle 
)

Register a notification function for a particular keystroke for the input device.

Parameters
ThisProtocol instance pointer.
KeyDataA pointer to a buffer that is filled in with the keystroke information for the key that was pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState are 0, then any incomplete keystroke will trigger a notification of the KeyNotificationFunction.
KeyNotificationFunctionPoints to the function to be called when the key sequence is typed specified by KeyData. This notification function should be called at <=TPL_CALLBACK.
NotifyHandlePoints to the unique handle assigned to the registered notification.
Return values
EFI_SUCCESSThe notification function was registered successfully.
EFI_OUT_OF_RESOURCESUnable to allocate resources for necessary data structures.
EFI_INVALID_PARAMETERKeyData or NotifyHandle or KeyNotificationFunction is NULL.

Definition at line 1088 of file EfiKey.c.

◆ USBKeyboardReset()

EFI_STATUS EFIAPI USBKeyboardReset ( IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL This,
IN BOOLEAN  ExtendedVerification 
)

Reset the input device and optionally run diagnostics

There are 2 types of reset for USB keyboard. For non-exhaustive reset, only keyboard buffer is cleared. For exhaustive reset, in addition to clearance of keyboard buffer, the hardware status is also re-initialized.

Parameters
ThisProtocol instance pointer.
ExtendedVerificationDriver may perform diagnostics on reset.
Return values
EFI_SUCCESSThe device was reset.
EFI_DEVICE_ERRORThe device is not functioning properly and could not be reset.

Definition at line 637 of file EfiKey.c.

◆ USBKeyboardResetEx()

EFI_STATUS EFIAPI USBKeyboardResetEx ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL This,
IN BOOLEAN  ExtendedVerification 
)

Resets the input device hardware.

The Reset() function resets the input device hardware. As part 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.

Parameters
ThisA pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
ExtendedVerificationIndicates that the driver may perform a more exhaustive verification operation of the device during reset.
Return values
EFI_SUCCESSThe device was reset.
EFI_DEVICE_ERRORThe device is not functioning correctly and could not be reset.

Definition at line 946 of file EfiKey.c.

◆ USBKeyboardSetState()

EFI_STATUS EFIAPI USBKeyboardSetState ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL This,
IN EFI_KEY_TOGGLE_STATE KeyToggleState 
)

Set certain state for the input device.

Parameters
ThisProtocol instance pointer.
KeyToggleStateA pointer to the EFI_KEY_TOGGLE_STATE to set the state for the input device.
Return values
EFI_SUCCESSThe device state was set appropriately.
EFI_DEVICE_ERRORThe device is not functioning correctly and could not have the setting adjusted.
EFI_UNSUPPORTEDThe device does not support the ability to have its state set.
EFI_INVALID_PARAMETERKeyToggleState is NULL.

Definition at line 1016 of file EfiKey.c.

◆ USBKeyboardTimerHandler()

VOID EFIAPI USBKeyboardTimerHandler ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Timer handler to convert the key from USB.

Parameters
EventIndicates the event that invoke this function.
ContextIndicates the calling context.

Definition at line 810 of file EfiKey.c.

◆ USBKeyboardUnregisterKeyNotify()

EFI_STATUS EFIAPI USBKeyboardUnregisterKeyNotify ( IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL This,
IN VOID *  NotificationHandle 
)

Remove a registered notification function from a particular keystroke.

Parameters
ThisProtocol instance pointer.
NotificationHandleThe handle of the notification function being unregistered.
Return values
EFI_SUCCESSThe notification function was unregistered successfully.
EFI_INVALID_PARAMETERThe NotificationHandle is invalid

Definition at line 1160 of file EfiKey.c.

◆ USBKeyboardWaitForKey()

VOID EFIAPI USBKeyboardWaitForKey ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Event notification function registered for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx and EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey.

Parameters
EventEvent to be signaled when a key is pressed.
ContextPoints to USB_KB_DEV instance.

Definition at line 756 of file EfiKey.c.

Variable Documentation

◆ gUsbKeyboardDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding
Initial value:
= {
0xa,
}
EFI_STATUS EFIAPI USBKeyboardDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: EfiKey.c:72
EFI_STATUS EFIAPI USBKeyboardDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: EfiKey.c:483
EFI_STATUS EFIAPI USBKeyboardDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: EfiKey.c:135
#define NULL
Definition: Base.h:319

Definition at line 16 of file EfiKey.c.