3.5.1.2 Non-removable Media Boot Behavior If a system does not support boot option recovery, then default boot processing will consist of the boot manager searching non-removable media that supports the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL or EFI_BLOCK_IO_PROTOCOL. In general the boot manager will search all candidate media but platform policy may optionally limit the search to a subset of all possible devices connected to a given system; choices for such policy limits are implementation specific. If the device supports the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL layered on an EFI system partition, then the system firmware will attempt to boot from the media by executing a default file name in the form \EFI\BOOT\BOOT{machine type short-name}.EFI.
3.4.3 Boot Option Variables Default Boot Behavior If system firmware supports boot option recovery as described in Section 3.4, system firmware must include a PlatformRecovery#### variable specifying a short-form File Path Media Device Path (see Table 3.1.2) containing the platform default file path for removable media (see Table 12). It is recommended for maximal compatibility with prior versions of this specification that this entry be the first such variable, though it may be at any position within the list. Sunny, I guess the wording in 3.4.3 may cause you confused. 3.4.1.2 (Non removable Media Boot Behavior) also says that \EFI\BOOT\BOOTIA32.efi should be tried. So for "maximal compatibility with prior versions", we need to try both non-removable and removable medias. Regards, Ray -----Original Message----- From: Wang, Sunny (HPS SW) [mailto:sunnyw...@hpe.com] Sent: Tuesday, November 3, 2015 5:56 PM To: Ni, Ruiyu <ruiyu...@intel.com>; edk2-devel@lists.01.org Cc: Dong, Eric <eric.d...@intel.com>; Wang, Sunny (HPS SW) <sunnyw...@hpe.com>; El-Haj-Mahmoud, Samer <samer.el-haj-mahm...@hpe.com> Subject: RE: [edk2] [Patch 06/11] MdeModulePkg: Support to expand File device path Hi Ray, I saw the following checks in BmExpandFileDevicePath. + if ((MediaType == 0 && BlockIo != NULL && BlockIo->Media->RemovableMedia) || + (MediaType == 1 && BlockIo != NULL && !BlockIo->Media->RemovableMedia) || + (MediaType == 2 && BlockIo == NULL) Does it mean launching PlatformRecovery option will try to find default boot file from all kinds of media (all simple SimpleFileSystem handles) rather than only removable media? According to UEFI 2.5 section 3.4.3 Boot Option Variables Default Boot Behavior, It seems we should try to find out default boot file only from removable media. Could you check this? Regards, Sunny Wang -----Original Message----- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ruiyu Ni Sent: Monday, November 02, 2015 7:34 PM To: edk2-devel@lists.01.org Cc: Ruiyu Ni; Eric Dong Subject: [edk2] [Patch 06/11] MdeModulePkg: Support to expand File device path To support platform recovery, File device path expanding capability is added. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu...@intel.com> Cc: Eric Dong <eric.d...@intel.com> --- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 76 ++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index 8f14cf6..8b7c7c2 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -1073,6 +1073,76 @@ BmExpandUsbDevicePath ( } /** + Expand File-path device path node to be full device path in platform. + + @param FilePath The device path pointing to a load option. + It could be a short-form device path. + @param FullPath Return the full device path of the load option after + short-form device path expanding. + Caller is responsible to free it. + @param FileSize Return the load option size. + + @return The load option buffer. Caller is responsible to free the memory. +**/ +VOID * +BmExpandFileDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *FilePath, + OUT EFI_DEVICE_PATH_PROTOCOL **FullPath, + OUT UINTN *FileSize + ) +{ + EFI_STATUS Status; + UINTN Index; + UINTN HandleCount; + EFI_HANDLE *Handles; + EFI_BLOCK_IO_PROTOCOL *BlockIo; + UINTN MediaType; + EFI_DEVICE_PATH_PROTOCOL *FullDevicePath; + VOID *FileBuffer; + UINT32 AuthenticationStatus; + + EfiBootManagerConnectAll (); + Status = gBS->LocateHandleBuffer (ByProtocol, + &gEfiSimpleFileSystemProtocolGuid, NULL, &HandleCount, &Handles); if (EFI_ERROR (Status)) { + HandleCount = 0; + Handles = NULL; + } + + // + // Enumerate all removable media devices followed by all fixed media devices, + // followed by media devices which don't layer on block io. + // + for (MediaType = 0; MediaType < 3; MediaType++) { + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->HandleProtocol (Handles[Index], &gEfiBlockIoProtocolGuid, (VOID *) &BlockIo); + if (EFI_ERROR (Status)) { + BlockIo = NULL; + } + if ((MediaType == 0 && BlockIo != NULL && BlockIo->Media->RemovableMedia) || + (MediaType == 1 && BlockIo != NULL && !BlockIo->Media->RemovableMedia) || + (MediaType == 2 && BlockIo == NULL) + ) { + FullDevicePath = AppendDevicePath (DevicePathFromHandle (Handles[Index]), FilePath); + FileBuffer = GetFileBufferByFilePath (TRUE, FullDevicePath, FileSize, &AuthenticationStatus); + if (FileBuffer != NULL) { + *FullPath = FullDevicePath; + FreePool (Handles); + return FileBuffer; + } + FreePool (FullDevicePath); + } + } + } + + if (Handles != NULL) { + FreePool (Handles); + } + + *FullPath = NULL; + return NULL; +} + +/** Save the partition DevicePath to the CachedDevicePath as the first instance. @param CachedDevicePath The device path cache. @@ -1473,6 +1543,12 @@ BmGetLoadOptionBuffer ( // Expand the Harddrive device path // return BmExpandPartitionDevicePath (FilePath, FullPath, FileSize); + } else if ((DevicePathType (FilePath) == MEDIA_DEVICE_PATH) && + (DevicePathSubType (FilePath) == MEDIA_FILEPATH_DP)) { + // + // Expand the File-path device path + // + return BmExpandFileDevicePath (FilePath, FullPath, FileSize); } else { for (Node = FilePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) { if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && -- 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel