OsLoader: Print all extra images

Currently only PreOs and Extra0 image info is printed in boot options
list, this patch prints all of them.

Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
This commit is contained in:
Jiaqing Zhao 2023-09-12 02:49:29 +00:00 committed by Guo Dong
parent 5968cfa919
commit c65cd572d2
4 changed files with 92 additions and 26 deletions

View File

@ -52,4 +52,18 @@ GetBootDeviceNameString (
OS_BOOT_MEDIUM_TYPE DevType
);
/**
Get image type name string by loaded image type
@param[in] ImageType Loaded Image Type
@retval String Return a string when loaded image type is found.
@retval NULL Return NULL if loaded image type is not found.
**/
CHAR8 *
EFIAPI
GetLoadedImageTypeNameString (
LOAD_IMAGE_TYPE ImageType
);
#endif

View File

@ -15,6 +15,7 @@
CHAR8 *mOsBootDeviceName[] = { "SATA", "SD", "MMC", "UFS", "SPI", "USB", "NVME", "MEM" };
CHAR8 *mOsFsTypeName[] = { "FAT", "EXT2", "AUTO", "RAW" };
CHAR8 *mImageTypeName[] = { "Normal", "PreOs", "Misc", "Extra0", "Extra1", "Extra2", "Extra3" };
/**
Get boot option list
@ -81,3 +82,22 @@ GetBootDeviceNameString (
return mOsBootDeviceName[DevType];
}
/**
Get image type name string by loaded image type
@param[in] ImageType Loaded Image Type
@retval String Return a string when loaded image type is found.
@retval NULL Return NULL if loaded image type is not found.
**/
CHAR8 *
EFIAPI
GetLoadedImageTypeNameString (
LOAD_IMAGE_TYPE ImageType
)
{
if (ImageType >= LoadImageTypeMax) {
return NULL;
}
return mImageTypeName[ImageType];
}

View File

@ -383,17 +383,29 @@ GetBootLbaInfo (
**/
VOID
PrintExtraImage (
OS_BOOT_OPTION *BootOption,
UINT8 Flags,
LOAD_IMAGE_TYPE ImageType
)
OS_BOOT_OPTION *BootOption,
UINT8 Flags,
LOAD_IMAGE_TYPE ImageType
)
{
BOOT_IMAGE *BootImage;
BootImage = &BootOption->Image[ImageType];
if ((BootOption->BootFlags & Flags) != 0){
if (BootOption->Image[ImageType].LbaImage.Valid == 1) {
ShellPrint (L" [%x|0x%x]", ImageType, BootOption->Image[ImageType].LbaImage.SwPart,
BootOption->Image[ImageType].LbaImage.LbaAddr);
} else if (BootOption->Image[ImageType].FileName[0] != '\0') {
ShellPrint (L" [%a]", BootOption->Image[ImageType].FileName);
if (BootImage->LbaImage.Valid == 1) {
ShellPrint (L" %6a | %4a | %4x | %a\n",
GetLoadedImageTypeNameString(ImageType),
"RAW",
BootImage->LbaImage.SwPart,
BootImage->LbaImage.LbaAddr
);
} else if (BootImage->FileImage.FileName[0] != '\0') {
ShellPrint (L" %6a | %4a | %4x | %a\n",
GetLoadedImageTypeNameString(ImageType),
GetFsTypeString(BootImage->FileImage.FsType),
BootImage->FileImage.SwPart,
BootImage->FileImage.FileName
);
}
}
}
@ -442,15 +454,19 @@ PrintBootOption (
BootOption->Image[0].LbaImage.LbaAddr \
);
}
//Print Pre-OS image filename
PrintExtraImage (BootOption,BOOT_FLAGS_PREOS,LoadImageTypePreOs);
//Print extra image filename
PrintExtraImage (BootOption,BOOT_FLAGS_EXTRA,LoadImageTypeExtra0);
if (Index == OsBootOptionList->CurrentBoot) {
ShellPrint (L" *Current");
}
ShellPrint (L"\n");
//Print Pre-OS image filename
for (UINT8 Type = LoadImageTypeExtra0; Type < LoadImageTypeMax; Type++) {
PrintExtraImage (BootOption, BOOT_FLAGS_EXTRA, Type);
}
//Print extra image filename
PrintExtraImage (BootOption,BOOT_FLAGS_PREOS,LoadImageTypePreOs);
}
}

View File

@ -16,17 +16,29 @@
**/
VOID
PrintExtraImages (
OS_BOOT_OPTION *BootOption,
UINT8 Flags,
LOAD_IMAGE_TYPE ImageType
)
OS_BOOT_OPTION *BootOption,
UINT8 Flags,
LOAD_IMAGE_TYPE ImageType
)
{
BOOT_IMAGE *BootImage;
BootImage = &BootOption->Image[ImageType];
if ((BootOption->BootFlags & Flags) != 0){
if (BootOption->Image[ImageType].LbaImage.Valid == 1) {
DEBUG ((DEBUG_INFO, " [%x|0x%x]", ImageType, BootOption->Image[ImageType].LbaImage.SwPart,
BootOption->Image[ImageType].LbaImage.LbaAddr));
} else if (BootOption->Image[ImageType].FileName[0] != '\0') {
DEBUG ((DEBUG_INFO, " [%a]", BootOption->Image[ImageType].FileName));
if (BootImage->LbaImage.Valid == 1) {
DEBUG ((DEBUG_INFO, " %6a | %4a | %4x | %a\n",
GetLoadedImageTypeNameString(ImageType),
"RAW",
BootImage->LbaImage.SwPart,
BootImage->LbaImage.LbaAddr
));
} else if (BootImage->FileImage.FileName[0] != '\0') {
DEBUG ((DEBUG_INFO, " %6a | %4a | %4x | %a\n",
GetLoadedImageTypeNameString(ImageType),
GetFsTypeString(BootImage->FileImage.FsType),
BootImage->FileImage.SwPart,
BootImage->FileImage.FileName
));
}
}
}
@ -75,15 +87,19 @@ PrintBootOptions (
BootOption->Image[0].LbaImage.LbaAddr \
));
}
//Print Pre-OS image filename
PrintExtraImages (BootOption,BOOT_FLAGS_PREOS,LoadImageTypePreOs);
//Print extra image filename
PrintExtraImages (BootOption,BOOT_FLAGS_EXTRA,LoadImageTypeExtra0);
if (Index == OsBootOptionList->CurrentBoot) {
DEBUG ((DEBUG_INFO," *Current"));
}
DEBUG ((DEBUG_INFO, "\n"));
//Print Pre-OS image filename
for (UINT8 Type = LoadImageTypeExtra0; Type < LoadImageTypeMax; Type++) {
PrintExtraImages (BootOption, BOOT_FLAGS_EXTRA, Type);
}
//Print extra image filename
PrintExtraImages (BootOption,BOOT_FLAGS_PREOS,LoadImageTypePreOs);
}
}