]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h
Add new API GetTimeInNanoSecond() to TimerLib to convert elapsed ticks to time in...
[mirror_edk2.git] / IntelFrameworkModulePkg / Csm / BiosThunk / KeyboardDxe / BiosKeyboard.h
CommitLineData
bcecde14 1/** @file\r
2\r
3Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
4\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions\r
7of the BSD License which accompanies this distribution. The\r
8full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _BIOS_KEYBOARD_H_\r
17#define _BIOS_KEYBOARD_H_\r
18\r
19\r
20#include <FrameworkDxe.h>\r
21\r
22#include <Guid/StatusCodeDataTypeId.h>\r
23#include <Protocol/SimpleTextIn.h>\r
24#include <Protocol/SimpleTextInEx.h>\r
25#include <Protocol/LegacyBios.h>\r
26#include <Protocol/IsaIo.h>\r
27#include <Protocol/DevicePath.h>\r
28#include <Protocol/Ps2Policy.h>\r
29\r
30#include <Library/DebugLib.h>\r
31#include <Library/UefiLib.h>\r
32#include <Library/BaseMemoryLib.h>\r
33#include <Library/ReportStatusCodeLib.h>\r
34#include <Library/UefiDriverEntryPoint.h>\r
35#include <Library/UefiBootServicesTableLib.h>\r
36#include <Library/MemoryAllocationLib.h>\r
37#include <Library/BaseLib.h>\r
38\r
39//\r
40// Driver Binding Externs\r
41//\r
42extern EFI_DRIVER_BINDING_PROTOCOL gBiosKeyboardDriverBinding;\r
43extern EFI_COMPONENT_NAME_PROTOCOL gBiosKeyboardComponentName;\r
44extern EFI_COMPONENT_NAME2_PROTOCOL gBiosKeyboardComponentName2;\r
45\r
46\r
47#include <IndustryStandard/Pci.h>\r
48\r
49//\r
50// BISO Keyboard Defines\r
51//\r
52#define CHAR_SCANCODE 0xe0\r
53#define CHAR_ESC 0x1b\r
54\r
55#define KEYBOARD_8042_DATA_REGISTER 0x60\r
56#define KEYBOARD_8042_STATUS_REGISTER 0x64\r
57#define KEYBOARD_8042_COMMAND_REGISTER 0x64\r
58\r
59#define KEYBOARD_TIMEOUT 65536 // 0.07s\r
60#define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s\r
61#define KEYBOARD_BAT_TIMEOUT 4000000 // 4s\r
62#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s\r
63// KEYBOARD COMMAND BYTE -- read by writing command KBC_CMDREG_VIA64_CMDBYTE_R to 64H, then read from 60H\r
64// write by wrting command KBC_CMDREG_VIA64_CMDBYTE_W to 64H, then write to 60H\r
65// 7: Reserved\r
66// 6: PC/XT translation mode convert\r
67// 5: Disable Auxiliary device interface\r
68// 4: Disable keyboard interface\r
69// 3: Reserved\r
70// 2: System Flag: selftest successful\r
71// 1: Enable Auxiliary device interrupt\r
72// 0: Enable Keyboard interrupt )\r
73//\r
74#define KB_CMMBYTE_KSCAN2UNI_COV (0x1 << 6)\r
75#define KB_CMMBYTE_DISABLE_AUX (0x1 << 5)\r
76#define KB_CMMBYTE_DISABLE_KB (0x1 << 4)\r
77#define KB_CMMBYTE_SLFTEST_SUCC (0x1 << 2)\r
78#define KB_CMMBYTE_ENABLE_AUXINT (0x1 << 1)\r
79#define KB_CMMBYTE_ENABLE_KBINT (0x1 << 0)\r
80\r
81//\r
82// KEYBOARD CONTROLLER STATUS REGISTER - read from 64h\r
83// 7: Parity error\r
84// 6: General time out\r
85// 5: Output buffer holds data for AUX\r
86// 4: Keyboard is not locked\r
87// 3: Command written via 64h / Data written via 60h\r
88// 2: KBC self-test successful / Power-on reset\r
89// 1: Input buffer holds CPU data / empty\r
90// 0: Output buffer holds keyboard data / empty\r
91//\r
92#define KBC_STSREG_VIA64_PARE (0x1 << 7)\r
93#define KBC_STSREG_VIA64_TIM (0x1 << 6)\r
94#define KBC_STSREG_VIA64_AUXB (0x1 << 5)\r
95#define KBC_STSREG_VIA64_KEYL (0x1 << 4)\r
96#define KBC_STSREG_VIA64_C_D (0x1 << 3)\r
97#define KBC_STSREG_VIA64_SYSF (0x1 << 2)\r
98#define KBC_STSREG_VIA64_INPB (0x1 << 1)\r
99#define KBC_STSREG_VIA64_OUTB (0x1 << 0)\r
100\r
101//\r
102// COMMANDs of KEYBOARD CONTROLLER COMMAND REGISTER - write to 64h\r
103//\r
104#define KBC_CMDREG_VIA64_CMDBYTE_R 0x20\r
105#define KBC_CMDREG_VIA64_CMDBYTE_W 0x60\r
106#define KBC_CMDREG_VIA64_AUX_DISABLE 0xA7\r
107#define KBC_CMDREG_VIA64_AUX_ENABLE 0xA8\r
108#define KBC_CMDREG_VIA64_KBC_SLFTEST 0xAA\r
109#define KBC_CMDREG_VIA64_KB_CKECK 0xAB\r
110#define KBC_CMDREG_VIA64_KB_DISABLE 0xAD\r
111#define KBC_CMDREG_VIA64_KB_ENABLE 0xAE\r
112#define KBC_CMDREG_VIA64_INTP_LOW_R 0xC0\r
113#define KBC_CMDREG_VIA64_INTP_HIGH_R 0xC2\r
114#define KBC_CMDREG_VIA64_OUTP_R 0xD0\r
115#define KBC_CMDREG_VIA64_OUTP_W 0xD1\r
116#define KBC_CMDREG_VIA64_OUTB_KB_W 0xD2\r
117#define KBC_CMDREG_VIA64_OUTB_AUX_W 0xD3\r
118#define KBC_CMDREG_VIA64_AUX_W 0xD4\r
119\r
120//\r
121// echos of KEYBOARD CONTROLLER COMMAND - read from 60h\r
122//\r
123#define KBC_CMDECHO_KBCSLFTEST_OK 0x55\r
124#define KBC_CMDECHO_KBCHECK_OK 0x00\r
125#define KBC_CMDECHO_ACK 0xFA\r
126#define KBC_CMDECHO_BATTEST_OK 0xAA\r
127#define KBC_CMDECHO_BATTEST_FAILE 0xFC\r
128\r
129//\r
130// OUTPUT PORT COMMANDs - write port by writing KBC_CMDREG_VIA64_OUTP_W via 64H, then write the command to 60H\r
131// drive data and clock of KB to high for at least 500us for BAT needs\r
132//\r
133#define KBC_OUTPORT_DCHIGH_BAT 0xC0\r
134//\r
135// scan code set type\r
136//\r
137#define KBC_INPBUF_VIA60_SCODESET1 0x01\r
138#define KBC_INPBUF_VIA60_SCODESET2 0x02\r
139#define KBC_INPBUF_VIA60_SCODESET3 0x03\r
140\r
141//\r
142// COMMANDs written to INPUT BUFFER - write to 60h\r
143//\r
144#define KBC_INPBUF_VIA60_KBECHO 0xEE\r
145#define KBC_INPBUF_VIA60_KBSCODE 0xF0\r
146#define KBC_INPBUF_VIA60_KBTYPE 0xF2\r
147#define KBC_INPBUF_VIA60_KBDELAY 0xF3\r
148#define KBC_INPBUF_VIA60_KBEN 0xF4\r
149#define KBC_INPBUF_VIA60_KBSTDDIS 0xF5\r
150#define KBC_INPBUF_VIA60_KBSTDEN 0xF6\r
151#define KBC_INPBUF_VIA60_KBRESEND 0xFE\r
152#define KBC_INPBUF_VIA60_KBRESET 0xFF\r
153\r
154//\r
155// 0040h:0017h - KEYBOARD - STATUS FLAGS 1\r
156// 7 INSert active\r
157// 6 Caps Lock active\r
158// 5 Num Lock active\r
159// 4 Scroll Lock active\r
160// 3 either Alt pressed\r
161// 2 either Ctrl pressed\r
162// 1 Left Shift pressed\r
163// 0 Right Shift pressed\r
164//\r
165// 0040h:0018h - KEYBOARD - STATUS FLAGS 2\r
166// 7: insert key is depressed\r
167// 6: caps-lock key is depressed (does not work well)\r
168// 5: num-lock key is depressed (does not work well)\r
169// 4: scroll lock key is depressed (does not work well)\r
170// 3: suspend key has been toggled (does not work well)\r
171// 2: system key is pressed and held (does not work well)\r
172// 1: left ALT key is pressed\r
173// 0: left CTRL key is pressed\r
174//\r
175#define KB_INSERT_BIT (0x1 << 7)\r
176#define KB_CAPS_LOCK_BIT (0x1 << 6)\r
177#define KB_NUM_LOCK_BIT (0x1 << 5)\r
178#define KB_SCROLL_LOCK_BIT (0x1 << 4)\r
179#define KB_ALT_PRESSED (0x1 << 3)\r
180#define KB_CTRL_PRESSED (0x1 << 2)\r
181#define KB_LEFT_SHIFT_PRESSED (0x1 << 1)\r
182#define KB_RIGHT_SHIFT_PRESSED (0x1 << 0)\r
183\r
184#define KB_SUSPEND_PRESSED (0x1 << 3)\r
185#define KB_SYSREQ_PRESSED (0x1 << 2)\r
186#define KB_LEFT_ALT_PRESSED (0x1 << 1)\r
187#define KB_LEFT_CTRL_PRESSED (0x1 << 0)\r
188\r
189//\r
190// BIOS Keyboard Device Structure\r
191//\r
192#define BIOS_KEYBOARD_DEV_SIGNATURE SIGNATURE_32 ('B', 'K', 'B', 'D')\r
193#define BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('c', 'b', 'k', 'h')\r
194\r
195typedef struct _BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY {\r
196 UINTN Signature;\r
197 EFI_HANDLE NotifyHandle;\r
198 EFI_KEY_DATA KeyData;\r
199 EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;\r
200 LIST_ENTRY NotifyEntry;\r
201} BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY;\r
202\r
203#define QUEUE_MAX_COUNT 32\r
204typedef struct {\r
205 UINTN Front;\r
206 UINTN Rear;\r
207 EFI_KEY_DATA Buffer[QUEUE_MAX_COUNT];\r
208} SIMPLE_QUEUE;\r
209\r
210typedef struct {\r
211 UINTN Signature;\r
212 EFI_HANDLE Handle;\r
213 EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;\r
214 EFI_ISA_IO_PROTOCOL *IsaIo;\r
215 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;\r
216 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInputEx;\r
217 UINT16 DataRegisterAddress;\r
218 UINT16 StatusRegisterAddress;\r
219 UINT16 CommandRegisterAddress;\r
220 BOOLEAN ExtendedKeyboard;\r
221 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
222 \r
223 //\r
224 // Buffer storing EFI_KEY_DATA\r
225 //\r
226 SIMPLE_QUEUE Queue;\r
227\r
228 //\r
229 // Notification Function List\r
230 //\r
231 LIST_ENTRY NotifyList;\r
232 EFI_EVENT TimerEvent;\r
233 \r
234} BIOS_KEYBOARD_DEV;\r
235\r
236#define BIOS_KEYBOARD_DEV_FROM_THIS(a) CR (a, BIOS_KEYBOARD_DEV, SimpleTextIn, BIOS_KEYBOARD_DEV_SIGNATURE)\r
237#define TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS(a) \\r
238 CR (a, \\r
239 BIOS_KEYBOARD_DEV, \\r
240 SimpleTextInputEx, \\r
241 BIOS_KEYBOARD_DEV_SIGNATURE \\r
242 )\r
243\r
244//\r
245// Global Variables\r
246//\r
247extern EFI_DRIVER_BINDING_PROTOCOL gBiosKeyboardDriverBinding;\r
248\r
249//\r
250// Driver Binding Protocol functions\r
251//\r
252\r
253/**\r
254 Check whether the driver supports this device.\r
255\r
256 @param This The Udriver binding protocol.\r
257 @param Controller The controller handle to check.\r
258 @param RemainingDevicePath The remaining device path.\r
259\r
260 @retval EFI_SUCCESS The driver supports this controller.\r
261 @retval other This device isn't supported.\r
262\r
263**/\r
264EFI_STATUS\r
265EFIAPI\r
266BiosKeyboardDriverBindingSupported (\r
267 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
268 IN EFI_HANDLE Controller,\r
269 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
270 );\r
271\r
272/**\r
273 Starts the device with this driver.\r
274\r
275 @param This The driver binding instance.\r
276 @param Controller Handle of device to bind driver to.\r
277 @param RemainingDevicePath Optional parameter use to pick a specific child\r
278 device to start.\r
279\r
280 @retval EFI_SUCCESS The controller is controlled by the driver.\r
281 @retval Other This controller cannot be started.\r
282\r
283**/\r
284EFI_STATUS\r
285EFIAPI\r
286BiosKeyboardDriverBindingStart (\r
287 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
288 IN EFI_HANDLE Controller,\r
289 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
290 );\r
291\r
292/**\r
293 Stop the device handled by this driver.\r
294\r
295 @param This The driver binding protocol.\r
296 @param Controller The controller to release.\r
297 @param NumberOfChildren The number of handles in ChildHandleBuffer.\r
298 @param ChildHandleBuffer The array of child handle.\r
299\r
300 @retval EFI_SUCCESS The device was stopped.\r
301 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
302 @retval Others Fail to uninstall protocols attached on the device.\r
303\r
304**/\r
305EFI_STATUS\r
306EFIAPI\r
307BiosKeyboardDriverBindingStop (\r
308 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
309 IN EFI_HANDLE Controller,\r
310 IN UINTN NumberOfChildren,\r
311 IN EFI_HANDLE *ChildHandleBuffer\r
312 );\r
313\r
314/**\r
315 Retrieves a Unicode string that is the user readable name of the driver.\r
316\r
317 This function retrieves the user readable name of a driver in the form of a\r
318 Unicode string. If the driver specified by This has a user readable name in\r
319 the language specified by Language, then a pointer to the driver name is\r
320 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
321 by This does not support the language specified by Language,\r
322 then EFI_UNSUPPORTED is returned.\r
323\r
324 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
325 EFI_COMPONENT_NAME_PROTOCOL instance.\r
326\r
327 @param Language[in] A pointer to a Null-terminated ASCII string\r
328 array indicating the language. This is the\r
329 language of the driver name that the caller is\r
330 requesting, and it must match one of the\r
331 languages specified in SupportedLanguages. The\r
332 number of languages supported by a driver is up\r
333 to the driver writer. Language is specified\r
334 in RFC 4646 or ISO 639-2 language code format.\r
335\r
336 @param DriverName[out] A pointer to the Unicode string to return.\r
337 This Unicode string is the name of the\r
338 driver specified by This in the language\r
339 specified by Language.\r
340\r
341 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
342 This and the language specified by Language was\r
343 returned in DriverName.\r
344\r
345 @retval EFI_INVALID_PARAMETER Language is NULL.\r
346\r
347 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
348\r
349 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
350 the language specified by Language.\r
351\r
352**/\r
353EFI_STATUS\r
354EFIAPI\r
355BiosKeyboardComponentNameGetDriverName (\r
356 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
357 IN CHAR8 *Language,\r
358 OUT CHAR16 **DriverName\r
359 );\r
360\r
361\r
362/**\r
363 Retrieves a Unicode string that is the user readable name of the controller\r
364 that is being managed by a driver.\r
365\r
366 This function retrieves the user readable name of the controller specified by\r
367 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
368 driver specified by This has a user readable name in the language specified by\r
369 Language, then a pointer to the controller name is returned in ControllerName,\r
370 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
371 managing the controller specified by ControllerHandle and ChildHandle,\r
372 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
373 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
374\r
375 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
376 EFI_COMPONENT_NAME_PROTOCOL instance.\r
377\r
378 @param ControllerHandle[in] The handle of a controller that the driver\r
379 specified by This is managing. This handle\r
380 specifies the controller whose name is to be\r
381 returned.\r
382\r
383 @param ChildHandle[in] The handle of the child controller to retrieve\r
384 the name of. This is an optional parameter that\r
385 may be NULL. It will be NULL for device\r
386 drivers. It will also be NULL for a bus drivers\r
387 that wish to retrieve the name of the bus\r
388 controller. It will not be NULL for a bus\r
389 driver that wishes to retrieve the name of a\r
390 child controller.\r
391\r
392 @param Language[in] A pointer to a Null-terminated ASCII string\r
393 array indicating the language. This is the\r
394 language of the driver name that the caller is\r
395 requesting, and it must match one of the\r
396 languages specified in SupportedLanguages. The\r
397 number of languages supported by a driver is up\r
398 to the driver writer. Language is specified in\r
399 RFC 4646 or ISO 639-2 language code format.\r
400\r
401 @param ControllerName[out] A pointer to the Unicode string to return.\r
402 This Unicode string is the name of the\r
403 controller specified by ControllerHandle and\r
404 ChildHandle in the language specified by\r
405 Language from the point of view of the driver\r
406 specified by This.\r
407\r
408 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
409 the language specified by Language for the\r
410 driver specified by This was returned in\r
411 DriverName.\r
412\r
0c9f676d 413 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
bcecde14 414\r
415 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
416 EFI_HANDLE.\r
417\r
418 @retval EFI_INVALID_PARAMETER Language is NULL.\r
419\r
420 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
421\r
422 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
423 managing the controller specified by\r
424 ControllerHandle and ChildHandle.\r
425\r
426 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
427 the language specified by Language.\r
428\r
429**/\r
430EFI_STATUS\r
431EFIAPI\r
432BiosKeyboardComponentNameGetControllerName (\r
433 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
434 IN EFI_HANDLE ControllerHandle,\r
435 IN EFI_HANDLE ChildHandle OPTIONAL,\r
436 IN CHAR8 *Language,\r
437 OUT CHAR16 **ControllerName\r
438 );\r
439\r
440\r
441//\r
442// Simple Text Input Protocol functions\r
443//\r
444/**\r
445 Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE) then do some extra keyboard validations.\r
446\r
447 @param This Pointer of simple text Protocol.\r
448 @param ExtendedVerification Whether perform the extra validation of keyboard. True: perform; FALSE: skip.\r
449\r
450 @retval EFI_SUCCESS The command byte is written successfully.\r
451 @retval EFI_DEVICE_ERROR Errors occurred during reseting keyboard.\r
452\r
453**/\r
454EFI_STATUS\r
455EFIAPI\r
456BiosKeyboardReset (\r
457 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
458 IN BOOLEAN ExtendedVerification\r
459 );\r
460\r
461/**\r
462 Read out the scan code of the key that has just been stroked.\r
463\r
464 @param This Pointer of simple text Protocol.\r
465 @param Key Pointer for store the key that read out.\r
466\r
467 @retval EFI_SUCCESS The key is read out successfully.\r
468 @retval other The key reading failed.\r
469\r
470**/\r
471EFI_STATUS\r
472EFIAPI\r
473BiosKeyboardReadKeyStroke (\r
474 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
475 OUT EFI_INPUT_KEY *Key\r
476 );\r
477\r
478//\r
479// Private worker functions\r
480//\r
481/**\r
482 Waiting on the keyboard event, if there's any key pressed by the user, signal the event\r
483\r
484 @param Event The event that be siganlled when any key has been stroked.\r
485 @param Context Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_PROTOCOL.\r
486\r
487**/\r
488VOID\r
489EFIAPI\r
490BiosKeyboardWaitForKey (\r
491 IN EFI_EVENT Event,\r
492 IN VOID *Context\r
493 );\r
494\r
495/**\r
496 Check key buffer to get the key stroke status.\r
497\r
498 @param This Pointer of the protocol EFI_SIMPLE_TEXT_IN_PROTOCOL.\r
499 \r
500 @retval EFI_SUCCESS A key is being pressed now.\r
501 @retval Other No key is now pressed.\r
502\r
503**/\r
504EFI_STATUS\r
505EFIAPI\r
506BiosKeyboardCheckForKey (\r
507 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
508 );\r
509\r
510/**\r
511 Convert unicode combined with scan code of key to the counterpart of EFIScancode of it.\r
512\r
513 @param KeyChar Unicode of key.\r
514 @param ScanCode Scan code of key.\r
515\r
516 @return The value of EFI Scancode for the key. \r
517 @retval SCAN_NULL No corresponding value in the EFI convert table is found for the key.\r
518\r
519**/\r
520UINT16\r
521ConvertToEFIScanCode (\r
522 IN CHAR16 KeyChar,\r
523 IN UINT16 ScanCode\r
524 );\r
525\r
526/**\r
527 Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command\r
528 If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device\r
529 should not be in system. \r
530\r
531 @param BiosKeyboardPrivate Keyboard Private Data Struture\r
532\r
533 @retval TRUE Keyboard in System.\r
534 @retval FALSE Keyboard not in System.\r
535\r
536**/\r
537BOOLEAN\r
538CheckKeyboardConnect (\r
539 IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate\r
540 );\r
541\r
542/**\r
543 Timer event handler: read a series of key stroke from 8042\r
544 and put them into memory key buffer. \r
545 It is registered as running under TPL_NOTIFY\r
546 \r
547 @param Event The timer event\r
548 @param Context A BIOS_KEYBOARD_DEV pointer\r
549\r
550**/\r
551VOID\r
552EFIAPI\r
553BiosKeyboardTimerHandler (\r
554 IN EFI_EVENT Event,\r
555 IN VOID *Context\r
556 );\r
557\r
558/**\r
559 Reset the input device and optionaly run diagnostics\r
560 \r
561 @param This Protocol instance pointer.\r
562 @param ExtendedVerification Driver may perform diagnostics on reset.\r
563\r
564 @retval EFI_SUCCESS The device was reset.\r
565 @retval EFI_DEVICE_ERROR The device is not functioning properly and could \r
566 not be reset.\r
567\r
568**/\r
569EFI_STATUS\r
570EFIAPI\r
571BiosKeyboardResetEx (\r
572 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
573 IN BOOLEAN ExtendedVerification\r
574 );\r
575\r
576/**\r
577 Reads the next keystroke from the input device. The WaitForKey Event can \r
578 be used to test for existance of a keystroke via WaitForEvent () call.\r
579\r
580 @param This Protocol instance pointer.\r
581 @param KeyData A pointer to a buffer that is filled in with the keystroke \r
582 state data for the key that was pressed.\r
583 \r
584 @retval EFI_SUCCESS The keystroke information was returned.\r
585 @retval EFI_NOT_READY There was no keystroke data availiable.\r
586 @retval EFI_DEVICE_ERROR The keystroke information was not returned due to \r
587 hardware errors.\r
588 @retval EFI_INVALID_PARAMETER KeyData is NULL. \r
589 \r
590**/\r
591EFI_STATUS\r
592EFIAPI\r
593BiosKeyboardReadKeyStrokeEx (\r
594 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
595 OUT EFI_KEY_DATA *KeyData\r
596 );\r
597\r
598/**\r
599 Set certain state for the input device.\r
600\r
601 @param This Protocol instance pointer.\r
602 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the \r
603 state for the input device.\r
604\r
605 @retval EFI_SUCCESS The device state was set successfully.\r
606 @retval EFI_DEVICE_ERROR The device is not functioning correctly and could \r
607 not have the setting adjusted.\r
608 @retval EFI_UNSUPPORTED The device does not have the ability to set its state.\r
609 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL. \r
610\r
611**/ \r
612EFI_STATUS\r
613EFIAPI\r
614BiosKeyboardSetState (\r
615 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
616 IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r
617 );\r
618\r
619/**\r
620 Register a notification function for a particular keystroke for the input device.\r
621\r
622 @param This Protocol instance pointer.\r
623 @param KeyData A pointer to a buffer that is filled in with the keystroke \r
624 information data for the key that was pressed.\r
625 @param KeyNotificationFunction Points to the function to be called when the key \r
626 sequence is typed specified by KeyData. \r
627 @param NotifyHandle Points to the unique handle assigned to the registered notification. \r
628\r
629 \r
630 @retval EFI_SUCCESS The notification function was registered successfully.\r
631 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.\r
632 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.\r
633 \r
634**/ \r
635EFI_STATUS\r
636EFIAPI\r
637BiosKeyboardRegisterKeyNotify (\r
638 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
639 IN EFI_KEY_DATA *KeyData,\r
640 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r
641 OUT EFI_HANDLE *NotifyHandle\r
642 );\r
643\r
644/**\r
645 Remove a registered notification function from a particular keystroke.\r
646\r
647 @param This Protocol instance pointer. \r
648 @param NotificationHandle The handle of the notification function being unregistered.\r
649 \r
650 @retval EFI_SUCCESS The notification function was unregistered successfully.\r
651 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.\r
652 \r
653**/ \r
654EFI_STATUS\r
655EFIAPI\r
656BiosKeyboardUnregisterKeyNotify (\r
657 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
658 IN EFI_HANDLE NotificationHandle\r
659 );\r
660\r
661/**\r
662 Wait for a specific value to be presented in\r
663 Data register of Keyboard Controller by keyboard and then read it,\r
664 used in keyboard commands ack\r
665\r
666 @param BiosKeyboardPrivate Keyboard instance pointer.\r
667 @param Value The value to be waited for\r
668 @param WaitForValueTimeOut The limit of microseconds for timeout\r
669\r
670 @retval EFI_SUCCESS The command byte is written successfully.\r
671 @retval EFI_TIMEOUT Timeout occurred during writing.\r
672\r
673**/\r
674EFI_STATUS\r
675KeyboardWaitForValue (\r
676 IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate,\r
677 IN UINT8 Value,\r
678 IN UINTN WaitForValueTimeOut\r
679 );\r
680\r
681/**\r
682 Write data byte to input buffer or input/output ports of Keyboard Controller with delay and waiting for buffer-empty state.\r
683\r
684 @param BiosKeyboardPrivate Keyboard instance pointer.\r
685 @param Data Data byte to write.\r
686\r
687 @retval EFI_SUCCESS The data byte is written successfully.\r
688 @retval EFI_TIMEOUT Timeout occurred during writing.\r
689\r
690**/\r
691EFI_STATUS\r
692KeyboardWrite (\r
693 IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate,\r
694 IN UINT8 Data\r
695 );\r
696\r
697/**\r
698 Free keyboard notify list.\r
699\r
700 @param ListHead The list head\r
701\r
702 @retval EFI_SUCCESS Free the notify list successfully\r
703 @retval EFI_INVALID_PARAMETER ListHead is invalid.\r
704\r
705**/\r
706EFI_STATUS\r
707BiosKeyboardFreeNotifyList (\r
708 IN OUT LIST_ENTRY *ListHead\r
709 ); \r
710\r
711/**\r
712 Check if key is registered.\r
713\r
714 @param RegsiteredData A pointer to a buffer that is filled in with the keystroke \r
715 state data for the key that was registered.\r
716 @param InputData A pointer to a buffer that is filled in with the keystroke \r
717 state data for the key that was pressed.\r
718\r
719 @retval TRUE Key be pressed matches a registered key.\r
720 @retval FLASE Match failed. \r
721 \r
722**/\r
723BOOLEAN\r
724IsKeyRegistered (\r
725 IN EFI_KEY_DATA *RegsiteredData,\r
726 IN EFI_KEY_DATA *InputData\r
727 );\r
728\r
729/**\r
730 Waiting on the keyboard event, if there's any key pressed by the user, signal the event\r
731\r
732 @param Event The event that be siganlled when any key has been stroked.\r
733 @param Context Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.\r
734 \r
735**/\r
736VOID\r
737EFIAPI\r
738BiosKeyboardWaitForKeyEx (\r
739 IN EFI_EVENT Event,\r
740 IN VOID *Context\r
741 );\r
742\r
743#endif\r
744\r