]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h
Fix bugs in decompress implement in EfiLdr, and enable FAT driver in FDF file.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / KeyBoard.h
CommitLineData
a7022cec 1/** @file\r
a7022cec 2 Function prototype for USB Keyboard Driver.\r
3\r
4Copyright (c) 2004 - 2008, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT 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
30BOOLEAN\r
31EFIAPI\r
32IsUSBKeyboard (\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
45EFI_STATUS\r
46EFIAPI\r
47InitUSBKeyboard (\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
66EFI_STATUS\r
67EFIAPI\r
68InitKeyboardLayout (\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
78VOID\r
79EFIAPI\r
80ReleaseKeyboardLayoutResources (\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
102EFI_STATUS\r
103EFIAPI\r
104KeyboardHandler (\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
124VOID\r
125EFIAPI\r
126USBKeyboardRecoveryHandler (\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
144EFI_STATUS\r
145EFIAPI\r
146USBParseKey (\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
a7022cec 164\r
165**/\r
166EFI_STATUS\r
167EFIAPI\r
5899f27e 168UsbKeyCodeToEfiInputKey (\r
a7022cec 169 IN USB_KB_DEV *UsbKeyboardDevice,\r
b4e73a63 170 IN UINT8 KeyCode,\r
a7022cec 171 OUT EFI_INPUT_KEY *Key\r
172 );\r
173\r
174/**\r
b4e73a63 175 Resets USB keyboard buffer.\r
a7022cec 176\r
b4e73a63 177 @param KeyboardBuffer Points to the USB keyboard buffer.\r
a7022cec 178\r
a7022cec 179**/\r
5899f27e 180VOID\r
a7022cec 181EFIAPI\r
182InitUSBKeyBuffer (\r
b4e73a63 183 OUT USB_KB_BUFFER *KeyboardBuffer\r
a7022cec 184 );\r
185\r
186/**\r
b4e73a63 187 Check whether USB keyboard buffer is empty.\r
a7022cec 188\r
b4e73a63 189 @param KeyboardBuffer USB keyboard buffer\r
a7022cec 190\r
b4e73a63 191 @retval TRUE Keyboard buffer is empty.\r
192 @retval FALSE Keyboard buffer is not empty.\r
a7022cec 193\r
194**/\r
195BOOLEAN\r
196EFIAPI\r
197IsUSBKeyboardBufferEmpty (\r
198 IN USB_KB_BUFFER *KeyboardBuffer\r
199 );\r
200\r
201/**\r
b4e73a63 202 Check whether USB keyboard buffer is full.\r
a7022cec 203\r
b4e73a63 204 @param KeyboardBuffer USB keyboard buffer\r
a7022cec 205\r
b4e73a63 206 @retval TRUE Keyboard buffer is full.\r
207 @retval FALSE Keyboard buffer is not full.\r
a7022cec 208\r
209**/\r
210BOOLEAN\r
211EFIAPI\r
212IsUSBKeyboardBufferFull (\r
213 IN USB_KB_BUFFER *KeyboardBuffer\r
214 );\r
215\r
216/**\r
b4e73a63 217 Inserts a keycode into keyboard buffer.\r
a7022cec 218\r
b4e73a63 219 @param KeyboardBuffer Points to the USB keyboard buffer.\r
220 @param Key Keycode to insert.\r
221 @param Down TRUE means key is pressed.\r
222 FALSE means key is released.\r
a7022cec 223\r
a7022cec 224**/\r
5899f27e 225VOID\r
a7022cec 226EFIAPI\r
227InsertKeyCode (\r
228 IN OUT USB_KB_BUFFER *KeyboardBuffer,\r
229 IN UINT8 Key,\r
3dad0f7c 230 IN BOOLEAN Down\r
a7022cec 231 );\r
232\r
233/**\r
b4e73a63 234 Remove a keycode from keyboard buffer and return it.\r
a7022cec 235\r
b4e73a63 236 @param KeyboardBuffer Points to the USB keyboard buffer.\r
237 @param UsbKey Points to the buffer that contains keycode for output.\r
a7022cec 238\r
b4e73a63 239 @retval EFI_SUCCESS Keycode successfully removed from keyboard buffer.\r
240 @retval EFI_DEVICE_ERROR Keyboard buffer is empty.\r
a7022cec 241\r
242**/\r
243EFI_STATUS\r
244EFIAPI\r
245RemoveKeyCode (\r
246 IN OUT USB_KB_BUFFER *KeyboardBuffer,\r
b4e73a63 247 OUT USB_KEY *UsbKey\r
a7022cec 248 );\r
249\r
250/**\r
b4e73a63 251 Handler for Repeat Key event.\r
252\r
253 This function is the handler for Repeat Key event triggered\r
254 by timer.\r
255 After a repeatable key is pressed, the event would be triggered\r
256 with interval of USBKBD_REPEAT_DELAY. Once the event is triggered,\r
257 following trigger will come with interval of USBKBD_REPEAT_RATE.\r
a7022cec 258\r
259 @param Event The Repeat Key event.\r
260 @param Context Points to the USB_KB_DEV instance.\r
261\r
a7022cec 262**/\r
263VOID\r
264EFIAPI\r
265USBKeyboardRepeatHandler (\r
266 IN EFI_EVENT Event,\r
267 IN VOID *Context\r
268 );\r
269\r
270/**\r
b4e73a63 271 Sets USB keyboard LED state.\r
a7022cec 272\r
273 @param UsbKeyboardDevice The USB_KB_DEV instance.\r
274\r
a7022cec 275**/\r
5899f27e 276VOID\r
a7022cec 277EFIAPI\r
278SetKeyLED (\r
279 IN USB_KB_DEV *UsbKeyboardDevice\r
280 );\r
281\r
282#endif\r