]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
Add 4 APIs to DevicePathLib: ConvertDeviceNodeToText, ConvertDevicePathToText, Conver...
[mirror_edk2.git] / OvmfPkg / Library / PlatformBdsLib / BdsPlatform.c
... / ...
CommitLineData
1/** @file\r
2 Platform BDS customizations.\r
3\r
4 Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "BdsPlatform.h"\r
16#include "QemuBootOrder.h"\r
17\r
18\r
19//\r
20// Global data\r
21//\r
22\r
23VOID *mEfiDevPathNotifyReg;\r
24EFI_EVENT mEfiDevPathEvent;\r
25VOID *mEmuVariableEventReg;\r
26EFI_EVENT mEmuVariableEvent;\r
27BOOLEAN mDetectVgaOnly;\r
28\r
29\r
30//\r
31// Type definitions\r
32//\r
33\r
34typedef\r
35EFI_STATUS\r
36(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(\r
37 IN EFI_HANDLE Handle,\r
38 IN VOID *Instance,\r
39 IN VOID *Context\r
40 );\r
41\r
42/**\r
43 @param[in] Handle - Handle of PCI device instance\r
44 @param[in] PciIo - PCI IO protocol instance\r
45 @param[in] Pci - PCI Header register block\r
46**/\r
47typedef\r
48EFI_STATUS\r
49(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(\r
50 IN EFI_HANDLE Handle,\r
51 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
52 IN PCI_TYPE00 *Pci\r
53 );\r
54\r
55\r
56//\r
57// Function prototypes\r
58//\r
59\r
60EFI_STATUS\r
61VisitAllInstancesOfProtocol (\r
62 IN EFI_GUID *Id,\r
63 IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,\r
64 IN VOID *Context\r
65 );\r
66\r
67EFI_STATUS\r
68VisitAllPciInstancesOfProtocol (\r
69 IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction\r
70 );\r
71\r
72VOID\r
73InstallDevicePathCallback (\r
74 VOID\r
75 );\r
76\r
77//\r
78// BDS Platform Functions\r
79//\r
80VOID\r
81EFIAPI\r
82PlatformBdsInit (\r
83 VOID\r
84 )\r
85/*++\r
86\r
87Routine Description:\r
88\r
89 Platform Bds init. Incude the platform firmware vendor, revision\r
90 and so crc check.\r
91\r
92Arguments:\r
93\r
94Returns:\r
95\r
96 None.\r
97\r
98--*/\r
99{\r
100 DEBUG ((EFI_D_INFO, "PlatformBdsInit\n"));\r
101 InstallDevicePathCallback ();\r
102}\r
103\r
104\r
105EFI_STATUS\r
106ConnectRootBridge (\r
107 VOID\r
108 )\r
109/*++\r
110\r
111Routine Description:\r
112\r
113 Connect RootBridge\r
114\r
115Arguments:\r
116\r
117 None.\r
118\r
119Returns:\r
120\r
121 EFI_SUCCESS - Connect RootBridge successfully.\r
122 EFI_STATUS - Connect RootBridge fail.\r
123\r
124--*/\r
125{\r
126 EFI_STATUS Status;\r
127 EFI_HANDLE RootHandle;\r
128\r
129 //\r
130 // Make all the PCI_IO protocols on PCI Seg 0 show up\r
131 //\r
132 BdsLibConnectDevicePath (gPlatformRootBridges[0]);\r
133\r
134 Status = gBS->LocateDevicePath (\r
135 &gEfiDevicePathProtocolGuid,\r
136 &gPlatformRootBridges[0],\r
137 &RootHandle\r
138 );\r
139 if (EFI_ERROR (Status)) {\r
140 return Status;\r
141 }\r
142\r
143 Status = gBS->ConnectController (RootHandle, NULL, NULL, FALSE);\r
144 if (EFI_ERROR (Status)) {\r
145 return Status;\r
146 }\r
147\r
148 return EFI_SUCCESS;\r
149}\r
150\r
151\r
152EFI_STATUS\r
153PrepareLpcBridgeDevicePath (\r
154 IN EFI_HANDLE DeviceHandle\r
155 )\r
156/*++\r
157\r
158Routine Description:\r
159\r
160 Add IsaKeyboard to ConIn,\r
161 add IsaSerial to ConOut, ConIn, ErrOut.\r
162 LPC Bridge: 06 01 00\r
163\r
164Arguments:\r
165\r
166 DeviceHandle - Handle of PCIIO protocol.\r
167\r
168Returns:\r
169\r
170 EFI_SUCCESS - LPC bridge is added to ConOut, ConIn, and ErrOut.\r
171 EFI_STATUS - No LPC bridge is added.\r
172\r
173--*/\r
174{\r
175 EFI_STATUS Status;\r
176 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
177 EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
178 CHAR16 *DevPathStr;\r
179\r
180 DevicePath = NULL;\r
181 Status = gBS->HandleProtocol (\r
182 DeviceHandle,\r
183 &gEfiDevicePathProtocolGuid,\r
184 (VOID*)&DevicePath\r
185 );\r
186 if (EFI_ERROR (Status)) {\r
187 return Status;\r
188 }\r
189 TempDevicePath = DevicePath;\r
190\r
191 //\r
192 // Register Keyboard\r
193 //\r
194 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);\r
195\r
196 BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
197\r
198 //\r
199 // Register COM1\r
200 //\r
201 DevicePath = TempDevicePath;\r
202 gPnp16550ComPortDeviceNode.UID = 0;\r
203\r
204 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
205 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
206 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
207\r
208 //\r
209 // Print Device Path\r
210 //\r
211 DevPathStr = DevicePathToStr(DevicePath);\r
212 DEBUG((\r
213 EFI_D_INFO,\r
214 "BdsPlatform.c+%d: COM%d DevPath: %s\n",\r
215 __LINE__,\r
216 gPnp16550ComPortDeviceNode.UID + 1,\r
217 DevPathStr\r
218 ));\r
219 FreePool(DevPathStr);\r
220\r
221 BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
222 BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
223 BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
224\r
225 //\r
226 // Register COM2\r
227 //\r
228 DevicePath = TempDevicePath;\r
229 gPnp16550ComPortDeviceNode.UID = 1;\r
230\r
231 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r
232 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
233 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
234\r
235 //\r
236 // Print Device Path\r
237 //\r
238 DevPathStr = DevicePathToStr(DevicePath);\r
239 DEBUG((\r
240 EFI_D_INFO,\r
241 "BdsPlatform.c+%d: COM%d DevPath: %s\n",\r
242 __LINE__,\r
243 gPnp16550ComPortDeviceNode.UID + 1,\r
244 DevPathStr\r
245 ));\r
246 FreePool(DevPathStr);\r
247\r
248 BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
249 BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
250 BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
251\r
252 return EFI_SUCCESS;\r
253}\r
254\r
255EFI_STATUS\r
256GetGopDevicePath (\r
257 IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r
258 OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath\r
259 )\r
260{\r
261 UINTN Index;\r
262 EFI_STATUS Status;\r
263 EFI_HANDLE PciDeviceHandle;\r
264 EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
265 EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;\r
266 UINTN GopHandleCount;\r
267 EFI_HANDLE *GopHandleBuffer;\r
268\r
269 if (PciDevicePath == NULL || GopDevicePath == NULL) {\r
270 return EFI_INVALID_PARAMETER;\r
271 }\r
272\r
273 //\r
274 // Initialize the GopDevicePath to be PciDevicePath\r
275 //\r
276 *GopDevicePath = PciDevicePath;\r
277 TempPciDevicePath = PciDevicePath;\r
278\r
279 Status = gBS->LocateDevicePath (\r
280 &gEfiDevicePathProtocolGuid,\r
281 &TempPciDevicePath,\r
282 &PciDeviceHandle\r
283 );\r
284 if (EFI_ERROR (Status)) {\r
285 return Status;\r
286 }\r
287\r
288 //\r
289 // Try to connect this handle, so that GOP dirver could start on this\r
290 // device and create child handles with GraphicsOutput Protocol installed\r
291 // on them, then we get device paths of these child handles and select\r
292 // them as possible console device.\r
293 //\r
294 gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);\r
295\r
296 Status = gBS->LocateHandleBuffer (\r
297 ByProtocol,\r
298 &gEfiGraphicsOutputProtocolGuid,\r
299 NULL,\r
300 &GopHandleCount,\r
301 &GopHandleBuffer\r
302 );\r
303 if (!EFI_ERROR (Status)) {\r
304 //\r
305 // Add all the child handles as possible Console Device\r
306 //\r
307 for (Index = 0; Index < GopHandleCount; Index++) {\r
308 Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r
309 if (EFI_ERROR (Status)) {\r
310 continue;\r
311 }\r
312 if (CompareMem (\r
313 PciDevicePath,\r
314 TempDevicePath,\r
315 GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH\r
316 ) == 0) {\r
317 //\r
318 // In current implementation, we only enable one of the child handles\r
319 // as console device, i.e. sotre one of the child handle's device\r
320 // path to variable "ConOut"\r
321 // In futhure, we could select all child handles to be console device\r
322 //\r
323\r
324 *GopDevicePath = TempDevicePath;\r
325\r
326 //\r
327 // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()\r
328 // Add the integrity GOP device path.\r
329 //\r
330 BdsLibUpdateConsoleVariable (VarConsoleOutDev, NULL, PciDevicePath);\r
331 BdsLibUpdateConsoleVariable (VarConsoleOutDev, TempDevicePath, NULL);\r
332 }\r
333 }\r
334 gBS->FreePool (GopHandleBuffer);\r
335 }\r
336\r
337 return EFI_SUCCESS;\r
338}\r
339\r
340EFI_STATUS\r
341PreparePciVgaDevicePath (\r
342 IN EFI_HANDLE DeviceHandle\r
343 )\r
344/*++\r
345\r
346Routine Description:\r
347\r
348 Add PCI VGA to ConOut.\r
349 PCI VGA: 03 00 00\r
350\r
351Arguments:\r
352\r
353 DeviceHandle - Handle of PCIIO protocol.\r
354\r
355Returns:\r
356\r
357 EFI_SUCCESS - PCI VGA is added to ConOut.\r
358 EFI_STATUS - No PCI VGA device is added.\r
359\r
360--*/\r
361{\r
362 EFI_STATUS Status;\r
363 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
364 EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r
365\r
366 DevicePath = NULL;\r
367 Status = gBS->HandleProtocol (\r
368 DeviceHandle,\r
369 &gEfiDevicePathProtocolGuid,\r
370 (VOID*)&DevicePath\r
371 );\r
372 if (EFI_ERROR (Status)) {\r
373 return Status;\r
374 }\r
375\r
376 GetGopDevicePath (DevicePath, &GopDevicePath);\r
377 DevicePath = GopDevicePath;\r
378\r
379 BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
380\r
381 return EFI_SUCCESS;\r
382}\r
383\r
384EFI_STATUS\r
385PreparePciSerialDevicePath (\r
386 IN EFI_HANDLE DeviceHandle\r
387 )\r
388/*++\r
389\r
390Routine Description:\r
391\r
392 Add PCI Serial to ConOut, ConIn, ErrOut.\r
393 PCI Serial: 07 00 02\r
394\r
395Arguments:\r
396\r
397 DeviceHandle - Handle of PCIIO protocol.\r
398\r
399Returns:\r
400\r
401 EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.\r
402 EFI_STATUS - No PCI Serial device is added.\r
403\r
404--*/\r
405{\r
406 EFI_STATUS Status;\r
407 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
408\r
409 DevicePath = NULL;\r
410 Status = gBS->HandleProtocol (\r
411 DeviceHandle,\r
412 &gEfiDevicePathProtocolGuid,\r
413 (VOID*)&DevicePath\r
414 );\r
415 if (EFI_ERROR (Status)) {\r
416 return Status;\r
417 }\r
418\r
419 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
420 DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
421\r
422 BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
423 BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
424 BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
425\r
426 return EFI_SUCCESS;\r
427}\r
428\r
429EFI_STATUS\r
430VisitAllInstancesOfProtocol (\r
431 IN EFI_GUID *Id,\r
432 IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,\r
433 IN VOID *Context\r
434 )\r
435{\r
436 EFI_STATUS Status;\r
437 UINTN HandleCount;\r
438 EFI_HANDLE *HandleBuffer;\r
439 UINTN Index;\r
440 VOID *Instance;\r
441\r
442 //\r
443 // Start to check all the PciIo to find all possible device\r
444 //\r
445 HandleCount = 0;\r
446 HandleBuffer = NULL;\r
447 Status = gBS->LocateHandleBuffer (\r
448 ByProtocol,\r
449 Id,\r
450 NULL,\r
451 &HandleCount,\r
452 &HandleBuffer\r
453 );\r
454 if (EFI_ERROR (Status)) {\r
455 return Status;\r
456 }\r
457\r
458 for (Index = 0; Index < HandleCount; Index++) {\r
459 Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);\r
460 if (EFI_ERROR (Status)) {\r
461 continue;\r
462 }\r
463\r
464 Status = (*CallBackFunction) (\r
465 HandleBuffer[Index],\r
466 Instance,\r
467 Context\r
468 );\r
469 }\r
470\r
471 gBS->FreePool (HandleBuffer);\r
472\r
473 return EFI_SUCCESS;\r
474}\r
475\r
476\r
477EFI_STATUS\r
478EFIAPI\r
479VisitingAPciInstance (\r
480 IN EFI_HANDLE Handle,\r
481 IN VOID *Instance,\r
482 IN VOID *Context\r
483 )\r
484{\r
485 EFI_STATUS Status;\r
486 EFI_PCI_IO_PROTOCOL *PciIo;\r
487 PCI_TYPE00 Pci;\r
488\r
489 PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;\r
490\r
491 //\r
492 // Check for all PCI device\r
493 //\r
494 Status = PciIo->Pci.Read (\r
495 PciIo,\r
496 EfiPciIoWidthUint32,\r
497 0,\r
498 sizeof (Pci) / sizeof (UINT32),\r
499 &Pci\r
500 );\r
501 if (EFI_ERROR (Status)) {\r
502 return Status;\r
503 }\r
504\r
505 return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (\r
506 Handle,\r
507 PciIo,\r
508 &Pci\r
509 );\r
510\r
511}\r
512\r
513\r
514\r
515EFI_STATUS\r
516VisitAllPciInstances (\r
517 IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction\r
518 )\r
519{\r
520 return VisitAllInstancesOfProtocol (\r
521 &gEfiPciIoProtocolGuid,\r
522 VisitingAPciInstance,\r
523 (VOID*)(UINTN) CallBackFunction\r
524 );\r
525}\r
526\r
527\r
528/**\r
529 Do platform specific PCI Device check and add them to\r
530 ConOut, ConIn, ErrOut.\r
531\r
532 @param[in] Handle - Handle of PCI device instance\r
533 @param[in] PciIo - PCI IO protocol instance\r
534 @param[in] Pci - PCI Header register block\r
535\r
536 @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
537 @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
538\r
539**/\r
540EFI_STATUS\r
541EFIAPI\r
542DetectAndPreparePlatformPciDevicePath (\r
543 IN EFI_HANDLE Handle,\r
544 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
545 IN PCI_TYPE00 *Pci\r
546 )\r
547{\r
548 EFI_STATUS Status;\r
549\r
550 Status = PciIo->Attributes (\r
551 PciIo,\r
552 EfiPciIoAttributeOperationEnable,\r
553 EFI_PCI_DEVICE_ENABLE,\r
554 NULL\r
555 );\r
556 ASSERT_EFI_ERROR (Status);\r
557\r
558 if (!mDetectVgaOnly) {\r
559 //\r
560 // Here we decide whether it is LPC Bridge\r
561 //\r
562 if ((IS_PCI_LPC (Pci)) ||\r
563 ((IS_PCI_ISA_PDECODE (Pci)) &&\r
564 (Pci->Hdr.VendorId == 0x8086) &&\r
565 (Pci->Hdr.DeviceId == 0x7000)\r
566 )\r
567 ) {\r
568 //\r
569 // Add IsaKeyboard to ConIn,\r
570 // add IsaSerial to ConOut, ConIn, ErrOut\r
571 //\r
572 DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));\r
573 PrepareLpcBridgeDevicePath (Handle);\r
574 return EFI_SUCCESS;\r
575 }\r
576 //\r
577 // Here we decide which Serial device to enable in PCI bus\r
578 //\r
579 if (IS_PCI_16550SERIAL (Pci)) {\r
580 //\r
581 // Add them to ConOut, ConIn, ErrOut.\r
582 //\r
583 DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));\r
584 PreparePciSerialDevicePath (Handle);\r
585 return EFI_SUCCESS;\r
586 }\r
587 }\r
588\r
589 //\r
590 // Here we decide which VGA device to enable in PCI bus\r
591 //\r
592 if (IS_PCI_VGA (Pci)) {\r
593 //\r
594 // Add them to ConOut.\r
595 //\r
596 DEBUG ((EFI_D_INFO, "Found PCI VGA device\n"));\r
597 PreparePciVgaDevicePath (Handle);\r
598 return EFI_SUCCESS;\r
599 }\r
600\r
601 return Status;\r
602}\r
603\r
604\r
605/**\r
606 Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
607\r
608 @param[in] DetectVgaOnly - Only detect VGA device if it's TRUE.\r
609\r
610 @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
611 @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
612\r
613**/\r
614EFI_STATUS\r
615DetectAndPreparePlatformPciDevicePaths (\r
616 BOOLEAN DetectVgaOnly\r
617 )\r
618{\r
619 mDetectVgaOnly = DetectVgaOnly;\r
620 return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);\r
621}\r
622\r
623\r
624EFI_STATUS\r
625PlatformBdsConnectConsole (\r
626 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
627 )\r
628/*++\r
629\r
630Routine Description:\r
631\r
632 Connect the predefined platform default console device. Always try to find\r
633 and enable the vga device if have.\r
634\r
635Arguments:\r
636\r
637 PlatformConsole - Predfined platform default console device array.\r
638\r
639Returns:\r
640\r
641 EFI_SUCCESS - Success connect at least one ConIn and ConOut\r
642 device, there must have one ConOut device is\r
643 active vga device.\r
644\r
645 EFI_STATUS - Return the status of\r
646 BdsLibConnectAllDefaultConsoles ()\r
647\r
648--*/\r
649{\r
650 EFI_STATUS Status;\r
651 UINTN Index;\r
652 EFI_DEVICE_PATH_PROTOCOL *VarConout;\r
653 EFI_DEVICE_PATH_PROTOCOL *VarConin;\r
654 UINTN DevicePathSize;\r
655\r
656 //\r
657 // Connect RootBridge\r
658 //\r
659 VarConout = BdsLibGetVariableAndSize (\r
660 VarConsoleOut,\r
661 &gEfiGlobalVariableGuid,\r
662 &DevicePathSize\r
663 );\r
664 VarConin = BdsLibGetVariableAndSize (\r
665 VarConsoleInp,\r
666 &gEfiGlobalVariableGuid,\r
667 &DevicePathSize\r
668 );\r
669\r
670 if (VarConout == NULL || VarConin == NULL) {\r
671 //\r
672 // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
673 //\r
674 DetectAndPreparePlatformPciDevicePaths (FALSE);\r
675\r
676 //\r
677 // Have chance to connect the platform default console,\r
678 // the platform default console is the minimue device group\r
679 // the platform should support\r
680 //\r
681 for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {\r
682 //\r
683 // Update the console variable with the connect type\r
684 //\r
685 if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
686 BdsLibUpdateConsoleVariable (VarConsoleInp, PlatformConsole[Index].DevicePath, NULL);\r
687 }\r
688 if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
689 BdsLibUpdateConsoleVariable (VarConsoleOut, PlatformConsole[Index].DevicePath, NULL);\r
690 }\r
691 if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
692 BdsLibUpdateConsoleVariable (VarErrorOut, PlatformConsole[Index].DevicePath, NULL);\r
693 }\r
694 }\r
695 } else {\r
696 //\r
697 // Only detect VGA device and add them to ConOut\r
698 //\r
699 DetectAndPreparePlatformPciDevicePaths (TRUE);\r
700 }\r
701\r
702 //\r
703 // Connect the all the default console with current cosole variable\r
704 //\r
705 Status = BdsLibConnectAllDefaultConsoles ();\r
706 if (EFI_ERROR (Status)) {\r
707 return Status;\r
708 }\r
709\r
710 return EFI_SUCCESS;\r
711}\r
712\r
713\r
714VOID\r
715PciInitialization (\r
716 )\r
717{\r
718 //\r
719 // Bus 0, Device 0, Function 0 - Host to PCI Bridge\r
720 //\r
721 PciWrite8 (PCI_LIB_ADDRESS (0, 0, 0, 0x3c), 0x00);\r
722\r
723 //\r
724 // Bus 0, Device 1, Function 0 - PCI to ISA Bridge\r
725 //\r
726 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x3c), 0x00);\r
727 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // LNKA routing target\r
728 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // LNKB routing target\r
729 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // LNKC routing target\r
730 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // LNKD routing target\r
731\r
732 //\r
733 // Bus 0, Device 1, Function 1 - IDE Controller\r
734 //\r
735 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x3c), 0x00);\r
736 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x0d), 0x40);\r
737\r
738 //\r
739 // Bus 0, Device 1, Function 3 - Power Managment Controller\r
740 //\r
741 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3c), 0x09);\r
742 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3d), 0x01); // INTA\r
743\r
744 //\r
745 // Bus 0, Device 2, Function 0 - Video Controller\r
746 //\r
747 PciWrite8 (PCI_LIB_ADDRESS (0, 2, 0, 0x3c), 0x00);\r
748\r
749 //\r
750 // Bus 0, Device 3, Function 0 - Network Controller\r
751 //\r
752 PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3c), 0x0a);\r
753 PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3d), 0x01); // INTA (-> LNKC)\r
754\r
755 //\r
756 // Bus 0, Device 5, Function 0 - RAM Memory\r
757 //\r
758 PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3c), 0x0b);\r
759 PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3d), 0x01); // INTA (-> LNKA)\r
760}\r
761\r
762\r
763VOID\r
764AcpiInitialization (\r
765 VOID\r
766 )\r
767{\r
768 //\r
769 // Set ACPI SCI_EN bit in PMCNTRL\r
770 //\r
771 IoOr16 ((PciRead32 (PCI_LIB_ADDRESS (0, 1, 3, 0x40)) & ~BIT0) + 4, BIT0);\r
772}\r
773\r
774\r
775EFI_STATUS\r
776EFIAPI\r
777ConnectRecursivelyIfPciMassStorage (\r
778 IN EFI_HANDLE Handle,\r
779 IN EFI_PCI_IO_PROTOCOL *Instance,\r
780 IN PCI_TYPE00 *PciHeader\r
781 )\r
782{\r
783 EFI_STATUS Status;\r
784 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
785 CHAR16 *DevPathStr;\r
786\r
787 if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {\r
788 DevicePath = NULL;\r
789 Status = gBS->HandleProtocol (\r
790 Handle,\r
791 &gEfiDevicePathProtocolGuid,\r
792 (VOID*)&DevicePath\r
793 );\r
794 if (EFI_ERROR (Status)) {\r
795 return Status;\r
796 }\r
797\r
798 //\r
799 // Print Device Path\r
800 //\r
801 DevPathStr = DevicePathToStr (DevicePath);\r
802 DEBUG((\r
803 EFI_D_INFO,\r
804 "Found Mass Storage device: %s\n",\r
805 DevPathStr\r
806 ));\r
807 FreePool(DevPathStr);\r
808\r
809 Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);\r
810 if (EFI_ERROR (Status)) {\r
811 return Status;\r
812 }\r
813\r
814 }\r
815\r
816 return EFI_SUCCESS;\r
817}\r
818\r
819\r
820/**\r
821 This notification function is invoked when the\r
822 EMU Variable FVB has been changed.\r
823\r
824 @param Event The event that occured\r
825 @param Context For EFI compatiblity. Not used.\r
826\r
827**/\r
828VOID\r
829EFIAPI\r
830EmuVariablesUpdatedCallback (\r
831 IN EFI_EVENT Event,\r
832 IN VOID *Context\r
833 )\r
834{\r
835 DEBUG ((EFI_D_INFO, "EmuVariablesUpdatedCallback\n"));\r
836 UpdateNvVarsOnFileSystem ();\r
837}\r
838\r
839\r
840EFI_STATUS\r
841EFIAPI\r
842VisitingFileSystemInstance (\r
843 IN EFI_HANDLE Handle,\r
844 IN VOID *Instance,\r
845 IN VOID *Context\r
846 )\r
847{\r
848 EFI_STATUS Status;\r
849 STATIC BOOLEAN ConnectedToFileSystem = FALSE;\r
850\r
851 if (ConnectedToFileSystem) {\r
852 return EFI_ALREADY_STARTED;\r
853 }\r
854\r
855 Status = ConnectNvVarsToFileSystem (Handle);\r
856 if (EFI_ERROR (Status)) {\r
857 return Status;\r
858 }\r
859\r
860 ConnectedToFileSystem = TRUE;\r
861 mEmuVariableEvent =\r
862 EfiCreateProtocolNotifyEvent (\r
863 &gEfiDevicePathProtocolGuid,\r
864 TPL_CALLBACK,\r
865 EmuVariablesUpdatedCallback,\r
866 NULL,\r
867 &mEmuVariableEventReg\r
868 );\r
869 PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);\r
870\r
871 return EFI_SUCCESS;\r
872}\r
873\r
874\r
875VOID\r
876PlatformBdsRestoreNvVarsFromHardDisk (\r
877 )\r
878{\r
879 VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);\r
880 VisitAllInstancesOfProtocol (\r
881 &gEfiSimpleFileSystemProtocolGuid,\r
882 VisitingFileSystemInstance,\r
883 NULL\r
884 );\r
885\r
886}\r
887\r
888\r
889VOID\r
890PlatformBdsConnectSequence (\r
891 VOID\r
892 )\r
893/*++\r
894\r
895Routine Description:\r
896\r
897 Connect with predeined platform connect sequence,\r
898 the OEM/IBV can customize with their own connect sequence.\r
899\r
900Arguments:\r
901\r
902 None.\r
903\r
904Returns:\r
905\r
906 None.\r
907\r
908--*/\r
909{\r
910 UINTN Index;\r
911\r
912 DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n"));\r
913\r
914 Index = 0;\r
915\r
916 //\r
917 // Here we can get the customized platform connect sequence\r
918 // Notes: we can connect with new variable which record the\r
919 // last time boots connect device path sequence\r
920 //\r
921 while (gPlatformConnectSequence[Index] != NULL) {\r
922 //\r
923 // Build the platform boot option\r
924 //\r
925 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
926 Index++;\r
927 }\r
928\r
929 //\r
930 // Just use the simple policy to connect all devices\r
931 //\r
932 BdsLibConnectAll ();\r
933\r
934 PciInitialization ();\r
935 AcpiInitialization ();\r
936\r
937 //\r
938 // Clear the logo after all devices are connected.\r
939 //\r
940 gST->ConOut->ClearScreen (gST->ConOut);\r
941}\r
942\r
943VOID\r
944PlatformBdsGetDriverOption (\r
945 IN OUT LIST_ENTRY *BdsDriverLists\r
946 )\r
947/*++\r
948\r
949Routine Description:\r
950\r
951 Load the predefined driver option, OEM/IBV can customize this\r
952 to load their own drivers\r
953\r
954Arguments:\r
955\r
956 BdsDriverLists - The header of the driver option link list.\r
957\r
958Returns:\r
959\r
960 None.\r
961\r
962--*/\r
963{\r
964 DEBUG ((EFI_D_INFO, "PlatformBdsGetDriverOption\n"));\r
965 return;\r
966}\r
967\r
968VOID\r
969PlatformBdsDiagnostics (\r
970 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
971 IN BOOLEAN QuietBoot,\r
972 IN BASEM_MEMORY_TEST BaseMemoryTest\r
973 )\r
974/*++\r
975\r
976Routine Description:\r
977\r
978 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
979 can customize this fuction to support specific platform diagnostic.\r
980\r
981Arguments:\r
982\r
983 MemoryTestLevel - The memory test intensive level\r
984\r
985 QuietBoot - Indicate if need to enable the quiet boot\r
986\r
987 BaseMemoryTest - A pointer to BaseMemoryTest()\r
988\r
989Returns:\r
990\r
991 None.\r
992\r
993--*/\r
994{\r
995 EFI_STATUS Status;\r
996\r
997 DEBUG ((EFI_D_INFO, "PlatformBdsDiagnostics\n"));\r
998\r
999 //\r
1000 // Here we can decide if we need to show\r
1001 // the diagnostics screen\r
1002 // Notes: this quiet boot code should be remove\r
1003 // from the graphic lib\r
1004 //\r
1005 if (QuietBoot) {\r
1006 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
1007 //\r
1008 // Perform system diagnostic\r
1009 //\r
1010 Status = BaseMemoryTest (MemoryTestLevel);\r
1011 if (EFI_ERROR (Status)) {\r
1012 DisableQuietBoot ();\r
1013 }\r
1014\r
1015 return ;\r
1016 }\r
1017 //\r
1018 // Perform system diagnostic\r
1019 //\r
1020 Status = BaseMemoryTest (MemoryTestLevel);\r
1021}\r
1022\r
1023\r
1024VOID\r
1025EFIAPI\r
1026PlatformBdsPolicyBehavior (\r
1027 IN OUT LIST_ENTRY *DriverOptionList,\r
1028 IN OUT LIST_ENTRY *BootOptionList,\r
1029 IN PROCESS_CAPSULES ProcessCapsules,\r
1030 IN BASEM_MEMORY_TEST BaseMemoryTest\r
1031 )\r
1032/*++\r
1033\r
1034Routine Description:\r
1035\r
1036 The function will excute with as the platform policy, current policy\r
1037 is driven by boot mode. IBV/OEM can customize this code for their specific\r
1038 policy action.\r
1039\r
1040Arguments:\r
1041\r
1042 DriverOptionList - The header of the driver option link list\r
1043\r
1044 BootOptionList - The header of the boot option link list\r
1045\r
1046 ProcessCapsules - A pointer to ProcessCapsules()\r
1047\r
1048 BaseMemoryTest - A pointer to BaseMemoryTest()\r
1049\r
1050Returns:\r
1051\r
1052 None.\r
1053\r
1054--*/\r
1055{\r
1056 EFI_STATUS Status;\r
1057 UINT16 Timeout;\r
1058 EFI_EVENT UserInputDurationTime;\r
1059 LIST_ENTRY *Link;\r
1060 BDS_COMMON_OPTION *BootOption;\r
1061 UINTN Index;\r
1062 EFI_INPUT_KEY Key;\r
1063 EFI_TPL OldTpl;\r
1064 EFI_BOOT_MODE BootMode;\r
1065\r
1066 DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));\r
1067\r
1068 ConnectRootBridge ();\r
1069\r
1070 //\r
1071 // Try to restore variables from the hard disk early so\r
1072 // they can be used for the other BDS connect operations.\r
1073 //\r
1074 PlatformBdsRestoreNvVarsFromHardDisk ();\r
1075\r
1076 //\r
1077 // Init the time out value\r
1078 //\r
1079 Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
1080\r
1081 //\r
1082 // Load the driver option as the driver option list\r
1083 //\r
1084 PlatformBdsGetDriverOption (DriverOptionList);\r
1085\r
1086 //\r
1087 // Get current Boot Mode\r
1088 //\r
1089 Status = BdsLibGetBootMode (&BootMode);\r
1090 DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));\r
1091\r
1092 //\r
1093 // Go the different platform policy with different boot mode\r
1094 // Notes: this part code can be change with the table policy\r
1095 //\r
1096 ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);\r
1097 //\r
1098 // Connect platform console\r
1099 //\r
1100 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
1101 if (EFI_ERROR (Status)) {\r
1102 //\r
1103 // Here OEM/IBV can customize with defined action\r
1104 //\r
1105 PlatformBdsNoConsoleAction ();\r
1106 }\r
1107 //\r
1108 // Create a 300ms duration event to ensure user has enough input time to enter Setup\r
1109 //\r
1110 Status = gBS->CreateEvent (\r
1111 EVT_TIMER,\r
1112 0,\r
1113 NULL,\r
1114 NULL,\r
1115 &UserInputDurationTime\r
1116 );\r
1117 ASSERT (Status == EFI_SUCCESS);\r
1118 Status = gBS->SetTimer (UserInputDurationTime, TimerRelative, 3000000);\r
1119 ASSERT (Status == EFI_SUCCESS);\r
1120 //\r
1121 // Memory test and Logo show\r
1122 //\r
1123 PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
1124\r
1125 //\r
1126 // Perform some platform specific connect sequence\r
1127 //\r
1128 PlatformBdsConnectSequence ();\r
1129\r
1130 //\r
1131 // Process QEMU's -kernel command line option\r
1132 //\r
1133 TryRunningQemuKernel ();\r
1134\r
1135 //\r
1136 // Give one chance to enter the setup if we\r
1137 // have the time out\r
1138 //\r
1139 if (Timeout != 0) {\r
1140 //PlatformBdsEnterFrontPage (Timeout, FALSE);\r
1141 }\r
1142\r
1143 DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n"));\r
1144 BdsLibConnectAll ();\r
1145 BdsLibEnumerateAllBootOption (BootOptionList);\r
1146\r
1147 SetBootOrderFromQemu (BootOptionList);\r
1148\r
1149 //\r
1150 // Please uncomment above ConnectAll and EnumerateAll code and remove following first boot\r
1151 // checking code in real production tip.\r
1152 //\r
1153 // In BOOT_WITH_FULL_CONFIGURATION boot mode, should always connect every device\r
1154 // and do enumerate all the default boot options. But in development system board, the boot mode\r
1155 // cannot be BOOT_ASSUMING_NO_CONFIGURATION_CHANGES because the machine box\r
1156 // is always open. So the following code only do the ConnectAll and EnumerateAll at first boot.\r
1157 //\r
1158 Status = BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
1159 if (EFI_ERROR(Status)) {\r
1160 //\r
1161 // If cannot find "BootOrder" variable, it may be first boot.\r
1162 // Try to connect all devices and enumerate all boot options here.\r
1163 //\r
1164 BdsLibConnectAll ();\r
1165 BdsLibEnumerateAllBootOption (BootOptionList);\r
1166 }\r
1167\r
1168 //\r
1169 // To give the User a chance to enter Setup here, if user set TimeOut is 0.\r
1170 // BDS should still give user a chance to enter Setup\r
1171 //\r
1172 // Connect first boot option, and then check user input before exit\r
1173 //\r
1174 for (Link = BootOptionList->ForwardLink; Link != BootOptionList;Link = Link->ForwardLink) {\r
1175 BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
1176 if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r
1177 //\r
1178 // skip the header of the link list, becuase it has no boot option\r
1179 //\r
1180 continue;\r
1181 } else {\r
1182 //\r
1183 // Make sure the boot option device path connected, but ignore the BBS device path\r
1184 //\r
1185 if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r
1186 BdsLibConnectDevicePath (BootOption->DevicePath);\r
1187 }\r
1188 break;\r
1189 }\r
1190 }\r
1191\r
1192 //\r
1193 // Check whether the user input after the duration time has expired\r
1194 //\r
1195 OldTpl = EfiGetCurrentTpl();\r
1196 gBS->RestoreTPL (TPL_APPLICATION);\r
1197 gBS->WaitForEvent (1, &UserInputDurationTime, &Index);\r
1198 gBS->CloseEvent (UserInputDurationTime);\r
1199 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
1200 gBS->RaiseTPL (OldTpl);\r
1201\r
1202 if (!EFI_ERROR (Status)) {\r
1203 //\r
1204 // Enter Setup if user input\r
1205 //\r
1206 Timeout = 0xffff;\r
1207 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
1208 }\r
1209\r
1210 return ;\r
1211}\r
1212\r
1213VOID\r
1214EFIAPI\r
1215PlatformBdsBootSuccess (\r
1216 IN BDS_COMMON_OPTION *Option\r
1217 )\r
1218/*++\r
1219\r
1220Routine Description:\r
1221\r
1222 Hook point after a boot attempt succeeds. We don't expect a boot option to\r
1223 return, so the EFI 1.0 specification defines that you will default to an\r
1224 interactive mode and stop processing the BootOrder list in this case. This\r
1225 is alos a platform implementation and can be customized by IBV/OEM.\r
1226\r
1227Arguments:\r
1228\r
1229 Option - Pointer to Boot Option that succeeded to boot.\r
1230\r
1231Returns:\r
1232\r
1233 None.\r
1234\r
1235--*/\r
1236{\r
1237 CHAR16 *TmpStr;\r
1238\r
1239 DEBUG ((EFI_D_INFO, "PlatformBdsBootSuccess\n"));\r
1240 //\r
1241 // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
1242 // select loop then we need to pop up a UI and wait for user input.\r
1243 //\r
1244 TmpStr = Option->StatusString;\r
1245 if (TmpStr != NULL) {\r
1246 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
1247 FreePool (TmpStr);\r
1248 }\r
1249}\r
1250\r
1251VOID\r
1252EFIAPI\r
1253PlatformBdsBootFail (\r
1254 IN BDS_COMMON_OPTION *Option,\r
1255 IN EFI_STATUS Status,\r
1256 IN CHAR16 *ExitData,\r
1257 IN UINTN ExitDataSize\r
1258 )\r
1259/*++\r
1260\r
1261Routine Description:\r
1262\r
1263 Hook point after a boot attempt fails.\r
1264\r
1265Arguments:\r
1266\r
1267 Option - Pointer to Boot Option that failed to boot.\r
1268\r
1269 Status - Status returned from failed boot.\r
1270\r
1271 ExitData - Exit data returned from failed boot.\r
1272\r
1273 ExitDataSize - Exit data size returned from failed boot.\r
1274\r
1275Returns:\r
1276\r
1277 None.\r
1278\r
1279--*/\r
1280{\r
1281 CHAR16 *TmpStr;\r
1282\r
1283 DEBUG ((EFI_D_INFO, "PlatformBdsBootFail\n"));\r
1284\r
1285 //\r
1286 // If Boot returned with failed status then we need to pop up a UI and wait\r
1287 // for user input.\r
1288 //\r
1289 TmpStr = Option->StatusString;\r
1290 if (TmpStr != NULL) {\r
1291 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
1292 FreePool (TmpStr);\r
1293 }\r
1294}\r
1295\r
1296EFI_STATUS\r
1297PlatformBdsNoConsoleAction (\r
1298 VOID\r
1299 )\r
1300/*++\r
1301\r
1302Routine Description:\r
1303\r
1304 This function is remained for IBV/OEM to do some platform action,\r
1305 if there no console device can be connected.\r
1306\r
1307Arguments:\r
1308\r
1309 None.\r
1310\r
1311Returns:\r
1312\r
1313 EFI_SUCCESS - Direct return success now.\r
1314\r
1315--*/\r
1316{\r
1317 DEBUG ((EFI_D_INFO, "PlatformBdsNoConsoleAction\n"));\r
1318 return EFI_SUCCESS;\r
1319}\r
1320\r
1321VOID\r
1322EFIAPI\r
1323PlatformBdsLockNonUpdatableFlash (\r
1324 VOID\r
1325 )\r
1326{\r
1327 DEBUG ((EFI_D_INFO, "PlatformBdsLockNonUpdatableFlash\n"));\r
1328 return;\r
1329}\r
1330\r
1331\r
1332/**\r
1333 This notification function is invoked when an instance of the\r
1334 EFI_DEVICE_PATH_PROTOCOL is produced.\r
1335\r
1336 @param Event The event that occured\r
1337 @param Context For EFI compatiblity. Not used.\r
1338\r
1339**/\r
1340VOID\r
1341EFIAPI\r
1342NotifyDevPath (\r
1343 IN EFI_EVENT Event,\r
1344 IN VOID *Context\r
1345 )\r
1346{\r
1347 EFI_HANDLE Handle;\r
1348 EFI_STATUS Status;\r
1349 UINTN BufferSize;\r
1350 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
1351 ATAPI_DEVICE_PATH *Atapi;\r
1352\r
1353 //\r
1354 // Examine all new handles\r
1355 //\r
1356 for (;;) {\r
1357 //\r
1358 // Get the next handle\r
1359 //\r
1360 BufferSize = sizeof (Handle);\r
1361 Status = gBS->LocateHandle (\r
1362 ByRegisterNotify,\r
1363 NULL,\r
1364 mEfiDevPathNotifyReg,\r
1365 &BufferSize,\r
1366 &Handle\r
1367 );\r
1368\r
1369 //\r
1370 // If not found, we're done\r
1371 //\r
1372 if (EFI_NOT_FOUND == Status) {\r
1373 break;\r
1374 }\r
1375\r
1376 if (EFI_ERROR (Status)) {\r
1377 continue;\r
1378 }\r
1379\r
1380 //\r
1381 // Get the DevicePath protocol on that handle\r
1382 //\r
1383 Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPathNode);\r
1384 ASSERT_EFI_ERROR (Status);\r
1385\r
1386 while (!IsDevicePathEnd (DevPathNode)) {\r
1387 //\r
1388 // Find the handler to dump this device path node\r
1389 //\r
1390 if (\r
1391 (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&\r
1392 (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)\r
1393 ) {\r
1394 Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;\r
1395 PciOr16 (\r
1396 PCI_LIB_ADDRESS (\r
1397 0,\r
1398 1,\r
1399 1,\r
1400 (Atapi->PrimarySecondary == 1) ? 0x42: 0x40\r
1401 ),\r
1402 BIT15\r
1403 );\r
1404 }\r
1405\r
1406 //\r
1407 // Next device path node\r
1408 //\r
1409 DevPathNode = NextDevicePathNode (DevPathNode);\r
1410 }\r
1411 }\r
1412\r
1413 return;\r
1414}\r
1415\r
1416\r
1417VOID\r
1418InstallDevicePathCallback (\r
1419 VOID\r
1420 )\r
1421{\r
1422 DEBUG ((EFI_D_INFO, "Registered NotifyDevPath Event\n"));\r
1423 mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (\r
1424 &gEfiDevicePathProtocolGuid,\r
1425 TPL_CALLBACK,\r
1426 NotifyDevPath,\r
1427 NULL,\r
1428 &mEfiDevPathNotifyReg\r
1429 );\r
1430}\r
1431\r
1432/**\r
1433 Lock the ConsoleIn device in system table. All key\r
1434 presses will be ignored until the Password is typed in. The only way to\r
1435 disable the password is to type it in to a ConIn device.\r
1436\r
1437 @param Password Password used to lock ConIn device.\r
1438\r
1439 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
1440 @retval EFI_UNSUPPORTED Password not found\r
1441\r
1442**/\r
1443EFI_STATUS\r
1444EFIAPI\r
1445LockKeyboards (\r
1446 IN CHAR16 *Password\r
1447 )\r
1448{\r
1449 return EFI_UNSUPPORTED;\r
1450}\r
1451\r