]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
SecurityPkg: SmmTcg2PhysicalPresenceLib: Fix coding style issue
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2KeyboardDxe / Ps2Keyboard.c
... / ...
CommitLineData
1/** @file\r
2\r
3 PS/2 Keyboard driver. Routines that interacts with callers,\r
4 conforming to EFI driver model\r
5\r
6Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
7This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include "Ps2Keyboard.h"\r
18\r
19//\r
20// Function prototypes\r
21//\r
22/**\r
23 Test controller is a keyboard Controller.\r
24 \r
25 @param This Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
26 @param Controller driver's controller\r
27 @param RemainingDevicePath children device path\r
28 \r
29 @retval EFI_UNSUPPORTED controller is not floppy disk\r
30 @retval EFI_SUCCESS controller is floppy disk\r
31**/\r
32EFI_STATUS\r
33EFIAPI\r
34KbdControllerDriverSupported (\r
35 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
36 IN EFI_HANDLE Controller,\r
37 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
38 );\r
39\r
40/**\r
41 Create KEYBOARD_CONSOLE_IN_DEV instance on controller.\r
42 \r
43 @param This Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
44 @param Controller driver controller handle\r
45 @param RemainingDevicePath Children's device path\r
46 \r
47 @retval whether success to create floppy control instance.\r
48**/\r
49EFI_STATUS\r
50EFIAPI\r
51KbdControllerDriverStart (\r
52 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
53 IN EFI_HANDLE Controller,\r
54 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
55 );\r
56\r
57/**\r
58 Stop this driver on ControllerHandle. Support stoping any child handles\r
59 created by this driver.\r
60\r
61 @param This Protocol instance pointer.\r
62 @param ControllerHandle Handle of device to stop driver on\r
63 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
64 children is zero stop the entire bus driver.\r
65 @param ChildHandleBuffer List of Child Handles to Stop.\r
66\r
67 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
68 @retval other This driver was not removed from this device\r
69\r
70**/\r
71EFI_STATUS\r
72EFIAPI\r
73KbdControllerDriverStop (\r
74 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
75 IN EFI_HANDLE Controller,\r
76 IN UINTN NumberOfChildren,\r
77 IN EFI_HANDLE *ChildHandleBuffer\r
78 );\r
79\r
80/**\r
81 Free the waiting key notify list.\r
82 \r
83 @param ListHead Pointer to list head\r
84 \r
85 @retval EFI_INVALID_PARAMETER ListHead is NULL\r
86 @retval EFI_SUCCESS Sucess to free NotifyList\r
87**/\r
88EFI_STATUS\r
89KbdFreeNotifyList (\r
90 IN OUT LIST_ENTRY *ListHead\r
91 ); \r
92\r
93//\r
94// DriverBinding Protocol Instance\r
95//\r
96EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver = {\r
97 KbdControllerDriverSupported,\r
98 KbdControllerDriverStart,\r
99 KbdControllerDriverStop,\r
100 0xa,\r
101 NULL,\r
102 NULL\r
103};\r
104\r
105/**\r
106 Test controller is a keyboard Controller.\r
107 \r
108 @param This Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
109 @param Controller driver's controller\r
110 @param RemainingDevicePath children device path\r
111 \r
112 @retval EFI_UNSUPPORTED controller is not floppy disk\r
113 @retval EFI_SUCCESS controller is floppy disk\r
114**/\r
115EFI_STATUS\r
116EFIAPI\r
117KbdControllerDriverSupported (\r
118 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
119 IN EFI_HANDLE Controller,\r
120 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
121 )\r
122{\r
123 EFI_STATUS Status;\r
124 EFI_ISA_IO_PROTOCOL *IsaIo;\r
125\r
126 //\r
127 // Open the IO Abstraction(s) needed to perform the supported test\r
128 //\r
129 Status = gBS->OpenProtocol (\r
130 Controller,\r
131 &gEfiIsaIoProtocolGuid,\r
132 (VOID **) &IsaIo,\r
133 This->DriverBindingHandle,\r
134 Controller,\r
135 EFI_OPEN_PROTOCOL_BY_DRIVER\r
136 );\r
137 if (EFI_ERROR (Status)) {\r
138 return Status;\r
139 }\r
140 //\r
141 // Use the ISA I/O Protocol to see if Controller is the Keyboard controller\r
142 //\r
143 if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303) || IsaIo->ResourceList->Device.UID != 0) {\r
144 Status = EFI_UNSUPPORTED;\r
145 }\r
146 //\r
147 // Close the I/O Abstraction(s) used to perform the supported test\r
148 //\r
149 gBS->CloseProtocol (\r
150 Controller,\r
151 &gEfiIsaIoProtocolGuid,\r
152 This->DriverBindingHandle,\r
153 Controller\r
154 );\r
155\r
156 return Status;\r
157}\r
158\r
159/**\r
160 Create KEYBOARD_CONSOLE_IN_DEV instance on controller.\r
161 \r
162 @param This Pointer of EFI_DRIVER_BINDING_PROTOCOL\r
163 @param Controller driver controller handle\r
164 @param RemainingDevicePath Children's device path\r
165 \r
166 @retval whether success to create floppy control instance.\r
167**/\r
168EFI_STATUS\r
169EFIAPI\r
170KbdControllerDriverStart (\r
171 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
172 IN EFI_HANDLE Controller,\r
173 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
174 )\r
175{\r
176 EFI_STATUS Status;\r
177 EFI_STATUS Status1;\r
178 EFI_ISA_IO_PROTOCOL *IsaIo;\r
179 KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r
180 UINT8 Data;\r
181 EFI_STATUS_CODE_VALUE StatusCode;\r
182 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
183\r
184 StatusCode = 0;\r
185\r
186 Status = gBS->OpenProtocol (\r
187 Controller,\r
188 &gEfiDevicePathProtocolGuid,\r
189 (VOID **) &ParentDevicePath,\r
190 This->DriverBindingHandle,\r
191 Controller,\r
192 EFI_OPEN_PROTOCOL_BY_DRIVER\r
193 );\r
194 if (EFI_ERROR (Status)) {\r
195 return Status;\r
196 }\r
197 //\r
198 // Report that the keyboard is being enabled\r
199 //\r
200 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
201 EFI_PROGRESS_CODE,\r
202 EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_ENABLE,\r
203 ParentDevicePath\r
204 );\r
205\r
206 //\r
207 // Get the ISA I/O Protocol on Controller's handle\r
208 //\r
209 Status = gBS->OpenProtocol (\r
210 Controller,\r
211 &gEfiIsaIoProtocolGuid,\r
212 (VOID **) &IsaIo,\r
213 This->DriverBindingHandle,\r
214 Controller,\r
215 EFI_OPEN_PROTOCOL_BY_DRIVER\r
216 );\r
217 if (EFI_ERROR (Status)) {\r
218 gBS->CloseProtocol (\r
219 Controller,\r
220 &gEfiDevicePathProtocolGuid,\r
221 This->DriverBindingHandle,\r
222 Controller\r
223 );\r
224 return EFI_INVALID_PARAMETER;\r
225 }\r
226 //\r
227 // Allocate private data\r
228 //\r
229 ConsoleIn = AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_DEV));\r
230 if (ConsoleIn == NULL) {\r
231 Status = EFI_OUT_OF_RESOURCES;\r
232 StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
233 goto ErrorExit;\r
234 }\r
235 //\r
236 // Setup the device instance\r
237 //\r
238 ConsoleIn->Signature = KEYBOARD_CONSOLE_IN_DEV_SIGNATURE;\r
239 ConsoleIn->Handle = Controller;\r
240 (ConsoleIn->ConIn).Reset = KeyboardEfiReset;\r
241 (ConsoleIn->ConIn).ReadKeyStroke = KeyboardReadKeyStroke;\r
242 ConsoleIn->DataRegisterAddress = KEYBOARD_8042_DATA_REGISTER;\r
243 ConsoleIn->StatusRegisterAddress = KEYBOARD_8042_STATUS_REGISTER;\r
244 ConsoleIn->CommandRegisterAddress = KEYBOARD_8042_COMMAND_REGISTER;\r
245 ConsoleIn->IsaIo = IsaIo;\r
246 ConsoleIn->DevicePath = ParentDevicePath;\r
247\r
248 ConsoleIn->ConInEx.Reset = KeyboardEfiResetEx;\r
249 ConsoleIn->ConInEx.ReadKeyStrokeEx = KeyboardReadKeyStrokeEx;\r
250 ConsoleIn->ConInEx.SetState = KeyboardSetState;\r
251 ConsoleIn->ConInEx.RegisterKeyNotify = KeyboardRegisterKeyNotify;\r
252 ConsoleIn->ConInEx.UnregisterKeyNotify = KeyboardUnregisterKeyNotify; \r
253 \r
254 InitializeListHead (&ConsoleIn->NotifyList);\r
255\r
256 //\r
257 // Fix for random hangs in System waiting for the Key if no KBC is present in BIOS.\r
258 // When KBC decode (IO port 0x60/0x64 decode) is not enabled, \r
259 // KeyboardRead will read back as 0xFF and return status is EFI_SUCCESS.\r
260 // So instead we read status register to detect after read if KBC decode is enabled.\r
261 //\r
262 \r
263 //\r
264 // Return code is ignored on purpose.\r
265 //\r
266 if (!PcdGetBool (PcdFastPS2Detection)) {\r
267 KeyboardRead (ConsoleIn, &Data);\r
268 if ((KeyReadStatusRegister (ConsoleIn) & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {\r
269 //\r
270 // If nobody decodes KBC I/O port, it will read back as 0xFF.\r
271 // Check the Time-Out and Parity bit to see if it has an active KBC in system\r
272 //\r
273 Status = EFI_DEVICE_ERROR;\r
274 StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;\r
275 goto ErrorExit;\r
276 }\r
277 }\r
278 \r
279 //\r
280 // Setup the WaitForKey event\r
281 //\r
282 Status = gBS->CreateEvent (\r
283 EVT_NOTIFY_WAIT,\r
284 TPL_NOTIFY,\r
285 KeyboardWaitForKey,\r
286 ConsoleIn,\r
287 &((ConsoleIn->ConIn).WaitForKey)\r
288 );\r
289 if (EFI_ERROR (Status)) {\r
290 Status = EFI_OUT_OF_RESOURCES;\r
291 StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
292 goto ErrorExit;\r
293 }\r
294 //\r
295 // Setup the WaitForKeyEx event\r
296 // \r
297 Status = gBS->CreateEvent (\r
298 EVT_NOTIFY_WAIT,\r
299 TPL_NOTIFY,\r
300 KeyboardWaitForKeyEx,\r
301 ConsoleIn,\r
302 &(ConsoleIn->ConInEx.WaitForKeyEx)\r
303 );\r
304 if (EFI_ERROR (Status)) {\r
305 Status = EFI_OUT_OF_RESOURCES;\r
306 StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
307 goto ErrorExit;\r
308 }\r
309 // Setup a periodic timer, used for reading keystrokes at a fixed interval\r
310 //\r
311 Status = gBS->CreateEvent (\r
312 EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
313 TPL_NOTIFY,\r
314 KeyboardTimerHandler,\r
315 ConsoleIn,\r
316 &ConsoleIn->TimerEvent\r
317 );\r
318 if (EFI_ERROR (Status)) {\r
319 Status = EFI_OUT_OF_RESOURCES;\r
320 StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
321 goto ErrorExit;\r
322 }\r
323\r
324 Status = gBS->SetTimer (\r
325 ConsoleIn->TimerEvent,\r
326 TimerPeriodic,\r
327 KEYBOARD_TIMER_INTERVAL\r
328 );\r
329 if (EFI_ERROR (Status)) {\r
330 Status = EFI_OUT_OF_RESOURCES;\r
331 StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
332 goto ErrorExit;\r
333 }\r
334\r
335 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
336 EFI_PROGRESS_CODE,\r
337 EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_PRESENCE_DETECT,\r
338 ParentDevicePath\r
339 );\r
340\r
341 //\r
342 // Reset the keyboard device\r
343 //\r
344 Status = ConsoleIn->ConInEx.Reset (&ConsoleIn->ConInEx, FeaturePcdGet (PcdPs2KbdExtendedVerification));\r
345 if (EFI_ERROR (Status)) {\r
346 Status = EFI_DEVICE_ERROR;\r
347 StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;\r
348 goto ErrorExit;\r
349 }\r
350\r
351 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
352 EFI_PROGRESS_CODE,\r
353 EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_DETECTED,\r
354 ParentDevicePath\r
355 );\r
356\r
357 ConsoleIn->ControllerNameTable = NULL;\r
358 AddUnicodeString2 (\r
359 "eng",\r
360 gPs2KeyboardComponentName.SupportedLanguages,\r
361 &ConsoleIn->ControllerNameTable,\r
362 L"PS/2 Keyboard Device",\r
363 TRUE\r
364 );\r
365 AddUnicodeString2 (\r
366 "en",\r
367 gPs2KeyboardComponentName2.SupportedLanguages,\r
368 &ConsoleIn->ControllerNameTable,\r
369 L"PS/2 Keyboard Device",\r
370 FALSE\r
371 );\r
372\r
373\r
374 //\r
375 // Install protocol interfaces for the keyboard device.\r
376 //\r
377 Status = gBS->InstallMultipleProtocolInterfaces (\r
378 &Controller,\r
379 &gEfiSimpleTextInProtocolGuid,\r
380 &ConsoleIn->ConIn,\r
381 &gEfiSimpleTextInputExProtocolGuid,\r
382 &ConsoleIn->ConInEx,\r
383 NULL\r
384 );\r
385 if (EFI_ERROR (Status)) {\r
386 StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
387 goto ErrorExit;\r
388 }\r
389\r
390 return Status;\r
391\r
392ErrorExit:\r
393 //\r
394 // Report error code\r
395 //\r
396 if (StatusCode != 0) {\r
397 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
398 EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
399 StatusCode,\r
400 ParentDevicePath\r
401 );\r
402 }\r
403\r
404 if ((ConsoleIn != NULL) && (ConsoleIn->ConIn.WaitForKey != NULL)) {\r
405 gBS->CloseEvent (ConsoleIn->ConIn.WaitForKey);\r
406 }\r
407\r
408 if ((ConsoleIn != NULL) && (ConsoleIn->TimerEvent != NULL)) {\r
409 gBS->CloseEvent (ConsoleIn->TimerEvent);\r
410 }\r
411 if ((ConsoleIn != NULL) && (ConsoleIn->ConInEx.WaitForKeyEx != NULL)) {\r
412 gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
413 }\r
414 KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
415 if ((ConsoleIn != NULL) && (ConsoleIn->ControllerNameTable != NULL)) {\r
416 FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
417 }\r
418 //\r
419 // Since there will be no timer handler for keyboard input any more,\r
420 // exhaust input data just in case there is still keyboard data left\r
421 //\r
422 if (ConsoleIn != NULL) {\r
423 Status1 = EFI_SUCCESS;\r
424 while (!EFI_ERROR (Status1) && (Status != EFI_DEVICE_ERROR)) {\r
425 Status1 = KeyboardRead (ConsoleIn, &Data);;\r
426 }\r
427 }\r
428 \r
429 if (ConsoleIn != NULL) {\r
430 gBS->FreePool (ConsoleIn);\r
431 }\r
432\r
433 gBS->CloseProtocol (\r
434 Controller,\r
435 &gEfiDevicePathProtocolGuid,\r
436 This->DriverBindingHandle,\r
437 Controller\r
438 );\r
439\r
440 gBS->CloseProtocol (\r
441 Controller,\r
442 &gEfiIsaIoProtocolGuid,\r
443 This->DriverBindingHandle,\r
444 Controller\r
445 );\r
446\r
447 return Status;\r
448}\r
449\r
450/**\r
451 Stop this driver on ControllerHandle. Support stoping any child handles\r
452 created by this driver.\r
453\r
454 @param This Protocol instance pointer.\r
455 @param ControllerHandle Handle of device to stop driver on\r
456 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
457 children is zero stop the entire bus driver.\r
458 @param ChildHandleBuffer List of Child Handles to Stop.\r
459\r
460 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
461 @retval other This driver was not removed from this device\r
462\r
463**/\r
464EFI_STATUS\r
465EFIAPI\r
466KbdControllerDriverStop (\r
467 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
468 IN EFI_HANDLE Controller,\r
469 IN UINTN NumberOfChildren,\r
470 IN EFI_HANDLE *ChildHandleBuffer\r
471 )\r
472{\r
473 EFI_STATUS Status;\r
474 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;\r
475 KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r
476 UINT8 Data;\r
477\r
478 //\r
479 // Disable Keyboard\r
480 //\r
481 Status = gBS->OpenProtocol (\r
482 Controller,\r
483 &gEfiSimpleTextInProtocolGuid,\r
484 (VOID **) &ConIn,\r
485 This->DriverBindingHandle,\r
486 Controller,\r
487 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
488 );\r
489 if (EFI_ERROR (Status)) {\r
490 return Status;\r
491 }\r
492 Status = gBS->OpenProtocol (\r
493 Controller,\r
494 &gEfiSimpleTextInputExProtocolGuid,\r
495 NULL,\r
496 This->DriverBindingHandle,\r
497 Controller,\r
498 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
499 );\r
500 if (EFI_ERROR (Status)) {\r
501 return Status;\r
502 }\r
503 \r
504 ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);\r
505\r
506 //\r
507 // Report that the keyboard is being disabled\r
508 //\r
509 REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
510 EFI_PROGRESS_CODE,\r
511 EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_DISABLE,\r
512 ConsoleIn->DevicePath\r
513 );\r
514\r
515 if (ConsoleIn->TimerEvent != NULL) {\r
516 gBS->CloseEvent (ConsoleIn->TimerEvent);\r
517 ConsoleIn->TimerEvent = NULL;\r
518 }\r
519\r
520 //\r
521 // Since there will be no timer handler for keyboard input any more,\r
522 // exhaust input data just in case there is still keyboard data left\r
523 //\r
524 Status = EFI_SUCCESS;\r
525 while (!EFI_ERROR (Status)) {\r
526 Status = KeyboardRead (ConsoleIn, &Data);;\r
527 }\r
528 //\r
529 // Uninstall the SimpleTextIn and SimpleTextInEx protocols\r
530 //\r
531 Status = gBS->UninstallMultipleProtocolInterfaces (\r
532 Controller,\r
533 &gEfiSimpleTextInProtocolGuid,\r
534 &ConsoleIn->ConIn,\r
535 &gEfiSimpleTextInputExProtocolGuid,\r
536 &ConsoleIn->ConInEx,\r
537 NULL\r
538 );\r
539 if (EFI_ERROR (Status)) {\r
540 return Status;\r
541 }\r
542\r
543 gBS->CloseProtocol (\r
544 Controller,\r
545 &gEfiDevicePathProtocolGuid,\r
546 This->DriverBindingHandle,\r
547 Controller\r
548 );\r
549\r
550 gBS->CloseProtocol (\r
551 Controller,\r
552 &gEfiIsaIoProtocolGuid,\r
553 This->DriverBindingHandle,\r
554 Controller\r
555 );\r
556\r
557 //\r
558 // Free other resources\r
559 //\r
560 if ((ConsoleIn->ConIn).WaitForKey != NULL) {\r
561 gBS->CloseEvent ((ConsoleIn->ConIn).WaitForKey);\r
562 (ConsoleIn->ConIn).WaitForKey = NULL;\r
563 }\r
564 if (ConsoleIn->ConInEx.WaitForKeyEx != NULL) {\r
565 gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
566 ConsoleIn->ConInEx.WaitForKeyEx = NULL;\r
567 }\r
568 KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
569 FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
570 gBS->FreePool (ConsoleIn);\r
571\r
572 return EFI_SUCCESS;\r
573}\r
574\r
575/**\r
576 Free the waiting key notify list.\r
577 \r
578 @param ListHead Pointer to list head\r
579 \r
580 @retval EFI_INVALID_PARAMETER ListHead is NULL\r
581 @retval EFI_SUCCESS Sucess to free NotifyList\r
582**/\r
583EFI_STATUS\r
584KbdFreeNotifyList (\r
585 IN OUT LIST_ENTRY *ListHead\r
586 )\r
587{\r
588 KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;\r
589\r
590 if (ListHead == NULL) {\r
591 return EFI_INVALID_PARAMETER;\r
592 }\r
593 while (!IsListEmpty (ListHead)) {\r
594 NotifyNode = CR (\r
595 ListHead->ForwardLink, \r
596 KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
597 NotifyEntry, \r
598 KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
599 );\r
600 RemoveEntryList (ListHead->ForwardLink);\r
601 gBS->FreePool (NotifyNode);\r
602 }\r
603 \r
604 return EFI_SUCCESS;\r
605}\r
606\r
607/**\r
608 The module Entry Point for module Ps2Keyboard. \r
609\r
610 @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
611 @param[in] SystemTable A pointer to the EFI System Table.\r
612 \r
613 @retval EFI_SUCCESS The entry point is executed successfully.\r
614 @retval other Some error occurs when executing this entry point.\r
615\r
616**/\r
617EFI_STATUS\r
618EFIAPI\r
619InitializePs2Keyboard(\r
620 IN EFI_HANDLE ImageHandle,\r
621 IN EFI_SYSTEM_TABLE *SystemTable\r
622 )\r
623{\r
624 EFI_STATUS Status;\r
625\r
626 //\r
627 // Install driver model protocol(s).\r
628 //\r
629 Status = EfiLibInstallDriverBindingComponentName2 (\r
630 ImageHandle,\r
631 SystemTable,\r
632 &gKeyboardControllerDriver,\r
633 ImageHandle,\r
634 &gPs2KeyboardComponentName,\r
635 &gPs2KeyboardComponentName2\r
636 );\r
637 ASSERT_EFI_ERROR (Status);\r
638\r
639\r
640 return Status;\r
641}\r
642\r