]>
Commit | Line | Data |
---|---|---|
a7022cec | 1 | /** @file\r |
a7022cec | 2 | Function prototype for USB Keyboard Driver.\r |
3 | \r | |
4 | Copyright (c) 2004 - 2008, Intel Corporation\r | |
5 | All rights reserved. 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 | /**\r | |
b4e73a63 | 22 | Uses USB I/O to check whether the device is a USB keyboard device.\r |
a7022cec | 23 | \r |
b4e73a63 | 24 | @param UsbIo Pointer to a USB I/O protocol instance.\r |
25 | \r | |
26 | @retval TRUE Device is a USB keyboard device.\r | |
27 | @retval FALSE Device is a not USB keyboard device.\r | |
a7022cec | 28 | \r |
29 | **/\r | |
30 | BOOLEAN\r | |
31 | EFIAPI\r | |
32 | IsUSBKeyboard (\r | |
33 | IN EFI_USB_IO_PROTOCOL *UsbIo\r | |
34 | );\r | |
35 | \r | |
36 | /**\r | |
b4e73a63 | 37 | Initialize USB keyboard device and all private data structures.\r |
a7022cec | 38 | \r |
39 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
40 | \r | |
41 | @retval EFI_SUCCESS Initialization is successful.\r | |
b4e73a63 | 42 | @retval EFI_DEVICE_ERROR Keyboard initialization failed.\r |
a7022cec | 43 | \r |
44 | **/\r | |
45 | EFI_STATUS\r | |
46 | EFIAPI\r | |
47 | InitUSBKeyboard (\r | |
b4e73a63 | 48 | IN OUT USB_KB_DEV *UsbKeyboardDevice\r |
a7022cec | 49 | );\r |
50 | \r | |
51 | /**\r | |
b4e73a63 | 52 | Initialize USB keyboard layout.\r |
53 | \r | |
54 | This function initializes Key Convertion Table for the USB keyboard device.\r | |
55 | It first tries to retrieve layout from HII database. If failed and default\r | |
56 | layout is enabled, then it just uses the default layout.\r | |
a7022cec | 57 | \r |
58 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
59 | \r | |
b4e73a63 | 60 | @retval EFI_SUCCESS Initialization succeeded.\r |
61 | @retval EFI_NOT_READY Keyboard layout cannot be retrieve from HII\r | |
62 | database, and default layout is disabled.\r | |
63 | @retval Other Fail to register event to EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group.\r | |
a7022cec | 64 | \r |
65 | **/\r | |
66 | EFI_STATUS\r | |
67 | EFIAPI\r | |
68 | InitKeyboardLayout (\r | |
b4e73a63 | 69 | OUT USB_KB_DEV *UsbKeyboardDevice\r |
a7022cec | 70 | );\r |
71 | \r | |
72 | /**\r | |
b4e73a63 | 73 | Destroy resources for keyboard layout.\r |
a7022cec | 74 | \r |
75 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
76 | \r | |
77 | **/\r | |
78 | VOID\r | |
79 | EFIAPI\r | |
80 | ReleaseKeyboardLayoutResources (\r | |
b4e73a63 | 81 | IN OUT USB_KB_DEV *UsbKeyboardDevice\r |
a7022cec | 82 | );\r |
83 | \r | |
84 | /**\r | |
b4e73a63 | 85 | Handler function for USB keyboard's asynchronous interrupt transfer.\r |
86 | \r | |
87 | This function is the handler function for USB keyboard's asynchronous interrupt transfer\r | |
88 | to manage the keyboard. It parses the USB keyboard input report, and inserts data to\r | |
89 | keyboard buffer according to state of modifer keys and normal keys. Timer for repeat key\r | |
90 | is also set accordingly.\r | |
a7022cec | 91 | \r |
92 | @param Data A pointer to a buffer that is filled with key data which is\r | |
93 | retrieved via asynchronous interrupt transfer.\r | |
94 | @param DataLength Indicates the size of the data buffer.\r | |
95 | @param Context Pointing to USB_KB_DEV instance.\r | |
96 | @param Result Indicates the result of the asynchronous interrupt transfer.\r | |
97 | \r | |
b4e73a63 | 98 | @retval EFI_SUCCESS Asynchronous interrupt transfer is handled successfully.\r |
99 | @retval EFI_DEVICE_ERROR Hardware error occurs.\r | |
a7022cec | 100 | \r |
101 | **/\r | |
102 | EFI_STATUS\r | |
103 | EFIAPI\r | |
104 | KeyboardHandler (\r | |
105 | IN VOID *Data,\r | |
106 | IN UINTN DataLength,\r | |
107 | IN VOID *Context,\r | |
108 | IN UINT32 Result\r | |
109 | );\r | |
110 | \r | |
111 | /**\r | |
b4e73a63 | 112 | Handler for Delayed Recovery event.\r |
113 | \r | |
114 | This function is the handler for Delayed Recovery event triggered\r | |
115 | by timer.\r | |
116 | After a device error occurs, the event would be triggered\r | |
117 | with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY\r | |
118 | is defined in USB standard for error handling.\r | |
a7022cec | 119 | \r |
120 | @param Event The Delayed Recovery event.\r | |
121 | @param Context Points to the USB_KB_DEV instance.\r | |
122 | \r | |
a7022cec | 123 | **/\r |
124 | VOID\r | |
125 | EFIAPI\r | |
126 | USBKeyboardRecoveryHandler (\r | |
127 | IN EFI_EVENT Event,\r | |
128 | IN VOID *Context\r | |
129 | );\r | |
130 | \r | |
131 | /**\r | |
b4e73a63 | 132 | Retrieves a USB keycode after parsing the raw data in keyboard buffer.\r |
133 | \r | |
134 | This function parses keyboard buffer. It updates state of modifier key for\r | |
135 | USB_KB_DEV instancem, and returns keycode for output.\r | |
a7022cec | 136 | \r |
137 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
b4e73a63 | 138 | @param KeyCode Pointer to the USB keycode for output.\r |
a7022cec | 139 | \r |
b4e73a63 | 140 | @retval EFI_SUCCESS Keycode successfully parsed.\r |
141 | @retval EFI_NOT_READY Keyboard buffer is not ready for a valid keycode\r | |
a7022cec | 142 | \r |
143 | **/\r | |
144 | EFI_STATUS\r | |
145 | EFIAPI\r | |
146 | USBParseKey (\r | |
147 | IN OUT USB_KB_DEV *UsbKeyboardDevice,\r | |
b4e73a63 | 148 | OUT UINT8 *KeyCode\r |
a7022cec | 149 | );\r |
150 | \r | |
151 | /**\r | |
b4e73a63 | 152 | Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY.\r |
a7022cec | 153 | \r |
b4e73a63 | 154 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r |
155 | @param KeyCode Indicates the key code that will be interpreted.\r | |
156 | @param Key A pointer to a buffer that is filled in with\r | |
157 | the keystroke information for the key that\r | |
158 | was pressed.\r | |
a7022cec | 159 | \r |
b4e73a63 | 160 | @retval EFI_SUCCESS Success.\r |
161 | @retval EFI_INVALID_PARAMETER KeyCode is not in the range of 0x4 to 0x65.\r | |
162 | @retval EFI_INVALID_PARAMETER Translated EFI_INPUT_KEY has zero for both ScanCode and UnicodeChar.\r | |
163 | @retval EFI_NOT_READY KeyCode represents a dead key with EFI_NS_KEY_MODIFIER\r | |
81464cf1 | 164 | @retval EFI_DEVICE_ERROR Keyboard layout is invalid.\r |
a7022cec | 165 | \r |
166 | **/\r | |
167 | EFI_STATUS\r | |
168 | EFIAPI\r | |
5899f27e | 169 | UsbKeyCodeToEfiInputKey (\r |
a7022cec | 170 | IN USB_KB_DEV *UsbKeyboardDevice,\r |
b4e73a63 | 171 | IN UINT8 KeyCode,\r |
a7022cec | 172 | OUT EFI_INPUT_KEY *Key\r |
173 | );\r | |
174 | \r | |
175 | /**\r | |
b4e73a63 | 176 | Resets USB keyboard buffer.\r |
a7022cec | 177 | \r |
b4e73a63 | 178 | @param KeyboardBuffer Points to the USB keyboard buffer.\r |
a7022cec | 179 | \r |
a7022cec | 180 | **/\r |
5899f27e | 181 | VOID\r |
a7022cec | 182 | EFIAPI\r |
183 | InitUSBKeyBuffer (\r | |
b4e73a63 | 184 | OUT USB_KB_BUFFER *KeyboardBuffer\r |
a7022cec | 185 | );\r |
186 | \r | |
187 | /**\r | |
b4e73a63 | 188 | Check whether USB keyboard buffer is empty.\r |
a7022cec | 189 | \r |
b4e73a63 | 190 | @param KeyboardBuffer USB keyboard buffer\r |
a7022cec | 191 | \r |
b4e73a63 | 192 | @retval TRUE Keyboard buffer is empty.\r |
193 | @retval FALSE Keyboard buffer is not empty.\r | |
a7022cec | 194 | \r |
195 | **/\r | |
196 | BOOLEAN\r | |
197 | EFIAPI\r | |
198 | IsUSBKeyboardBufferEmpty (\r | |
199 | IN USB_KB_BUFFER *KeyboardBuffer\r | |
200 | );\r | |
201 | \r | |
202 | /**\r | |
b4e73a63 | 203 | Check whether USB keyboard buffer is full.\r |
a7022cec | 204 | \r |
b4e73a63 | 205 | @param KeyboardBuffer USB keyboard buffer\r |
a7022cec | 206 | \r |
b4e73a63 | 207 | @retval TRUE Keyboard buffer is full.\r |
208 | @retval FALSE Keyboard buffer is not full.\r | |
a7022cec | 209 | \r |
210 | **/\r | |
211 | BOOLEAN\r | |
212 | EFIAPI\r | |
213 | IsUSBKeyboardBufferFull (\r | |
214 | IN USB_KB_BUFFER *KeyboardBuffer\r | |
215 | );\r | |
216 | \r | |
217 | /**\r | |
b4e73a63 | 218 | Inserts a keycode into keyboard buffer.\r |
a7022cec | 219 | \r |
b4e73a63 | 220 | @param KeyboardBuffer Points to the USB keyboard buffer.\r |
221 | @param Key Keycode to insert.\r | |
222 | @param Down TRUE means key is pressed.\r | |
223 | FALSE means key is released.\r | |
a7022cec | 224 | \r |
a7022cec | 225 | **/\r |
5899f27e | 226 | VOID\r |
a7022cec | 227 | EFIAPI\r |
228 | InsertKeyCode (\r | |
229 | IN OUT USB_KB_BUFFER *KeyboardBuffer,\r | |
230 | IN UINT8 Key,\r | |
3dad0f7c | 231 | IN BOOLEAN Down\r |
a7022cec | 232 | );\r |
233 | \r | |
234 | /**\r | |
b4e73a63 | 235 | Remove a keycode from keyboard buffer and return it.\r |
a7022cec | 236 | \r |
b4e73a63 | 237 | @param KeyboardBuffer Points to the USB keyboard buffer.\r |
238 | @param UsbKey Points to the buffer that contains keycode for output.\r | |
a7022cec | 239 | \r |
b4e73a63 | 240 | @retval EFI_SUCCESS Keycode successfully removed from keyboard buffer.\r |
241 | @retval EFI_DEVICE_ERROR Keyboard buffer is empty.\r | |
a7022cec | 242 | \r |
243 | **/\r | |
244 | EFI_STATUS\r | |
245 | EFIAPI\r | |
246 | RemoveKeyCode (\r | |
247 | IN OUT USB_KB_BUFFER *KeyboardBuffer,\r | |
b4e73a63 | 248 | OUT USB_KEY *UsbKey\r |
a7022cec | 249 | );\r |
250 | \r | |
251 | /**\r | |
b4e73a63 | 252 | Handler for Repeat Key event.\r |
253 | \r | |
254 | This function is the handler for Repeat Key event triggered\r | |
255 | by timer.\r | |
256 | After a repeatable key is pressed, the event would be triggered\r | |
257 | with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,\r | |
258 | following trigger will come with interval of USBKBD_REPEAT_RATE.\r | |
a7022cec | 259 | \r |
260 | @param Event The Repeat Key event.\r | |
261 | @param Context Points to the USB_KB_DEV instance.\r | |
262 | \r | |
a7022cec | 263 | **/\r |
264 | VOID\r | |
265 | EFIAPI\r | |
266 | USBKeyboardRepeatHandler (\r | |
267 | IN EFI_EVENT Event,\r | |
268 | IN VOID *Context\r | |
269 | );\r | |
270 | \r | |
271 | /**\r | |
b4e73a63 | 272 | Sets USB keyboard LED state.\r |
a7022cec | 273 | \r |
274 | @param UsbKeyboardDevice The USB_KB_DEV instance.\r | |
275 | \r | |
a7022cec | 276 | **/\r |
5899f27e | 277 | VOID\r |
a7022cec | 278 | EFIAPI\r |
279 | SetKeyLED (\r | |
280 | IN USB_KB_DEV *UsbKeyboardDevice\r | |
281 | );\r | |
282 | \r | |
283 | #endif\r |