]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Function prototype for USB Keyboard Driver.\r | |
3 | \r | |
4 | Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _EFI_KEYBOARD_H_\r | |
16 | #define _EFI_KEYBOARD_H_\r | |
17 | \r | |
18 | \r | |
19 | #include "EfiKey.h"\r | |
20 | \r | |
21 | #define USB_KEYBOARD_LAYOUT_PACKAGE_GUID \\r | |
22 | { \\r | |
23 | 0xc0f3b43, 0x44de, 0x4907, { 0xb4, 0x78, 0x22, 0x5f, 0x6f, 0x62, 0x89, 0xdc } \\r | |
24 | }\r | |
25 | \r | |
26 | #define USB_KEYBOARD_LAYOUT_KEY_GUID \\r | |
27 | { \\r | |
28 | 0x3a4d7a7c, 0x18a, 0x4b42, { 0x81, 0xb3, 0xdc, 0x10, 0xe3, 0xb5, 0x91, 0xbd } \\r | |
29 | }\r | |
30 | \r | |
31 | #define USB_KEYBOARD_KEY_COUNT 104\r | |
32 | \r | |
33 | #define USB_KEYBOARD_LANGUAGE_STR_LEN 5 // RFC4646 Language Code: "en-US"\r | |
34 | #define USB_KEYBOARD_DESCRIPTION_STR_LEN (16 + 1) // Description: "English Keyboard"\r | |
35 | \r | |
36 | #pragma pack (1)\r | |
37 | typedef struct {\r | |
38 | //\r | |
39 | // This 4-bytes total array length is required by PreparePackageList()\r | |
40 | //\r | |
41 | UINT32 Length;\r | |
42 | \r | |
43 | //\r | |
44 | // Keyboard Layout package definition\r | |
45 | //\r | |
46 | EFI_HII_PACKAGE_HEADER PackageHeader;\r | |
47 | UINT16 LayoutCount;\r | |
48 | \r | |
49 | //\r | |
50 | // EFI_HII_KEYBOARD_LAYOUT\r | |
51 | //\r | |
52 | UINT16 LayoutLength;\r | |
53 | EFI_GUID Guid;\r | |
54 | UINT32 LayoutDescriptorStringOffset;\r | |
55 | UINT8 DescriptorCount;\r | |
56 | EFI_KEY_DESCRIPTOR KeyDescriptor[USB_KEYBOARD_KEY_COUNT];\r | |
57 | UINT16 DescriptionCount;\r | |
58 | CHAR16 Language[USB_KEYBOARD_LANGUAGE_STR_LEN];\r | |
59 | CHAR16 Space;\r | |
60 | CHAR16 DescriptionString[USB_KEYBOARD_DESCRIPTION_STR_LEN];\r | |
61 | } USB_KEYBOARD_LAYOUT_PACK_BIN;\r | |
62 | #pragma pack()\r | |
63 | /**\r | |
64 | Uses USB I/O to check whether the device is a USB keyboard device.\r | |
65 | \r | |
66 | @param UsbIo Pointer to a USB I/O protocol instance.\r | |
67 | \r | |
68 | @retval TRUE Device is a USB keyboard device.\r | |
69 | @retval FALSE Device is a not USB keyboard device.\r | |
70 | \r | |
71 | **/\r | |
72 | BOOLEAN\r | |
73 | EFIAPI\r | |
74 | IsUSBKeyboard (\r | |
75 | IN EFI_USB_IO_PROTOCOL *UsbIo\r | |
76 | );\r | |
77 | \r | |
78 | /**\r | |
79 | Initialize USB keyboard device and all private data structures.\r | |
80 | \r | |
81 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
82 | \r | |
83 | @retval EFI_SUCCESS Initialization is successful.\r | |
84 | @retval EFI_DEVICE_ERROR Keyboard initialization failed.\r | |
85 | \r | |
86 | **/\r | |
87 | EFI_STATUS\r | |
88 | EFIAPI\r | |
89 | InitUSBKeyboard (\r | |
90 | IN OUT USB_KB_DEV *UsbKeyboardDevice\r | |
91 | );\r | |
92 | \r | |
93 | /**\r | |
94 | Initialize USB keyboard layout.\r | |
95 | \r | |
96 | This function initializes Key Convertion Table for the USB keyboard device.\r | |
97 | It first tries to retrieve layout from HII database. If failed and default\r | |
98 | layout is enabled, then it just uses the default layout.\r | |
99 | \r | |
100 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
101 | \r | |
102 | @retval EFI_SUCCESS Initialization succeeded.\r | |
103 | @retval EFI_NOT_READY Keyboard layout cannot be retrieve from HII\r | |
104 | database, and default layout is disabled.\r | |
105 | @retval Other Fail to register event to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group.\r | |
106 | \r | |
107 | **/\r | |
108 | EFI_STATUS\r | |
109 | EFIAPI\r | |
110 | InitKeyboardLayout (\r | |
111 | OUT USB_KB_DEV *UsbKeyboardDevice\r | |
112 | );\r | |
113 | \r | |
114 | /**\r | |
115 | Destroy resources for keyboard layout.\r | |
116 | \r | |
117 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
118 | \r | |
119 | **/\r | |
120 | VOID\r | |
121 | EFIAPI\r | |
122 | ReleaseKeyboardLayoutResources (\r | |
123 | IN OUT USB_KB_DEV *UsbKeyboardDevice\r | |
124 | );\r | |
125 | \r | |
126 | /**\r | |
127 | Handler function for USB keyboard's asynchronous interrupt transfer.\r | |
128 | \r | |
129 | This function is the handler function for USB keyboard's asynchronous interrupt transfer\r | |
130 | to manage the keyboard. It parses the USB keyboard input report, and inserts data to\r | |
131 | keyboard buffer according to state of modifer keys and normal keys. Timer for repeat key\r | |
132 | is also set accordingly.\r | |
133 | \r | |
134 | @param Data A pointer to a buffer that is filled with key data which is\r | |
135 | retrieved via asynchronous interrupt transfer.\r | |
136 | @param DataLength Indicates the size of the data buffer.\r | |
137 | @param Context Pointing to USB_KB_DEV instance.\r | |
138 | @param Result Indicates the result of the asynchronous interrupt transfer.\r | |
139 | \r | |
140 | @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.\r | |
141 | @retval EFI_DEVICE_ERROR Hardware error occurs.\r | |
142 | \r | |
143 | **/\r | |
144 | EFI_STATUS\r | |
145 | EFIAPI\r | |
146 | KeyboardHandler (\r | |
147 | IN VOID *Data,\r | |
148 | IN UINTN DataLength,\r | |
149 | IN VOID *Context,\r | |
150 | IN UINT32 Result\r | |
151 | );\r | |
152 | \r | |
153 | /**\r | |
154 | Handler for Delayed Recovery event.\r | |
155 | \r | |
156 | This function is the handler for Delayed Recovery event triggered\r | |
157 | by timer.\r | |
158 | After a device error occurs, the event would be triggered\r | |
159 | with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY\r | |
160 | is defined in USB standard for error handling.\r | |
161 | \r | |
162 | @param Event The Delayed Recovery event.\r | |
163 | @param Context Points to the USB_KB_DEV instance.\r | |
164 | \r | |
165 | **/\r | |
166 | VOID\r | |
167 | EFIAPI\r | |
168 | USBKeyboardRecoveryHandler (\r | |
169 | IN EFI_EVENT Event,\r | |
170 | IN VOID *Context\r | |
171 | );\r | |
172 | \r | |
173 | /**\r | |
174 | Retrieves a USB keycode after parsing the raw data in keyboard buffer.\r | |
175 | \r | |
176 | This function parses keyboard buffer. It updates state of modifier key for\r | |
177 | USB_KB_DEV instancem, and returns keycode for output.\r | |
178 | \r | |
179 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
180 | @param KeyCode Pointer to the USB keycode for output.\r | |
181 | \r | |
182 | @retval EFI_SUCCESS Keycode successfully parsed.\r | |
183 | @retval EFI_NOT_READY Keyboard buffer is not ready for a valid keycode\r | |
184 | \r | |
185 | **/\r | |
186 | EFI_STATUS\r | |
187 | EFIAPI\r | |
188 | USBParseKey (\r | |
189 | IN OUT USB_KB_DEV *UsbKeyboardDevice,\r | |
190 | OUT UINT8 *KeyCode\r | |
191 | );\r | |
192 | \r | |
193 | /**\r | |
194 | Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.\r | |
195 | \r | |
196 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
197 | @param KeyCode Indicates the key code that will be interpreted.\r | |
198 | @param Key A pointer to a buffer that is filled in with\r | |
199 | the keystroke information for the key that\r | |
200 | was pressed.\r | |
201 | \r | |
202 | @retval EFI_SUCCESS Success.\r | |
203 | @retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.\r | |
204 | @retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.\r | |
205 | @retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER\r | |
206 | @retval EFI_DEVICE_ERROR Keyboard layout is invalid.\r | |
207 | \r | |
208 | **/\r | |
209 | EFI_STATUS\r | |
210 | EFIAPI\r | |
211 | UsbKeyCodeToEfiInputKey (\r | |
212 | IN USB_KB_DEV *UsbKeyboardDevice,\r | |
213 | IN UINT8 KeyCode,\r | |
214 | OUT EFI_INPUT_KEY *Key\r | |
215 | );\r | |
216 | \r | |
217 | /**\r | |
218 | Resets USB keyboard buffer.\r | |
219 | \r | |
220 | @param KeyboardBuffer Points to the USB keyboard buffer.\r | |
221 | \r | |
222 | **/\r | |
223 | VOID\r | |
224 | EFIAPI\r | |
225 | InitUSBKeyBuffer (\r | |
226 | OUT USB_KB_BUFFER *KeyboardBuffer\r | |
227 | );\r | |
228 | \r | |
229 | /**\r | |
230 | Check whether USB keyboard buffer is empty.\r | |
231 | \r | |
232 | @param KeyboardBuffer USB keyboard buffer\r | |
233 | \r | |
234 | @retval TRUE Keyboard buffer is empty.\r | |
235 | @retval FALSE Keyboard buffer is not empty.\r | |
236 | \r | |
237 | **/\r | |
238 | BOOLEAN\r | |
239 | EFIAPI\r | |
240 | IsUSBKeyboardBufferEmpty (\r | |
241 | IN USB_KB_BUFFER *KeyboardBuffer\r | |
242 | );\r | |
243 | \r | |
244 | /**\r | |
245 | Check whether USB keyboard buffer is full.\r | |
246 | \r | |
247 | @param KeyboardBuffer USB keyboard buffer\r | |
248 | \r | |
249 | @retval TRUE Keyboard buffer is full.\r | |
250 | @retval FALSE Keyboard buffer is not full.\r | |
251 | \r | |
252 | **/\r | |
253 | BOOLEAN\r | |
254 | EFIAPI\r | |
255 | IsUSBKeyboardBufferFull (\r | |
256 | IN USB_KB_BUFFER *KeyboardBuffer\r | |
257 | );\r | |
258 | \r | |
259 | /**\r | |
260 | Inserts a keycode into keyboard buffer.\r | |
261 | \r | |
262 | @param KeyboardBuffer Points to the USB keyboard buffer.\r | |
263 | @param Key Keycode to insert.\r | |
264 | @param Down TRUE means key is pressed.\r | |
265 | FALSE means key is released.\r | |
266 | \r | |
267 | **/\r | |
268 | VOID\r | |
269 | EFIAPI\r | |
270 | InsertKeyCode (\r | |
271 | IN OUT USB_KB_BUFFER *KeyboardBuffer,\r | |
272 | IN UINT8 Key,\r | |
273 | IN BOOLEAN Down\r | |
274 | );\r | |
275 | \r | |
276 | /**\r | |
277 | Remove a keycode from keyboard buffer and return it.\r | |
278 | \r | |
279 | @param KeyboardBuffer Points to the USB keyboard buffer.\r | |
280 | @param UsbKey Points to the buffer that contains keycode for output.\r | |
281 | \r | |
282 | @retval EFI_SUCCESS Keycode successfully removed from keyboard buffer.\r | |
283 | @retval EFI_DEVICE_ERROR Keyboard buffer is empty.\r | |
284 | \r | |
285 | **/\r | |
286 | EFI_STATUS\r | |
287 | EFIAPI\r | |
288 | RemoveKeyCode (\r | |
289 | IN OUT USB_KB_BUFFER *KeyboardBuffer,\r | |
290 | OUT USB_KEY *UsbKey\r | |
291 | );\r | |
292 | \r | |
293 | /**\r | |
294 | Handler for Repeat Key event.\r | |
295 | \r | |
296 | This function is the handler for Repeat Key event triggered\r | |
297 | by timer.\r | |
298 | After a repeatable key is pressed, the event would be triggered\r | |
299 | with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,\r | |
300 | following trigger will come with interval of USBKBD_REPEAT_RATE.\r | |
301 | \r | |
302 | @param Event The Repeat Key event.\r | |
303 | @param Context Points to the USB_KB_DEV instance.\r | |
304 | \r | |
305 | **/\r | |
306 | VOID\r | |
307 | EFIAPI\r | |
308 | USBKeyboardRepeatHandler (\r | |
309 | IN EFI_EVENT Event,\r | |
310 | IN VOID *Context\r | |
311 | );\r | |
312 | \r | |
313 | /**\r | |
314 | Sets USB keyboard LED state.\r | |
315 | \r | |
316 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
317 | \r | |
318 | **/\r | |
319 | VOID\r | |
320 | EFIAPI\r | |
321 | SetKeyLED (\r | |
322 | IN USB_KB_DEV *UsbKeyboardDevice\r | |
323 | );\r | |
324 | \r | |
325 | #endif\r |