2 Function prototype for USB Keyboard Driver.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _EFI_KEYBOARD_H_
10 #define _EFI_KEYBOARD_H_
15 #define USB_KEYBOARD_KEY_COUNT 105
17 #define USB_KEYBOARD_LANGUAGE_STR_LEN 5 // RFC4646 Language Code: "en-US"
18 #define USB_KEYBOARD_DESCRIPTION_STR_LEN (16 + 1) // Description: "English Keyboard"
23 // This 4-bytes total array length is required by PreparePackageList()
28 // Keyboard Layout package definition
30 EFI_HII_PACKAGE_HEADER PackageHeader
;
34 // EFI_HII_KEYBOARD_LAYOUT
38 UINT32 LayoutDescriptorStringOffset
;
39 UINT8 DescriptorCount
;
40 EFI_KEY_DESCRIPTOR KeyDescriptor
[USB_KEYBOARD_KEY_COUNT
];
41 UINT16 DescriptionCount
;
42 CHAR16 Language
[USB_KEYBOARD_LANGUAGE_STR_LEN
];
44 CHAR16 DescriptionString
[USB_KEYBOARD_DESCRIPTION_STR_LEN
];
45 } USB_KEYBOARD_LAYOUT_PACK_BIN
;
48 Uses USB I/O to check whether the device is a USB keyboard device.
50 @param UsbIo Pointer to a USB I/O protocol instance.
52 @retval TRUE Device is a USB keyboard device.
53 @retval FALSE Device is a not USB keyboard device.
58 IN EFI_USB_IO_PROTOCOL
*UsbIo
62 Initialize USB keyboard device and all private data structures.
64 @param UsbKeyboardDevice The USB_KB_DEV instance.
66 @retval EFI_SUCCESS Initialization is successful.
67 @retval EFI_DEVICE_ERROR Keyboard initialization failed.
72 IN OUT USB_KB_DEV
*UsbKeyboardDevice
76 Initialize USB keyboard layout.
78 This function initializes Key Convertion Table for the USB keyboard device.
79 It first tries to retrieve layout from HII database. If failed and default
80 layout is enabled, then it just uses the default layout.
82 @param UsbKeyboardDevice The USB_KB_DEV instance.
84 @retval EFI_SUCCESS Initialization succeeded.
85 @retval EFI_NOT_READY Keyboard layout cannot be retrieve from HII
86 database, and default layout is disabled.
87 @retval Other Fail to register event to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group.
92 OUT USB_KB_DEV
*UsbKeyboardDevice
96 Destroy resources for keyboard layout.
98 @param UsbKeyboardDevice The USB_KB_DEV instance.
102 ReleaseKeyboardLayoutResources (
103 IN OUT USB_KB_DEV
*UsbKeyboardDevice
107 Handler function for USB keyboard's asynchronous interrupt transfer.
109 This function is the handler function for USB keyboard's asynchronous interrupt transfer
110 to manage the keyboard. It parses the USB keyboard input report, and inserts data to
111 keyboard buffer according to state of modifer keys and normal keys. Timer for repeat key
112 is also set accordingly.
114 @param Data A pointer to a buffer that is filled with key data which is
115 retrieved via asynchronous interrupt transfer.
116 @param DataLength Indicates the size of the data buffer.
117 @param Context Pointing to USB_KB_DEV instance.
118 @param Result Indicates the result of the asynchronous interrupt transfer.
120 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
121 @retval EFI_DEVICE_ERROR Hardware error occurs.
134 Handler for Delayed Recovery event.
136 This function is the handler for Delayed Recovery event triggered
138 After a device error occurs, the event would be triggered
139 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
140 is defined in USB standard for error handling.
142 @param Event The Delayed Recovery event.
143 @param Context Points to the USB_KB_DEV instance.
148 USBKeyboardRecoveryHandler (
154 Retrieves a USB keycode after parsing the raw data in keyboard buffer.
156 This function parses keyboard buffer. It updates state of modifier key for
157 USB_KB_DEV instancem, and returns keycode for output.
159 @param UsbKeyboardDevice The USB_KB_DEV instance.
160 @param KeyCode Pointer to the USB keycode for output.
162 @retval EFI_SUCCESS Keycode successfully parsed.
163 @retval EFI_NOT_READY Keyboard buffer is not ready for a valid keycode
168 IN OUT USB_KB_DEV
*UsbKeyboardDevice
,
173 Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.
175 @param UsbKeyboardDevice The USB_KB_DEV instance.
176 @param KeyCode Indicates the key code that will be interpreted.
177 @param KeyData A pointer to a buffer that is filled in with
178 the keystroke information for the key that
181 @retval EFI_SUCCESS Success.
182 @retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.
183 @retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.
184 @retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER
185 @retval EFI_DEVICE_ERROR Keyboard layout is invalid.
189 UsbKeyCodeToEfiInputKey (
190 IN USB_KB_DEV
*UsbKeyboardDevice
,
192 OUT EFI_KEY_DATA
*KeyData
199 @param Queue Points to the queue.
200 @param ItemSize Size of the single item.
205 IN OUT USB_SIMPLE_QUEUE
*Queue
,
212 @param Queue Points to the queue.
216 IN OUT USB_SIMPLE_QUEUE
*Queue
221 Check whether the queue is empty.
223 @param Queue Points to the queue.
225 @retval TRUE Queue is empty.
226 @retval FALSE Queue is not empty.
231 IN USB_SIMPLE_QUEUE
*Queue
236 Check whether the queue is full.
238 @param Queue Points to the queue.
240 @retval TRUE Queue is full.
241 @retval FALSE Queue is not full.
246 IN USB_SIMPLE_QUEUE
*Queue
251 Enqueue the item to the queue.
253 @param Queue Points to the queue.
254 @param Item Points to the item to be enqueued.
255 @param ItemSize Size of the item.
259 IN OUT USB_SIMPLE_QUEUE
*Queue
,
266 Dequeue a item from the queue.
268 @param Queue Points to the queue.
269 @param Item Receives the item.
270 @param ItemSize Size of the item.
272 @retval EFI_SUCCESS Item was successfully dequeued.
273 @retval EFI_DEVICE_ERROR The queue is empty.
278 IN OUT USB_SIMPLE_QUEUE
*Queue
,
284 Handler for Repeat Key event.
286 This function is the handler for Repeat Key event triggered
288 After a repeatable key is pressed, the event would be triggered
289 with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,
290 following trigger will come with interval of USBKBD_REPEAT_RATE.
292 @param Event The Repeat Key event.
293 @param Context Points to the USB_KB_DEV instance.
298 USBKeyboardRepeatHandler (
304 Sets USB keyboard LED state.
306 @param UsbKeyboardDevice The USB_KB_DEV instance.
311 IN USB_KB_DEV
*UsbKeyboardDevice
315 Initialize the key state.
317 @param UsbKeyboardDevice The USB_KB_DEV instance.
318 @param KeyState A pointer to receive the key state information.
322 IN USB_KB_DEV
*UsbKeyboardDevice
,
323 OUT EFI_KEY_STATE
*KeyState