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
;
100 InstallPs2KeyboardDriver (
101 IN EFI_HANDLE ImageHandle
,
102 IN EFI_SYSTEM_TABLE
*SystemTable
108 GC_TODO: Add function description
112 ImageHandle - GC_TODO: add argument description
113 SystemTable - GC_TODO: add argument description
117 GC_TODO: add return values
122 #define KEYBOARD_8042_DATA_REGISTER 0x60
123 #define KEYBOARD_8042_STATUS_REGISTER 0x64
124 #define KEYBOARD_8042_COMMAND_REGISTER 0x64
126 #define KEYBOARD_KBEN 0xF4
127 #define KEYBOARD_CMDECHO_ACK 0xFA
129 #define KEYBOARD_TIMEOUT 65536 // 0.07s
130 #define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
131 #define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
132 #define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
133 #define SCANCODE_EXTENDED 0xE0
134 #define SCANCODE_EXTENDED1 0xE1
135 #define SCANCODE_CTRL_MAKE 0x1D
136 #define SCANCODE_CTRL_BREAK 0x9D
137 #define SCANCODE_ALT_MAKE 0x38
138 #define SCANCODE_ALT_BREAK 0xB8
139 #define SCANCODE_LEFT_SHIFT_MAKE 0x2A
140 #define SCANCODE_LEFT_SHIFT_BREAK 0xAA
141 #define SCANCODE_RIGHT_SHIFT_MAKE 0x36
142 #define SCANCODE_RIGHT_SHIFT_BREAK 0xB6
143 #define SCANCODE_CAPS_LOCK_MAKE 0x3A
144 #define SCANCODE_NUM_LOCK_MAKE 0x45
145 #define SCANCODE_SCROLL_LOCK_MAKE 0x46
146 #define SCANCODE_MAX_MAKE 0x59
149 // Other functions that are used among .c files
153 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
,
160 GC_TODO: Add function description
164 ConsoleIn - GC_TODO: add argument description
165 Data - GC_TODO: add argument description
169 GC_TODO: add return values
176 IN OUT KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
182 GC_TODO: Add function description
186 ConsoleIn - GC_TODO: add argument description
190 GC_TODO: add return values
197 IN OUT KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
,
198 IN BOOLEAN ExtendedVerification
204 GC_TODO: Add function description
208 ConsoleIn - GC_TODO: add argument description
209 ExtendedVerification - GC_TODO: add argument description
213 GC_TODO: add return values
220 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
226 GC_TODO: Add function description
230 ConsoleIn - GC_TODO: add argument description
234 GC_TODO: add return values
241 KeyboardTimerHandler (
249 GC_TODO: Add function description
253 Event - GC_TODO: add argument description
254 Context - GC_TODO: add argument description
258 GC_TODO: add return values
266 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
267 IN BOOLEAN ExtendedVerification
273 GC_TODO: Add function description
277 This - GC_TODO: add argument description
278 ExtendedVerification - GC_TODO: add argument description
282 GC_TODO: add return values
289 KeyboardReadKeyStroke (
290 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
291 OUT EFI_INPUT_KEY
*Key
297 GC_TODO: Add function description
301 This - GC_TODO: add argument description
302 Key - GC_TODO: add argument description
306 GC_TODO: add return values
321 GC_TODO: Add function description
325 Event - GC_TODO: add argument description
326 Context - GC_TODO: add argument description
330 GC_TODO: add return values
336 KeyReadStatusRegister (
337 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
343 GC_TODO: Add function description
347 ConsoleIn - GC_TODO: add argument description
351 GC_TODO: add return values
357 Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
358 If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device
359 should not be in system.
361 @param[in] BiosKeyboardPrivate Keyboard Private Data Structure
363 @retval TRUE Keyboard in System.
364 @retval FALSE Keyboard not in System.
368 CheckKeyboardConnect (
369 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn