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