]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.h
e93a8665a449ce02fe612a47b3936692a72111f2
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / efikey.h
1 /** @file
2 Copyright (c) 2004 - 2007, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
7
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11 Module Name:
12
13 EfiKey.h
14
15 Abstract:
16
17 Header file for USB Keyboard Driver's Data Structures
18
19 Revision History
20
21 **/
22 #ifndef _USB_KB_H
23 #define _USB_KB_H
24
25 //
26 // The package level header files this module uses
27 //
28 #include <PiDxe.h>
29 //
30 // The protocols, PPI and GUID defintions for this module
31 //
32 #include <Protocol/SimpleTextIn.h>
33 #include <Guid/HotPlugDevice.h>
34 #include <Protocol/UsbIo.h>
35 #include <Protocol/DevicePath.h>
36 //
37 // The Library classes this module consumes
38 //
39 #include <Library/DebugLib.h>
40 #include <Library/ReportStatusCodeLib.h>
41 #include <Library/BaseMemoryLib.h>
42 #include <Library/UefiRuntimeServicesTableLib.h>
43 #include <Library/UefiDriverEntryPoint.h>
44 #include <Library/UefiBootServicesTableLib.h>
45 #include <Library/UefiLib.h>
46 #include <Library/MemoryAllocationLib.h>
47 #include <Library/PcdLib.h>
48 #include <Library/UsbLib.h>
49
50
51 #include <IndustryStandard/Usb.h>
52
53 #define MAX_KEY_ALLOWED 32
54
55 #define HZ 1000 * 1000 * 10
56 #define USBKBD_REPEAT_DELAY ((HZ) / 2)
57 #define USBKBD_REPEAT_RATE ((HZ) / 50)
58
59 #define CLASS_HID 3
60 #define SUBCLASS_BOOT 1
61 #define PROTOCOL_KEYBOARD 1
62
63 #define BOOT_PROTOCOL 0
64 #define REPORT_PROTOCOL 1
65
66 typedef struct {
67 UINT8 Down;
68 UINT8 KeyCode;
69 } USB_KEY;
70
71 typedef struct {
72 USB_KEY buffer[MAX_KEY_ALLOWED + 1];
73 UINT8 bHead;
74 UINT8 bTail;
75 } USB_KB_BUFFER;
76
77 #define USB_KB_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'k', 'b', 'd')
78 typedef struct {
79 UINTN Signature;
80 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
81 EFI_EVENT DelayedRecoveryEvent;
82 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;
83 EFI_USB_IO_PROTOCOL *UsbIo;
84
85 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
86 EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
87
88 USB_KB_BUFFER KeyboardBuffer;
89 UINT8 CtrlOn;
90 UINT8 AltOn;
91 UINT8 ShiftOn;
92 UINT8 NumLockOn;
93 UINT8 CapsOn;
94 UINT8 ScrollOn;
95 UINT8 LastKeyCodeArray[8];
96 UINT8 CurKeyChar;
97
98 UINT8 RepeatKey;
99 EFI_EVENT RepeatTimer;
100
101 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
102
103 } USB_KB_DEV;
104
105 //
106 // Global Variables
107 //
108 extern EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding;
109 extern EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName;
110 extern EFI_GUID gEfiUsbKeyboardDriverGuid;
111
112 VOID
113 KbdReportStatusCode (
114 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
115 IN EFI_STATUS_CODE_TYPE CodeType,
116 IN EFI_STATUS_CODE_VALUE Value
117 );
118
119 #define USB_KB_DEV_FROM_THIS(a) \
120 CR(a, USB_KB_DEV, SimpleInput, USB_KB_DEV_SIGNATURE)
121
122 #define MOD_CONTROL_L 0x01
123 #define MOD_CONTROL_R 0x10
124 #define MOD_SHIFT_L 0x02
125 #define MOD_SHIFT_R 0x20
126 #define MOD_ALT_L 0x04
127 #define MOD_ALT_R 0x40
128 #define MOD_WIN_L 0x08
129 #define MOD_WIN_R 0x80
130
131 typedef struct {
132 UINT8 Mask;
133 UINT8 Key;
134 } KB_MODIFIER;
135
136 #define USB_KEYCODE_MAX_MAKE 0x64
137
138 #define USBKBD_VALID_KEYCODE(key) ((UINT8) (key) > 3)
139
140 typedef struct {
141 UINT8 NumLock : 1;
142 UINT8 CapsLock : 1;
143 UINT8 ScrollLock : 1;
144 UINT8 Resrvd : 5;
145 } LED_MAP;
146 #endif