2 PS/2 keyboard driver header file
4 Copyright (c) 2006 - 2007 Intel Corporation. All rights reserved. <BR>
5 This software and associated documentation (if any) is furnished
6 under a license and may only be used or copied in accordance
7 with the terms of the license. Except as permitted by such
8 license, no part of this software or documentation may be
9 reproduced, stored in a retrieval system, or transmitted in any
10 form or by any means without the express written consent of
15 #ifndef _PS2KEYBOARD_H
16 #define _PS2KEYBOARD_H
19 // Include common header file for this module.
21 #include "CommonHeader.h"
24 // Driver Private Data
26 #define KEYBOARD_BUFFER_MAX_COUNT 32
27 #define KEYBOARD_CONSOLE_IN_DEV_SIGNATURE EFI_SIGNATURE_32 ('k', 'k', 'e', 'y')
33 EFI_SIMPLE_TEXT_INPUT_PROTOCOL ConIn
;
34 EFI_ISA_IO_PROTOCOL
*IsaIo
;
38 UINT32 DataRegisterAddress
;
39 UINT32 StatusRegisterAddress
;
40 UINT32 CommandRegisterAddress
;
52 // Buffer storing key scancodes
54 UINT8 ScancodeBuf
[KEYBOARD_BUFFER_MAX_COUNT
];
55 UINT32 ScancodeBufStartPos
;
56 UINT32 ScancodeBufEndPos
;
57 UINT32 ScancodeBufCount
;
60 // Indicators of the key pressing state, used in detecting Alt+Ctrl+Del
70 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
72 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
73 } KEYBOARD_CONSOLE_IN_DEV
;
75 #define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYBOARD_CONSOLE_IN_DEV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE)
82 extern EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver
;
83 extern EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName
;
89 InstallPs2KeyboardDriver (
90 IN EFI_HANDLE ImageHandle
,
91 IN EFI_SYSTEM_TABLE
*SystemTable
97 GC_TODO: Add function description
101 ImageHandle - GC_TODO: add argument description
102 SystemTable - GC_TODO: add argument description
106 GC_TODO: add return values
111 #define KEYBOARD_8042_DATA_REGISTER 0x60
112 #define KEYBOARD_8042_STATUS_REGISTER 0x64
113 #define KEYBOARD_8042_COMMAND_REGISTER 0x64
115 #define KEYBOARD_KBEN 0xF4
116 #define KEYBOARD_CMDECHO_ACK 0xFA
118 #define KEYBOARD_TIMEOUT 65536 // 0.07s
119 #define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
120 #define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
121 #define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
122 #define SCANCODE_EXTENDED 0xE0
123 #define SCANCODE_EXTENDED1 0xE1
124 #define SCANCODE_CTRL_MAKE 0x1D
125 #define SCANCODE_CTRL_BREAK 0x9D
126 #define SCANCODE_ALT_MAKE 0x38
127 #define SCANCODE_ALT_BREAK 0xB8
128 #define SCANCODE_LEFT_SHIFT_MAKE 0x2A
129 #define SCANCODE_LEFT_SHIFT_BREAK 0xAA
130 #define SCANCODE_RIGHT_SHIFT_MAKE 0x36
131 #define SCANCODE_RIGHT_SHIFT_BREAK 0xB6
132 #define SCANCODE_CAPS_LOCK_MAKE 0x3A
133 #define SCANCODE_NUM_LOCK_MAKE 0x45
134 #define SCANCODE_SCROLL_LOCK_MAKE 0x46
135 #define SCANCODE_MAX_MAKE 0x59
138 // Other functions that are used among .c files
142 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
,
149 GC_TODO: Add function description
153 ConsoleIn - GC_TODO: add argument description
154 Data - GC_TODO: add argument description
158 GC_TODO: add return values
165 IN OUT KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
171 GC_TODO: Add function description
175 ConsoleIn - GC_TODO: add argument description
179 GC_TODO: add return values
186 IN OUT KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
,
187 IN BOOLEAN ExtendedVerification
193 GC_TODO: Add function description
197 ConsoleIn - GC_TODO: add argument description
198 ExtendedVerification - GC_TODO: add argument description
202 GC_TODO: add return values
209 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
215 GC_TODO: Add function description
219 ConsoleIn - GC_TODO: add argument description
223 GC_TODO: add return values
230 KeyboardTimerHandler (
238 GC_TODO: Add function description
242 Event - GC_TODO: add argument description
243 Context - GC_TODO: add argument description
247 GC_TODO: add return values
255 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
256 IN BOOLEAN ExtendedVerification
262 GC_TODO: Add function description
266 This - GC_TODO: add argument description
267 ExtendedVerification - GC_TODO: add argument description
271 GC_TODO: add return values
278 KeyboardReadKeyStroke (
279 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
280 OUT EFI_INPUT_KEY
*Key
286 GC_TODO: Add function description
290 This - GC_TODO: add argument description
291 Key - GC_TODO: add argument description
295 GC_TODO: add return values
310 GC_TODO: Add function description
314 Event - GC_TODO: add argument description
315 Context - GC_TODO: add argument description
319 GC_TODO: add return values
325 KeyReadStatusRegister (
326 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn
332 GC_TODO: Add function description
336 ConsoleIn - GC_TODO: add argument description
340 GC_TODO: add return values
346 Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
347 If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device
348 should not be in system.
350 @param[in] BiosKeyboardPrivate Keyboard Private Data Structure
352 @retval TRUE Keyboard in System.
353 @retval FALSE Keyboard not in System.
357 CheckKeyboardConnect (
358 IN KEYBOARD_CONSOLE_IN_DEV
*ConsoleIn