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