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