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 |
29 | #include <Guid/HotPlugDevice.h>\r |
30 | #include <Protocol/UsbIo.h>\r |
31 | #include <Protocol/DevicePath.h>\r |
ed7748fe |
32 | \r |
ed838d0c |
33 | #include <Library/DebugLib.h>\r |
34 | #include <Library/ReportStatusCodeLib.h>\r |
35 | #include <Library/BaseMemoryLib.h>\r |
36 | #include <Library/UefiRuntimeServicesTableLib.h>\r |
37 | #include <Library/UefiDriverEntryPoint.h>\r |
38 | #include <Library/UefiBootServicesTableLib.h>\r |
39 | #include <Library/UefiLib.h>\r |
40 | #include <Library/MemoryAllocationLib.h>\r |
41 | #include <Library/PcdLib.h>\r |
42 | #include <Library/UsbLib.h>\r |
43 | \r |
44 | \r |
45 | #include <IndustryStandard/Usb.h>\r |
46 | \r |
47 | #define MAX_KEY_ALLOWED 32\r |
48 | \r |
49 | #define HZ 1000 * 1000 * 10\r |
50 | #define USBKBD_REPEAT_DELAY ((HZ) / 2)\r |
51 | #define USBKBD_REPEAT_RATE ((HZ) / 50)\r |
52 | \r |
53 | #define CLASS_HID 3\r |
54 | #define SUBCLASS_BOOT 1\r |
55 | #define PROTOCOL_KEYBOARD 1\r |
56 | \r |
57 | #define BOOT_PROTOCOL 0\r |
58 | #define REPORT_PROTOCOL 1\r |
59 | \r |
60 | typedef struct {\r |
61 | UINT8 Down;\r |
62 | UINT8 KeyCode;\r |
63 | } USB_KEY;\r |
64 | \r |
65 | typedef struct {\r |
66 | USB_KEY buffer[MAX_KEY_ALLOWED + 1];\r |
67 | UINT8 bHead;\r |
68 | UINT8 bTail;\r |
69 | } USB_KB_BUFFER;\r |
70 | \r |
71 | #define USB_KB_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'k', 'b', 'd')\r |
72 | typedef struct {\r |
73 | UINTN Signature;\r |
74 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r |
75 | EFI_EVENT DelayedRecoveryEvent;\r |
76 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;\r |
77 | EFI_USB_IO_PROTOCOL *UsbIo;\r |
78 | \r |
79 | EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;\r |
80 | EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;\r |
81 | \r |
82 | USB_KB_BUFFER KeyboardBuffer;\r |
83 | UINT8 CtrlOn;\r |
84 | UINT8 AltOn;\r |
85 | UINT8 ShiftOn;\r |
86 | UINT8 NumLockOn;\r |
87 | UINT8 CapsOn;\r |
88 | UINT8 ScrollOn;\r |
89 | UINT8 LastKeyCodeArray[8];\r |
90 | UINT8 CurKeyChar;\r |
91 | \r |
92 | UINT8 RepeatKey;\r |
93 | EFI_EVENT RepeatTimer;\r |
94 | \r |
95 | EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r |
96 | \r |
97 | } USB_KB_DEV;\r |
98 | \r |
99 | //\r |
100 | // Global Variables\r |
101 | //\r |
102 | extern EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding;\r |
103 | extern EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName;\r |
104 | extern EFI_GUID gEfiUsbKeyboardDriverGuid;\r |
105 | \r |
106 | VOID\r |
107 | KbdReportStatusCode (\r |
108 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r |
109 | IN EFI_STATUS_CODE_TYPE CodeType,\r |
110 | IN EFI_STATUS_CODE_VALUE Value\r |
111 | );\r |
112 | \r |
113 | #define USB_KB_DEV_FROM_THIS(a) \\r |
114 | CR(a, USB_KB_DEV, SimpleInput, USB_KB_DEV_SIGNATURE)\r |
115 | \r |
116 | #define MOD_CONTROL_L 0x01\r |
117 | #define MOD_CONTROL_R 0x10\r |
118 | #define MOD_SHIFT_L 0x02\r |
119 | #define MOD_SHIFT_R 0x20\r |
120 | #define MOD_ALT_L 0x04\r |
121 | #define MOD_ALT_R 0x40\r |
122 | #define MOD_WIN_L 0x08\r |
123 | #define MOD_WIN_R 0x80\r |
124 | \r |
125 | typedef struct {\r |
126 | UINT8 Mask;\r |
127 | UINT8 Key;\r |
128 | } KB_MODIFIER;\r |
129 | \r |
130 | #define USB_KEYCODE_MAX_MAKE 0x64\r |
131 | \r |
132 | #define USBKBD_VALID_KEYCODE(key) ((UINT8) (key) > 3)\r |
133 | \r |
134 | typedef struct {\r |
135 | UINT8 NumLock : 1;\r |
136 | UINT8 CapsLock : 1;\r |
137 | UINT8 ScrollLock : 1;\r |
138 | UINT8 Resrvd : 5;\r |
139 | } LED_MAP;\r |
140 | #endif\r |