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