]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h
clean up the un-suitable ';' location when declaring the functions.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / EfiKey.h
CommitLineData
ed838d0c 1/** @file\r
a7022cec 2\r
3 Header file for USB Keyboard Driver's Data Structures.\r
4\r
813acf3a 5Copyright (c) 2004 - 2008, Intel Corporation\r
ed838d0c 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
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
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
66aa04e4 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
813acf3a 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
ed838d0c 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
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 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
66aa04e4 158extern 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 170VOID\r
a7022cec 171EFIAPI\r
ed838d0c 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
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
193typedef 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
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
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 223EFI_STATUS\r
224EFIAPI\r
225USBKeyboardResetEx (\r
226 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
227 IN BOOLEAN ExtendedVerification\r
ed66e1bc 228 );\r
66aa04e4 229\r
a7022cec 230/**\r
231 Reads the next keystroke from the input device. The WaitForKey Event can\r
232 be used to test for existance of a keystroke via WaitForEvent () call.\r
66aa04e4 233\r
a7022cec 234 @param This Protocol instance pointer.\r
235 @param KeyData A pointer to a buffer that is filled in with the keystroke\r
236 state data for the key that was pressed.\r
66aa04e4 237\r
a7022cec 238 @return EFI_SUCCESS The keystroke information was returned successfully.\r
239 @retval EFI_INVALID_PARAMETER KeyData is NULL.\r
240 @retval Other Read key stroke information failed.\r
66aa04e4 241\r
a7022cec 242**/\r
66aa04e4 243EFI_STATUS\r
244EFIAPI\r
245USBKeyboardReadKeyStrokeEx (\r
246 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
247 OUT EFI_KEY_DATA *KeyData\r
ed66e1bc 248 );\r
66aa04e4 249\r
a7022cec 250/**\r
251 Set certain state for the input device.\r
66aa04e4 252\r
a7022cec 253 @param This Protocol instance pointer.\r
254 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the\r
255 state for the input device.\r
66aa04e4 256\r
a7022cec 257 @retval EFI_SUCCESS The device state was set successfully.\r
258 @retval EFI_UNSUPPORTED The device does not have the ability to set its state.\r
259 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.\r
66aa04e4 260\r
a7022cec 261**/\r
66aa04e4 262EFI_STATUS\r
263EFIAPI\r
264USBKeyboardSetState (\r
265 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
266 IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r
ed66e1bc 267 );\r
66aa04e4 268\r
a7022cec 269/**\r
270 Register a notification function for a particular keystroke for the input device.\r
271\r
272 @param This Protocol instance pointer.\r
273 @param KeyData A pointer to a buffer that is filled in with the keystroke\r
274 information data for the key that was pressed.\r
275 @param KeyNotificationFunction Points to the function to be called when the key\r
276 sequence is typed specified by KeyData.\r
277 @param NotifyHandle Points to the unique handle assigned to the registered notification.\r
278\r
279 @retval EFI_SUCCESS The notification function was registered successfully.\r
280 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.\r
281 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.\r
282\r
283**/\r
66aa04e4 284EFI_STATUS\r
285EFIAPI\r
286USBKeyboardRegisterKeyNotify (\r
287 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
288 IN EFI_KEY_DATA *KeyData,\r
289 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r
290 OUT EFI_HANDLE *NotifyHandle\r
ed66e1bc 291 );\r
66aa04e4 292\r
a7022cec 293/**\r
294 Remove a registered notification function from a particular keystroke.\r
295\r
296 @param This Protocol instance pointer.\r
297 @param NotificationHandle The handle of the notification function being unregistered.\r
298\r
299 @retval EFI_SUCCESS The notification function was unregistered successfully.\r
300 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid or opening gSimpleTextInExNotifyGuid\r
301 on NotificationHandle fails.\r
302 @retval EFI_NOT_FOUND Can not find the matching entry in database.\r
303\r
304**/\r
66aa04e4 305EFI_STATUS\r
306EFIAPI\r
307USBKeyboardUnregisterKeyNotify (\r
308 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
309 IN EFI_HANDLE NotificationHandle\r
ed66e1bc 310 );\r
66aa04e4 311\r
ed838d0c 312#endif\r
66aa04e4 313\r