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