]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Bus/Usb/UsbKb/Dxe/efikey.h
091dd695a51f264ffb0c6c59d869d4f7fc720c35
[mirror_edk2.git] / EdkModulePkg / Bus / Usb / UsbKb / Dxe / efikey.h
1 /*++
2 Copyright (c) 2006, 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 #ifndef _USB_KB_H
22 #define _USB_KB_H
23
24
25 #include <IndustryStandard/Usb.h>
26
27 #define MAX_KEY_ALLOWED 32
28
29 #define HZ 1000 * 1000 * 10
30 #define USBKBD_REPEAT_DELAY ((HZ) / 2)
31 #define USBKBD_REPEAT_RATE ((HZ) / 50)
32
33 #define CLASS_HID 3
34 #define SUBCLASS_BOOT 1
35 #define PROTOCOL_KEYBOARD 1
36
37 #define BOOT_PROTOCOL 0
38 #define REPORT_PROTOCOL 1
39
40 typedef struct {
41 UINT8 Down;
42 UINT8 KeyCode;
43 } USB_KEY;
44
45 typedef struct {
46 USB_KEY buffer[MAX_KEY_ALLOWED + 1];
47 UINT8 bHead;
48 UINT8 bTail;
49 } USB_KB_BUFFER;
50
51 #define USB_KB_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'k', 'b', 'd')
52 typedef struct {
53 UINTN Signature;
54 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
55 EFI_EVENT DelayedRecoveryEvent;
56 EFI_SIMPLE_TEXT_IN_PROTOCOL SimpleInput;
57 EFI_USB_IO_PROTOCOL *UsbIo;
58
59 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
60 EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
61
62 USB_KB_BUFFER KeyboardBuffer;
63 UINT8 CtrlOn;
64 UINT8 AltOn;
65 UINT8 ShiftOn;
66 UINT8 NumLockOn;
67 UINT8 CapsOn;
68 UINT8 LastKeyCodeArray[8];
69 UINT8 CurKeyChar;
70
71 UINT8 RepeatKey;
72 EFI_EVENT RepeatTimer;
73
74 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
75
76 } USB_KB_DEV;
77
78 //
79 // Global Variables
80 //
81 extern EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding;
82 extern EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponentName;
83 extern EFI_GUID gEfiUsbKeyboardDriverGuid;
84
85 VOID
86 KbdReportStatusCode (
87 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
88 IN EFI_STATUS_CODE_TYPE CodeType,
89 IN EFI_STATUS_CODE_VALUE Value
90 );
91
92 #define USB_KB_DEV_FROM_THIS(a) \
93 CR(a, USB_KB_DEV, SimpleInput, USB_KB_DEV_SIGNATURE)
94
95 #define MOD_CONTROL_L 0x01
96 #define MOD_CONTROL_R 0x10
97 #define MOD_SHIFT_L 0x02
98 #define MOD_SHIFT_R 0x20
99 #define MOD_ALT_L 0x04
100 #define MOD_ALT_R 0x40
101 #define MOD_WIN_L 0x08
102 #define MOD_WIN_R 0x80
103
104 typedef struct {
105 UINT8 Mask;
106 UINT8 Key;
107 } KB_MODIFIER;
108
109 #define USB_KEYCODE_MAX_MAKE 0x64
110
111 #define USBKBD_VALID_KEYCODE(key) ((UINT8) (key) > 3)
112
113 typedef struct {
114 UINT8 NumLock : 1;
115 UINT8 CapsLock : 1;
116 UINT8 Resrvd : 6;
117 } LED_MAP;
118 #endif