2 Function prototype for USB Keyboard Driver.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _EFI_KEYBOARD_H_
16 #define _EFI_KEYBOARD_H_
21 #define USB_KEYBOARD_KEY_COUNT 105
23 #define USB_KEYBOARD_LANGUAGE_STR_LEN 5 // RFC4646 Language Code: "en-US"
24 #define USB_KEYBOARD_DESCRIPTION_STR_LEN (16 + 1) // Description: "English Keyboard"
29 // This 4-bytes total array length is required by PreparePackageList()
34 // Keyboard Layout package definition
36 EFI_HII_PACKAGE_HEADER PackageHeader
;
40 // EFI_HII_KEYBOARD_LAYOUT
44 UINT32 LayoutDescriptorStringOffset
;
45 UINT8 DescriptorCount
;
46 EFI_KEY_DESCRIPTOR KeyDescriptor
[USB_KEYBOARD_KEY_COUNT
];
47 UINT16 DescriptionCount
;
48 CHAR16 Language
[USB_KEYBOARD_LANGUAGE_STR_LEN
];
50 CHAR16 DescriptionString
[USB_KEYBOARD_DESCRIPTION_STR_LEN
];
51 } USB_KEYBOARD_LAYOUT_PACK_BIN
;
54 Uses USB I/O to check whether the device is a USB keyboard device.
56 @param UsbIo Pointer to a USB I/O protocol instance.
58 @retval TRUE Device is a USB keyboard device.
59 @retval FALSE Device is a not USB keyboard device.
64 IN EFI_USB_IO_PROTOCOL
*UsbIo
68 Initialize USB keyboard device and all private data structures.
70 @param UsbKeyboardDevice The USB_KB_DEV instance.
72 @retval EFI_SUCCESS Initialization is successful.
73 @retval EFI_DEVICE_ERROR Keyboard initialization failed.
78 IN OUT USB_KB_DEV
*UsbKeyboardDevice
82 Initialize USB keyboard layout.
84 This function initializes Key Convertion Table for the USB keyboard device.
85 It first tries to retrieve layout from HII database. If failed and default
86 layout is enabled, then it just uses the default layout.
88 @param UsbKeyboardDevice The USB_KB_DEV instance.
90 @retval EFI_SUCCESS Initialization succeeded.
91 @retval EFI_NOT_READY Keyboard layout cannot be retrieve from HII
92 database, and default layout is disabled.
93 @retval Other Fail to register event to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group.
98 OUT USB_KB_DEV
*UsbKeyboardDevice
102 Destroy resources for keyboard layout.
104 @param UsbKeyboardDevice The USB_KB_DEV instance.
108 ReleaseKeyboardLayoutResources (
109 IN OUT USB_KB_DEV
*UsbKeyboardDevice
113 Handler function for USB keyboard's asynchronous interrupt transfer.
115 This function is the handler function for USB keyboard's asynchronous interrupt transfer
116 to manage the keyboard. It parses the USB keyboard input report, and inserts data to
117 keyboard buffer according to state of modifer keys and normal keys. Timer for repeat key
118 is also set accordingly.
120 @param Data A pointer to a buffer that is filled with key data which is
121 retrieved via asynchronous interrupt transfer.
122 @param DataLength Indicates the size of the data buffer.
123 @param Context Pointing to USB_KB_DEV instance.
124 @param Result Indicates the result of the asynchronous interrupt transfer.
126 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
127 @retval EFI_DEVICE_ERROR Hardware error occurs.
140 Handler for Delayed Recovery event.
142 This function is the handler for Delayed Recovery event triggered
144 After a device error occurs, the event would be triggered
145 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
146 is defined in USB standard for error handling.
148 @param Event The Delayed Recovery event.
149 @param Context Points to the USB_KB_DEV instance.
154 USBKeyboardRecoveryHandler (
160 Retrieves a USB keycode after parsing the raw data in keyboard buffer.
162 This function parses keyboard buffer. It updates state of modifier key for
163 USB_KB_DEV instancem, and returns keycode for output.
165 @param UsbKeyboardDevice The USB_KB_DEV instance.
166 @param KeyCode Pointer to the USB keycode for output.
168 @retval EFI_SUCCESS Keycode successfully parsed.
169 @retval EFI_NOT_READY Keyboard buffer is not ready for a valid keycode
174 IN OUT USB_KB_DEV
*UsbKeyboardDevice
,
179 Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.
181 @param UsbKeyboardDevice The USB_KB_DEV instance.
182 @param KeyCode Indicates the key code that will be interpreted.
183 @param KeyData A pointer to a buffer that is filled in with
184 the keystroke information for the key that
187 @retval EFI_SUCCESS Success.
188 @retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.
189 @retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.
190 @retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER
191 @retval EFI_DEVICE_ERROR Keyboard layout is invalid.
195 UsbKeyCodeToEfiInputKey (
196 IN USB_KB_DEV
*UsbKeyboardDevice
,
198 OUT EFI_KEY_DATA
*KeyData
205 @param Queue Points to the queue.
206 @param ItemSize Size of the single item.
211 IN OUT USB_SIMPLE_QUEUE
*Queue
,
218 @param Queue Points to the queue.
222 IN OUT USB_SIMPLE_QUEUE
*Queue
227 Check whether the queue is empty.
229 @param Queue Points to the queue.
231 @retval TRUE Queue is empty.
232 @retval FALSE Queue is not empty.
237 IN USB_SIMPLE_QUEUE
*Queue
242 Check whether the queue is full.
244 @param Queue Points to the queue.
246 @retval TRUE Queue is full.
247 @retval FALSE Queue is not full.
252 IN USB_SIMPLE_QUEUE
*Queue
257 Enqueue the item to the queue.
259 @param Queue Points to the queue.
260 @param Item Points to the item to be enqueued.
261 @param ItemSize Size of the item.
265 IN OUT USB_SIMPLE_QUEUE
*Queue
,
272 Dequeue a item from the queue.
274 @param Queue Points to the queue.
275 @param Item Receives the item.
276 @param ItemSize Size of the item.
278 @retval EFI_SUCCESS Item was successfully dequeued.
279 @retval EFI_DEVICE_ERROR The queue is empty.
284 IN OUT USB_SIMPLE_QUEUE
*Queue
,
290 Handler for Repeat Key event.
292 This function is the handler for Repeat Key event triggered
294 After a repeatable key is pressed, the event would be triggered
295 with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,
296 following trigger will come with interval of USBKBD_REPEAT_RATE.
298 @param Event The Repeat Key event.
299 @param Context Points to the USB_KB_DEV instance.
304 USBKeyboardRepeatHandler (
310 Sets USB keyboard LED state.
312 @param UsbKeyboardDevice The USB_KB_DEV instance.
317 IN USB_KB_DEV
*UsbKeyboardDevice
321 Initialize the key state.
323 @param UsbKeyboardDevice The USB_KB_DEV instance.
324 @param KeyState A pointer to receive the key state information.
328 IN USB_KB_DEV
*UsbKeyboardDevice
,
329 OUT EFI_KEY_STATE
*KeyState