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_
14 #define USB_KEYBOARD_KEY_COUNT 105
16 #define USB_KEYBOARD_LANGUAGE_STR_LEN 5 // RFC4646 Language Code: "en-US"
17 #define USB_KEYBOARD_DESCRIPTION_STR_LEN (16 + 1) // Description: "English Keyboard"
22 // This 4-bytes total array length is required by PreparePackageList()
27 // Keyboard Layout package definition
29 EFI_HII_PACKAGE_HEADER PackageHeader
;
33 // EFI_HII_KEYBOARD_LAYOUT
37 UINT32 LayoutDescriptorStringOffset
;
38 UINT8 DescriptorCount
;
39 EFI_KEY_DESCRIPTOR KeyDescriptor
[USB_KEYBOARD_KEY_COUNT
];
40 UINT16 DescriptionCount
;
41 CHAR16 Language
[USB_KEYBOARD_LANGUAGE_STR_LEN
];
43 CHAR16 DescriptionString
[USB_KEYBOARD_DESCRIPTION_STR_LEN
];
44 } 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 modifier 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
198 @param Queue Points to the queue.
199 @param ItemSize Size of the single item.
204 IN OUT USB_SIMPLE_QUEUE
*Queue
,
211 @param Queue Points to the queue.
215 IN OUT USB_SIMPLE_QUEUE
*Queue
219 Check whether the queue is empty.
221 @param Queue Points to the queue.
223 @retval TRUE Queue is empty.
224 @retval FALSE Queue is not empty.
229 IN USB_SIMPLE_QUEUE
*Queue
233 Check whether the queue is full.
235 @param Queue Points to the queue.
237 @retval TRUE Queue is full.
238 @retval FALSE Queue is not full.
243 IN USB_SIMPLE_QUEUE
*Queue
247 Enqueue the item to the queue.
249 @param Queue Points to the queue.
250 @param Item Points to the item to be enqueued.
251 @param ItemSize Size of the item.
255 IN OUT USB_SIMPLE_QUEUE
*Queue
,
261 Dequeue a item from the queue.
263 @param Queue Points to the queue.
264 @param Item Receives the item.
265 @param ItemSize Size of the item.
267 @retval EFI_SUCCESS Item was successfully dequeued.
268 @retval EFI_DEVICE_ERROR The queue is empty.
273 IN OUT USB_SIMPLE_QUEUE
*Queue
,
279 Handler for Repeat Key event.
281 This function is the handler for Repeat Key event triggered
283 After a repeatable key is pressed, the event would be triggered
284 with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,
285 following trigger will come with interval of USBKBD_REPEAT_RATE.
287 @param Event The Repeat Key event.
288 @param Context Points to the USB_KB_DEV instance.
293 USBKeyboardRepeatHandler (
299 Sets USB keyboard LED state.
301 @param UsbKeyboardDevice The USB_KB_DEV instance.
306 IN USB_KB_DEV
*UsbKeyboardDevice
310 Initialize the key state.
312 @param UsbKeyboardDevice The USB_KB_DEV instance.
313 @param KeyState A pointer to receive the key state information.
317 IN USB_KB_DEV
*UsbKeyboardDevice
,
318 OUT EFI_KEY_STATE
*KeyState