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