]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h
IntelFrameworkModule/ThunkKb: ReadKeyStrokeEx always return key state
[mirror_edk2.git] / IntelFrameworkModulePkg / Csm / BiosThunk / KeyboardDxe / BiosKeyboard.h
1 /** @file
2
3 Copyright (c) 2006 - 2018, 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 EFI_KEY_STATE KeyState;
225 //
226 // Buffer storing EFI_KEY_DATA
227 //
228 SIMPLE_QUEUE Queue;
229 SIMPLE_QUEUE QueueForNotify;
230
231 //
232 // Notification Function List
233 //
234 LIST_ENTRY NotifyList;
235 EFI_EVENT KeyNotifyProcessEvent;
236 EFI_EVENT TimerEvent;
237
238 } BIOS_KEYBOARD_DEV;
239
240 #define BIOS_KEYBOARD_DEV_FROM_THIS(a) CR (a, BIOS_KEYBOARD_DEV, SimpleTextIn, BIOS_KEYBOARD_DEV_SIGNATURE)
241 #define TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS(a) \
242 CR (a, \
243 BIOS_KEYBOARD_DEV, \
244 SimpleTextInputEx, \
245 BIOS_KEYBOARD_DEV_SIGNATURE \
246 )
247
248 //
249 // Global Variables
250 //
251 extern EFI_DRIVER_BINDING_PROTOCOL gBiosKeyboardDriverBinding;
252
253 //
254 // Driver Binding Protocol functions
255 //
256
257 /**
258 Check whether the driver supports this device.
259
260 @param This The Udriver binding protocol.
261 @param Controller The controller handle to check.
262 @param RemainingDevicePath The remaining device path.
263
264 @retval EFI_SUCCESS The driver supports this controller.
265 @retval other This device isn't supported.
266
267 **/
268 EFI_STATUS
269 EFIAPI
270 BiosKeyboardDriverBindingSupported (
271 IN EFI_DRIVER_BINDING_PROTOCOL *This,
272 IN EFI_HANDLE Controller,
273 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
274 );
275
276 /**
277 Starts the device with this driver.
278
279 @param This The driver binding instance.
280 @param Controller Handle of device to bind driver to.
281 @param RemainingDevicePath Optional parameter use to pick a specific child
282 device to start.
283
284 @retval EFI_SUCCESS The controller is controlled by the driver.
285 @retval Other This controller cannot be started.
286
287 **/
288 EFI_STATUS
289 EFIAPI
290 BiosKeyboardDriverBindingStart (
291 IN EFI_DRIVER_BINDING_PROTOCOL *This,
292 IN EFI_HANDLE Controller,
293 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
294 );
295
296 /**
297 Stop the device handled by this driver.
298
299 @param This The driver binding protocol.
300 @param Controller The controller to release.
301 @param NumberOfChildren The number of handles in ChildHandleBuffer.
302 @param ChildHandleBuffer The array of child handle.
303
304 @retval EFI_SUCCESS The device was stopped.
305 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
306 @retval Others Fail to uninstall protocols attached on the device.
307
308 **/
309 EFI_STATUS
310 EFIAPI
311 BiosKeyboardDriverBindingStop (
312 IN EFI_DRIVER_BINDING_PROTOCOL *This,
313 IN EFI_HANDLE Controller,
314 IN UINTN NumberOfChildren,
315 IN EFI_HANDLE *ChildHandleBuffer
316 );
317
318 /**
319 Retrieves a Unicode string that is the user readable name of the driver.
320
321 This function retrieves the user readable name of a driver in the form of a
322 Unicode string. If the driver specified by This has a user readable name in
323 the language specified by Language, then a pointer to the driver name is
324 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
325 by This does not support the language specified by Language,
326 then EFI_UNSUPPORTED is returned.
327
328 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
329 EFI_COMPONENT_NAME_PROTOCOL instance.
330
331 @param Language[in] A pointer to a Null-terminated ASCII string
332 array indicating the language. This is the
333 language of the driver name that the caller is
334 requesting, and it must match one of the
335 languages specified in SupportedLanguages. The
336 number of languages supported by a driver is up
337 to the driver writer. Language is specified
338 in RFC 4646 or ISO 639-2 language code format.
339
340 @param DriverName[out] A pointer to the Unicode string to return.
341 This Unicode string is the name of the
342 driver specified by This in the language
343 specified by Language.
344
345 @retval EFI_SUCCESS The Unicode string for the Driver specified by
346 This and the language specified by Language was
347 returned in DriverName.
348
349 @retval EFI_INVALID_PARAMETER Language is NULL.
350
351 @retval EFI_INVALID_PARAMETER DriverName is NULL.
352
353 @retval EFI_UNSUPPORTED The driver specified by This does not support
354 the language specified by Language.
355
356 **/
357 EFI_STATUS
358 EFIAPI
359 BiosKeyboardComponentNameGetDriverName (
360 IN EFI_COMPONENT_NAME_PROTOCOL *This,
361 IN CHAR8 *Language,
362 OUT CHAR16 **DriverName
363 );
364
365
366 /**
367 Retrieves a Unicode string that is the user readable name of the controller
368 that is being managed by a driver.
369
370 This function retrieves the user readable name of the controller specified by
371 ControllerHandle and ChildHandle in the form of a Unicode string. If the
372 driver specified by This has a user readable name in the language specified by
373 Language, then a pointer to the controller name is returned in ControllerName,
374 and EFI_SUCCESS is returned. If the driver specified by This is not currently
375 managing the controller specified by ControllerHandle and ChildHandle,
376 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
377 support the language specified by Language, then EFI_UNSUPPORTED is returned.
378
379 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
380 EFI_COMPONENT_NAME_PROTOCOL instance.
381
382 @param ControllerHandle[in] The handle of a controller that the driver
383 specified by This is managing. This handle
384 specifies the controller whose name is to be
385 returned.
386
387 @param ChildHandle[in] The handle of the child controller to retrieve
388 the name of. This is an optional parameter that
389 may be NULL. It will be NULL for device
390 drivers. It will also be NULL for a bus drivers
391 that wish to retrieve the name of the bus
392 controller. It will not be NULL for a bus
393 driver that wishes to retrieve the name of a
394 child controller.
395
396 @param Language[in] A pointer to a Null-terminated ASCII string
397 array indicating the language. This is the
398 language of the driver name that the caller is
399 requesting, and it must match one of the
400 languages specified in SupportedLanguages. The
401 number of languages supported by a driver is up
402 to the driver writer. Language is specified in
403 RFC 4646 or ISO 639-2 language code format.
404
405 @param ControllerName[out] A pointer to the Unicode string to return.
406 This Unicode string is the name of the
407 controller specified by ControllerHandle and
408 ChildHandle in the language specified by
409 Language from the point of view of the driver
410 specified by This.
411
412 @retval EFI_SUCCESS The Unicode string for the user readable name in
413 the language specified by Language for the
414 driver specified by This was returned in
415 DriverName.
416
417 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
418
419 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
420 EFI_HANDLE.
421
422 @retval EFI_INVALID_PARAMETER Language is NULL.
423
424 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
425
426 @retval EFI_UNSUPPORTED The driver specified by This is not currently
427 managing the controller specified by
428 ControllerHandle and ChildHandle.
429
430 @retval EFI_UNSUPPORTED The driver specified by This does not support
431 the language specified by Language.
432
433 **/
434 EFI_STATUS
435 EFIAPI
436 BiosKeyboardComponentNameGetControllerName (
437 IN EFI_COMPONENT_NAME_PROTOCOL *This,
438 IN EFI_HANDLE ControllerHandle,
439 IN EFI_HANDLE ChildHandle OPTIONAL,
440 IN CHAR8 *Language,
441 OUT CHAR16 **ControllerName
442 );
443
444
445 //
446 // Simple Text Input Protocol functions
447 //
448 /**
449 Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE) then do some extra keyboard validations.
450
451 @param This Pointer of simple text Protocol.
452 @param ExtendedVerification Whether perform the extra validation of keyboard. True: perform; FALSE: skip.
453
454 @retval EFI_SUCCESS The command byte is written successfully.
455 @retval EFI_DEVICE_ERROR Errors occurred during resetting keyboard.
456
457 **/
458 EFI_STATUS
459 EFIAPI
460 BiosKeyboardReset (
461 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
462 IN BOOLEAN ExtendedVerification
463 );
464
465 /**
466 Read out the scan code of the key that has just been stroked.
467
468 @param This Pointer of simple text Protocol.
469 @param Key Pointer for store the key that read out.
470
471 @retval EFI_SUCCESS The key is read out successfully.
472 @retval other The key reading failed.
473
474 **/
475 EFI_STATUS
476 EFIAPI
477 BiosKeyboardReadKeyStroke (
478 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
479 OUT EFI_INPUT_KEY *Key
480 );
481
482 //
483 // Private worker functions
484 //
485 /**
486 Waiting on the keyboard event, if there's any key pressed by the user, signal the event
487
488 @param Event The event that be siganlled when any key has been stroked.
489 @param Context Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_PROTOCOL.
490
491 **/
492 VOID
493 EFIAPI
494 BiosKeyboardWaitForKey (
495 IN EFI_EVENT Event,
496 IN VOID *Context
497 );
498
499 /**
500 Check key buffer to get the key stroke status.
501
502 @param This Pointer of the protocol EFI_SIMPLE_TEXT_IN_PROTOCOL.
503
504 @retval EFI_SUCCESS A key is being pressed now.
505 @retval Other No key is now pressed.
506
507 **/
508 EFI_STATUS
509 EFIAPI
510 BiosKeyboardCheckForKey (
511 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
512 );
513
514 /**
515 Convert unicode combined with scan code of key to the counterpart of EFIScancode of it.
516
517 @param KeyChar Unicode of key.
518 @param ScanCode Scan code of key.
519
520 @return The value of EFI Scancode for the key.
521 @retval SCAN_NULL No corresponding value in the EFI convert table is found for the key.
522
523 **/
524 UINT16
525 ConvertToEFIScanCode (
526 IN CHAR16 KeyChar,
527 IN UINT16 ScanCode
528 );
529
530 /**
531 Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
532 If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device
533 should not be in system.
534
535 @param BiosKeyboardPrivate Keyboard Private Data Struture
536
537 @retval TRUE Keyboard in System.
538 @retval FALSE Keyboard not in System.
539
540 **/
541 BOOLEAN
542 CheckKeyboardConnect (
543 IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate
544 );
545
546 /**
547 Timer event handler: read a series of key stroke from 8042
548 and put them into memory key buffer.
549 It is registered as running under TPL_NOTIFY
550
551 @param Event The timer event
552 @param Context A BIOS_KEYBOARD_DEV pointer
553
554 **/
555 VOID
556 EFIAPI
557 BiosKeyboardTimerHandler (
558 IN EFI_EVENT Event,
559 IN VOID *Context
560 );
561
562 /**
563 Process key notify.
564
565 @param Event Indicates the event that invoke this function.
566 @param Context Indicates the calling context.
567 **/
568 VOID
569 EFIAPI
570 KeyNotifyProcessHandler (
571 IN EFI_EVENT Event,
572 IN VOID *Context
573 );
574
575 /**
576 Reset the input device and optionaly run diagnostics
577
578 @param This Protocol instance pointer.
579 @param ExtendedVerification Driver may perform diagnostics on reset.
580
581 @retval EFI_SUCCESS The device was reset.
582 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
583 not be reset.
584
585 **/
586 EFI_STATUS
587 EFIAPI
588 BiosKeyboardResetEx (
589 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
590 IN BOOLEAN ExtendedVerification
591 );
592
593 /**
594 Reads the next keystroke from the input device. The WaitForKey Event can
595 be used to test for existance of a keystroke via WaitForEvent () call.
596
597 @param This Protocol instance pointer.
598 @param KeyData A pointer to a buffer that is filled in with the keystroke
599 state data for the key that was pressed.
600
601 @retval EFI_SUCCESS The keystroke information was returned.
602 @retval EFI_NOT_READY There was no keystroke data availiable.
603 @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
604 hardware errors.
605 @retval EFI_INVALID_PARAMETER KeyData is NULL.
606
607 **/
608 EFI_STATUS
609 EFIAPI
610 BiosKeyboardReadKeyStrokeEx (
611 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
612 OUT EFI_KEY_DATA *KeyData
613 );
614
615 /**
616 Set certain state for the input device.
617
618 @param This Protocol instance pointer.
619 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
620 state for the input device.
621
622 @retval EFI_SUCCESS The device state was set successfully.
623 @retval EFI_DEVICE_ERROR The device is not functioning correctly and could
624 not have the setting adjusted.
625 @retval EFI_UNSUPPORTED The device does not have the ability to set its state.
626 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
627
628 **/
629 EFI_STATUS
630 EFIAPI
631 BiosKeyboardSetState (
632 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
633 IN EFI_KEY_TOGGLE_STATE *KeyToggleState
634 );
635
636 /**
637 Register a notification function for a particular keystroke for the input device.
638
639 @param This Protocol instance pointer.
640 @param KeyData A pointer to a buffer that is filled in with the keystroke
641 information data for the key that was pressed. If KeyData.Key,
642 KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState
643 are 0, then any incomplete keystroke will trigger a notification of
644 the KeyNotificationFunction.
645 @param KeyNotificationFunction Points to the function to be called when the key
646 sequence is typed specified by KeyData. This notification function
647 should be called at <=TPL_CALLBACK.
648 @param NotifyHandle Points to the unique handle assigned to the registered notification.
649
650
651 @retval EFI_SUCCESS The notification function was registered successfully.
652 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.
653 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.
654
655 **/
656 EFI_STATUS
657 EFIAPI
658 BiosKeyboardRegisterKeyNotify (
659 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
660 IN EFI_KEY_DATA *KeyData,
661 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
662 OUT VOID **NotifyHandle
663 );
664
665 /**
666 Remove a registered notification function from a particular keystroke.
667
668 @param This Protocol instance pointer.
669 @param NotificationHandle The handle of the notification function being unregistered.
670
671 @retval EFI_SUCCESS The notification function was unregistered successfully.
672 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
673
674 **/
675 EFI_STATUS
676 EFIAPI
677 BiosKeyboardUnregisterKeyNotify (
678 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
679 IN VOID *NotificationHandle
680 );
681
682 /**
683 Wait for a specific value to be presented in
684 Data register of Keyboard Controller by keyboard and then read it,
685 used in keyboard commands ack
686
687 @param BiosKeyboardPrivate Keyboard instance pointer.
688 @param Value The value to be waited for
689 @param WaitForValueTimeOut The limit of microseconds for timeout
690
691 @retval EFI_SUCCESS The command byte is written successfully.
692 @retval EFI_TIMEOUT Timeout occurred during writing.
693
694 **/
695 EFI_STATUS
696 KeyboardWaitForValue (
697 IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate,
698 IN UINT8 Value,
699 IN UINTN WaitForValueTimeOut
700 );
701
702 /**
703 Write data byte to input buffer or input/output ports of Keyboard Controller with delay and waiting for buffer-empty state.
704
705 @param BiosKeyboardPrivate Keyboard instance pointer.
706 @param Data Data byte to write.
707
708 @retval EFI_SUCCESS The data byte is written successfully.
709 @retval EFI_TIMEOUT Timeout occurred during writing.
710
711 **/
712 EFI_STATUS
713 KeyboardWrite (
714 IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate,
715 IN UINT8 Data
716 );
717
718 /**
719 Free keyboard notify list.
720
721 @param ListHead The list head
722
723 @retval EFI_SUCCESS Free the notify list successfully
724 @retval EFI_INVALID_PARAMETER ListHead is invalid.
725
726 **/
727 EFI_STATUS
728 BiosKeyboardFreeNotifyList (
729 IN OUT LIST_ENTRY *ListHead
730 );
731
732 /**
733 Check if key is registered.
734
735 @param RegsiteredData A pointer to a buffer that is filled in with the keystroke
736 state data for the key that was registered.
737 @param InputData A pointer to a buffer that is filled in with the keystroke
738 state data for the key that was pressed.
739
740 @retval TRUE Key be pressed matches a registered key.
741 @retval FLASE Match failed.
742
743 **/
744 BOOLEAN
745 IsKeyRegistered (
746 IN EFI_KEY_DATA *RegsiteredData,
747 IN EFI_KEY_DATA *InputData
748 );
749
750 /**
751 Waiting on the keyboard event, if there's any key pressed by the user, signal the event
752
753 @param Event The event that be siganlled when any key has been stroked.
754 @param Context Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
755
756 **/
757 VOID
758 EFIAPI
759 BiosKeyboardWaitForKeyEx (
760 IN EFI_EVENT Event,
761 IN VOID *Context
762 );
763
764 #endif
765