IntelSiliconPkg/SpiFvbService: Add support for VariableFlashInfoLib
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3478 Adds support for getting the variable flash information from VariableFlashInfoLib. This library abstracts the source of flash information so platforms could expect the information to come from a different source in the library implementation than the PCDs previously used as the information source in this module. In particular, the library allows Standalone MM platforms to dynamically pass the information behind the library API. Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Isaac Oram <isaac.w.oram@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Sai Chaganty <rangasai.v.chaganty@intel.com> Reviewed-by: Isaac Oram <isaac.w.oram@intel.com>
This commit is contained in:
Родитель
b7bd9c41f6
Коммит
81e0246c61
|
@ -3,6 +3,7 @@
|
||||||
These data is intent to decouple FVB driver with FV header.
|
These data is intent to decouple FVB driver with FV header.
|
||||||
|
|
||||||
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) Microsoft Corporation.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -11,51 +12,92 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
#define FIRMWARE_BLOCK_SIZE 0x10000
|
#define FIRMWARE_BLOCK_SIZE 0x10000
|
||||||
#define FVB_MEDIA_BLOCK_SIZE FIRMWARE_BLOCK_SIZE
|
#define FVB_MEDIA_BLOCK_SIZE FIRMWARE_BLOCK_SIZE
|
||||||
|
|
||||||
#define NV_STORAGE_BASE_ADDRESS FixedPcdGet32(PcdFlashNvStorageVariableBase)
|
|
||||||
#define SYSTEM_NV_BLOCK_NUM ((FixedPcdGet32(PcdFlashNvStorageVariableSize)+ FixedPcdGet32(PcdFlashNvStorageFtwWorkingSize) + FixedPcdGet32(PcdFlashNvStorageFtwSpareSize))/ FVB_MEDIA_BLOCK_SIZE)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
EFI_PHYSICAL_ADDRESS BaseAddress;
|
EFI_PHYSICAL_ADDRESS BaseAddress;
|
||||||
EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
|
EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
|
||||||
EFI_FV_BLOCK_MAP_ENTRY End[1];
|
EFI_FV_BLOCK_MAP_ENTRY End[1];
|
||||||
} EFI_FVB2_MEDIA_INFO;
|
} EFI_FVB2_MEDIA_INFO;
|
||||||
|
|
||||||
//
|
/**
|
||||||
// This data structure contains a template of all correct FV headers, which is used to restore
|
Returns FVB media information for NV variable storage.
|
||||||
// Fv header if it's corrupted.
|
|
||||||
//
|
@return FvbMediaInfo A pointer to an instance of FVB media info produced by this function.
|
||||||
EFI_FVB2_MEDIA_INFO mPlatformFvbMediaInfo[] = {
|
The buffer is allocated internally to this function and it is the caller's
|
||||||
//
|
responsibility to free the memory
|
||||||
// Systen NvStorage FVB
|
|
||||||
//
|
**/
|
||||||
{
|
typedef
|
||||||
NV_STORAGE_BASE_ADDRESS,
|
EFI_STATUS
|
||||||
{
|
(*FVB_MEDIA_INFO_GENERATOR)(
|
||||||
{0,}, //ZeroVector[16]
|
OUT EFI_FVB2_MEDIA_INFO *FvbMediaInfo
|
||||||
EFI_SYSTEM_NV_DATA_FV_GUID,
|
);
|
||||||
FVB_MEDIA_BLOCK_SIZE * SYSTEM_NV_BLOCK_NUM,
|
|
||||||
EFI_FVH_SIGNATURE,
|
/**
|
||||||
0x0004feff, // check MdePkg/Include/Pi/PiFirmwareVolume.h for details on EFI_FVB_ATTRIBUTES_2
|
Returns FVB media information for NV variable storage.
|
||||||
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
|
|
||||||
0, //CheckSum which will be calucated dynamically.
|
@param[out] FvbMediaInfo A pointer to an instance of FVB media info produced by this function.
|
||||||
0, //ExtHeaderOffset
|
|
||||||
{0,}, //Reserved[1]
|
@retval EFI_SUCCESS A structure was successfully written to the FvbMediaInfo buffer.
|
||||||
2, //Revision
|
@retval EFI_INVALID_PARAMETER The FvbMediaInfo parameter is NULL.
|
||||||
{
|
@retval EFI_UNSUPPORTED An error occurred retrieving variable FV information.
|
||||||
{
|
@retval EFI_BAD_BUFFER_SIZE An overflow or underflow of the FV buffer occurred with the information found.
|
||||||
SYSTEM_NV_BLOCK_NUM,
|
|
||||||
FVB_MEDIA_BLOCK_SIZE,
|
**/
|
||||||
}
|
EFI_STATUS
|
||||||
}
|
GenerateNvStorageFvbMediaInfo (
|
||||||
},
|
OUT EFI_FVB2_MEDIA_INFO *FvbMediaInfo
|
||||||
{
|
)
|
||||||
{
|
{
|
||||||
0,
|
EFI_STATUS Status;
|
||||||
0
|
UINT32 NvBlockNum;
|
||||||
}
|
UINT32 TotalNvVariableStorageSize;
|
||||||
}
|
EFI_PHYSICAL_ADDRESS NvStorageBaseAddress;
|
||||||
|
EFI_FIRMWARE_VOLUME_HEADER FvbInfo = {
|
||||||
|
{0,}, //ZeroVector[16]
|
||||||
|
EFI_SYSTEM_NV_DATA_FV_GUID, //FileSystemGuid
|
||||||
|
0, //FvLength
|
||||||
|
EFI_FVH_SIGNATURE, //Signature
|
||||||
|
0x0004feff, //Attributes
|
||||||
|
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + //HeaderLength
|
||||||
|
sizeof (EFI_FV_BLOCK_MAP_ENTRY),
|
||||||
|
0, //Checksum
|
||||||
|
0, //ExtHeaderOffset
|
||||||
|
{0,}, //Reserved[1]
|
||||||
|
2, //Revision
|
||||||
|
{ //BlockMap[1]
|
||||||
|
{0,0}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (FvbMediaInfo == NULL) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZeroMem (FvbMediaInfo, sizeof (*FvbMediaInfo));
|
||||||
|
|
||||||
|
GetVariableFvInfo (&NvStorageBaseAddress, &TotalNvVariableStorageSize);
|
||||||
|
if ((NvStorageBaseAddress == 0) || (TotalNvVariableStorageSize == 0)) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NvBlockNum = TotalNvVariableStorageSize / FVB_MEDIA_BLOCK_SIZE;
|
||||||
|
|
||||||
|
Status = SafeUint64Mult ((UINT64)NvBlockNum, FVB_MEDIA_BLOCK_SIZE, &FvbInfo.FvLength);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return EFI_BAD_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
FvbInfo.BlockMap[0].NumBlocks = NvBlockNum;
|
||||||
|
FvbInfo.BlockMap[0].Length = FVB_MEDIA_BLOCK_SIZE;
|
||||||
|
|
||||||
|
FvbMediaInfo->BaseAddress = NvStorageBaseAddress;
|
||||||
|
CopyMem (&FvbMediaInfo->FvbInfo, &FvbInfo, sizeof (FvbInfo));
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
FVB_MEDIA_INFO_GENERATOR mFvbMediaInfoGenerators[] = {
|
||||||
|
GenerateNvStorageFvbMediaInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -64,12 +106,16 @@ GetFvbInfo (
|
||||||
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
|
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_FVB2_MEDIA_INFO FvbMediaInfo;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
|
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
|
||||||
|
|
||||||
for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB2_MEDIA_INFO); Index++) {
|
for (Index = 0; Index < ARRAY_SIZE (mFvbMediaInfoGenerators); Index++) {
|
||||||
if (mPlatformFvbMediaInfo[Index].BaseAddress == FvBaseAddress) {
|
Status = mFvbMediaInfoGenerators[Index](&FvbMediaInfo);
|
||||||
FvHeader = &mPlatformFvbMediaInfo[Index].FvbInfo;
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
if (!EFI_ERROR (Status) && (FvbMediaInfo.BaseAddress == FvBaseAddress)) {
|
||||||
|
FvHeader = AllocateCopyPool (sizeof (EFI_FIRMWARE_VOLUME_HEADER), &FvbMediaInfo.FvbInfo);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update the checksum value of FV header.
|
// Update the checksum value of FV header.
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
which are compliant with the Intel(R) Serial Flash Interface Compatibility Specification.
|
which are compliant with the Intel(R) Serial Flash Interface Compatibility Specification.
|
||||||
|
|
||||||
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) Microsoft Corporation.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -25,12 +26,6 @@ FV_INFO mPlatformFvBaseAddress[] = {
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
FV_INFO mPlatformDefaultBaseAddress[] = {
|
|
||||||
{0, 0}, // {FixedPcdGet32(PcdFlashNvStorageVariableBase), FixedPcdGet32(PcdFlashNvStorageVariableSize)},
|
|
||||||
{0, 0}, // {FixedPcdGet32(PcdFlashMicrocodeFvBase), FixedPcdGet32(PcdFlashMicrocodeFvSize)},
|
|
||||||
{0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = {
|
FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -530,6 +525,85 @@ FvbSetVolumeAttributes (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the total size of the firmware volume on flash used for variable store operations.
|
||||||
|
|
||||||
|
@param[out] BaseAddress Base address of the variable store firmware volume.
|
||||||
|
@param[out] Length Length in bytes of the firmware volume used for variable store operations.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
GetVariableFvInfo (
|
||||||
|
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||||
|
OUT UINT32 *Length
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_PHYSICAL_ADDRESS NvBaseAddress;
|
||||||
|
EFI_PHYSICAL_ADDRESS NvVariableBaseAddress;
|
||||||
|
UINT64 Length64;
|
||||||
|
UINT32 NvStoreLength;
|
||||||
|
UINT32 FtwSpareLength;
|
||||||
|
UINT32 FtwWorkingLength;
|
||||||
|
UINT32 TotalLength;
|
||||||
|
|
||||||
|
TotalLength = 0;
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
|
if ((BaseAddress == NULL) || (Length == NULL)) {
|
||||||
|
ASSERT ((BaseAddress != NULL) && (Length != NULL));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*BaseAddress = 0;
|
||||||
|
*Length = 0;
|
||||||
|
|
||||||
|
Status = GetVariableFlashNvStorageInfo (&NvBaseAddress, &Length64);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
NvVariableBaseAddress = NvBaseAddress;
|
||||||
|
// Stay within the current UINT32 size assumptions in the variable stack.
|
||||||
|
Status = SafeUint64ToUint32 (Length64, &NvStoreLength);
|
||||||
|
}
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = GetVariableFlashFtwSpareInfo (&NvBaseAddress, &Length64);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
// Stay within the current UINT32 size assumptions in the variable stack.
|
||||||
|
Status = SafeUint64ToUint32 (Length64, &FtwSpareLength);
|
||||||
|
}
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = GetVariableFlashFtwWorkingInfo (&NvBaseAddress, &Length64);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
// Stay within the current UINT32 size assumptions in the variable stack.
|
||||||
|
Status = SafeUint64ToUint32 (Length64, &FtwWorkingLength);
|
||||||
|
}
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = SafeUint32Add (NvStoreLength, FtwSpareLength, &TotalLength);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = SafeUint32Add (TotalLength, FtwWorkingLength, &TotalLength);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*BaseAddress = NvVariableBaseAddress;
|
||||||
|
*Length = TotalLength;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check the integrity of firmware volume header
|
Check the integrity of firmware volume header
|
||||||
|
|
||||||
|
@ -545,7 +619,12 @@ IsFvHeaderValid (
|
||||||
IN CONST EFI_FIRMWARE_VOLUME_HEADER *FvHeader
|
IN CONST EFI_FIRMWARE_VOLUME_HEADER *FvHeader
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (FvBase == PcdGet32(PcdFlashNvStorageVariableBase)) {
|
EFI_PHYSICAL_ADDRESS NvStorageFvBaseAddress;
|
||||||
|
UINT32 NvStorageSize;
|
||||||
|
|
||||||
|
GetVariableFvInfo (&NvStorageFvBaseAddress, &NvStorageSize);
|
||||||
|
|
||||||
|
if (FvBase == NvStorageFvBaseAddress) {
|
||||||
if (CompareMem (&FvHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid, sizeof(EFI_GUID)) != 0 ) {
|
if (CompareMem (&FvHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid, sizeof(EFI_GUID)) != 0 ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
Common source definitions used in serial flash drivers
|
Common source definitions used in serial flash drivers
|
||||||
|
|
||||||
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) Microsoft Corporation.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -12,6 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
#include <Guid/EventGroup.h>
|
#include <Guid/EventGroup.h>
|
||||||
#include <Guid/FirmwareFileSystem2.h>
|
#include <Guid/FirmwareFileSystem2.h>
|
||||||
#include <Guid/SystemNvDataGuid.h>
|
#include <Guid/SystemNvDataGuid.h>
|
||||||
|
#include <Pi/PiFirmwareVolume.h>
|
||||||
#include <Protocol/DevicePath.h>
|
#include <Protocol/DevicePath.h>
|
||||||
#include <Protocol/FirmwareVolumeBlock.h>
|
#include <Protocol/FirmwareVolumeBlock.h>
|
||||||
|
|
||||||
|
@ -24,6 +26,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
#include <Library/PcdLib.h>
|
#include <Library/PcdLib.h>
|
||||||
#include <Library/DevicePathLib.h>
|
#include <Library/DevicePathLib.h>
|
||||||
#include <Library/HobLib.h>
|
#include <Library/HobLib.h>
|
||||||
|
#include <Library/VariableFlashInfoLib.h>
|
||||||
|
#include <Library/SafeIntLib.h>
|
||||||
|
|
||||||
#include <Library/SpiFlashCommonLib.h>
|
#include <Library/SpiFlashCommonLib.h>
|
||||||
|
|
||||||
|
@ -148,11 +152,23 @@ GetFvbInfo (
|
||||||
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
|
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the total size of the firmware volume on flash used for variable store operations.
|
||||||
|
|
||||||
|
@param[out] BaseAddress Base address of the variable store firmware volume.
|
||||||
|
@param[out] Length Length in bytes of the firmware volume used for variable store operations.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
GetVariableFvInfo (
|
||||||
|
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||||
|
OUT UINT32 *Length
|
||||||
|
);
|
||||||
|
|
||||||
extern FVB_GLOBAL mFvbModuleGlobal;
|
extern FVB_GLOBAL mFvbModuleGlobal;
|
||||||
extern FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate;
|
extern FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate;
|
||||||
extern FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate;
|
extern FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate;
|
||||||
extern EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL mFvbProtocolTemplate;
|
extern EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL mFvbProtocolTemplate;
|
||||||
extern FV_INFO mPlatformFvBaseAddress[];
|
extern FV_INFO mPlatformFvBaseAddress[];
|
||||||
extern FV_INFO mPlatformDefaultBaseAddress[];
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -113,15 +113,31 @@ FvbInitialize (
|
||||||
UINT32 MaxLbaSize;
|
UINT32 MaxLbaSize;
|
||||||
UINT32 BytesWritten;
|
UINT32 BytesWritten;
|
||||||
UINTN BytesErased;
|
UINTN BytesErased;
|
||||||
|
UINT64 NvStorageFvSize;
|
||||||
|
|
||||||
|
Status = GetVariableFlashNvStorageInfo (&BaseAddress, &NvStorageFvSize);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
DEBUG ((DEBUG_ERROR, "[%a] - An error ocurred getting variable info - %r.\n", __FUNCTION__, Status));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stay within the current UINT32 size assumptions in the variable stack.
|
||||||
|
Status = SafeUint64ToUint32 (BaseAddress, &mPlatformFvBaseAddress[0].FvBase);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
DEBUG ((DEBUG_ERROR, "[%a] - 64-bit variable storage base address not supported.\n", __FUNCTION__));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Status = SafeUint64ToUint32 (NvStorageFvSize, &mPlatformFvBaseAddress[0].FvSize);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
DEBUG ((DEBUG_ERROR, "[%a] - 64-bit variable storage size not supported.\n", __FUNCTION__));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mPlatformFvBaseAddress[0].FvBase = PcdGet32(PcdFlashNvStorageVariableBase);
|
|
||||||
mPlatformFvBaseAddress[0].FvSize = PcdGet32(PcdFlashNvStorageVariableSize);
|
|
||||||
mPlatformFvBaseAddress[1].FvBase = PcdGet32(PcdFlashMicrocodeFvBase);
|
mPlatformFvBaseAddress[1].FvBase = PcdGet32(PcdFlashMicrocodeFvBase);
|
||||||
mPlatformFvBaseAddress[1].FvSize = PcdGet32(PcdFlashMicrocodeFvSize);
|
mPlatformFvBaseAddress[1].FvSize = PcdGet32(PcdFlashMicrocodeFvSize);
|
||||||
mPlatformDefaultBaseAddress[0].FvBase = PcdGet32(PcdFlashNvStorageVariableBase);
|
|
||||||
mPlatformDefaultBaseAddress[0].FvSize = PcdGet32(PcdFlashNvStorageVariableSize);
|
|
||||||
mPlatformDefaultBaseAddress[1].FvBase = PcdGet32(PcdFlashMicrocodeFvBase);
|
|
||||||
mPlatformDefaultBaseAddress[1].FvSize = PcdGet32(PcdFlashMicrocodeFvSize);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// We will only continue with FVB installation if the
|
// We will only continue with FVB installation if the
|
||||||
|
@ -143,7 +159,8 @@ FvbInitialize (
|
||||||
BytesWritten = 0;
|
BytesWritten = 0;
|
||||||
BytesErased = 0;
|
BytesErased = 0;
|
||||||
DEBUG ((DEBUG_ERROR, "ERROR - The FV in 0x%x is invalid!\n", FvHeader));
|
DEBUG ((DEBUG_ERROR, "ERROR - The FV in 0x%x is invalid!\n", FvHeader));
|
||||||
Status = GetFvbInfo (BaseAddress, &FvHeader);
|
FvHeader = NULL;
|
||||||
|
Status = GetFvbInfo (BaseAddress, &FvHeader);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN, "ERROR - Can't recovery FV header at 0x%x. GetFvbInfo Status %r\n", BaseAddress, Status));
|
DEBUG ((DEBUG_WARN, "ERROR - Can't recovery FV header at 0x%x. GetFvbInfo Status %r\n", BaseAddress, Status));
|
||||||
continue;
|
continue;
|
||||||
|
@ -156,27 +173,42 @@ FvbInitialize (
|
||||||
Status = SpiFlashBlockErase( (UINTN) BaseAddress, &BytesErased);
|
Status = SpiFlashBlockErase( (UINTN) BaseAddress, &BytesErased);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN, "ERROR - SpiFlashBlockErase Error %r\n", Status));
|
DEBUG ((DEBUG_WARN, "ERROR - SpiFlashBlockErase Error %r\n", Status));
|
||||||
|
if (FvHeader != NULL) {
|
||||||
|
FreePool (FvHeader);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (BytesErased != FvHeader->BlockMap->Length) {
|
if (BytesErased != FvHeader->BlockMap->Length) {
|
||||||
DEBUG ((DEBUG_WARN, "ERROR - BytesErased != FvHeader->BlockMap->Length\n"));
|
DEBUG ((DEBUG_WARN, "ERROR - BytesErased != FvHeader->BlockMap->Length\n"));
|
||||||
DEBUG ((DEBUG_INFO, " BytesErased = 0x%X\n Length = 0x%X\n", BytesErased, FvHeader->BlockMap->Length));
|
DEBUG ((DEBUG_INFO, " BytesErased = 0x%X\n Length = 0x%X\n", BytesErased, FvHeader->BlockMap->Length));
|
||||||
|
if (FvHeader != NULL) {
|
||||||
|
FreePool (FvHeader);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BytesWritten = FvHeader->HeaderLength;
|
BytesWritten = FvHeader->HeaderLength;
|
||||||
Status = SpiFlashWrite ((UINTN)BaseAddress, &BytesWritten, (UINT8*)FvHeader);
|
Status = SpiFlashWrite ((UINTN)BaseAddress, &BytesWritten, (UINT8*)FvHeader);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN, "ERROR - SpiFlashWrite Error %r\n", Status));
|
DEBUG ((DEBUG_WARN, "ERROR - SpiFlashWrite Error %r\n", Status));
|
||||||
|
if (FvHeader != NULL) {
|
||||||
|
FreePool (FvHeader);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (BytesWritten != FvHeader->HeaderLength) {
|
if (BytesWritten != FvHeader->HeaderLength) {
|
||||||
DEBUG ((DEBUG_WARN, "ERROR - BytesWritten != HeaderLength\n"));
|
DEBUG ((DEBUG_WARN, "ERROR - BytesWritten != HeaderLength\n"));
|
||||||
DEBUG ((DEBUG_INFO, " BytesWritten = 0x%X\n HeaderLength = 0x%X\n", BytesWritten, FvHeader->HeaderLength));
|
DEBUG ((DEBUG_INFO, " BytesWritten = 0x%X\n HeaderLength = 0x%X\n", BytesWritten, FvHeader->HeaderLength));
|
||||||
|
if (FvHeader != NULL) {
|
||||||
|
FreePool (FvHeader);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Status = SpiFlashLock ();
|
Status = SpiFlashLock ();
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN, "ERROR - SpiFlashLock Error %r\n", Status));
|
DEBUG ((DEBUG_WARN, "ERROR - SpiFlashLock Error %r\n", Status));
|
||||||
|
if (FvHeader != NULL) {
|
||||||
|
FreePool (FvHeader);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DEBUG ((DEBUG_INFO, "FV Header @ 0x%X restored with static data\n", BaseAddress));
|
DEBUG ((DEBUG_INFO, "FV Header @ 0x%X restored with static data\n", BaseAddress));
|
||||||
|
@ -184,6 +216,9 @@ FvbInitialize (
|
||||||
// Clear cache for this range.
|
// Clear cache for this range.
|
||||||
//
|
//
|
||||||
WriteBackInvalidateDataCacheRange ( (VOID *) (UINTN) BaseAddress, FvHeader->BlockMap->Length);
|
WriteBackInvalidateDataCacheRange ( (VOID *) (UINTN) BaseAddress, FvHeader->BlockMap->Length);
|
||||||
|
if (FvHeader != NULL) {
|
||||||
|
FreePool (FvHeader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,10 @@
|
||||||
BaseLib
|
BaseLib
|
||||||
UefiBootServicesTableLib
|
UefiBootServicesTableLib
|
||||||
UefiDriverEntryPoint
|
UefiDriverEntryPoint
|
||||||
|
SafeIntLib
|
||||||
SpiFlashCommonLib
|
SpiFlashCommonLib
|
||||||
MmServicesTableLib
|
MmServicesTableLib
|
||||||
|
VariableFlashInfoLib
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
@ -41,10 +43,6 @@
|
||||||
IntelSiliconPkg/IntelSiliconPkg.dec
|
IntelSiliconPkg/IntelSiliconPkg.dec
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## CONSUMES
|
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
|
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
|
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
|
|
||||||
gIntelSiliconPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase ## CONSUMES
|
gIntelSiliconPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase ## CONSUMES
|
||||||
gIntelSiliconPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize ## CONSUMES
|
gIntelSiliconPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize ## CONSUMES
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,10 @@
|
||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
PcdLib
|
PcdLib
|
||||||
MmServicesTableLib
|
MmServicesTableLib
|
||||||
|
SafeIntLib
|
||||||
SpiFlashCommonLib
|
SpiFlashCommonLib
|
||||||
StandaloneMmDriverEntryPoint
|
StandaloneMmDriverEntryPoint
|
||||||
|
VariableFlashInfoLib
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
@ -40,10 +42,6 @@
|
||||||
IntelSiliconPkg/IntelSiliconPkg.dec
|
IntelSiliconPkg/IntelSiliconPkg.dec
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## CONSUMES
|
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
|
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
|
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
|
|
||||||
gIntelSiliconPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase ## CONSUMES
|
gIntelSiliconPkgTokenSpaceGuid.PcdFlashMicrocodeFvBase ## CONSUMES
|
||||||
gIntelSiliconPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize ## CONSUMES
|
gIntelSiliconPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize ## CONSUMES
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,11 @@
|
||||||
PeiGetVtdPmrAlignmentLib|IntelSiliconPkg/Library/PeiGetVtdPmrAlignmentLib/PeiGetVtdPmrAlignmentLib.inf
|
PeiGetVtdPmrAlignmentLib|IntelSiliconPkg/Library/PeiGetVtdPmrAlignmentLib/PeiGetVtdPmrAlignmentLib.inf
|
||||||
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
|
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
|
||||||
MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
|
MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
|
||||||
|
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
|
||||||
SpiFlashCommonLib|IntelSiliconPkg/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.inf
|
SpiFlashCommonLib|IntelSiliconPkg/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.inf
|
||||||
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
|
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
|
||||||
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
|
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
|
||||||
|
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
|
||||||
|
|
||||||
[LibraryClasses.common.PEIM]
|
[LibraryClasses.common.PEIM]
|
||||||
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
|
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
|
||||||
|
@ -63,11 +65,16 @@
|
||||||
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
|
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
|
||||||
|
|
||||||
[LibraryClasses.common.DXE_SMM_DRIVER]
|
[LibraryClasses.common.DXE_SMM_DRIVER]
|
||||||
|
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
|
||||||
|
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
|
||||||
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
|
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
|
||||||
MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
|
MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
|
||||||
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
|
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
|
||||||
|
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
|
||||||
|
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
|
||||||
|
|
||||||
[LibraryClasses.common.MM_STANDALONE]
|
[LibraryClasses.common.MM_STANDALONE]
|
||||||
|
HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
|
||||||
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
|
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
|
||||||
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
|
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
|
||||||
StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
|
StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
|
||||||
|
|
Загрузка…
Ссылка в новой задаче