Fix the boot option
When PreOS is configured from OS boot option data, the common function FillBootOptionListFromCfgData () need update it to correct boot option image LoadImageTypePreOs. Similarly when extra image is specified, need update to extra image. Update ImageType value and fix an image load issue for RTCM. Signed-off-by: Guo Dong <guo.dong@intel.com>
This commit is contained in:
parent
923d27ac81
commit
d4f1efd8d6
|
@ -822,14 +822,15 @@ LoadBootImages (
|
|||
LoadedImagesInfo->Signature = LOADED_IMAGES_INFO_SIGNATURE;
|
||||
|
||||
for (Index = 0; Index < LoadImageTypeMax; Index++) {
|
||||
if ((Index == LoadImageTypePreOs) && !(BootFlags & BOOT_FLAGS_PREOS)) {
|
||||
if ((Index == LoadImageTypePreOs) && ((BootFlags & BOOT_FLAGS_PREOS) == 0)) {
|
||||
continue;
|
||||
}
|
||||
if (Index == LoadImageTypeMisc) {
|
||||
continue;
|
||||
}
|
||||
if ((Index >= LoadImageTypeExtra0) && !(BootFlags & BOOT_FLAGS_EXTRA)) {
|
||||
if (!BootImage[Index].LbaImage.Valid) {
|
||||
|
||||
if (Index >= LoadImageTypeExtra0) {
|
||||
if (((BootFlags & BOOT_FLAGS_EXTRA) == 0) || (BootImage[Index].LbaImage.Valid == 0)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -853,7 +854,7 @@ LoadBootImages (
|
|||
Status = GetBootImageFromRawPartition (OsBootOption, LoadedImage);
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "LoadBootImage ImageType-%d Image\n", Index));
|
||||
DEBUG ((DEBUG_INFO, "LoadBootImage ImageType-%d %r\n", Index, Status));
|
||||
LoadedImagesInfo->LoadedImageList[Index] = LoadedImage;
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# Slim Bootloader Platform CFGDATA Template File.
|
||||
#
|
||||
# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
##
|
||||
|
@ -18,10 +18,12 @@ BOOT_OPTION_TMPL: >
|
|||
- ImageType_$(1) :
|
||||
name : Image Type
|
||||
type : Combo
|
||||
option : 0:Default, 1:Android, 2:ClearLinux, 3:Acrn, 4:Fastboot, 0xFE:Addendum, 0xFF:Not used
|
||||
option : 0:Default, 1:Android, 2:ClearLinux, 3:Acrn, 4:Fastboot, 0x1E:Extra image, 0x9E:PreOS image, 0xFF:Not used
|
||||
help : >
|
||||
Specify boot image type.
|
||||
Specially 'Addendum' indicates this option is not a standalone boot option. Instead, it provides additional information for the previous boot option.
|
||||
Extra and PreOS image type indicates this option is not a standalone boot option. Instead, it provides additional information for the previous boot option.
|
||||
Extra image means load and run extra image before normal OS image. The extra image will return to SBL and SBL will continue run normal OS.
|
||||
PreOs image means load and run PreOS image before normal OS image. SBL prepares normal OS info and passes to PreOS so the PreOs will not return to SBL.
|
||||
'Not used' indicates this option will be ignored.
|
||||
length : 0x01
|
||||
value : $(2)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/** @file
|
||||
|
||||
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
@ -18,8 +18,8 @@
|
|||
#include <Library/SpiFlashLib.h>
|
||||
#include <Library/CryptoLib.h>
|
||||
|
||||
#define IMAGE_TYPE_ADDENDUM 0xFE
|
||||
#define IMAGE_TYPE_NOT_USED 0xFF
|
||||
#define IMAGE_TYPE_ADDENDUM 0x1E
|
||||
#define IMAGE_TYPE_NOT_USED 0x1F
|
||||
|
||||
#define NATIVE_PSTATE_LATENCY 10
|
||||
#define PSTATE_BM_LATENCY 10
|
||||
|
@ -62,7 +62,6 @@ FillBootOptionListFromCfgData (
|
|||
OS_BOOT_OPTION *BootOption;
|
||||
OS_BOOT_OPTION *BootOptionCfgData;
|
||||
UINT8 PrevBootOptionIndex;
|
||||
UINT8 UpdateFlag;
|
||||
UINTN ImageIdx;
|
||||
UINT32 Idx;
|
||||
UINT64 Lba;
|
||||
|
@ -82,43 +81,43 @@ FillBootOptionListFromCfgData (
|
|||
continue;
|
||||
}
|
||||
|
||||
UpdateFlag = 0;
|
||||
if (BootOptionCfgData->ImageType == IMAGE_TYPE_ADDENDUM) {
|
||||
// This entry is an addendum for previous boot option entry
|
||||
if (ImageIdx < ARRAY_SIZE(BootOption->Image)) {
|
||||
UpdateFlag = 2;
|
||||
BootOption = &OsBootOptionList->OsBootOption[PrevBootOptionIndex];
|
||||
BootOption = &OsBootOptionList->OsBootOption[PrevBootOptionIndex];
|
||||
if (BootOptionCfgData->PreOsImageType < MAX_EXTRA_IMAGE_NUM) {
|
||||
// extra image addendum
|
||||
ImageIdx = LoadImageTypeExtra0 + BootOptionCfgData->PreOsImageType;
|
||||
} else {
|
||||
// PreOS addendum
|
||||
ImageIdx = LoadImageTypePreOs;
|
||||
}
|
||||
} else {
|
||||
// CFGDATA has short structure to save size on flash
|
||||
// Need to translate the short format to OS_BOOT_OPTION format
|
||||
UpdateFlag = 1;
|
||||
ImageIdx = 0;
|
||||
BootOption = &OsBootOptionList->OsBootOption[OsBootOptionList->OsBootOptionCount];
|
||||
CopyMem (BootOption, BootOptionCfgData, OFFSET_OF (OS_BOOT_OPTION, Image[0]));
|
||||
}
|
||||
|
||||
if (UpdateFlag > 0) {
|
||||
StrPtr = (CHAR8 *)BootOptionCfgData->Image[0].FileName;
|
||||
// Use either LBA or filename. '#' indicates it is LBA string.
|
||||
if ((StrPtr[0] == '#') && (AsciiStrHexToUint64S (StrPtr + 1, NULL, &Lba) == RETURN_SUCCESS)) {
|
||||
BootOption->Image[ImageIdx].LbaImage.Valid = 1;
|
||||
BootOption->Image[ImageIdx].LbaImage.SwPart = BootOptionCfgData->SwPart;
|
||||
// LBA should be defined as 64bit.
|
||||
// Will remove the typecast when the structure is fixed.
|
||||
BootOption->Image[ImageIdx].LbaImage.LbaAddr = (UINT32)Lba;
|
||||
} else {
|
||||
CopyMem (BootOption->Image[ImageIdx].FileName, BootOptionCfgData->Image[0].FileName,
|
||||
sizeof (BootOption->Image[ImageIdx].FileName));
|
||||
StrPtr = (CHAR8 *)BootOptionCfgData->Image[0].FileName;
|
||||
// Use either LBA or filename. '#' indicates it is LBA string.
|
||||
if ((StrPtr[0] == '#') && (AsciiStrHexToUint64S (StrPtr + 1, NULL, &Lba) == RETURN_SUCCESS)) {
|
||||
BootOption->Image[ImageIdx].LbaImage.Valid = 1;
|
||||
BootOption->Image[ImageIdx].LbaImage.SwPart = BootOptionCfgData->SwPart;
|
||||
// LBA should be defined as 64bit.
|
||||
// Will remove the typecast when the structure is fixed.
|
||||
BootOption->Image[ImageIdx].LbaImage.LbaAddr = (UINT32)Lba;
|
||||
} else {
|
||||
CopyMem (BootOption->Image[ImageIdx].FileName, BootOptionCfgData->Image[0].FileName,
|
||||
sizeof (BootOption->Image[ImageIdx].FileName));
|
||||
}
|
||||
|
||||
if (BootOptionCfgData->ImageType != IMAGE_TYPE_ADDENDUM) {
|
||||
PrevBootOptionIndex = OsBootOptionList->OsBootOptionCount;
|
||||
OsBootOptionList->OsBootOptionCount++;
|
||||
if (OsBootOptionList->OsBootOptionCount >= PcdGet32 (PcdOsBootOptionNumber)) {
|
||||
break;
|
||||
}
|
||||
if (UpdateFlag == 1) {
|
||||
PrevBootOptionIndex = OsBootOptionList->OsBootOptionCount;
|
||||
OsBootOptionList->OsBootOptionCount++;
|
||||
if (OsBootOptionList->OsBootOptionCount >= PcdGet32 (PcdOsBootOptionNumber)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ImageIdx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue