2 Implementation for PlatformBootManagerLib library class interfaces.
4 Copyright (C) 2015-2016, Red Hat, Inc.
5 Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>
6 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <IndustryStandard/Pci22.h>
13 #include <IndustryStandard/Virtio095.h>
14 #include <Library/BootLogoLib.h>
15 #include <Library/DevicePathLib.h>
16 #include <Library/PcdLib.h>
17 #include <Library/PlatformBmPrintScLib.h>
18 #include <Library/QemuBootOrderLib.h>
19 #include <Library/UefiBootManagerLib.h>
20 #include <Protocol/DevicePath.h>
21 #include <Protocol/FirmwareVolume2.h>
22 #include <Protocol/GraphicsOutput.h>
23 #include <Protocol/LoadedImage.h>
24 #include <Protocol/PciIo.h>
25 #include <Protocol/PciRootBridgeIo.h>
26 #include <Protocol/VirtioDevice.h>
27 #include <Guid/EventGroup.h>
28 #include <Guid/RootBridgesConnectedEventGroup.h>
30 #include "PlatformBm.h"
32 #define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }
37 VENDOR_DEVICE_PATH SerialDxe
;
38 UART_DEVICE_PATH Uart
;
39 VENDOR_DEFINED_DEVICE_PATH TermType
;
40 EFI_DEVICE_PATH_PROTOCOL End
;
41 } PLATFORM_SERIAL_CONSOLE
;
44 #define SERIAL_DXE_FILE_GUID { \
45 0xD3987D4B, 0x971A, 0x435F, \
46 { 0x8C, 0xAF, 0x49, 0x67, 0xEB, 0x62, 0x72, 0x41 } \
49 STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole
= {
51 // VENDOR_DEVICE_PATH SerialDxe
54 { HARDWARE_DEVICE_PATH
, HW_VENDOR_DP
, DP_NODE_LEN (VENDOR_DEVICE_PATH
) },
59 // UART_DEVICE_PATH Uart
62 { MESSAGING_DEVICE_PATH
, MSG_UART_DP
, DP_NODE_LEN (UART_DEVICE_PATH
) },
64 FixedPcdGet64 (PcdUartDefaultBaudRate
), // BaudRate
65 FixedPcdGet8 (PcdUartDefaultDataBits
), // DataBits
66 FixedPcdGet8 (PcdUartDefaultParity
), // Parity
67 FixedPcdGet8 (PcdUartDefaultStopBits
) // StopBits
71 // VENDOR_DEFINED_DEVICE_PATH TermType
75 MESSAGING_DEVICE_PATH
, MSG_VENDOR_DP
,
76 DP_NODE_LEN (VENDOR_DEFINED_DEVICE_PATH
)
79 // Guid to be filled in dynamically
84 // EFI_DEVICE_PATH_PROTOCOL End
87 END_DEVICE_PATH_TYPE
, END_ENTIRE_DEVICE_PATH_SUBTYPE
,
88 DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL
)
95 USB_CLASS_DEVICE_PATH Keyboard
;
96 EFI_DEVICE_PATH_PROTOCOL End
;
97 } PLATFORM_USB_KEYBOARD
;
100 STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard
= {
102 // USB_CLASS_DEVICE_PATH Keyboard
106 MESSAGING_DEVICE_PATH
, MSG_USB_CLASS_DP
,
107 DP_NODE_LEN (USB_CLASS_DEVICE_PATH
)
109 0xFFFF, // VendorId: any
110 0xFFFF, // ProductId: any
111 3, // DeviceClass: HID
112 1, // DeviceSubClass: boot
113 1 // DeviceProtocol: keyboard
117 // EFI_DEVICE_PATH_PROTOCOL End
120 END_DEVICE_PATH_TYPE
, END_ENTIRE_DEVICE_PATH_SUBTYPE
,
121 DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL
)
127 Check if the handle satisfies a particular condition.
129 @param[in] Handle The handle to check.
130 @param[in] ReportText A caller-allocated string passed in for reporting
131 purposes. It must never be NULL.
133 @retval TRUE The condition is satisfied.
134 @retval FALSE Otherwise. This includes the case when the condition could not
135 be fully evaluated due to an error.
139 (EFIAPI
*FILTER_FUNCTION
) (
140 IN EFI_HANDLE Handle
,
141 IN CONST CHAR16
*ReportText
148 @param[in] Handle The handle to process.
149 @param[in] ReportText A caller-allocated string passed in for reporting
150 purposes. It must never be NULL.
154 (EFIAPI
*CALLBACK_FUNCTION
) (
155 IN EFI_HANDLE Handle
,
156 IN CONST CHAR16
*ReportText
160 Locate all handles that carry the specified protocol, filter them with a
161 callback function, and pass each handle that passes the filter to another
164 @param[in] ProtocolGuid The protocol to look for.
166 @param[in] Filter The filter function to pass each handle to. If this
167 parameter is NULL, then all handles are processed.
169 @param[in] Process The callback function to pass each handle to that
175 IN EFI_GUID
*ProtocolGuid
,
176 IN FILTER_FUNCTION Filter OPTIONAL
,
177 IN CALLBACK_FUNCTION Process
185 Status
= gBS
->LocateHandleBuffer (ByProtocol
, ProtocolGuid
,
186 NULL
/* SearchKey */, &NoHandles
, &Handles
);
187 if (EFI_ERROR (Status
)) {
189 // This is not an error, just an informative condition.
191 DEBUG ((EFI_D_VERBOSE
, "%a: %g: %r\n", __FUNCTION__
, ProtocolGuid
,
196 ASSERT (NoHandles
> 0);
197 for (Idx
= 0; Idx
< NoHandles
; ++Idx
) {
198 CHAR16
*DevicePathText
;
199 STATIC CHAR16 Fallback
[] = L
"<device path unavailable>";
202 // The ConvertDevicePathToText() function handles NULL input transparently.
204 DevicePathText
= ConvertDevicePathToText (
205 DevicePathFromHandle (Handles
[Idx
]),
206 FALSE
, // DisplayOnly
207 FALSE
// AllowShortcuts
209 if (DevicePathText
== NULL
) {
210 DevicePathText
= Fallback
;
213 if (Filter
== NULL
|| Filter (Handles
[Idx
], DevicePathText
)) {
214 Process (Handles
[Idx
], DevicePathText
);
217 if (DevicePathText
!= Fallback
) {
218 FreePool (DevicePathText
);
221 gBS
->FreePool (Handles
);
226 This FILTER_FUNCTION checks if a handle corresponds to a PCI display device.
232 IN EFI_HANDLE Handle
,
233 IN CONST CHAR16
*ReportText
237 EFI_PCI_IO_PROTOCOL
*PciIo
;
240 Status
= gBS
->HandleProtocol (Handle
, &gEfiPciIoProtocolGuid
,
242 if (EFI_ERROR (Status
)) {
244 // This is not an error worth reporting.
249 Status
= PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint32
, 0 /* Offset */,
250 sizeof Pci
/ sizeof (UINT32
), &Pci
);
251 if (EFI_ERROR (Status
)) {
252 DEBUG ((EFI_D_ERROR
, "%a: %s: %r\n", __FUNCTION__
, ReportText
, Status
));
256 return IS_PCI_DISPLAY (&Pci
);
261 This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
262 the VIRTIO_DEVICE_PROTOCOL level.
268 IN EFI_HANDLE Handle
,
269 IN CONST CHAR16
*ReportText
273 VIRTIO_DEVICE_PROTOCOL
*VirtIo
;
275 Status
= gBS
->HandleProtocol (Handle
, &gVirtioDeviceProtocolGuid
,
277 if (EFI_ERROR (Status
)) {
280 return (BOOLEAN
)(VirtIo
->SubSystemDeviceId
==
281 VIRTIO_SUBSYSTEM_ENTROPY_SOURCE
);
286 This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
287 the EFI_PCI_IO_PROTOCOL level.
293 IN EFI_HANDLE Handle
,
294 IN CONST CHAR16
*ReportText
298 EFI_PCI_IO_PROTOCOL
*PciIo
;
305 Status
= gBS
->HandleProtocol (Handle
, &gEfiPciIoProtocolGuid
,
307 if (EFI_ERROR (Status
)) {
312 // Read and check VendorId.
314 Status
= PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint16
, PCI_VENDOR_ID_OFFSET
,
316 if (EFI_ERROR (Status
)) {
319 if (VendorId
!= VIRTIO_VENDOR_ID
) {
324 // Read DeviceId and RevisionId.
326 Status
= PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint16
, PCI_DEVICE_ID_OFFSET
,
328 if (EFI_ERROR (Status
)) {
331 Status
= PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint8
, PCI_REVISION_ID_OFFSET
,
333 if (EFI_ERROR (Status
)) {
338 // From DeviceId and RevisionId, determine whether the device is a
339 // modern-only Virtio 1.0 device. In case of Virtio 1.0, DeviceId can
340 // immediately be restricted to VIRTIO_SUBSYSTEM_ENTROPY_SOURCE, and
341 // SubsystemId will only play a sanity-check role. Otherwise, DeviceId can
342 // only be sanity-checked, and SubsystemId will decide.
344 if (DeviceId
== 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE
&&
345 RevisionId
>= 0x01) {
347 } else if (DeviceId
>= 0x1000 && DeviceId
<= 0x103F && RevisionId
== 0x00) {
354 // Read and check SubsystemId as dictated by Virtio10.
356 Status
= PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint16
,
357 PCI_SUBSYSTEM_ID_OFFSET
, 1, &SubsystemId
);
358 if (EFI_ERROR (Status
)) {
361 if (Virtio10
&& SubsystemId
>= 0x40) {
364 if (!Virtio10
&& SubsystemId
== VIRTIO_SUBSYSTEM_ENTROPY_SOURCE
) {
370 DEBUG ((DEBUG_ERROR
, "%a: %s: %r\n", __FUNCTION__
, ReportText
, Status
));
376 This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking
377 the matching driver to produce all first-level child handles.
383 IN EFI_HANDLE Handle
,
384 IN CONST CHAR16
*ReportText
389 Status
= gBS
->ConnectController (
390 Handle
, // ControllerHandle
391 NULL
, // DriverImageHandle
392 NULL
, // RemainingDevicePath -- produce all children
395 DEBUG ((EFI_ERROR (Status
) ? EFI_D_ERROR
: EFI_D_VERBOSE
, "%a: %s: %r\n",
396 __FUNCTION__
, ReportText
, Status
));
401 This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the
402 handle, and adds it to ConOut and ErrOut.
408 IN EFI_HANDLE Handle
,
409 IN CONST CHAR16
*ReportText
413 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
415 DevicePath
= DevicePathFromHandle (Handle
);
416 if (DevicePath
== NULL
) {
417 DEBUG ((EFI_D_ERROR
, "%a: %s: handle %p: device path not found\n",
418 __FUNCTION__
, ReportText
, Handle
));
422 Status
= EfiBootManagerUpdateConsoleVariable (ConOut
, DevicePath
, NULL
);
423 if (EFI_ERROR (Status
)) {
424 DEBUG ((EFI_D_ERROR
, "%a: %s: adding to ConOut: %r\n", __FUNCTION__
,
425 ReportText
, Status
));
429 Status
= EfiBootManagerUpdateConsoleVariable (ErrOut
, DevicePath
, NULL
);
430 if (EFI_ERROR (Status
)) {
431 DEBUG ((EFI_D_ERROR
, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__
,
432 ReportText
, Status
));
436 DEBUG ((EFI_D_VERBOSE
, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__
,
442 PlatformRegisterFvBootOption (
450 EFI_BOOT_MANAGER_LOAD_OPTION NewOption
;
451 EFI_BOOT_MANAGER_LOAD_OPTION
*BootOptions
;
452 UINTN BootOptionCount
;
453 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode
;
454 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
455 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
457 Status
= gBS
->HandleProtocol (
459 &gEfiLoadedImageProtocolGuid
,
460 (VOID
**) &LoadedImage
462 ASSERT_EFI_ERROR (Status
);
464 EfiInitializeFwVolDevicepathNode (&FileNode
, FileGuid
);
465 DevicePath
= DevicePathFromHandle (LoadedImage
->DeviceHandle
);
466 ASSERT (DevicePath
!= NULL
);
467 DevicePath
= AppendDevicePathNode (
469 (EFI_DEVICE_PATH_PROTOCOL
*) &FileNode
471 ASSERT (DevicePath
!= NULL
);
473 Status
= EfiBootManagerInitializeLoadOption (
475 LoadOptionNumberUnassigned
,
483 ASSERT_EFI_ERROR (Status
);
484 FreePool (DevicePath
);
486 BootOptions
= EfiBootManagerGetLoadOptions (
487 &BootOptionCount
, LoadOptionTypeBoot
490 OptionIndex
= EfiBootManagerFindLoadOption (
491 &NewOption
, BootOptions
, BootOptionCount
494 if (OptionIndex
== -1) {
495 Status
= EfiBootManagerAddLoadOptionVariable (&NewOption
, MAX_UINTN
);
496 ASSERT_EFI_ERROR (Status
);
498 EfiBootManagerFreeLoadOption (&NewOption
);
499 EfiBootManagerFreeLoadOptions (BootOptions
, BootOptionCount
);
504 Remove all MemoryMapped(...)/FvFile(...) and Fv(...)/FvFile(...) boot options
505 whose device paths do not resolve exactly to an FvFile in the system.
507 This removes any boot options that point to binaries built into the firmware
508 and have become stale due to any of the following:
509 - FvMain's base address or size changed (historical),
510 - FvMain's FvNameGuid changed,
511 - the FILE_GUID of the pointed-to binary changed,
512 - the referenced binary is no longer built into the firmware.
514 EfiBootManagerFindLoadOption() used in PlatformRegisterFvBootOption() only
515 avoids exact duplicates.
519 RemoveStaleFvFileOptions (
523 EFI_BOOT_MANAGER_LOAD_OPTION
*BootOptions
;
524 UINTN BootOptionCount
;
527 BootOptions
= EfiBootManagerGetLoadOptions (&BootOptionCount
,
530 for (Index
= 0; Index
< BootOptionCount
; ++Index
) {
531 EFI_DEVICE_PATH_PROTOCOL
*Node1
, *Node2
, *SearchNode
;
536 // If the device path starts with neither MemoryMapped(...) nor Fv(...),
537 // then keep the boot option.
539 Node1
= BootOptions
[Index
].FilePath
;
540 if (!(DevicePathType (Node1
) == HARDWARE_DEVICE_PATH
&&
541 DevicePathSubType (Node1
) == HW_MEMMAP_DP
) &&
542 !(DevicePathType (Node1
) == MEDIA_DEVICE_PATH
&&
543 DevicePathSubType (Node1
) == MEDIA_PIWG_FW_VOL_DP
)) {
548 // If the second device path node is not FvFile(...), then keep the boot
551 Node2
= NextDevicePathNode (Node1
);
552 if (DevicePathType (Node2
) != MEDIA_DEVICE_PATH
||
553 DevicePathSubType (Node2
) != MEDIA_PIWG_FW_FILE_DP
) {
558 // Locate the Firmware Volume2 protocol instance that is denoted by the
559 // boot option. If this lookup fails (i.e., the boot option references a
560 // firmware volume that doesn't exist), then we'll proceed to delete the
564 Status
= gBS
->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid
,
565 &SearchNode
, &FvHandle
);
567 if (!EFI_ERROR (Status
)) {
569 // The firmware volume was found; now let's see if it contains the FvFile
570 // identified by GUID.
572 EFI_FIRMWARE_VOLUME2_PROTOCOL
*FvProtocol
;
573 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFileNode
;
575 EFI_FV_FILETYPE FoundType
;
576 EFI_FV_FILE_ATTRIBUTES FileAttributes
;
577 UINT32 AuthenticationStatus
;
579 Status
= gBS
->HandleProtocol (FvHandle
, &gEfiFirmwareVolume2ProtocolGuid
,
580 (VOID
**)&FvProtocol
);
581 ASSERT_EFI_ERROR (Status
);
583 FvFileNode
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*)Node2
;
585 // Buffer==NULL means we request metadata only: BufferSize, FoundType,
588 Status
= FvProtocol
->ReadFile (
590 &FvFileNode
->FvFileName
, // NameGuid
595 &AuthenticationStatus
597 if (!EFI_ERROR (Status
)) {
599 // The FvFile was found. Keep the boot option.
606 // Delete the boot option.
608 Status
= EfiBootManagerDeleteLoadOptionVariable (
609 BootOptions
[Index
].OptionNumber
, LoadOptionTypeBoot
);
611 CHAR16
*DevicePathString
;
613 DevicePathString
= ConvertDevicePathToText(BootOptions
[Index
].FilePath
,
616 EFI_ERROR (Status
) ? EFI_D_WARN
: EFI_D_VERBOSE
,
617 "%a: removing stale Boot#%04x %s: %r\n",
619 (UINT32
)BootOptions
[Index
].OptionNumber
,
620 DevicePathString
== NULL
? L
"<unavailable>" : DevicePathString
,
623 if (DevicePathString
!= NULL
) {
624 FreePool (DevicePathString
);
629 EfiBootManagerFreeLoadOptions (BootOptions
, BootOptionCount
);
635 PlatformRegisterOptionsAndKeys (
643 EFI_BOOT_MANAGER_LOAD_OPTION BootOption
;
646 // Register ENTER as CONTINUE key
648 Enter
.ScanCode
= SCAN_NULL
;
649 Enter
.UnicodeChar
= CHAR_CARRIAGE_RETURN
;
650 Status
= EfiBootManagerRegisterContinueKeyOption (0, &Enter
, NULL
);
651 ASSERT_EFI_ERROR (Status
);
654 // Map F2 and ESC to Boot Manager Menu
656 F2
.ScanCode
= SCAN_F2
;
657 F2
.UnicodeChar
= CHAR_NULL
;
658 Esc
.ScanCode
= SCAN_ESC
;
659 Esc
.UnicodeChar
= CHAR_NULL
;
660 Status
= EfiBootManagerGetBootManagerMenu (&BootOption
);
661 ASSERT_EFI_ERROR (Status
);
662 Status
= EfiBootManagerAddKeyOptionVariable (
663 NULL
, (UINT16
) BootOption
.OptionNumber
, 0, &F2
, NULL
665 ASSERT (Status
== EFI_SUCCESS
|| Status
== EFI_ALREADY_STARTED
);
666 Status
= EfiBootManagerAddKeyOptionVariable (
667 NULL
, (UINT16
) BootOption
.OptionNumber
, 0, &Esc
, NULL
669 ASSERT (Status
== EFI_SUCCESS
|| Status
== EFI_ALREADY_STARTED
);
674 // BDS Platform Functions
677 Do the platform init, can be customized by OEM/IBV
678 Possible things that can be done in PlatformBootManagerBeforeConsole:
679 > Update console variable: 1. include hot-plug devices;
680 > 2. Clear ConIn and add SOL for AMT
681 > Register new Driver#### or Boot####
682 > Register new Key####: e.g.: F12
683 > Signal ReadyToLock event
684 > Authentication action: 1. connect Auth devices;
685 > 2. Identify auto logon user.
689 PlatformBootManagerBeforeConsole (
693 RETURN_STATUS PcdStatus
;
696 // Signal EndOfDxe PI Event
698 EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid
);
701 // Dispatch deferred images after EndOfDxe event.
703 EfiBootManagerDispatchDeferredImages ();
706 // Locate the PCI root bridges and make the PCI bus driver connect each,
707 // non-recursively. This will produce a number of child handles with PciIo on
710 FilterAndProcess (&gEfiPciRootBridgeIoProtocolGuid
, NULL
, Connect
);
713 // Signal the ACPI platform driver that it can download QEMU ACPI tables.
715 EfiEventGroupSignal (&gRootBridgesConnectedEventGroupGuid
);
718 // Find all display class PCI devices (using the handles from the previous
719 // step), and connect them non-recursively. This should produce a number of
720 // child handles with GOPs on them.
722 FilterAndProcess (&gEfiPciIoProtocolGuid
, IsPciDisplay
, Connect
);
725 // Now add the device path of all handles with GOP on them to ConOut and
728 FilterAndProcess (&gEfiGraphicsOutputProtocolGuid
, NULL
, AddOutput
);
731 // Add the hardcoded short-form USB keyboard device path to ConIn.
733 EfiBootManagerUpdateConsoleVariable (ConIn
,
734 (EFI_DEVICE_PATH_PROTOCOL
*)&mUsbKeyboard
, NULL
);
737 // Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
739 CopyGuid (&mSerialConsole
.TermType
.Guid
,
740 PcdGetPtr (PcdTerminalTypeGuidBuffer
));
741 EfiBootManagerUpdateConsoleVariable (ConIn
,
742 (EFI_DEVICE_PATH_PROTOCOL
*)&mSerialConsole
, NULL
);
743 EfiBootManagerUpdateConsoleVariable (ConOut
,
744 (EFI_DEVICE_PATH_PROTOCOL
*)&mSerialConsole
, NULL
);
745 EfiBootManagerUpdateConsoleVariable (ErrOut
,
746 (EFI_DEVICE_PATH_PROTOCOL
*)&mSerialConsole
, NULL
);
749 // Set the front page timeout from the QEMU configuration.
751 PcdStatus
= PcdSet16S (PcdPlatformBootTimeOut
,
752 GetFrontPageTimeoutFromQemu ());
753 ASSERT_RETURN_ERROR (PcdStatus
);
756 // Register platform-specific boot options and keyboard shortcuts.
758 PlatformRegisterOptionsAndKeys ();
761 // At this point, VIRTIO_DEVICE_PROTOCOL instances exist only for Virtio MMIO
762 // transports. Install EFI_RNG_PROTOCOL instances on Virtio MMIO RNG devices.
764 FilterAndProcess (&gVirtioDeviceProtocolGuid
, IsVirtioRng
, Connect
);
767 // Install both VIRTIO_DEVICE_PROTOCOL and (dependent) EFI_RNG_PROTOCOL
768 // instances on Virtio PCI RNG devices.
770 FilterAndProcess (&gEfiPciIoProtocolGuid
, IsVirtioPciRng
, Connect
);
774 Do the platform specific action after the console is ready
775 Possible things that can be done in PlatformBootManagerAfterConsole:
776 > Console post action:
777 > Dynamically switch output mode from 100x31 to 80x25 for certain scenario
778 > Signal console ready platform customized event
779 > Run diagnostics like memory testing
780 > Connect certain devices
781 > Dispatch additional option roms
782 > Special boot: e.g.: USB boot, enter UI
786 PlatformBootManagerAfterConsole (
790 RETURN_STATUS Status
;
793 // Show the splash screen.
795 BootLogoEnableLogo ();
798 // Process QEMU's -kernel command line option. The kernel booted this way
799 // will receive ACPI tables: in PlatformBootManagerBeforeConsole(), we
800 // connected any and all PCI root bridges, and then signaled the ACPI
803 TryRunningQemuKernel ();
806 // Connect the purported boot devices.
808 Status
= ConnectDevicesFromQemu ();
809 if (RETURN_ERROR (Status
)) {
811 // Connect the rest of the devices.
813 EfiBootManagerConnectAll ();
817 // Enumerate all possible boot options, then filter and reorder them based on
818 // the QEMU configuration.
820 EfiBootManagerRefreshAllBootOption ();
823 // Register UEFI Shell
825 PlatformRegisterFvBootOption (
826 &gUefiShellFileGuid
, L
"EFI Internal Shell", LOAD_OPTION_ACTIVE
829 RemoveStaleFvFileOptions ();
830 SetBootOrderFromQemu ();
832 PlatformBmPrintScRegisterHandler ();
836 This function is called each second during the boot manager waits the
839 @param TimeoutRemain The remaining timeout.
843 PlatformBootManagerWaitCallback (
847 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black
;
848 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White
;
851 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
853 Black
.Raw
= 0x00000000;
854 White
.Raw
= 0x00FFFFFF;
856 BootLogoUpdateProgress (
859 L
"Start boot option",
861 (Timeout
- TimeoutRemain
) * 100 / Timeout
,
867 The function is called when no boot option could be launched,
868 including platform recovery options and options pointing to applications
869 built into firmware volumes.
871 If this function returns, BDS attempts to enter an infinite loop.
875 PlatformBootManagerUnableToBoot (
881 EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu
;
885 // BootManagerMenu doesn't contain the correct information when return status
888 Status
= EfiBootManagerGetBootManagerMenu (&BootManagerMenu
);
889 if (EFI_ERROR (Status
)) {
893 // Normally BdsDxe does not print anything to the system console, but this is
894 // a last resort -- the end-user will likely not see any DEBUG messages
895 // logged in this situation.
897 // AsciiPrint() will NULL-check gST->ConOut internally. We check gST->ConIn
898 // here to see if it makes sense to request and wait for a keypress.
900 if (gST
->ConIn
!= NULL
) {
902 "%a: No bootable option or device was found.\n"
903 "%a: Press any key to enter the Boot Manager Menu.\n",
907 Status
= gBS
->WaitForEvent (1, &gST
->ConIn
->WaitForKey
, &Index
);
908 ASSERT_EFI_ERROR (Status
);
912 // Drain any queued keys.
914 while (!EFI_ERROR (gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
))) {
916 // just throw away Key
922 EfiBootManagerBoot (&BootManagerMenu
);