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