]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h
modify coding style to pass ecc tool
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / EfiKey.h
... / ...
CommitLineData
1/** @file\r
2\r
3 Header file for USB Keyboard Driver's Data Structures.\r
4\r
5Copyright (c) 2004 - 2008, Intel Corporation\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15#ifndef _EFI_USB_KB_H_\r
16#define _EFI_USB_KB_H_\r
17\r
18\r
19#include <PiDxe.h>\r
20\r
21#include <Protocol/SimpleTextIn.h>\r
22#include <Protocol/SimpleTextInEx.h>\r
23#include <Protocol/HiiDatabase.h>\r
24#include <Protocol/UsbIo.h>\r
25#include <Protocol/DevicePath.h>\r
26#include <Guid/HiiKeyBoardLayout.h>\r
27#include <Guid/HotPlugDevice.h>\r
28\r
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
39#include <Library/BaseLib.h>\r
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
56typedef struct {\r
57 UINT8 Down;\r
58 UINT8 KeyCode;\r
59} USB_KEY;\r
60\r
61typedef 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
68#define USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE EFI_SIGNATURE_32 ('u', 'k', 'b', 'x')\r
69\r
70typedef 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
77\r
78#define USB_NS_KEY_SIGNATURE EFI_SIGNATURE_32 ('u', 'n', 's', 'k')\r
79\r
80typedef 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
98typedef 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
103 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;\r
104 EFI_USB_IO_PROTOCOL *UsbIo;\r
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
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
134 UINT8 AltGrOn;\r
135\r
136 EFI_KEY_STATE KeyState;\r
137 //\r
138 // Notification function list\r
139 //\r
140 LIST_ENTRY NotifyList;\r
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
149} USB_KB_DEV;\r
150\r
151//\r
152// Global Variables\r
153//\r
154extern EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding;\r
155extern EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName;\r
156extern EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2;\r
157extern EFI_GUID gEfiUsbKeyboardDriverGuid;\r
158extern EFI_GUID gSimpleTextInExNotifyGuid;\r
159\r
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
170VOID\r
171EFIAPI\r
172KbdReportStatusCode (\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
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
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
193typedef struct {\r
194 UINT8 Mask;\r
195 UINT8 Key;\r
196} KB_MODIFIER;\r
197\r
198#define USB_KEYCODE_MAX_MAKE 0x62\r
199\r
200#define USBKBD_VALID_KEYCODE(key) ((UINT8) (key) > 3)\r
201\r
202typedef 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
208\r
209//\r
210// Simple Text Input Ex protocol functions\r
211//\r
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
223EFI_STATUS\r
224EFIAPI\r
225USBKeyboardResetEx (\r
226 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
227 IN BOOLEAN ExtendedVerification\r
228 )\r
229;\r
230\r
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
234\r
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
238\r
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
242\r
243**/\r
244EFI_STATUS\r
245EFIAPI\r
246USBKeyboardReadKeyStrokeEx (\r
247 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
248 OUT EFI_KEY_DATA *KeyData\r
249 )\r
250;\r
251\r
252/**\r
253 Set certain state for the input device.\r
254\r
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
258\r
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
262\r
263**/\r
264EFI_STATUS\r
265EFIAPI\r
266USBKeyboardSetState (\r
267 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
268 IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r
269 )\r
270;\r
271\r
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
287EFI_STATUS\r
288EFIAPI\r
289USBKeyboardRegisterKeyNotify (\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
295;\r
296\r
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
309EFI_STATUS\r
310EFIAPI\r
311USBKeyboardUnregisterKeyNotify (\r
312 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
313 IN EFI_HANDLE NotificationHandle\r
314 )\r
315;\r
316\r
317#endif\r
318\r