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