2 Function prototype for USB Keyboard Driver.
4 Copyright (c) 2004 - 2011, 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_LAYOUT_PACKAGE_GUID \
23 0xc0f3b43, 0x44de, 0x4907, { 0xb4, 0x78, 0x22, 0x5f, 0x6f, 0x62, 0x89, 0xdc } \
26 #define USB_KEYBOARD_LAYOUT_KEY_GUID \
28 0x3a4d7a7c, 0x18a, 0x4b42, { 0x81, 0xb3, 0xdc, 0x10, 0xe3, 0xb5, 0x91, 0xbd } \
31 #define USB_KEYBOARD_KEY_COUNT 104
33 #define USB_KEYBOARD_LANGUAGE_STR_LEN 5 // RFC4646 Language Code: "en-US"
34 #define USB_KEYBOARD_DESCRIPTION_STR_LEN (16 + 1) // Description: "English Keyboard"
39 // This 4-bytes total array length is required by PreparePackageList()
44 // Keyboard Layout package definition
46 EFI_HII_PACKAGE_HEADER PackageHeader
;
50 // EFI_HII_KEYBOARD_LAYOUT
54 UINT32 LayoutDescriptorStringOffset
;
55 UINT8 DescriptorCount
;
56 EFI_KEY_DESCRIPTOR KeyDescriptor
[USB_KEYBOARD_KEY_COUNT
];
57 UINT16 DescriptionCount
;
58 CHAR16 Language
[USB_KEYBOARD_LANGUAGE_STR_LEN
];
60 CHAR16 DescriptionString
[USB_KEYBOARD_DESCRIPTION_STR_LEN
];
61 } USB_KEYBOARD_LAYOUT_PACK_BIN
;
64 Uses USB I/O to check whether the device is a USB keyboard device.
66 @param UsbIo Pointer to a USB I/O protocol instance.
68 @retval TRUE Device is a USB keyboard device.
69 @retval FALSE Device is a not USB keyboard device.
74 IN EFI_USB_IO_PROTOCOL
*UsbIo
78 Initialize USB keyboard device and all private data structures.
80 @param UsbKeyboardDevice The USB_KB_DEV instance.
82 @retval EFI_SUCCESS Initialization is successful.
83 @retval EFI_DEVICE_ERROR Keyboard initialization failed.
88 IN OUT USB_KB_DEV
*UsbKeyboardDevice
92 Initialize USB keyboard layout.
94 This function initializes Key Convertion Table for the USB keyboard device.
95 It first tries to retrieve layout from HII database. If failed and default
96 layout is enabled, then it just uses the default layout.
98 @param UsbKeyboardDevice The USB_KB_DEV instance.
100 @retval EFI_SUCCESS Initialization succeeded.
101 @retval EFI_NOT_READY Keyboard layout cannot be retrieve from HII
102 database, and default layout is disabled.
103 @retval Other Fail to register event to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group.
108 OUT USB_KB_DEV
*UsbKeyboardDevice
112 Destroy resources for keyboard layout.
114 @param UsbKeyboardDevice The USB_KB_DEV instance.
118 ReleaseKeyboardLayoutResources (
119 IN OUT USB_KB_DEV
*UsbKeyboardDevice
123 Handler function for USB keyboard's asynchronous interrupt transfer.
125 This function is the handler function for USB keyboard's asynchronous interrupt transfer
126 to manage the keyboard. It parses the USB keyboard input report, and inserts data to
127 keyboard buffer according to state of modifer keys and normal keys. Timer for repeat key
128 is also set accordingly.
130 @param Data A pointer to a buffer that is filled with key data which is
131 retrieved via asynchronous interrupt transfer.
132 @param DataLength Indicates the size of the data buffer.
133 @param Context Pointing to USB_KB_DEV instance.
134 @param Result Indicates the result of the asynchronous interrupt transfer.
136 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
137 @retval EFI_DEVICE_ERROR Hardware error occurs.
150 Handler for Delayed Recovery event.
152 This function is the handler for Delayed Recovery event triggered
154 After a device error occurs, the event would be triggered
155 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
156 is defined in USB standard for error handling.
158 @param Event The Delayed Recovery event.
159 @param Context Points to the USB_KB_DEV instance.
164 USBKeyboardRecoveryHandler (
170 Retrieves a USB keycode after parsing the raw data in keyboard buffer.
172 This function parses keyboard buffer. It updates state of modifier key for
173 USB_KB_DEV instancem, and returns keycode for output.
175 @param UsbKeyboardDevice The USB_KB_DEV instance.
176 @param KeyCode Pointer to the USB keycode for output.
178 @retval EFI_SUCCESS Keycode successfully parsed.
179 @retval EFI_NOT_READY Keyboard buffer is not ready for a valid keycode
184 IN OUT USB_KB_DEV
*UsbKeyboardDevice
,
189 Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.
191 @param UsbKeyboardDevice The USB_KB_DEV instance.
192 @param KeyCode Indicates the key code that will be interpreted.
193 @param KeyData A pointer to a buffer that is filled in with
194 the keystroke information for the key that
197 @retval EFI_SUCCESS Success.
198 @retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.
199 @retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.
200 @retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER
201 @retval EFI_DEVICE_ERROR Keyboard layout is invalid.
205 UsbKeyCodeToEfiInputKey (
206 IN USB_KB_DEV
*UsbKeyboardDevice
,
208 OUT EFI_KEY_DATA
*KeyData
215 @param Queue Points to the queue.
216 @param ItemSize Size of the single item.
221 IN OUT USB_SIMPLE_QUEUE
*Queue
,
228 @param Queue Points to the queue.
232 IN OUT USB_SIMPLE_QUEUE
*Queue
237 Check whether the queue is empty.
239 @param Queue Points to the queue.
241 @retval TRUE Queue is empty.
242 @retval FALSE Queue is not empty.
247 IN USB_SIMPLE_QUEUE
*Queue
252 Check whether the queue is full.
254 @param Queue Points to the queue.
256 @retval TRUE Queue is full.
257 @retval FALSE Queue is not full.
262 IN USB_SIMPLE_QUEUE
*Queue
267 Enqueue the item to the queue.
269 @param Queue Points to the queue.
270 @param Item Points to the item to be enqueued.
271 @param ItemSize Size of the item.
275 IN OUT USB_SIMPLE_QUEUE
*Queue
,
282 Dequeue a item from the queue.
284 @param Queue Points to the queue.
285 @param Item Receives the item.
286 @param ItemSize Size of the item.
288 @retval EFI_SUCCESS Item was successfully dequeued.
289 @retval EFI_DEVICE_ERROR The queue is empty.
294 IN OUT USB_SIMPLE_QUEUE
*Queue
,
300 Handler for Repeat Key event.
302 This function is the handler for Repeat Key event triggered
304 After a repeatable key is pressed, the event would be triggered
305 with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,
306 following trigger will come with interval of USBKBD_REPEAT_RATE.
308 @param Event The Repeat Key event.
309 @param Context Points to the USB_KB_DEV instance.
314 USBKeyboardRepeatHandler (
320 Sets USB keyboard LED state.
322 @param UsbKeyboardDevice The USB_KB_DEV instance.
327 IN USB_KB_DEV
*UsbKeyboardDevice