2 Function prototype for USB Keyboard Driver.
4 Copyright (c) 2004 - 2008, 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.
75 IN EFI_USB_IO_PROTOCOL
*UsbIo
79 Initialize USB keyboard device and all private data structures.
81 @param UsbKeyboardDevice The USB_KB_DEV instance.
83 @retval EFI_SUCCESS Initialization is successful.
84 @retval EFI_DEVICE_ERROR Keyboard initialization failed.
90 IN OUT USB_KB_DEV
*UsbKeyboardDevice
94 Initialize USB keyboard layout.
96 This function initializes Key Convertion Table for the USB keyboard device.
97 It first tries to retrieve layout from HII database. If failed and default
98 layout is enabled, then it just uses the default layout.
100 @param UsbKeyboardDevice The USB_KB_DEV instance.
102 @retval EFI_SUCCESS Initialization succeeded.
103 @retval EFI_NOT_READY Keyboard layout cannot be retrieve from HII
104 database, and default layout is disabled.
105 @retval Other Fail to register event to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group.
111 OUT USB_KB_DEV
*UsbKeyboardDevice
115 Destroy resources for keyboard layout.
117 @param UsbKeyboardDevice The USB_KB_DEV instance.
122 ReleaseKeyboardLayoutResources (
123 IN OUT USB_KB_DEV
*UsbKeyboardDevice
127 Handler function for USB keyboard's asynchronous interrupt transfer.
129 This function is the handler function for USB keyboard's asynchronous interrupt transfer
130 to manage the keyboard. It parses the USB keyboard input report, and inserts data to
131 keyboard buffer according to state of modifer keys and normal keys. Timer for repeat key
132 is also set accordingly.
134 @param Data A pointer to a buffer that is filled with key data which is
135 retrieved via asynchronous interrupt transfer.
136 @param DataLength Indicates the size of the data buffer.
137 @param Context Pointing to USB_KB_DEV instance.
138 @param Result Indicates the result of the asynchronous interrupt transfer.
140 @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.
141 @retval EFI_DEVICE_ERROR Hardware error occurs.
154 Handler for Delayed Recovery event.
156 This function is the handler for Delayed Recovery event triggered
158 After a device error occurs, the event would be triggered
159 with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY
160 is defined in USB standard for error handling.
162 @param Event The Delayed Recovery event.
163 @param Context Points to the USB_KB_DEV instance.
168 USBKeyboardRecoveryHandler (
174 Retrieves a USB keycode after parsing the raw data in keyboard buffer.
176 This function parses keyboard buffer. It updates state of modifier key for
177 USB_KB_DEV instancem, and returns keycode for output.
179 @param UsbKeyboardDevice The USB_KB_DEV instance.
180 @param KeyCode Pointer to the USB keycode for output.
182 @retval EFI_SUCCESS Keycode successfully parsed.
183 @retval EFI_NOT_READY Keyboard buffer is not ready for a valid keycode
189 IN OUT USB_KB_DEV
*UsbKeyboardDevice
,
194 Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.
196 @param UsbKeyboardDevice The USB_KB_DEV instance.
197 @param KeyCode Indicates the key code that will be interpreted.
198 @param Key A pointer to a buffer that is filled in with
199 the keystroke information for the key that
202 @retval EFI_SUCCESS Success.
203 @retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.
204 @retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.
205 @retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER
206 @retval EFI_DEVICE_ERROR Keyboard layout is invalid.
211 UsbKeyCodeToEfiInputKey (
212 IN USB_KB_DEV
*UsbKeyboardDevice
,
214 OUT EFI_INPUT_KEY
*Key
218 Resets USB keyboard buffer.
220 @param KeyboardBuffer Points to the USB keyboard buffer.
226 OUT USB_KB_BUFFER
*KeyboardBuffer
230 Check whether USB keyboard buffer is empty.
232 @param KeyboardBuffer USB keyboard buffer
234 @retval TRUE Keyboard buffer is empty.
235 @retval FALSE Keyboard buffer is not empty.
240 IsUSBKeyboardBufferEmpty (
241 IN USB_KB_BUFFER
*KeyboardBuffer
245 Check whether USB keyboard buffer is full.
247 @param KeyboardBuffer USB keyboard buffer
249 @retval TRUE Keyboard buffer is full.
250 @retval FALSE Keyboard buffer is not full.
255 IsUSBKeyboardBufferFull (
256 IN USB_KB_BUFFER
*KeyboardBuffer
260 Inserts a keycode into keyboard buffer.
262 @param KeyboardBuffer Points to the USB keyboard buffer.
263 @param Key Keycode to insert.
264 @param Down TRUE means key is pressed.
265 FALSE means key is released.
271 IN OUT USB_KB_BUFFER
*KeyboardBuffer
,
277 Remove a keycode from keyboard buffer and return it.
279 @param KeyboardBuffer Points to the USB keyboard buffer.
280 @param UsbKey Points to the buffer that contains keycode for output.
282 @retval EFI_SUCCESS Keycode successfully removed from keyboard buffer.
283 @retval EFI_DEVICE_ERROR Keyboard buffer is empty.
289 IN OUT USB_KB_BUFFER
*KeyboardBuffer
,
294 Handler for Repeat Key event.
296 This function is the handler for Repeat Key event triggered
298 After a repeatable key is pressed, the event would be triggered
299 with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,
300 following trigger will come with interval of USBKBD_REPEAT_RATE.
302 @param Event The Repeat Key event.
303 @param Context Points to the USB_KB_DEV instance.
308 USBKeyboardRepeatHandler (
314 Sets USB keyboard LED state.
316 @param UsbKeyboardDevice The USB_KB_DEV instance.
322 IN USB_KB_DEV
*UsbKeyboardDevice