2 Platform BDS customizations.
4 Copyright (c) 2004 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "BdsPlatform.h"
22 VOID
*mEfiDevPathNotifyReg
;
23 EFI_EVENT mEfiDevPathEvent
;
27 // Function prototypes
31 InstallDevicePathCallback (
43 PciRomLoadEfiDriversFromRomImage (
44 IN EFI_PHYSICAL_ADDRESS Rom
,
49 // BDS Platform Functions
60 Platform Bds init. Incude the platform firmware vendor, revision
71 DEBUG ((EFI_D_INFO
, "PlatformBdsInit\n"));
72 InstallDevicePathCallback ();
93 EFI_SUCCESS - Connect RootBridge successfully.
94 EFI_STATUS - Connect RootBridge fail.
99 EFI_HANDLE RootHandle
;
102 // Make all the PCI_IO protocols on PCI Seg 0 show up
104 BdsLibConnectDevicePath (gPlatformRootBridges
[0]);
106 Status
= gBS
->LocateDevicePath (
107 &gEfiDevicePathProtocolGuid
,
108 &gPlatformRootBridges
[0],
111 if (EFI_ERROR (Status
)) {
115 Status
= gBS
->ConnectController (RootHandle
, NULL
, NULL
, FALSE
);
116 if (EFI_ERROR (Status
)) {
125 PrepareLpcBridgeDevicePath (
126 IN EFI_HANDLE DeviceHandle
132 Add IsaKeyboard to ConIn,
133 add IsaSerial to ConOut, ConIn, ErrOut.
138 DeviceHandle - Handle of PCIIO protocol.
142 EFI_SUCCESS - LPC bridge is added to ConOut, ConIn, and ErrOut.
143 EFI_STATUS - No LPC bridge is added.
148 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
149 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
153 Status
= gBS
->HandleProtocol (
155 &gEfiDevicePathProtocolGuid
,
158 if (EFI_ERROR (Status
)) {
161 TempDevicePath
= DevicePath
;
166 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gPnpPs2KeyboardDeviceNode
);
168 BdsLibUpdateConsoleVariable (VarConsoleInp
, DevicePath
, NULL
);
173 DevicePath
= TempDevicePath
;
174 gPnp16550ComPortDeviceNode
.UID
= 0;
176 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gPnp16550ComPortDeviceNode
);
177 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gUartDeviceNode
);
178 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gTerminalTypeDeviceNode
);
183 DevPathStr
= DevicePathToStr(DevicePath
);
186 "BdsPlatform.c+%d: COM%d DevPath: %s\n",
188 gPnp16550ComPortDeviceNode
.UID
+ 1,
191 FreePool(DevPathStr
);
193 BdsLibUpdateConsoleVariable (VarConsoleOut
, DevicePath
, NULL
);
194 BdsLibUpdateConsoleVariable (VarConsoleInp
, DevicePath
, NULL
);
195 BdsLibUpdateConsoleVariable (VarErrorOut
, DevicePath
, NULL
);
200 DevicePath
= TempDevicePath
;
201 gPnp16550ComPortDeviceNode
.UID
= 1;
203 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gPnp16550ComPortDeviceNode
);
204 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gUartDeviceNode
);
205 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gTerminalTypeDeviceNode
);
210 DevPathStr
= DevicePathToStr(DevicePath
);
213 "BdsPlatform.c+%d: COM%d DevPath: %s\n",
215 gPnp16550ComPortDeviceNode
.UID
+ 1,
218 FreePool(DevPathStr
);
220 BdsLibUpdateConsoleVariable (VarConsoleOut
, DevicePath
, NULL
);
221 BdsLibUpdateConsoleVariable (VarConsoleInp
, DevicePath
, NULL
);
222 BdsLibUpdateConsoleVariable (VarErrorOut
, DevicePath
, NULL
);
229 IN EFI_DEVICE_PATH_PROTOCOL
*PciDevicePath
,
230 OUT EFI_DEVICE_PATH_PROTOCOL
**GopDevicePath
235 EFI_HANDLE PciDeviceHandle
;
236 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
237 EFI_DEVICE_PATH_PROTOCOL
*TempPciDevicePath
;
238 UINTN GopHandleCount
;
239 EFI_HANDLE
*GopHandleBuffer
;
241 if (PciDevicePath
== NULL
|| GopDevicePath
== NULL
) {
242 return EFI_INVALID_PARAMETER
;
246 // Initialize the GopDevicePath to be PciDevicePath
248 *GopDevicePath
= PciDevicePath
;
249 TempPciDevicePath
= PciDevicePath
;
251 Status
= gBS
->LocateDevicePath (
252 &gEfiDevicePathProtocolGuid
,
256 if (EFI_ERROR (Status
)) {
261 // Try to connect this handle, so that GOP dirver could start on this
262 // device and create child handles with GraphicsOutput Protocol installed
263 // on them, then we get device paths of these child handles and select
264 // them as possible console device.
266 gBS
->ConnectController (PciDeviceHandle
, NULL
, NULL
, FALSE
);
268 Status
= gBS
->LocateHandleBuffer (
270 &gEfiGraphicsOutputProtocolGuid
,
275 if (!EFI_ERROR (Status
)) {
277 // Add all the child handles as possible Console Device
279 for (Index
= 0; Index
< GopHandleCount
; Index
++) {
280 Status
= gBS
->HandleProtocol (GopHandleBuffer
[Index
], &gEfiDevicePathProtocolGuid
, (VOID
*)&TempDevicePath
);
281 if (EFI_ERROR (Status
)) {
287 GetDevicePathSize (PciDevicePath
) - END_DEVICE_PATH_LENGTH
290 // In current implementation, we only enable one of the child handles
291 // as console device, i.e. sotre one of the child handle's device
292 // path to variable "ConOut"
293 // In futhure, we could select all child handles to be console device
296 *GopDevicePath
= TempDevicePath
;
299 // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()
300 // Add the integrity GOP device path.
302 BdsLibUpdateConsoleVariable (VarConsoleOutDev
, NULL
, PciDevicePath
);
303 BdsLibUpdateConsoleVariable (VarConsoleOutDev
, TempDevicePath
, NULL
);
306 gBS
->FreePool (GopHandleBuffer
);
313 PreparePciVgaDevicePath (
314 IN EFI_HANDLE DeviceHandle
320 Add PCI VGA to ConOut.
325 DeviceHandle - Handle of PCIIO protocol.
329 EFI_SUCCESS - PCI VGA is added to ConOut.
330 EFI_STATUS - No PCI VGA device is added.
335 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
336 EFI_DEVICE_PATH_PROTOCOL
*GopDevicePath
;
339 Status
= gBS
->HandleProtocol (
341 &gEfiDevicePathProtocolGuid
,
344 if (EFI_ERROR (Status
)) {
348 GetGopDevicePath (DevicePath
, &GopDevicePath
);
349 DevicePath
= GopDevicePath
;
351 BdsLibUpdateConsoleVariable (VarConsoleOut
, DevicePath
, NULL
);
357 PreparePciSerialDevicePath (
358 IN EFI_HANDLE DeviceHandle
364 Add PCI Serial to ConOut, ConIn, ErrOut.
369 DeviceHandle - Handle of PCIIO protocol.
373 EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.
374 EFI_STATUS - No PCI Serial device is added.
379 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
382 Status
= gBS
->HandleProtocol (
384 &gEfiDevicePathProtocolGuid
,
387 if (EFI_ERROR (Status
)) {
391 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gUartDeviceNode
);
392 DevicePath
= AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&gTerminalTypeDeviceNode
);
394 BdsLibUpdateConsoleVariable (VarConsoleOut
, DevicePath
, NULL
);
395 BdsLibUpdateConsoleVariable (VarConsoleInp
, DevicePath
, NULL
);
396 BdsLibUpdateConsoleVariable (VarErrorOut
, DevicePath
, NULL
);
402 DetectAndPreparePlatformPciDevicePath (
403 BOOLEAN DetectVgaOnly
409 Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
413 DetectVgaOnly - Only detect VGA device if it's TRUE.
417 EFI_SUCCESS - PCI Device check and Console variable update successfully.
418 EFI_STATUS - PCI Device check or Console variable update fail.
424 EFI_HANDLE
*HandleBuffer
;
426 EFI_PCI_IO_PROTOCOL
*PciIo
;
430 // Start to check all the PciIo to find all possible device
434 Status
= gBS
->LocateHandleBuffer (
436 &gEfiPciIoProtocolGuid
,
441 if (EFI_ERROR (Status
)) {
445 for (Index
= 0; Index
< HandleCount
; Index
++) {
446 Status
= gBS
->HandleProtocol (HandleBuffer
[Index
], &gEfiPciIoProtocolGuid
, (VOID
*)&PciIo
);
447 if (EFI_ERROR (Status
)) {
452 // Check for all PCI device
454 Status
= PciIo
->Pci
.Read (
458 sizeof (Pci
) / sizeof (UINT32
),
461 if (EFI_ERROR (Status
)) {
465 Status
= PciIo
->Attributes (
467 EfiPciIoAttributeOperationEnable
,
468 EFI_PCI_DEVICE_ENABLE
,
471 ASSERT_EFI_ERROR (Status
);
473 if (!DetectVgaOnly
) {
475 // Here we decide whether it is LPC Bridge
477 if ((IS_PCI_LPC (&Pci
)) ||
478 ((IS_PCI_ISA_PDECODE (&Pci
)) &&
479 (Pci
.Hdr
.VendorId
== 0x8086) &&
480 (Pci
.Hdr
.DeviceId
== 0x7000)
484 // Add IsaKeyboard to ConIn,
485 // add IsaSerial to ConOut, ConIn, ErrOut
487 DEBUG ((EFI_D_INFO
, "Found LPC Bridge device\n"));
488 PrepareLpcBridgeDevicePath (HandleBuffer
[Index
]);
492 // Here we decide which Serial device to enable in PCI bus
494 if (IS_PCI_16550SERIAL (&Pci
)) {
496 // Add them to ConOut, ConIn, ErrOut.
498 DEBUG ((EFI_D_INFO
, "Found PCI 16550 SERIAL device\n"));
499 PreparePciSerialDevicePath (HandleBuffer
[Index
]);
505 // Here we decide which VGA device to enable in PCI bus
507 if (IS_PCI_VGA (&Pci
)) {
509 // Add them to ConOut.
511 DEBUG ((EFI_D_INFO
, "Found PCI VGA device\n"));
512 PreparePciVgaDevicePath (HandleBuffer
[Index
]);
517 gBS
->FreePool (HandleBuffer
);
524 PlatformBdsConnectConsole (
525 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
531 Connect the predefined platform default console device. Always try to find
532 and enable the vga device if have.
536 PlatformConsole - Predfined platform default console device array.
540 EFI_SUCCESS - Success connect at least one ConIn and ConOut
541 device, there must have one ConOut device is
544 EFI_STATUS - Return the status of
545 BdsLibConnectAllDefaultConsoles ()
551 EFI_DEVICE_PATH_PROTOCOL
*VarConout
;
552 EFI_DEVICE_PATH_PROTOCOL
*VarConin
;
553 UINTN DevicePathSize
;
556 // Connect RootBridge
558 ConnectRootBridge ();
560 VarConout
= BdsLibGetVariableAndSize (
562 &gEfiGlobalVariableGuid
,
565 VarConin
= BdsLibGetVariableAndSize (
567 &gEfiGlobalVariableGuid
,
571 if (VarConout
== NULL
|| VarConin
== NULL
) {
573 // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
575 DetectAndPreparePlatformPciDevicePath (FALSE
);
578 // Have chance to connect the platform default console,
579 // the platform default console is the minimue device group
580 // the platform should support
582 for (Index
= 0; PlatformConsole
[Index
].DevicePath
!= NULL
; ++Index
) {
584 // Update the console variable with the connect type
586 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
587 BdsLibUpdateConsoleVariable (VarConsoleInp
, PlatformConsole
[Index
].DevicePath
, NULL
);
589 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
590 BdsLibUpdateConsoleVariable (VarConsoleOut
, PlatformConsole
[Index
].DevicePath
, NULL
);
592 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
593 BdsLibUpdateConsoleVariable (VarErrorOut
, PlatformConsole
[Index
].DevicePath
, NULL
);
598 // Only detect VGA device and add them to ConOut
600 DetectAndPreparePlatformPciDevicePath (TRUE
);
604 // Connect the all the default console with current cosole variable
606 Status
= BdsLibConnectAllDefaultConsoles ();
607 if (EFI_ERROR (Status
)) {
620 // Bus 0, Device 0, Function 0 - Host to PCI Bridge
622 PciWrite8 (PCI_LIB_ADDRESS (0, 0, 0, 0x3c), 0x00);
625 // Bus 0, Device 1, Function 0 - PCI to ISA Bridge
627 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x3c), 0x00);
628 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b);
629 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x09);
630 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0b);
631 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x09);
634 // Bus 0, Device 1, Function 1 - IDE Controller
636 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x3c), 0x00);
637 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x0d), 0x40);
640 // Bus 0, Device 1, Function 3 - Power Managment Controller
642 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3c), 0x0b);
643 PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3d), 0x01);
646 // Bus 0, Device 2, Function 0 - Video Controller
648 PciWrite8 (PCI_LIB_ADDRESS (0, 2, 0, 0x3c), 0x00);
651 // Bus 0, Device 3, Function 0 - Network Controller
653 PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3c), 0x0b);
654 PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3d), 0x01);
657 // Bus 0, Device 4, Function 0 - RAM Memory
659 PciWrite8 (PCI_LIB_ADDRESS (0, 4, 0, 0x3c), 0x09);
660 PciWrite8 (PCI_LIB_ADDRESS (0, 4, 0, 0x3d), 0x01);
665 PlatformBdsConnectSequence (
672 Connect with predeined platform connect sequence,
673 the OEM/IBV can customize with their own connect sequence.
687 DEBUG ((EFI_D_INFO
, "PlatformBdsConnectSequence\n"));
692 // Here we can get the customized platform connect sequence
693 // Notes: we can connect with new variable which record the
694 // last time boots connect device path sequence
696 while (gPlatformConnectSequence
[Index
] != NULL
) {
698 // Build the platform boot option
700 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
705 // Just use the simple policy to connect all devices
709 PciInitialization ();
712 // Clear the logo after all devices are connected.
714 gST
->ConOut
->ClearScreen (gST
->ConOut
);
718 PlatformBdsGetDriverOption (
719 IN OUT LIST_ENTRY
*BdsDriverLists
725 Load the predefined driver option, OEM/IBV can customize this
726 to load their own drivers
730 BdsDriverLists - The header of the driver option link list.
738 DEBUG ((EFI_D_INFO
, "PlatformBdsGetDriverOption\n"));
743 PlatformBdsDiagnostics (
744 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
745 IN BOOLEAN QuietBoot
,
746 IN BASEM_MEMORY_TEST BaseMemoryTest
752 Perform the platform diagnostic, such like test memory. OEM/IBV also
753 can customize this fuction to support specific platform diagnostic.
757 MemoryTestLevel - The memory test intensive level
759 QuietBoot - Indicate if need to enable the quiet boot
761 BaseMemoryTest - A pointer to BaseMemoryTest()
771 DEBUG ((EFI_D_INFO
, "PlatformBdsDiagnostics\n"));
774 // Here we can decide if we need to show
775 // the diagnostics screen
776 // Notes: this quiet boot code should be remove
777 // from the graphic lib
780 EnableQuietBoot (PcdGetPtr(PcdLogoFile
));
782 // Perform system diagnostic
784 Status
= BaseMemoryTest (MemoryTestLevel
);
785 if (EFI_ERROR (Status
)) {
792 // Perform system diagnostic
794 Status
= BaseMemoryTest (MemoryTestLevel
);
800 PlatformBdsPolicyBehavior (
801 IN OUT LIST_ENTRY
*DriverOptionList
,
802 IN OUT LIST_ENTRY
*BootOptionList
,
803 IN PROCESS_CAPSULES ProcessCapsules
,
804 IN BASEM_MEMORY_TEST BaseMemoryTest
810 The function will excute with as the platform policy, current policy
811 is driven by boot mode. IBV/OEM can customize this code for their specific
816 DriverOptionList - The header of the driver option link list
818 BootOptionList - The header of the boot option link list
820 ProcessCapsules - A pointer to ProcessCapsules()
822 BaseMemoryTest - A pointer to BaseMemoryTest()
832 EFI_EVENT UserInputDurationTime
;
834 BDS_COMMON_OPTION
*BootOption
;
838 EFI_BOOT_MODE BootMode
;
840 DEBUG ((EFI_D_INFO
, "PlatformBdsPolicyBehavior\n"));
843 // Init the time out value
845 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
848 // Load the driver option as the driver option list
850 PlatformBdsGetDriverOption (DriverOptionList
);
853 // Get current Boot Mode
855 Status
= BdsLibGetBootMode (&BootMode
);
856 DEBUG ((EFI_D_ERROR
, "Boot Mode:%x\n", BootMode
));
859 // Go the different platform policy with different boot mode
860 // Notes: this part code can be change with the table policy
862 ASSERT (BootMode
== BOOT_WITH_FULL_CONFIGURATION
);
864 // Connect platform console
866 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
867 if (EFI_ERROR (Status
)) {
869 // Here OEM/IBV can customize with defined action
871 PlatformBdsNoConsoleAction ();
874 // Create a 300ms duration event to ensure user has enough input time to enter Setup
876 Status
= gBS
->CreateEvent (
881 &UserInputDurationTime
883 ASSERT (Status
== EFI_SUCCESS
);
884 Status
= gBS
->SetTimer (UserInputDurationTime
, TimerRelative
, 3000000);
885 ASSERT (Status
== EFI_SUCCESS
);
887 // Memory test and Logo show
889 PlatformBdsDiagnostics (IGNORE
, TRUE
, BaseMemoryTest
);
892 // Perform some platform specific connect sequence
894 PlatformBdsConnectSequence ();
897 // Give one chance to enter the setup if we
901 //PlatformBdsEnterFrontPage (Timeout, FALSE);
904 DEBUG ((EFI_D_INFO
, "BdsLibConnectAll\n"));
906 BdsLibEnumerateAllBootOption (BootOptionList
);
909 // Please uncomment above ConnectAll and EnumerateAll code and remove following first boot
910 // checking code in real production tip.
912 // In BOOT_WITH_FULL_CONFIGURATION boot mode, should always connect every device
913 // and do enumerate all the default boot options. But in development system board, the boot mode
914 // cannot be BOOT_ASSUMING_NO_CONFIGURATION_CHANGES because the machine box
915 // is always open. So the following code only do the ConnectAll and EnumerateAll at first boot.
917 Status
= BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
918 if (EFI_ERROR(Status
)) {
920 // If cannot find "BootOrder" variable, it may be first boot.
921 // Try to connect all devices and enumerate all boot options here.
924 BdsLibEnumerateAllBootOption (BootOptionList
);
928 // To give the User a chance to enter Setup here, if user set TimeOut is 0.
929 // BDS should still give user a chance to enter Setup
931 // Connect first boot option, and then check user input before exit
933 for (Link
= BootOptionList
->ForwardLink
; Link
!= BootOptionList
;Link
= Link
->ForwardLink
) {
934 BootOption
= CR (Link
, BDS_COMMON_OPTION
, Link
, BDS_LOAD_OPTION_SIGNATURE
);
935 if (!IS_LOAD_OPTION_TYPE (BootOption
->Attribute
, LOAD_OPTION_ACTIVE
)) {
937 // skip the header of the link list, becuase it has no boot option
942 // Make sure the boot option device path connected, but ignore the BBS device path
944 if (DevicePathType (BootOption
->DevicePath
) != BBS_DEVICE_PATH
) {
945 BdsLibConnectDevicePath (BootOption
->DevicePath
);
952 // Check whether the user input after the duration time has expired
954 OldTpl
= EfiGetCurrentTpl();
955 gBS
->RestoreTPL (TPL_APPLICATION
);
956 gBS
->WaitForEvent (1, &UserInputDurationTime
, &Index
);
957 gBS
->CloseEvent (UserInputDurationTime
);
958 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
959 gBS
->RaiseTPL (OldTpl
);
961 if (!EFI_ERROR (Status
)) {
963 // Enter Setup if user input
966 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
974 PlatformBdsBootSuccess (
975 IN BDS_COMMON_OPTION
*Option
981 Hook point after a boot attempt succeeds. We don't expect a boot option to
982 return, so the EFI 1.0 specification defines that you will default to an
983 interactive mode and stop processing the BootOrder list in this case. This
984 is alos a platform implementation and can be customized by IBV/OEM.
988 Option - Pointer to Boot Option that succeeded to boot.
998 DEBUG ((EFI_D_INFO
, "PlatformBdsBootSuccess\n"));
1000 // If Boot returned with EFI_SUCCESS and there is not in the boot device
1001 // select loop then we need to pop up a UI and wait for user input.
1003 TmpStr
= Option
->StatusString
;
1004 if (TmpStr
!= NULL
) {
1005 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
1012 PlatformBdsBootFail (
1013 IN BDS_COMMON_OPTION
*Option
,
1014 IN EFI_STATUS Status
,
1015 IN CHAR16
*ExitData
,
1016 IN UINTN ExitDataSize
1020 Routine Description:
1022 Hook point after a boot attempt fails.
1026 Option - Pointer to Boot Option that failed to boot.
1028 Status - Status returned from failed boot.
1030 ExitData - Exit data returned from failed boot.
1032 ExitDataSize - Exit data size returned from failed boot.
1042 DEBUG ((EFI_D_INFO
, "PlatformBdsBootFail\n"));
1045 // If Boot returned with failed status then we need to pop up a UI and wait
1048 TmpStr
= Option
->StatusString
;
1049 if (TmpStr
!= NULL
) {
1050 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
1056 PlatformBdsNoConsoleAction (
1061 Routine Description:
1063 This function is remained for IBV/OEM to do some platform action,
1064 if there no console device can be connected.
1072 EFI_SUCCESS - Direct return success now.
1076 DEBUG ((EFI_D_INFO
, "PlatformBdsNoConsoleAction\n"));
1082 PlatformBdsLockNonUpdatableFlash (
1086 DEBUG ((EFI_D_INFO
, "PlatformBdsLockNonUpdatableFlash\n"));
1092 This notification function is invoked when an instance of the
1093 EFI_DEVICE_PATH_PROTOCOL is produced.
1095 @param Event The event that occured
1096 @param Context For EFI compatiblity. Not used.
1109 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1110 ATAPI_DEVICE_PATH
*Atapi
;
1113 // Examine all new handles
1117 // Get the next handle
1119 BufferSize
= sizeof (Handle
);
1120 Status
= gBS
->LocateHandle (
1123 mEfiDevPathNotifyReg
,
1129 // If not found, we're done
1131 if (EFI_NOT_FOUND
== Status
) {
1135 if (EFI_ERROR (Status
)) {
1140 // Get the DevicePath protocol on that handle
1142 Status
= gBS
->HandleProtocol (Handle
, &gEfiDevicePathProtocolGuid
, (VOID
**)&DevPathNode
);
1143 ASSERT_EFI_ERROR (Status
);
1145 while (!IsDevicePathEnd (DevPathNode
)) {
1147 // Find the handler to dump this device path node
1150 (DevicePathType(DevPathNode
) == MESSAGING_DEVICE_PATH
) &&
1151 (DevicePathSubType(DevPathNode
) == MSG_ATAPI_DP
)
1153 Atapi
= (ATAPI_DEVICE_PATH
*) DevPathNode
;
1159 (Atapi
->PrimarySecondary
== 1) ? 0x42: 0x40
1166 // Next device path node
1168 DevPathNode
= NextDevicePathNode (DevPathNode
);
1177 InstallDevicePathCallback (
1181 DEBUG ((EFI_D_INFO
, "Registered NotifyDevPath Event\n"));
1182 mEfiDevPathEvent
= EfiCreateProtocolNotifyEvent (
1183 &gEfiDevicePathProtocolGuid
,
1187 &mEfiDevPathNotifyReg
1192 Lock the ConsoleIn device in system table. All key
1193 presses will be ignored until the Password is typed in. The only way to
1194 disable the password is to type it in to a ConIn device.
1196 @param Password Password used to lock ConIn device.
1198 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
1199 @retval EFI_UNSUPPORTED Password not found
1208 return EFI_UNSUPPORTED
;
1218 PCI_DATA_STRUCTURE
*Pcir
;
1222 // The virtual machines sometimes load the video rom image
1223 // directly at the legacy video BIOS location of C000:0000,
1224 // and do not implement the PCI expansion ROM feature.
1226 Pcir
= (PCI_DATA_STRUCTURE
*) (UINTN
) 0xc0000;
1227 RomSize
= Pcir
->ImageLength
* 512;
1228 PciRomLoadEfiDriversFromRomImage (0xc0000, RomSize
);
1234 PciRomLoadEfiDriversFromRomImage (
1235 IN EFI_PHYSICAL_ADDRESS Rom
,
1240 EFI_PCI_EXPANSION_ROM_HEADER
*EfiRomHeader
;
1241 PCI_DATA_STRUCTURE
*Pcir
;
1246 EFI_HANDLE ImageHandle
;
1248 EFI_STATUS retStatus
;
1249 EFI_DEVICE_PATH_PROTOCOL
*FilePath
;
1251 UINT32 DestinationSize
;
1255 VOID
*DecompressedImageBuffer
;
1257 EFI_DECOMPRESS_PROTOCOL
*Decompress
;
1259 FileName
= L
"PciRomInMemory";
1261 //FileName = L"PciRom Addr=0000000000000000";
1262 //HexToString (&FileName[12], Rom, 16);
1265 retStatus
= EFI_NOT_FOUND
;
1266 RomOffset
= (UINTN
) Rom
;
1270 EfiRomHeader
= (EFI_PCI_EXPANSION_ROM_HEADER
*) (UINTN
) RomOffset
;
1272 if (EfiRomHeader
->Signature
!= 0xaa55) {
1276 Pcir
= (PCI_DATA_STRUCTURE
*) (UINTN
) (RomOffset
+ EfiRomHeader
->PcirOffset
);
1277 ImageSize
= Pcir
->ImageLength
* 512;
1279 if ((Pcir
->CodeType
== PCI_CODE_TYPE_EFI_IMAGE
) &&
1280 (EfiRomHeader
->EfiSignature
== EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE
) ) {
1282 if ((EfiRomHeader
->EfiSubsystem
== EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
) ||
1283 (EfiRomHeader
->EfiSubsystem
== EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
) ) {
1285 ImageOffset
= EfiRomHeader
->EfiImageHeaderOffset
;
1286 ImageSize
= EfiRomHeader
->InitializationSize
* 512;
1288 ImageBuffer
= (VOID
*) (UINTN
) (RomOffset
+ ImageOffset
);
1289 ImageLength
= ImageSize
- ImageOffset
;
1290 DecompressedImageBuffer
= NULL
;
1293 // decompress here if needed
1296 if (EfiRomHeader
->CompressionType
> EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED
) {
1300 if (EfiRomHeader
->CompressionType
== EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED
) {
1301 Status
= gBS
->LocateProtocol (&gEfiDecompressProtocolGuid
, NULL
, (VOID
**) &Decompress
);
1302 if (EFI_ERROR (Status
)) {
1306 Status
= Decompress
->GetInfo (
1313 if (!EFI_ERROR (Status
)) {
1314 DecompressedImageBuffer
= NULL
;
1315 DecompressedImageBuffer
= AllocatePool (DestinationSize
);
1316 if (DecompressedImageBuffer
!= NULL
) {
1317 Scratch
= AllocatePool (ScratchSize
);
1318 if (Scratch
!= NULL
) {
1319 Status
= Decompress
->Decompress (
1323 DecompressedImageBuffer
,
1328 if (!EFI_ERROR (Status
)) {
1329 ImageBuffer
= DecompressedImageBuffer
;
1330 ImageLength
= DestinationSize
;
1334 gBS
->FreePool (Scratch
);
1344 // load image and start image
1347 FilePath
= FileDevicePath (NULL
, FileName
);
1349 Status
= gBS
->LoadImage (
1357 if (!EFI_ERROR (Status
)) {
1358 Status
= gBS
->StartImage (ImageHandle
, NULL
, NULL
);
1359 if (!EFI_ERROR (Status
)) {
1363 if (FilePath
!= NULL
) {
1364 gBS
->FreePool (FilePath
);
1368 if (DecompressedImageBuffer
!= NULL
) {
1369 gBS
->FreePool (DecompressedImageBuffer
);
1375 RomOffset
= RomOffset
+ ImageSize
;
1377 } while (((Pcir
->Indicator
& 0x80) == 0x00) && ((RomOffset
- (UINTN
) Rom
) < RomSize
));