Update to BSD license header.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2KeyboardDxe / Ps2Keyboard.h
1 /**@file
2 PS/2 keyboard driver header file
3
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
9
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.
12
13 **/
14
15 #ifndef _PS2KEYBOARD_H
16 #define _PS2KEYBOARD_H
17
18 //
19 // Include common header file for this module.
20 //
21 #include "CommonHeader.h"
22
23 //
24 // Driver Private Data
25 //
26 #define KEYBOARD_BUFFER_MAX_COUNT 32
27 #define KEYBOARD_CONSOLE_IN_DEV_SIGNATURE EFI_SIGNATURE_32 ('k', 'k', 'e', 'y')
28
29 typedef struct {
30 UINTN Signature;
31
32 EFI_HANDLE Handle;
33 EFI_SIMPLE_TEXT_INPUT_PROTOCOL ConIn;
34 EFI_ISA_IO_PROTOCOL *IsaIo;
35
36 EFI_EVENT TimerEvent;
37
38 UINT32 DataRegisterAddress;
39 UINT32 StatusRegisterAddress;
40 UINT32 CommandRegisterAddress;
41
42 EFI_INPUT_KEY Key;
43
44 BOOLEAN Ctrl;
45 BOOLEAN Alt;
46 BOOLEAN Shift;
47 BOOLEAN CapsLock;
48 BOOLEAN NumLock;
49 BOOLEAN ScrollLock;
50
51 //
52 // Buffer storing key scancodes
53 //
54 UINT8 ScancodeBuf[KEYBOARD_BUFFER_MAX_COUNT];
55 UINT32 ScancodeBufStartPos;
56 UINT32 ScancodeBufEndPos;
57 UINT32 ScancodeBufCount;
58
59 //
60 // Indicators of the key pressing state, used in detecting Alt+Ctrl+Del
61 //
62 BOOLEAN Ctrled;
63 BOOLEAN Alted;
64
65 //
66 // Error state
67 //
68 BOOLEAN KeyboardErr;
69
70 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
71
72 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
73 } KEYBOARD_CONSOLE_IN_DEV;
74
75 #define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYBOARD_CONSOLE_IN_DEV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE)
76
77 #define TABLE_END 0x0
78
79 //
80 // Global Variables
81 //
82 extern EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver;
83 extern EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName;
84
85 //
86 // Driver entry point
87 //
88 EFI_STATUS
89 InstallPs2KeyboardDriver (
90 IN EFI_HANDLE ImageHandle,
91 IN EFI_SYSTEM_TABLE *SystemTable
92 )
93 /*++
94
95 Routine Description:
96
97 GC_TODO: Add function description
98
99 Arguments:
100
101 ImageHandle - GC_TODO: add argument description
102 SystemTable - GC_TODO: add argument description
103
104 Returns:
105
106 GC_TODO: add return values
107
108 --*/
109 ;
110
111 #define KEYBOARD_8042_DATA_REGISTER 0x60
112 #define KEYBOARD_8042_STATUS_REGISTER 0x64
113 #define KEYBOARD_8042_COMMAND_REGISTER 0x64
114
115 #define KEYBOARD_KBEN 0xF4
116 #define KEYBOARD_CMDECHO_ACK 0xFA
117
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
136
137 //
138 // Other functions that are used among .c files
139 //
140 EFI_STATUS
141 KeyboardRead (
142 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
143 OUT UINT8 *Data
144 )
145 /*++
146
147 Routine Description:
148
149 GC_TODO: Add function description
150
151 Arguments:
152
153 ConsoleIn - GC_TODO: add argument description
154 Data - GC_TODO: add argument description
155
156 Returns:
157
158 GC_TODO: add return values
159
160 --*/
161 ;
162
163 EFI_STATUS
164 KeyGetchar (
165 IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
166 )
167 /*++
168
169 Routine Description:
170
171 GC_TODO: Add function description
172
173 Arguments:
174
175 ConsoleIn - GC_TODO: add argument description
176
177 Returns:
178
179 GC_TODO: add return values
180
181 --*/
182 ;
183
184 EFI_STATUS
185 InitKeyboard (
186 IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
187 IN BOOLEAN ExtendedVerification
188 )
189 /*++
190
191 Routine Description:
192
193 GC_TODO: Add function description
194
195 Arguments:
196
197 ConsoleIn - GC_TODO: add argument description
198 ExtendedVerification - GC_TODO: add argument description
199
200 Returns:
201
202 GC_TODO: add return values
203
204 --*/
205 ;
206
207 EFI_STATUS
208 DisableKeyboard (
209 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
210 )
211 /*++
212
213 Routine Description:
214
215 GC_TODO: Add function description
216
217 Arguments:
218
219 ConsoleIn - GC_TODO: add argument description
220
221 Returns:
222
223 GC_TODO: add return values
224
225 --*/
226 ;
227
228 VOID
229 EFIAPI
230 KeyboardTimerHandler (
231 IN EFI_EVENT Event,
232 IN VOID *Context
233 )
234 /*++
235
236 Routine Description:
237
238 GC_TODO: Add function description
239
240 Arguments:
241
242 Event - GC_TODO: add argument description
243 Context - GC_TODO: add argument description
244
245 Returns:
246
247 GC_TODO: add return values
248
249 --*/
250 ;
251
252 EFI_STATUS
253 EFIAPI
254 KeyboardEfiReset (
255 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
256 IN BOOLEAN ExtendedVerification
257 )
258 /*++
259
260 Routine Description:
261
262 GC_TODO: Add function description
263
264 Arguments:
265
266 This - GC_TODO: add argument description
267 ExtendedVerification - GC_TODO: add argument description
268
269 Returns:
270
271 GC_TODO: add return values
272
273 --*/
274 ;
275
276 EFI_STATUS
277 EFIAPI
278 KeyboardReadKeyStroke (
279 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
280 OUT EFI_INPUT_KEY *Key
281 )
282 /*++
283
284 Routine Description:
285
286 GC_TODO: Add function description
287
288 Arguments:
289
290 This - GC_TODO: add argument description
291 Key - GC_TODO: add argument description
292
293 Returns:
294
295 GC_TODO: add return values
296
297 --*/
298 ;
299
300 VOID
301 EFIAPI
302 KeyboardWaitForKey (
303 IN EFI_EVENT Event,
304 IN VOID *Context
305 )
306 /*++
307
308 Routine Description:
309
310 GC_TODO: Add function description
311
312 Arguments:
313
314 Event - GC_TODO: add argument description
315 Context - GC_TODO: add argument description
316
317 Returns:
318
319 GC_TODO: add return values
320
321 --*/
322 ;
323
324 UINT8
325 KeyReadStatusRegister (
326 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
327 )
328 /*++
329
330 Routine Description:
331
332 GC_TODO: Add function description
333
334 Arguments:
335
336 ConsoleIn - GC_TODO: add argument description
337
338 Returns:
339
340 GC_TODO: add return values
341
342 --*/
343 ;
344
345 /**
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.
349
350 @param[in] BiosKeyboardPrivate Keyboard Private Data Structure
351
352 @retval TRUE Keyboard in System.
353 @retval FALSE Keyboard not in System.
354 **/
355 BOOLEAN
356 EFIAPI
357 CheckKeyboardConnect (
358 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
359 )
360 ;
361 #endif