mirror of https://github.com/acidanthera/audk.git
UefiPayloadPkg: Add a common FVB SMM module
This FVB module is used to initialize NV variable region and provide SMM FVB protocol to read/write SPI variable region. This module consume HOB gNvVariableInfoGuid and depends on FlashDeviceLib for the actual SPI device operate. During FVB initialization, it will initialize the variable region if the variable region is not valid. And it support to write initial variable data from FFS file if it is found. Signed-off-by: Guo Dong <guo.dong@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Maurice Ma <maurice.ma@intel.com> Cc: Benjamin You <benjamin.you@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Benjamin You <benjamin.you@intel.com>
This commit is contained in:
parent
04714cef46
commit
ae8acce8ae
|
@ -0,0 +1,151 @@
|
|||
/** @file
|
||||
|
||||
Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/FirmwareVolumeBlock.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Guid/FirmwareFileSystem2.h>
|
||||
#include <Guid/SystemNvDataGuid.h>
|
||||
#include <Guid/NvVariableInfoGuid.h>
|
||||
#include <Library/HobLib.h>
|
||||
|
||||
#define FVB_MEDIA_BLOCK_SIZE 0x1000
|
||||
|
||||
typedef struct {
|
||||
EFI_FIRMWARE_VOLUME_HEADER FvInfo;
|
||||
EFI_FV_BLOCK_MAP_ENTRY End[1];
|
||||
} EFI_FVB2_MEDIA_INFO;
|
||||
|
||||
//
|
||||
// This data structure contains a template of FV header which is used to restore
|
||||
// Fv header if it's corrupted.
|
||||
//
|
||||
EFI_FVB2_MEDIA_INFO mFvbMediaInfo = {
|
||||
{
|
||||
{0,}, // ZeroVector[16]
|
||||
EFI_SYSTEM_NV_DATA_FV_GUID,
|
||||
0,
|
||||
EFI_FVH_SIGNATURE,
|
||||
0x0004feff, // check PiFirmwareVolume.h for details on EFI_FVB_ATTRIBUTES_2
|
||||
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
|
||||
0, // CheckSum which will be calucated dynamically.
|
||||
0, // ExtHeaderOffset
|
||||
{0,},
|
||||
EFI_FVH_REVISION,
|
||||
{
|
||||
{
|
||||
0,
|
||||
FVB_MEDIA_BLOCK_SIZE,
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
0,
|
||||
0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
Initialize the variable store
|
||||
|
||||
@retval EFI_SUCCESS if initialize the store success.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
InitVariableStore (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 NvStorageBase;
|
||||
UINT32 NvStorageSize;
|
||||
UINT32 NvVariableSize;
|
||||
UINT32 FtwWorkingSize;
|
||||
UINT32 FtwSpareSize;
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
NV_VARIABLE_INFO *NvVariableInfo;
|
||||
|
||||
//
|
||||
// Find SPI flash variable hob
|
||||
//
|
||||
GuidHob = GetFirstGuidHob (&gNvVariableInfoGuid);
|
||||
if (GuidHob == NULL) {
|
||||
ASSERT (FALSE);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
NvVariableInfo = (NV_VARIABLE_INFO *) GET_GUID_HOB_DATA (GuidHob);
|
||||
|
||||
//
|
||||
// Get variable region base and size.
|
||||
//
|
||||
NvStorageSize = NvVariableInfo->VariableStoreSize;
|
||||
NvStorageBase = NvVariableInfo->VariableStoreBase;
|
||||
|
||||
//
|
||||
// NvStorageBase needs to be 4KB aligned, NvStorageSize needs to be 8KB * n
|
||||
//
|
||||
if (((NvStorageBase & (SIZE_4KB - 1)) != 0) || ((NvStorageSize & (SIZE_8KB - 1)) != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
FtwSpareSize = NvStorageSize / 2;
|
||||
FtwWorkingSize = 0x2000;
|
||||
NvVariableSize = NvStorageSize / 2 - FtwWorkingSize;
|
||||
DEBUG ((DEBUG_INFO, "NvStorageBase:0x%x, NvStorageSize:0x%x\n", NvStorageBase, NvStorageSize));
|
||||
|
||||
if (NvVariableSize >= 0x80000000) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
Status = PcdSet32S(PcdFlashNvStorageVariableSize, NvVariableSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = PcdSet32S(PcdFlashNvStorageVariableBase, NvStorageBase);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = PcdSet64S(PcdFlashNvStorageVariableBase64, NvStorageBase);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = PcdSet32S(PcdFlashNvStorageFtwWorkingSize, FtwWorkingSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = PcdSet32S(PcdFlashNvStorageFtwWorkingBase, NvStorageBase + NvVariableSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = PcdSet32S(PcdFlashNvStorageFtwSpareSize, FtwSpareSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = PcdSet32S(PcdFlashNvStorageFtwSpareBase, NvStorageBase + FtwSpareSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get a heathy FV header used for variable store recovery
|
||||
|
||||
@retval The FV header.
|
||||
|
||||
**/
|
||||
EFI_FIRMWARE_VOLUME_HEADER *
|
||||
GetFvHeaderTemplate (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
|
||||
UINTN FvSize;
|
||||
|
||||
FvSize = PcdGet32(PcdFlashNvStorageFtwSpareSize) * 2;
|
||||
FvHeader = &mFvbMediaInfo.FvInfo;
|
||||
FvHeader->FvLength = FvSize;
|
||||
FvHeader->BlockMap[0].NumBlocks = (UINT32) (FvSize / FvHeader->BlockMap[0].Length);
|
||||
FvHeader->Checksum = 0;
|
||||
FvHeader->Checksum = CalculateCheckSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength);
|
||||
|
||||
return FvHeader;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,187 @@
|
|||
/** @file
|
||||
The header file for Firmware volume block driver.
|
||||
|
||||
Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef FW_BLOCK_SERVICE_H_
|
||||
#define FW_BLOCK_SERVICE_H_
|
||||
|
||||
#include <Guid/EventGroup.h>
|
||||
#include <Guid/FirmwareFileSystem2.h>
|
||||
#include <Guid/SystemNvDataGuid.h>
|
||||
#include <Guid/VariableFormat.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/FirmwareVolumeBlock.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/CacheMaintenanceLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/FlashDeviceLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/DxeServicesLib.h>
|
||||
#include <Guid/NvVariableInfoGuid.h>
|
||||
#include <Register/ArchitecturalMsr.h>
|
||||
|
||||
//
|
||||
// Define two helper macro to extract the Capability field or Status field in FVB
|
||||
// bit fields
|
||||
//
|
||||
#define EFI_FVB2_CAPABILITIES (EFI_FVB2_READ_DISABLED_CAP | \
|
||||
EFI_FVB2_READ_ENABLED_CAP | \
|
||||
EFI_FVB2_WRITE_DISABLED_CAP | \
|
||||
EFI_FVB2_WRITE_ENABLED_CAP | \
|
||||
EFI_FVB2_LOCK_CAP \
|
||||
)
|
||||
|
||||
#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINTN FvBase;
|
||||
UINTN NumOfBlocks;
|
||||
//
|
||||
// Note!!!: VolumeHeader must be the last element
|
||||
// of the structure.
|
||||
//
|
||||
EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
|
||||
} EFI_FW_VOL_INSTANCE;
|
||||
|
||||
|
||||
typedef struct {
|
||||
EFI_FW_VOL_INSTANCE *FvInstance;
|
||||
UINT32 NumFv;
|
||||
UINT32 Flags;
|
||||
} FWB_GLOBAL;
|
||||
|
||||
//
|
||||
// Fvb Protocol instance data
|
||||
//
|
||||
#define FVB_DEVICE_FROM_THIS(a) CR(a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)
|
||||
#define FVB_EXTEND_DEVICE_FROM_THIS(a) CR(a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE)
|
||||
#define FVB_DEVICE_SIGNATURE SIGNATURE_32('F','V','B','C')
|
||||
|
||||
typedef struct {
|
||||
MEDIA_FW_VOL_DEVICE_PATH FvDevPath;
|
||||
EFI_DEVICE_PATH_PROTOCOL EndDevPath;
|
||||
} FV_PIWG_DEVICE_PATH;
|
||||
|
||||
typedef struct {
|
||||
MEMMAP_DEVICE_PATH MemMapDevPath;
|
||||
EFI_DEVICE_PATH_PROTOCOL EndDevPath;
|
||||
} FV_MEMMAP_DEVICE_PATH;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN Instance;
|
||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
|
||||
} EFI_FW_VOL_BLOCK_DEVICE;
|
||||
|
||||
/**
|
||||
Get a heathy FV header used for variable store recovery
|
||||
|
||||
@retval The FV header.
|
||||
|
||||
**/
|
||||
EFI_FIRMWARE_VOLUME_HEADER *
|
||||
GetFvHeaderTemplate (
|
||||
VOID
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
InitVariableStore (
|
||||
VOID
|
||||
);
|
||||
|
||||
//
|
||||
// Protocol APIs
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolGetAttributes (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolSetAttributes (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolGetPhysicalAddress (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Address
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolGetBlockSize (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN EFI_LBA Lba,
|
||||
OUT UINTN *BlockSize,
|
||||
OUT UINTN *NumOfBlocks
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolRead (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN OUT UINTN *NumBytes,
|
||||
OUT UINT8 *Buffer
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolWrite (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN OUT UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolEraseBlocks (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
...
|
||||
);
|
||||
|
||||
EFI_FW_VOL_INSTANCE *
|
||||
GetFvbInstance (
|
||||
IN UINTN Instance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
InstallFvbProtocol (
|
||||
IN EFI_FW_VOL_INSTANCE *FwhInstance,
|
||||
IN UINTN InstanceNum
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
FvbInitialize (
|
||||
VOID
|
||||
);
|
||||
|
||||
extern FWB_GLOBAL mFvbModuleGlobal;
|
||||
extern EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate;
|
||||
extern FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate;
|
||||
extern FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,139 @@
|
|||
/** @file
|
||||
SMM Firmware Volume Block Driver.
|
||||
|
||||
Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include <PiSmm.h>
|
||||
#include <Library/SmmServicesTableLib.h>
|
||||
#include "FvbSmmCommon.h"
|
||||
#include "FvbService.h"
|
||||
|
||||
/**
|
||||
The function installs EFI_SMM_FIRMWARE_VOLUME_BLOCK protocol
|
||||
for each FV in the system.
|
||||
|
||||
@param[in] FwhInstance The pointer to a FW volume instance structure,
|
||||
which contains the information about one FV.
|
||||
@param[in] InstanceNum The instance number which can be used as a ID
|
||||
to locate this FwhInstance in other functions.
|
||||
|
||||
@retval EFI_SUCESS Installed successfully.
|
||||
@retval Else Did not install successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
InstallFvbProtocol (
|
||||
IN EFI_FW_VOL_INSTANCE *FwhInstance,
|
||||
IN UINTN InstanceNum
|
||||
)
|
||||
{
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE FvbHandle;
|
||||
FV_MEMMAP_DEVICE_PATH *FvDevicePath;
|
||||
VOID *TempPtr;
|
||||
|
||||
FvbDevice = (EFI_FW_VOL_BLOCK_DEVICE *) AllocateRuntimeCopyPool (
|
||||
sizeof (EFI_FW_VOL_BLOCK_DEVICE),
|
||||
&mFvbDeviceTemplate
|
||||
);
|
||||
if (FvbDevice == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
FvbDevice->Instance = InstanceNum;
|
||||
FwVolHeader = &FwhInstance->VolumeHeader;
|
||||
|
||||
//
|
||||
// Set up the devicepath
|
||||
//
|
||||
if (FwVolHeader->ExtHeaderOffset == 0) {
|
||||
//
|
||||
// FV does not contains extension header, then produce MEMMAP_DEVICE_PATH
|
||||
//
|
||||
TempPtr = AllocateRuntimeCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate);
|
||||
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;
|
||||
if (FvbDevice->DevicePath == NULL) {
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
FvDevicePath = (FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath;
|
||||
FvDevicePath->MemMapDevPath.StartingAddress = FwhInstance->FvBase;
|
||||
FvDevicePath->MemMapDevPath.EndingAddress = FwhInstance->FvBase + FwVolHeader->FvLength - 1;
|
||||
} else {
|
||||
TempPtr = AllocateRuntimeCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate);
|
||||
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;
|
||||
if (FvbDevice->DevicePath == NULL) {
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyGuid (
|
||||
&((FV_PIWG_DEVICE_PATH *)FvbDevice->DevicePath)->FvDevPath.FvName,
|
||||
(GUID *)(UINTN)(FwhInstance->FvBase + FwVolHeader->ExtHeaderOffset)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Install the SMM Firmware Volume Block Protocol and Device Path Protocol
|
||||
//
|
||||
FvbHandle = NULL;
|
||||
Status = gSmst->SmmInstallProtocolInterface (
|
||||
&FvbHandle,
|
||||
&gEfiSmmFirmwareVolumeBlockProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&FvbDevice->FwVolBlockInstance
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gSmst->SmmInstallProtocolInterface (
|
||||
&FvbHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
FvbDevice->DevicePath
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Notify the Fvb wrapper driver SMM fvb is ready
|
||||
//
|
||||
FvbHandle = NULL;
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
&FvbHandle,
|
||||
&gEfiSmmFirmwareVolumeBlockProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&FvbDevice->FwVolBlockInstance
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The driver entry point for SMM Firmware Volume Block Driver.
|
||||
|
||||
The function does the necessary initialization work
|
||||
Firmware Volume Block Driver.
|
||||
|
||||
@param[in] ImageHandle The firmware allocated handle for the UEFI image.
|
||||
@param[in] SystemTable A pointer to the EFI system table.
|
||||
|
||||
@retval EFI_SUCCESS This funtion always return EFI_SUCCESS.
|
||||
It will ASSERT on errors.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbSmmInitialize (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
FvbInitialize ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
## @file
|
||||
# This driver installs the EFI_SMM_FIRMWARE_VOLUMEN_PROTOCOL.
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = FvbSmm
|
||||
FILE_GUID = A4EC8ADB-B7A8-47d1-8E52-EC820D0ACF6F
|
||||
MODULE_TYPE = DXE_SMM_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
PI_SPECIFICATION_VERSION = 0x0001000A
|
||||
ENTRY_POINT = FvbSmmInitialize
|
||||
|
||||
[Sources]
|
||||
FvbInfo.c
|
||||
FvbService.h
|
||||
FvbService.c
|
||||
FvbServiceSmm.c
|
||||
FvbSmmCommon.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
UefiCpuPkg/UefiCpuPkg.dec
|
||||
UefiPayloadPkg/UefiPayloadPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
FlashDeviceLib
|
||||
PcdLib
|
||||
MemoryAllocationLib
|
||||
CacheMaintenanceLib
|
||||
IoLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
BaseLib
|
||||
UefiLib
|
||||
SmmServicesTableLib
|
||||
UefiBootServicesTableLib
|
||||
UefiDriverEntryPoint
|
||||
HobLib
|
||||
DxeServicesLib
|
||||
|
||||
[Guids]
|
||||
gEfiFirmwareFileSystem2Guid # ALWAYS_CONSUMED
|
||||
gEfiSystemNvDataFvGuid # ALWAYS_CONSUMED
|
||||
gEfiAuthenticatedVariableGuid
|
||||
gNvVariableInfoGuid
|
||||
|
||||
[Protocols]
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
||||
gEfiSmmFirmwareVolumeBlockProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
|
||||
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
|
||||
gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile
|
||||
|
||||
[Depex]
|
||||
TRUE
|
|
@ -0,0 +1,69 @@
|
|||
/** @file
|
||||
The common header file for SMM FVB module.
|
||||
|
||||
Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef SMM_FVB_COMMON_H_
|
||||
#define SMM_FVB_COMMON_H_
|
||||
|
||||
#include <Protocol/SmmFirmwareVolumeBlock.h>
|
||||
|
||||
#define EFI_FUNCTION_GET_ATTRIBUTES 1
|
||||
#define EFI_FUNCTION_SET_ATTRIBUTES 2
|
||||
#define EFI_FUNCTION_GET_PHYSICAL_ADDRESS 3
|
||||
#define EFI_FUNCTION_GET_BLOCK_SIZE 4
|
||||
#define EFI_FUNCTION_READ 5
|
||||
#define EFI_FUNCTION_WRITE 6
|
||||
#define EFI_FUNCTION_ERASE_BLOCKS 7
|
||||
|
||||
typedef struct {
|
||||
UINTN Function;
|
||||
EFI_STATUS ReturnStatus;
|
||||
UINT8 Data[1];
|
||||
} SMM_FVB_COMMUNICATE_FUNCTION_HEADER;
|
||||
|
||||
|
||||
///
|
||||
/// Size of SMM communicate header, without including the payload.
|
||||
///
|
||||
#define SMM_COMMUNICATE_HEADER_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data))
|
||||
|
||||
///
|
||||
/// Size of SMM FVB communicate function header, without including the payload.
|
||||
///
|
||||
#define SMM_FVB_COMMUNICATE_HEADER_SIZE (OFFSET_OF (SMM_FVB_COMMUNICATE_FUNCTION_HEADER, Data))
|
||||
|
||||
typedef struct {
|
||||
EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *SmmFvb;
|
||||
EFI_FVB_ATTRIBUTES_2 Attributes;
|
||||
} SMM_FVB_ATTRIBUTES_HEADER;
|
||||
|
||||
typedef struct {
|
||||
EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *SmmFvb;
|
||||
EFI_PHYSICAL_ADDRESS Address;
|
||||
} SMM_FVB_PHYSICAL_ADDRESS_HEADER;
|
||||
|
||||
typedef struct {
|
||||
EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *SmmFvb;
|
||||
EFI_LBA Lba;
|
||||
UINTN BlockSize;
|
||||
UINTN NumOfBlocks;
|
||||
} SMM_FVB_BLOCK_SIZE_HEADER;
|
||||
|
||||
typedef struct {
|
||||
EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *SmmFvb;
|
||||
EFI_LBA Lba;
|
||||
UINTN Offset;
|
||||
UINTN NumBytes;
|
||||
} SMM_FVB_READ_WRITE_HEADER;
|
||||
|
||||
typedef struct {
|
||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *SmmFvb;
|
||||
EFI_LBA StartLba;
|
||||
UINTN NumOfLba;
|
||||
} SMM_FVB_BLOCKS_HEADER;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,24 @@
|
|||
/** @file
|
||||
This file defines the hob structure for the SPI flash variable info.
|
||||
|
||||
Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef NV_VARIABLE_INFO_GUID_H_
|
||||
#define NV_VARIABLE_INFO_GUID_H_
|
||||
|
||||
//
|
||||
// NV variable hob info GUID
|
||||
//
|
||||
extern EFI_GUID gNvVariableInfoGuid;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Revision;
|
||||
UINT8 Reserved[3];
|
||||
UINT32 VariableStoreBase;
|
||||
UINT32 VariableStoreSize;
|
||||
} NV_VARIABLE_INFO;
|
||||
|
||||
#endif
|
|
@ -37,6 +37,8 @@
|
|||
gUefiSerialPortInfoGuid = { 0x6c6872fe, 0x56a9, 0x4403, { 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } }
|
||||
gLoaderMemoryMapInfoGuid = { 0xa1ff7424, 0x7a1a, 0x478e, { 0xa9, 0xe4, 0x92, 0xf3, 0x57, 0xd1, 0x28, 0x32 } }
|
||||
|
||||
# SMM variable support
|
||||
gNvVariableInfoGuid = { 0x7a345dca, 0xc26, 0x4f2a, { 0xa8, 0x9a, 0x57, 0xc0, 0x8d, 0xdd, 0x22, 0xee } }
|
||||
gSpiFlashInfoGuid = { 0x2d4aac1b, 0x91a5, 0x4cd5, { 0x9b, 0x5c, 0xb4, 0x0f, 0x5d, 0x28, 0x51, 0xa1 } }
|
||||
gSmmRegisterInfoGuid = { 0xaa9bd7a7, 0xcafb, 0x4499, { 0xa4, 0xa9, 0xb, 0x34, 0x6b, 0x40, 0xa6, 0x22 } }
|
||||
gS3CommunicationGuid = { 0x88e31ba1, 0x1856, 0x4b8b, { 0xbb, 0xdf, 0xf8, 0x16, 0xdd, 0x94, 0xa, 0xef } }
|
||||
|
@ -81,3 +83,7 @@ gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x80|UINT32|0x
|
|||
gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x02000000|UINT32|0x00000017
|
||||
|
||||
gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }|VOID*|0x00000018
|
||||
|
||||
## FFS filename to find the default variable initial data file.
|
||||
# @Prompt FFS Name of variable initial data file
|
||||
gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile |{ 0x1a, 0xf1, 0xb1, 0xae, 0x42, 0xcc, 0xcf, 0x4e, 0xac, 0x60, 0xdb, 0xab, 0xf6, 0xca, 0x69, 0xe6 }|VOID*|0x00000025
|
||||
|
|
Loading…
Reference in New Issue