]>
Commit | Line | Data |
---|---|---|
ed838d0c | 1 | /** @file\r |
2 | Copyright (c) 2004 - 2007, Intel Corporation\r | |
3 | All rights reserved. This program and the accompanying materials\r | |
4 | are licensed and made available under the terms and conditions of the BSD License\r | |
5 | which accompanies this distribution. The full text of the license may be found at\r | |
6 | http://opensource.org/licenses/bsd-license.php\r | |
7 | \r | |
8 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
9 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
10 | \r | |
11 | Module Name:\r | |
12 | \r | |
13 | EfiKey.h\r | |
14 | \r | |
15 | Abstract:\r | |
16 | \r | |
17 | Header file for USB Keyboard Driver's Data Structures\r | |
18 | \r | |
19 | Revision History\r | |
20 | \r | |
21 | **/\r | |
22 | #ifndef _USB_KB_H\r | |
23 | #define _USB_KB_H\r | |
24 | \r | |
ed7748fe | 25 | \r |
ed838d0c | 26 | #include <PiDxe.h>\r |
ed7748fe | 27 | \r |
ed838d0c | 28 | #include <Protocol/SimpleTextIn.h>\r |
66aa04e4 | 29 | #include <Protocol/SimpleTextInEx.h>\r |
ed838d0c | 30 | #include <Guid/HotPlugDevice.h>\r |
31 | #include <Protocol/UsbIo.h>\r | |
32 | #include <Protocol/DevicePath.h>\r | |
ed7748fe | 33 | \r |
ed838d0c | 34 | #include <Library/DebugLib.h>\r |
35 | #include <Library/ReportStatusCodeLib.h>\r | |
36 | #include <Library/BaseMemoryLib.h>\r | |
37 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
38 | #include <Library/UefiDriverEntryPoint.h>\r | |
39 | #include <Library/UefiBootServicesTableLib.h>\r | |
40 | #include <Library/UefiLib.h>\r | |
41 | #include <Library/MemoryAllocationLib.h>\r | |
42 | #include <Library/PcdLib.h>\r | |
43 | #include <Library/UsbLib.h>\r | |
66aa04e4 | 44 | #include <Library/BaseLib.h>\r |
ed838d0c | 45 | \r |
46 | #include <IndustryStandard/Usb.h>\r | |
47 | \r | |
48 | #define MAX_KEY_ALLOWED 32\r | |
49 | \r | |
50 | #define HZ 1000 * 1000 * 10\r | |
51 | #define USBKBD_REPEAT_DELAY ((HZ) / 2)\r | |
52 | #define USBKBD_REPEAT_RATE ((HZ) / 50)\r | |
53 | \r | |
54 | #define CLASS_HID 3\r | |
55 | #define SUBCLASS_BOOT 1\r | |
56 | #define PROTOCOL_KEYBOARD 1\r | |
57 | \r | |
58 | #define BOOT_PROTOCOL 0\r | |
59 | #define REPORT_PROTOCOL 1\r | |
60 | \r | |
61 | typedef struct {\r | |
62 | UINT8 Down;\r | |
63 | UINT8 KeyCode;\r | |
64 | } USB_KEY;\r | |
65 | \r | |
66 | typedef struct {\r | |
67 | USB_KEY buffer[MAX_KEY_ALLOWED + 1];\r | |
68 | UINT8 bHead;\r | |
69 | UINT8 bTail;\r | |
70 | } USB_KB_BUFFER;\r | |
71 | \r | |
72 | #define USB_KB_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'k', 'b', 'd')\r | |
66aa04e4 | 73 | #define USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE EFI_SIGNATURE_32 ('u', 'k', 'b', 'x')\r |
74 | \r | |
75 | typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY {\r | |
76 | UINTN Signature;\r | |
77 | EFI_HANDLE NotifyHandle;\r | |
78 | EFI_KEY_DATA KeyData;\r | |
79 | EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;\r | |
80 | LIST_ENTRY NotifyEntry;\r | |
81 | } KEYBOARD_CONSOLE_IN_EX_NOTIFY;\r | |
ed838d0c | 82 | typedef struct {\r |
83 | UINTN Signature;\r | |
84 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
85 | EFI_EVENT DelayedRecoveryEvent;\r | |
86 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;\r | |
66aa04e4 | 87 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;\r |
88 | EFI_USB_IO_PROTOCOL *UsbIo;\r | |
ed838d0c | 89 | \r |
90 | EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;\r | |
91 | EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;\r | |
92 | \r | |
93 | USB_KB_BUFFER KeyboardBuffer;\r | |
94 | UINT8 CtrlOn;\r | |
95 | UINT8 AltOn;\r | |
96 | UINT8 ShiftOn;\r | |
97 | UINT8 NumLockOn;\r | |
98 | UINT8 CapsOn;\r | |
99 | UINT8 ScrollOn;\r | |
100 | UINT8 LastKeyCodeArray[8];\r | |
101 | UINT8 CurKeyChar;\r | |
102 | \r | |
103 | UINT8 RepeatKey;\r | |
104 | EFI_EVENT RepeatTimer;\r | |
105 | \r | |
106 | EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r | |
66aa04e4 | 107 | \r |
108 | UINT8 LeftCtrlOn;\r | |
109 | UINT8 LeftAltOn;\r | |
110 | UINT8 LeftShiftOn;\r | |
111 | UINT8 LeftLogoOn;\r | |
112 | UINT8 RightCtrlOn;\r | |
113 | UINT8 RightAltOn;\r | |
114 | UINT8 RightShiftOn;\r | |
115 | UINT8 RightLogoOn; \r | |
116 | UINT8 MenuKeyOn;\r | |
117 | UINT8 SysReqOn;\r | |
118 | \r | |
119 | EFI_KEY_STATE KeyState;\r | |
120 | //\r | |
121 | // Notification function list\r | |
122 | //\r | |
123 | LIST_ENTRY NotifyList;\r | |
ed838d0c | 124 | } USB_KB_DEV;\r |
125 | \r | |
126 | //\r | |
127 | // Global Variables\r | |
128 | //\r | |
62b9bb55 | 129 | extern EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding;\r |
130 | extern EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName;\r | |
131 | extern EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2;\r | |
132 | extern EFI_GUID gEfiUsbKeyboardDriverGuid;\r | |
66aa04e4 | 133 | extern EFI_GUID gSimpleTextInExNotifyGuid;\r |
ed838d0c | 134 | \r |
135 | VOID\r | |
136 | KbdReportStatusCode (\r | |
137 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
138 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
139 | IN EFI_STATUS_CODE_VALUE Value\r | |
140 | );\r | |
141 | \r | |
142 | #define USB_KB_DEV_FROM_THIS(a) \\r | |
143 | CR(a, USB_KB_DEV, SimpleInput, USB_KB_DEV_SIGNATURE)\r | |
66aa04e4 | 144 | #define TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS(a) \\r |
145 | CR(a, USB_KB_DEV, SimpleInputEx, USB_KB_DEV_SIGNATURE)\r | |
146 | \r | |
ed838d0c | 147 | \r |
148 | #define MOD_CONTROL_L 0x01\r | |
149 | #define MOD_CONTROL_R 0x10\r | |
150 | #define MOD_SHIFT_L 0x02\r | |
151 | #define MOD_SHIFT_R 0x20\r | |
152 | #define MOD_ALT_L 0x04\r | |
153 | #define MOD_ALT_R 0x40\r | |
154 | #define MOD_WIN_L 0x08\r | |
155 | #define MOD_WIN_R 0x80\r | |
156 | \r | |
157 | typedef struct {\r | |
158 | UINT8 Mask;\r | |
159 | UINT8 Key;\r | |
160 | } KB_MODIFIER;\r | |
161 | \r | |
66aa04e4 | 162 | #define USB_KEYCODE_MAX_MAKE 0x7E\r |
ed838d0c | 163 | \r |
164 | #define USBKBD_VALID_KEYCODE(key) ((UINT8) (key) > 3)\r | |
165 | \r | |
166 | typedef struct {\r | |
167 | UINT8 NumLock : 1;\r | |
168 | UINT8 CapsLock : 1;\r | |
169 | UINT8 ScrollLock : 1;\r | |
170 | UINT8 Resrvd : 5;\r | |
171 | } LED_MAP;\r | |
66aa04e4 | 172 | \r |
173 | //\r | |
174 | // Simple Text Input Ex protocol functions\r | |
175 | //\r | |
176 | EFI_STATUS\r | |
177 | EFIAPI\r | |
178 | USBKeyboardResetEx (\r | |
179 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
180 | IN BOOLEAN ExtendedVerification\r | |
181 | )\r | |
182 | /*++\r | |
183 | \r | |
184 | Routine Description:\r | |
185 | Reset the input device and optionaly run diagnostics\r | |
186 | \r | |
187 | Arguments:\r | |
188 | This - Protocol instance pointer.\r | |
189 | ExtendedVerification - Driver may perform diagnostics on reset.\r | |
190 | \r | |
191 | Returns:\r | |
192 | EFI_SUCCESS - The device was reset.\r | |
193 | EFI_DEVICE_ERROR - The device is not functioning properly and could \r | |
194 | not be reset.\r | |
195 | \r | |
196 | --*/\r | |
197 | ;\r | |
198 | \r | |
199 | EFI_STATUS\r | |
200 | EFIAPI\r | |
201 | USBKeyboardReadKeyStrokeEx (\r | |
202 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
203 | OUT EFI_KEY_DATA *KeyData\r | |
204 | )\r | |
205 | /*++\r | |
206 | \r | |
207 | Routine Description:\r | |
208 | Reads the next keystroke from the input device. The WaitForKey Event can \r | |
209 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
210 | \r | |
211 | Arguments:\r | |
212 | This - Protocol instance pointer.\r | |
213 | KeyData - A pointer to a buffer that is filled in with the keystroke \r | |
214 | state data for the key that was pressed.\r | |
215 | \r | |
216 | Returns:\r | |
217 | EFI_SUCCESS - The keystroke information was returned.\r | |
218 | EFI_NOT_READY - There was no keystroke data availiable.\r | |
219 | EFI_DEVICE_ERROR - The keystroke information was not returned due to \r | |
220 | hardware errors.\r | |
221 | EFI_INVALID_PARAMETER - KeyData is NULL. \r | |
222 | \r | |
223 | --*/\r | |
224 | ;\r | |
225 | \r | |
226 | EFI_STATUS\r | |
227 | EFIAPI\r | |
228 | USBKeyboardSetState (\r | |
229 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
230 | IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r | |
231 | )\r | |
232 | /*++\r | |
233 | \r | |
234 | Routine Description:\r | |
235 | Set certain state for the input device.\r | |
236 | \r | |
237 | Arguments:\r | |
238 | This - Protocol instance pointer.\r | |
239 | KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the \r | |
240 | state for the input device.\r | |
241 | \r | |
242 | Returns: \r | |
243 | EFI_SUCCESS - The device state was set successfully.\r | |
244 | EFI_DEVICE_ERROR - The device is not functioning correctly and could \r | |
245 | not have the setting adjusted.\r | |
246 | EFI_UNSUPPORTED - The device does not have the ability to set its state.\r | |
247 | EFI_INVALID_PARAMETER - KeyToggleState is NULL. \r | |
248 | \r | |
249 | --*/ \r | |
250 | ;\r | |
251 | \r | |
252 | EFI_STATUS\r | |
253 | EFIAPI\r | |
254 | USBKeyboardRegisterKeyNotify (\r | |
255 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
256 | IN EFI_KEY_DATA *KeyData,\r | |
257 | IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r | |
258 | OUT EFI_HANDLE *NotifyHandle\r | |
259 | )\r | |
260 | /*++\r | |
261 | \r | |
262 | Routine Description:\r | |
263 | Register a notification function for a particular keystroke for the input device.\r | |
264 | \r | |
265 | Arguments:\r | |
266 | This - Protocol instance pointer.\r | |
267 | KeyData - A pointer to a buffer that is filled in with the keystroke \r | |
268 | information data for the key that was pressed.\r | |
269 | KeyNotificationFunction - Points to the function to be called when the key \r | |
270 | sequence is typed specified by KeyData. \r | |
271 | NotifyHandle - Points to the unique handle assigned to the registered notification. \r | |
272 | \r | |
273 | Returns:\r | |
274 | EFI_SUCCESS - The notification function was registered successfully.\r | |
275 | EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.\r | |
276 | EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL. \r | |
277 | \r | |
278 | --*/ \r | |
279 | ;\r | |
280 | \r | |
281 | EFI_STATUS\r | |
282 | EFIAPI\r | |
283 | USBKeyboardUnregisterKeyNotify (\r | |
284 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
285 | IN EFI_HANDLE NotificationHandle\r | |
286 | )\r | |
287 | /*++\r | |
288 | \r | |
289 | Routine Description:\r | |
290 | Remove a registered notification function from a particular keystroke.\r | |
291 | \r | |
292 | Arguments:\r | |
293 | This - Protocol instance pointer. \r | |
294 | NotificationHandle - The handle of the notification function being unregistered.\r | |
295 | \r | |
296 | Returns:\r | |
297 | EFI_SUCCESS - The notification function was unregistered successfully.\r | |
298 | EFI_INVALID_PARAMETER - The NotificationHandle is invalid.\r | |
299 | EFI_NOT_FOUND - Can not find the matching entry in database. \r | |
300 | \r | |
301 | --*/ \r | |
302 | ;\r | |
303 | \r | |
ed838d0c | 304 | #endif\r |
66aa04e4 | 305 | \r |