2 PS/2 keyboard driver header file
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _PS2KEYBOARD_H
16 #define _PS2KEYBOARD_H
19 #include <Framework/StatusCode.h>
21 #include <Protocol/SimpleTextIn.h>
22 #include <Protocol/IsaIo.h>
23 #include <Protocol/DevicePath.h>
24 #include <Protocol/Ps2Policy.h>
26 #include <Library/UefiDriverEntryPoint.h>
27 #include <Library/UefiLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/ReportStatusCodeLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/UefiRuntimeServicesTableLib.h>
32 #include <Library/MemoryAllocationLib.h>
35 // Driver Private Data
37 #define KEYBOARD_BUFFER_MAX_COUNT 32
38 #define KEYBOARD_CONSOLE_IN_DEV_SIGNATURE EFI_SIGNATURE_32 ('k', 'k', 'e', 'y')
44 EFI_SIMPLE_TEXT_INPUT_PROTOCOL ConIn
;
45 EFI_ISA_IO_PROTOCOL
*IsaIo
;
49 UINT32 DataRegisterAddress
;
50 UINT32 StatusRegisterAddress
;
51 UINT32 CommandRegisterAddress
;
63 // Buffer storing key scancodes
65 UINT8 ScancodeBuf
[KEYBOARD_BUFFER_MAX_COUNT
];
66 UINT32 ScancodeBufStartPos
;
67 UINT32 ScancodeBufEndPos
;
68 UINT32 ScancodeBufCount
;
71 // Indicators of the key pressing state, used in detecting Alt+Ctrl+Del
81 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
83 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
84 } KEYBOARD_CONSOLE_IN_DEV
;
86 #define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYBOARD_CONSOLE_IN_DEV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE)
93 extern EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver
;
94 extern EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName
;
95 extern EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2
;
101 InstallPs2KeyboardDriver (
102 IN EFI_HANDLE ImageHandle
,
103 IN EFI_SYSTEM_TABLE
*SystemTable
109 GC_TODO: Add function description
113 ImageHandle - GC_TODO: add argument description
114 SystemTable - GC_TODO: add argument description
118 GC_TODO: add return values
123 #define KEYBOARD_8042_DATA_REGISTER 0x60
124 #define KEYBOARD_8042_STATUS_REGISTER 0x64
125 #define KEYBOARD_8042_COMMAND_REGISTER 0x64
127 #define KEYBOARD_KBEN 0xF4
128 #define KEYBOARD_CMDECHO_ACK 0xFA
130 #define KEYBOARD_TIMEOUT 65536 // 0.07s
131 #define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
132 #define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
133 #define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
134 #define SCANCODE_EXTENDED 0xE0
135 #define SCANCODE_EXTENDED1 0xE1
136 #define SCANCODE_CTRL_MAKE 0x1D
137 #define SCANCODE_CTRL_BREAK 0x9D
138 #define SCANCODE_ALT_MAKE 0x38
139 #define SCANCODE_ALT_BREAK 0xB8
140 #define SCANCODE_LEFT_SHIFT_MAKE 0x2A
141 #define SCANCODE_LEFT_SHIFT_BREAK 0xAA
142 #define SCANCODE_RIGHT_SHIFT_MAKE 0x36
143 #define SCANCODE_RIGHT_SHIFT_BREAK 0xB6
144 #define SCANCODE_CAPS_LOCK_MAKE 0x3A
145 #define SCANCODE_NUM_LOCK_MAKE 0x45
146 #define SCANCODE_SCROLL_LOCK_MAKE 0x46
147 #define SCANCODE_MAX_MAKE 0x59
150 // Other functions that are used among .c files
154 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
,
161 GC_TODO: Add function description
165 ConsoleIn - GC_TODO: add argument description
166 Data - GC_TODO: add argument description
170 GC_TODO: add return values
177 IN OUT KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
183 GC_TODO: Add function description
187 ConsoleIn - GC_TODO: add argument description
191 GC_TODO: add return values
198 IN OUT KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
,
199 IN BOOLEAN ExtendedVerification
205 GC_TODO: Add function description
209 ConsoleIn - GC_TODO: add argument description
210 ExtendedVerification - GC_TODO: add argument description
214 GC_TODO: add return values
221 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
227 GC_TODO: Add function description
231 ConsoleIn - GC_TODO: add argument description
235 GC_TODO: add return values
242 KeyboardTimerHandler (
250 GC_TODO: Add function description
254 Event - GC_TODO: add argument description
255 Context - GC_TODO: add argument description
259 GC_TODO: add return values
267 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
268 IN BOOLEAN ExtendedVerification
274 GC_TODO: Add function description
278 This - GC_TODO: add argument description
279 ExtendedVerification - GC_TODO: add argument description
283 GC_TODO: add return values
290 KeyboardReadKeyStroke (
291 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
292 OUT EFI_INPUT_KEY
*Key
298 GC_TODO: Add function description
302 This - GC_TODO: add argument description
303 Key - GC_TODO: add argument description
307 GC_TODO: add return values
322 GC_TODO: Add function description
326 Event - GC_TODO: add argument description
327 Context - GC_TODO: add argument description
331 GC_TODO: add return values
337 KeyReadStatusRegister (
338 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
344 GC_TODO: Add function description
348 ConsoleIn - GC_TODO: add argument description
352 GC_TODO: add return values
358 Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
359 If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device
360 should not be in system.
362 @param[in] BiosKeyboardPrivate Keyboard Private Data Structure
364 @retval TRUE Keyboard in System.
365 @retval FALSE Keyboard not in System.
369 CheckKeyboardConnect (
370 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn