]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
Update to support to produce Component Name and & Component Name 2 protocol based...
[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 extern EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2;
96
97 //
98 // Driver entry point
99 //
100 EFI_STATUS
101 InstallPs2KeyboardDriver (
102 IN EFI_HANDLE ImageHandle,
103 IN EFI_SYSTEM_TABLE *SystemTable
104 )
105 /*++
106
107 Routine Description:
108
109 GC_TODO: Add function description
110
111 Arguments:
112
113 ImageHandle - GC_TODO: add argument description
114 SystemTable - GC_TODO: add argument description
115
116 Returns:
117
118 GC_TODO: add return values
119
120 --*/
121 ;
122
123 #define KEYBOARD_8042_DATA_REGISTER 0x60
124 #define KEYBOARD_8042_STATUS_REGISTER 0x64
125 #define KEYBOARD_8042_COMMAND_REGISTER 0x64
126
127 #define KEYBOARD_KBEN 0xF4
128 #define KEYBOARD_CMDECHO_ACK 0xFA
129
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
148
149 //
150 // Other functions that are used among .c files
151 //
152 EFI_STATUS
153 KeyboardRead (
154 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
155 OUT UINT8 *Data
156 )
157 /*++
158
159 Routine Description:
160
161 GC_TODO: Add function description
162
163 Arguments:
164
165 ConsoleIn - GC_TODO: add argument description
166 Data - GC_TODO: add argument description
167
168 Returns:
169
170 GC_TODO: add return values
171
172 --*/
173 ;
174
175 EFI_STATUS
176 KeyGetchar (
177 IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
178 )
179 /*++
180
181 Routine Description:
182
183 GC_TODO: Add function description
184
185 Arguments:
186
187 ConsoleIn - GC_TODO: add argument description
188
189 Returns:
190
191 GC_TODO: add return values
192
193 --*/
194 ;
195
196 EFI_STATUS
197 InitKeyboard (
198 IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
199 IN BOOLEAN ExtendedVerification
200 )
201 /*++
202
203 Routine Description:
204
205 GC_TODO: Add function description
206
207 Arguments:
208
209 ConsoleIn - GC_TODO: add argument description
210 ExtendedVerification - GC_TODO: add argument description
211
212 Returns:
213
214 GC_TODO: add return values
215
216 --*/
217 ;
218
219 EFI_STATUS
220 DisableKeyboard (
221 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
222 )
223 /*++
224
225 Routine Description:
226
227 GC_TODO: Add function description
228
229 Arguments:
230
231 ConsoleIn - GC_TODO: add argument description
232
233 Returns:
234
235 GC_TODO: add return values
236
237 --*/
238 ;
239
240 VOID
241 EFIAPI
242 KeyboardTimerHandler (
243 IN EFI_EVENT Event,
244 IN VOID *Context
245 )
246 /*++
247
248 Routine Description:
249
250 GC_TODO: Add function description
251
252 Arguments:
253
254 Event - GC_TODO: add argument description
255 Context - GC_TODO: add argument description
256
257 Returns:
258
259 GC_TODO: add return values
260
261 --*/
262 ;
263
264 EFI_STATUS
265 EFIAPI
266 KeyboardEfiReset (
267 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
268 IN BOOLEAN ExtendedVerification
269 )
270 /*++
271
272 Routine Description:
273
274 GC_TODO: Add function description
275
276 Arguments:
277
278 This - GC_TODO: add argument description
279 ExtendedVerification - GC_TODO: add argument description
280
281 Returns:
282
283 GC_TODO: add return values
284
285 --*/
286 ;
287
288 EFI_STATUS
289 EFIAPI
290 KeyboardReadKeyStroke (
291 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
292 OUT EFI_INPUT_KEY *Key
293 )
294 /*++
295
296 Routine Description:
297
298 GC_TODO: Add function description
299
300 Arguments:
301
302 This - GC_TODO: add argument description
303 Key - GC_TODO: add argument description
304
305 Returns:
306
307 GC_TODO: add return values
308
309 --*/
310 ;
311
312 VOID
313 EFIAPI
314 KeyboardWaitForKey (
315 IN EFI_EVENT Event,
316 IN VOID *Context
317 )
318 /*++
319
320 Routine Description:
321
322 GC_TODO: Add function description
323
324 Arguments:
325
326 Event - GC_TODO: add argument description
327 Context - GC_TODO: add argument description
328
329 Returns:
330
331 GC_TODO: add return values
332
333 --*/
334 ;
335
336 UINT8
337 KeyReadStatusRegister (
338 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
339 )
340 /*++
341
342 Routine Description:
343
344 GC_TODO: Add function description
345
346 Arguments:
347
348 ConsoleIn - GC_TODO: add argument description
349
350 Returns:
351
352 GC_TODO: add return values
353
354 --*/
355 ;
356
357 /**
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.
361
362 @param[in] BiosKeyboardPrivate Keyboard Private Data Structure
363
364 @retval TRUE Keyboard in System.
365 @retval FALSE Keyboard not in System.
366 **/
367 BOOLEAN
368 EFIAPI
369 CheckKeyboardConnect (
370 IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
371 )
372 ;
373 #endif