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