OvmfPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the OvmfPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Andrew Fish <afish@apple.com>
This commit is contained in:
committed by
mergify[bot]
parent
d1050b9dff
commit
ac0a286f4d
@@ -31,12 +31,12 @@
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
typedef struct {
|
||||
UINT64 FvLength;
|
||||
EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
|
||||
UINT64 FvLength;
|
||||
EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
|
||||
//
|
||||
// EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0
|
||||
//
|
||||
EFI_FV_BLOCK_MAP_ENTRY End[1];
|
||||
EFI_FV_BLOCK_MAP_ENTRY End[1];
|
||||
} EFI_FVB_MEDIA_INFO;
|
||||
|
||||
EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
|
||||
@@ -59,12 +59,12 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
|
||||
FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize),
|
||||
EFI_FVH_SIGNATURE,
|
||||
EFI_FVB2_MEMORY_MAPPED |
|
||||
EFI_FVB2_READ_ENABLED_CAP |
|
||||
EFI_FVB2_READ_STATUS |
|
||||
EFI_FVB2_WRITE_ENABLED_CAP |
|
||||
EFI_FVB2_WRITE_STATUS |
|
||||
EFI_FVB2_ERASE_POLARITY |
|
||||
EFI_FVB2_ALIGNMENT_16,
|
||||
EFI_FVB2_READ_ENABLED_CAP |
|
||||
EFI_FVB2_READ_STATUS |
|
||||
EFI_FVB2_WRITE_ENABLED_CAP |
|
||||
EFI_FVB2_WRITE_STATUS |
|
||||
EFI_FVB2_ERASE_POLARITY |
|
||||
EFI_FVB2_ALIGNMENT_16,
|
||||
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
|
||||
0, // CheckSum
|
||||
0, // ExtHeaderOffset
|
||||
@@ -94,31 +94,34 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
|
||||
|
||||
EFI_STATUS
|
||||
GetFvbInfo (
|
||||
IN UINT64 FvLength,
|
||||
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
|
||||
IN UINT64 FvLength,
|
||||
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
|
||||
)
|
||||
{
|
||||
STATIC BOOLEAN Checksummed = FALSE;
|
||||
UINTN Index;
|
||||
STATIC BOOLEAN Checksummed = FALSE;
|
||||
UINTN Index;
|
||||
|
||||
if (!Checksummed) {
|
||||
for (Index = 0;
|
||||
Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO);
|
||||
Index += 1) {
|
||||
UINT16 Checksum;
|
||||
Index += 1)
|
||||
{
|
||||
UINT16 Checksum;
|
||||
mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = 0;
|
||||
Checksum = CalculateCheckSum16 (
|
||||
(UINT16*) &mPlatformFvbMediaInfo[Index].FvbInfo,
|
||||
mPlatformFvbMediaInfo[Index].FvbInfo.HeaderLength
|
||||
);
|
||||
Checksum = CalculateCheckSum16 (
|
||||
(UINT16 *)&mPlatformFvbMediaInfo[Index].FvbInfo,
|
||||
mPlatformFvbMediaInfo[Index].FvbInfo.HeaderLength
|
||||
);
|
||||
mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = Checksum;
|
||||
}
|
||||
|
||||
Checksummed = TRUE;
|
||||
}
|
||||
|
||||
for (Index = 0;
|
||||
Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO);
|
||||
Index += 1) {
|
||||
Index += 1)
|
||||
{
|
||||
if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
|
||||
*FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
|
||||
return EFI_SUCCESS;
|
||||
|
@@ -37,9 +37,9 @@
|
||||
#define EFI_FVB2_STATUS \
|
||||
(EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
|
||||
|
||||
ESAL_FWB_GLOBAL *mFvbModuleGlobal;
|
||||
ESAL_FWB_GLOBAL *mFvbModuleGlobal;
|
||||
|
||||
FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = {
|
||||
FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = {
|
||||
{
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
@@ -50,8 +50,8 @@ FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = {
|
||||
}
|
||||
},
|
||||
EfiMemoryMappedIO,
|
||||
(EFI_PHYSICAL_ADDRESS) 0,
|
||||
(EFI_PHYSICAL_ADDRESS) 0,
|
||||
(EFI_PHYSICAL_ADDRESS)0,
|
||||
(EFI_PHYSICAL_ADDRESS)0,
|
||||
},
|
||||
{
|
||||
END_DEVICE_PATH_TYPE,
|
||||
@@ -63,7 +63,7 @@ FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = {
|
||||
}
|
||||
};
|
||||
|
||||
FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = {
|
||||
FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = {
|
||||
{
|
||||
{
|
||||
MEDIA_DEVICE_PATH,
|
||||
@@ -85,7 +85,7 @@ FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = {
|
||||
}
|
||||
};
|
||||
|
||||
EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
|
||||
EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
|
||||
FVB_DEVICE_SIGNATURE,
|
||||
NULL,
|
||||
0,
|
||||
@@ -101,13 +101,13 @@ EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
GetFvbInstance (
|
||||
IN UINTN Instance,
|
||||
IN ESAL_FWB_GLOBAL *Global,
|
||||
OUT EFI_FW_VOL_INSTANCE **FwhInstance
|
||||
IN UINTN Instance,
|
||||
IN ESAL_FWB_GLOBAL *Global,
|
||||
OUT EFI_FW_VOL_INSTANCE **FwhInstance
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -126,22 +126,23 @@ GetFvbInstance (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_FW_VOL_INSTANCE *FwhRecord;
|
||||
EFI_FW_VOL_INSTANCE *FwhRecord;
|
||||
|
||||
*FwhInstance = NULL;
|
||||
if (Instance >= Global->NumFv) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Find the right instance of the FVB private data
|
||||
//
|
||||
FwhRecord = Global->FvInstance;
|
||||
while (Instance > 0) {
|
||||
FwhRecord = (EFI_FW_VOL_INSTANCE *)
|
||||
(
|
||||
(UINTN) ((UINT8 *) FwhRecord) + FwhRecord->VolumeHeader.HeaderLength +
|
||||
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
|
||||
);
|
||||
(
|
||||
(UINTN)((UINT8 *)FwhRecord) + FwhRecord->VolumeHeader.HeaderLength +
|
||||
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
|
||||
);
|
||||
Instance--;
|
||||
}
|
||||
|
||||
@@ -152,10 +153,11 @@ GetFvbInstance (
|
||||
|
||||
EFI_STATUS
|
||||
FvbGetPhysicalAddress (
|
||||
IN UINTN Instance,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Address,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
IN UINTN Instance,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Address,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -176,8 +178,8 @@ FvbGetPhysicalAddress (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
EFI_STATUS Status;
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Find the right instance of the FVB private data
|
||||
@@ -191,10 +193,11 @@ FvbGetPhysicalAddress (
|
||||
|
||||
EFI_STATUS
|
||||
FvbGetVolumeAttributes (
|
||||
IN UINTN Instance,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
IN UINTN Instance,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -214,8 +217,8 @@ FvbGetVolumeAttributes (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
EFI_STATUS Status;
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Find the right instance of the FVB private data
|
||||
@@ -229,13 +232,14 @@ FvbGetVolumeAttributes (
|
||||
|
||||
EFI_STATUS
|
||||
FvbGetLbaAddress (
|
||||
IN UINTN Instance,
|
||||
IN EFI_LBA Lba,
|
||||
OUT UINTN *LbaAddress,
|
||||
OUT UINTN *LbaLength,
|
||||
OUT UINTN *NumOfBlocks,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
IN UINTN Instance,
|
||||
IN EFI_LBA Lba,
|
||||
OUT UINTN *LbaAddress,
|
||||
OUT UINTN *LbaLength,
|
||||
OUT UINTN *NumOfBlocks,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -275,9 +279,9 @@ FvbGetLbaAddress (
|
||||
Status = GetFvbInstance (Instance, Global, &FwhInstance);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
StartLba = 0;
|
||||
Offset = 0;
|
||||
BlockMap = &(FwhInstance->VolumeHeader.BlockMap[0]);
|
||||
StartLba = 0;
|
||||
Offset = 0;
|
||||
BlockMap = &(FwhInstance->VolumeHeader.BlockMap[0]);
|
||||
|
||||
//
|
||||
// Parse the blockmap of the FV to find which map entry the Lba belongs to
|
||||
@@ -286,7 +290,7 @@ FvbGetLbaAddress (
|
||||
NumBlocks = BlockMap->NumBlocks;
|
||||
BlockLength = BlockMap->Length;
|
||||
|
||||
if (NumBlocks == 0 || BlockLength == 0) {
|
||||
if ((NumBlocks == 0) || (BlockLength == 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -295,8 +299,8 @@ FvbGetLbaAddress (
|
||||
//
|
||||
// The map entry found
|
||||
//
|
||||
if (Lba >= StartLba && Lba < NextLba) {
|
||||
Offset = Offset + (UINTN) MultU64x32 ((Lba - StartLba), BlockLength);
|
||||
if ((Lba >= StartLba) && (Lba < NextLba)) {
|
||||
Offset = Offset + (UINTN)MultU64x32 ((Lba - StartLba), BlockLength);
|
||||
if (LbaAddress != NULL) {
|
||||
*LbaAddress = FwhInstance->FvBase + Offset;
|
||||
}
|
||||
@@ -306,24 +310,25 @@ FvbGetLbaAddress (
|
||||
}
|
||||
|
||||
if (NumOfBlocks != NULL) {
|
||||
*NumOfBlocks = (UINTN) (NextLba - Lba);
|
||||
*NumOfBlocks = (UINTN)(NextLba - Lba);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
StartLba = NextLba;
|
||||
Offset = Offset + NumBlocks * BlockLength;
|
||||
StartLba = NextLba;
|
||||
Offset = Offset + NumBlocks * BlockLength;
|
||||
BlockMap++;
|
||||
}
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
FvbSetVolumeAttributes (
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -364,8 +369,8 @@ FvbSetVolumeAttributes (
|
||||
Status = GetFvbInstance (Instance, Global, &FwhInstance);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
AttribPtr =
|
||||
(EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);
|
||||
AttribPtr =
|
||||
(EFI_FVB_ATTRIBUTES_2 *)&(FwhInstance->VolumeHeader.Attributes);
|
||||
OldAttributes = *AttribPtr;
|
||||
Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \
|
||||
EFI_FVB2_READ_ENABLED_CAP | \
|
||||
@@ -373,8 +378,8 @@ FvbSetVolumeAttributes (
|
||||
EFI_FVB2_WRITE_ENABLED_CAP | \
|
||||
EFI_FVB2_LOCK_CAP \
|
||||
);
|
||||
OldStatus = OldAttributes & EFI_FVB2_STATUS;
|
||||
NewStatus = *Attributes & EFI_FVB2_STATUS;
|
||||
OldStatus = OldAttributes & EFI_FVB2_STATUS;
|
||||
NewStatus = *Attributes & EFI_FVB2_STATUS;
|
||||
|
||||
UnchangedAttributes = EFI_FVB2_READ_DISABLED_CAP | \
|
||||
EFI_FVB2_READ_ENABLED_CAP | \
|
||||
@@ -392,9 +397,11 @@ FvbSetVolumeAttributes (
|
||||
// Some attributes of FV is read only can *not* be set
|
||||
//
|
||||
if ((OldAttributes & UnchangedAttributes) ^
|
||||
(*Attributes & UnchangedAttributes)) {
|
||||
(*Attributes & UnchangedAttributes))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// If firmware volume is locked, no status bit can be updated
|
||||
//
|
||||
@@ -403,6 +410,7 @@ FvbSetVolumeAttributes (
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Test read disable
|
||||
//
|
||||
@@ -411,6 +419,7 @@ FvbSetVolumeAttributes (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Test read enable
|
||||
//
|
||||
@@ -419,6 +428,7 @@ FvbSetVolumeAttributes (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Test write disable
|
||||
//
|
||||
@@ -427,6 +437,7 @@ FvbSetVolumeAttributes (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Test write enable
|
||||
//
|
||||
@@ -435,6 +446,7 @@ FvbSetVolumeAttributes (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Test lock
|
||||
//
|
||||
@@ -457,9 +469,10 @@ FvbSetVolumeAttributes (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolGetPhysicalAddress (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Address
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Address
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -476,22 +489,26 @@ FvbProtocolGetPhysicalAddress (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
|
||||
return FvbGetPhysicalAddress (FvbDevice->Instance, Address,
|
||||
mFvbModuleGlobal);
|
||||
return FvbGetPhysicalAddress (
|
||||
FvbDevice->Instance,
|
||||
Address,
|
||||
mFvbModuleGlobal
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolGetBlockSize (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN CONST EFI_LBA Lba,
|
||||
OUT UINTN *BlockSize,
|
||||
OUT UINTN *NumOfBlocks
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN CONST EFI_LBA Lba,
|
||||
OUT UINTN *BlockSize,
|
||||
OUT UINTN *NumOfBlocks
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -513,26 +530,27 @@ FvbProtocolGetBlockSize (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
|
||||
return FvbGetLbaAddress (
|
||||
FvbDevice->Instance,
|
||||
Lba,
|
||||
NULL,
|
||||
BlockSize,
|
||||
NumOfBlocks,
|
||||
mFvbModuleGlobal
|
||||
);
|
||||
FvbDevice->Instance,
|
||||
Lba,
|
||||
NULL,
|
||||
BlockSize,
|
||||
NumOfBlocks,
|
||||
mFvbModuleGlobal
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolGetAttributes (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -547,20 +565,24 @@ FvbProtocolGetAttributes (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
|
||||
return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes,
|
||||
mFvbModuleGlobal);
|
||||
return FvbGetVolumeAttributes (
|
||||
FvbDevice->Instance,
|
||||
Attributes,
|
||||
mFvbModuleGlobal
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolSetAttributes (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -575,20 +597,24 @@ FvbProtocolSetAttributes (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
|
||||
return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes,
|
||||
mFvbModuleGlobal);
|
||||
return FvbSetVolumeAttributes (
|
||||
FvbDevice->Instance,
|
||||
Attributes,
|
||||
mFvbModuleGlobal
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolEraseBlocks (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
...
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -615,18 +641,21 @@ FvbProtocolEraseBlocks (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
UINTN NumOfBlocks;
|
||||
VA_LIST args;
|
||||
EFI_LBA StartingLba;
|
||||
UINTN NumOfLba;
|
||||
EFI_STATUS Status;
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
UINTN NumOfBlocks;
|
||||
VA_LIST args;
|
||||
EFI_LBA StartingLba;
|
||||
UINTN NumOfLba;
|
||||
EFI_STATUS Status;
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
|
||||
Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal,
|
||||
&FwhInstance);
|
||||
Status = GetFvbInstance (
|
||||
FvbDevice->Instance,
|
||||
mFvbModuleGlobal,
|
||||
&FwhInstance
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
NumOfBlocks = FwhInstance->NumOfBlocks;
|
||||
@@ -671,7 +700,6 @@ FvbProtocolEraseBlocks (
|
||||
StartingLba++;
|
||||
NumOfLba--;
|
||||
}
|
||||
|
||||
} while (1);
|
||||
|
||||
VA_END (args);
|
||||
@@ -682,12 +710,13 @@ FvbProtocolEraseBlocks (
|
||||
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
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN OUT UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -720,19 +749,24 @@ FvbProtocolWrite (
|
||||
|
||||
--*/
|
||||
{
|
||||
return QemuFlashWrite ((EFI_LBA)Lba, (UINTN)Offset, NumBytes,
|
||||
(UINT8 *)Buffer);
|
||||
return QemuFlashWrite (
|
||||
(EFI_LBA)Lba,
|
||||
(UINTN)Offset,
|
||||
NumBytes,
|
||||
(UINT8 *)Buffer
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolRead (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN CONST EFI_LBA Lba,
|
||||
IN CONST UINTN Offset,
|
||||
IN OUT UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN CONST EFI_LBA Lba,
|
||||
IN CONST UINTN Offset,
|
||||
IN OUT UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -765,14 +799,19 @@ FvbProtocolRead (
|
||||
|
||||
--*/
|
||||
{
|
||||
return QemuFlashRead ((EFI_LBA)Lba, (UINTN)Offset, NumBytes,
|
||||
(UINT8 *)Buffer);
|
||||
return QemuFlashRead (
|
||||
(EFI_LBA)Lba,
|
||||
(UINTN)Offset,
|
||||
NumBytes,
|
||||
(UINT8 *)Buffer
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ValidateFvHeader (
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -788,7 +827,7 @@ ValidateFvHeader (
|
||||
|
||||
--*/
|
||||
{
|
||||
UINT16 Checksum;
|
||||
UINT16 Checksum;
|
||||
|
||||
//
|
||||
// Verify the header revision, header signature, length
|
||||
@@ -797,9 +836,10 @@ ValidateFvHeader (
|
||||
//
|
||||
if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||
|
||||
(FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
|
||||
(FwVolHeader->FvLength == ((UINTN) -1)) ||
|
||||
(FwVolHeader->FvLength == ((UINTN)-1)) ||
|
||||
((FwVolHeader->HeaderLength & 0x01) != 0)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -807,16 +847,23 @@ ValidateFvHeader (
|
||||
// Verify the header checksum
|
||||
//
|
||||
|
||||
Checksum = CalculateSum16 ((UINT16 *) FwVolHeader,
|
||||
FwVolHeader->HeaderLength);
|
||||
Checksum = CalculateSum16 (
|
||||
(UINT16 *)FwVolHeader,
|
||||
FwVolHeader->HeaderLength
|
||||
);
|
||||
if (Checksum != 0) {
|
||||
UINT16 Expected;
|
||||
UINT16 Expected;
|
||||
|
||||
Expected =
|
||||
(UINT16) (((UINTN) FwVolHeader->Checksum + 0x10000 - Checksum) & 0xffff);
|
||||
(UINT16)(((UINTN)FwVolHeader->Checksum + 0x10000 - Checksum) & 0xffff);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "FV@%p Checksum is 0x%x, expected 0x%x\n",
|
||||
FwVolHeader, FwVolHeader->Checksum, Expected));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"FV@%p Checksum is 0x%x, expected 0x%x\n",
|
||||
FwVolHeader,
|
||||
FwVolHeader->Checksum,
|
||||
Expected
|
||||
));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -829,16 +876,16 @@ InitializeVariableFvHeader (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *GoodFwVolHeader;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||
UINTN Length;
|
||||
UINTN WriteLength;
|
||||
UINTN BlockSize;
|
||||
EFI_STATUS Status;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *GoodFwVolHeader;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||
UINTN Length;
|
||||
UINTN WriteLength;
|
||||
UINTN BlockSize;
|
||||
|
||||
FwVolHeader =
|
||||
(EFI_FIRMWARE_VOLUME_HEADER *) (UINTN)
|
||||
PcdGet32 (PcdOvmfFlashNvStorageVariableBase);
|
||||
(EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)
|
||||
PcdGet32 (PcdOvmfFlashNvStorageVariableBase);
|
||||
|
||||
Length =
|
||||
(FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
|
||||
@@ -848,19 +895,23 @@ InitializeVariableFvHeader (
|
||||
|
||||
BlockSize = PcdGet32 (PcdOvmfFirmwareBlockSize);
|
||||
|
||||
Status = ValidateFvHeader (FwVolHeader);
|
||||
Status = ValidateFvHeader (FwVolHeader);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (FwVolHeader->FvLength != Length ||
|
||||
FwVolHeader->BlockMap[0].Length != BlockSize) {
|
||||
if ((FwVolHeader->FvLength != Length) ||
|
||||
(FwVolHeader->BlockMap[0].Length != BlockSize))
|
||||
{
|
||||
Status = EFI_VOLUME_CORRUPTED;
|
||||
}
|
||||
}
|
||||
if (EFI_ERROR (Status)) {
|
||||
UINTN Offset;
|
||||
UINTN Start;
|
||||
|
||||
DEBUG ((DEBUG_INFO,
|
||||
"Variable FV header is not valid. It will be reinitialized.\n"));
|
||||
if (EFI_ERROR (Status)) {
|
||||
UINTN Offset;
|
||||
UINTN Start;
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Variable FV header is not valid. It will be reinitialized.\n"
|
||||
));
|
||||
|
||||
//
|
||||
// Get FvbInfo to provide in FwhInstance.
|
||||
@@ -868,7 +919,7 @@ InitializeVariableFvHeader (
|
||||
Status = GetFvbInfo (Length, &GoodFwVolHeader);
|
||||
ASSERT (!EFI_ERROR (Status));
|
||||
|
||||
Start = (UINTN)(UINT8*) FwVolHeader - PcdGet32 (PcdOvmfFdBaseAddress);
|
||||
Start = (UINTN)(UINT8 *)FwVolHeader - PcdGet32 (PcdOvmfFdBaseAddress);
|
||||
ASSERT (Start % BlockSize == 0 && Length % BlockSize == 0);
|
||||
ASSERT (GoodFwVolHeader->HeaderLength <= BlockSize);
|
||||
|
||||
@@ -884,11 +935,12 @@ InitializeVariableFvHeader (
|
||||
// Write good FV header
|
||||
//
|
||||
WriteLength = GoodFwVolHeader->HeaderLength;
|
||||
Status = QemuFlashWrite (
|
||||
Start / BlockSize,
|
||||
0,
|
||||
&WriteLength,
|
||||
(UINT8 *) GoodFwVolHeader);
|
||||
Status = QemuFlashWrite (
|
||||
Start / BlockSize,
|
||||
0,
|
||||
&WriteLength,
|
||||
(UINT8 *)GoodFwVolHeader
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
ASSERT (WriteLength == GoodFwVolHeader->HeaderLength);
|
||||
}
|
||||
@@ -899,9 +951,10 @@ InitializeVariableFvHeader (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbInitialize (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -913,24 +966,26 @@ FvbInitialize (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||
UINT32 BufferSize;
|
||||
EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
UINT32 MaxLbaSize;
|
||||
EFI_PHYSICAL_ADDRESS BaseAddress;
|
||||
UINTN Length;
|
||||
UINTN NumOfBlocks;
|
||||
RETURN_STATUS PcdStatus;
|
||||
EFI_STATUS Status;
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||
UINT32 BufferSize;
|
||||
EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
UINT32 MaxLbaSize;
|
||||
EFI_PHYSICAL_ADDRESS BaseAddress;
|
||||
UINTN Length;
|
||||
UINTN NumOfBlocks;
|
||||
RETURN_STATUS PcdStatus;
|
||||
|
||||
if (EFI_ERROR (QemuFlashInitialize ())) {
|
||||
//
|
||||
// Return an error so image will be unloaded
|
||||
//
|
||||
DEBUG ((DEBUG_INFO,
|
||||
"QEMU flash was not detected. Writable FVB is not being installed.\n"));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"QEMU flash was not detected. Writable FVB is not being installed.\n"
|
||||
));
|
||||
return EFI_WRITE_PROTECTED;
|
||||
}
|
||||
|
||||
@@ -941,17 +996,19 @@ FvbInitialize (
|
||||
mFvbModuleGlobal = AllocateRuntimePool (sizeof (ESAL_FWB_GLOBAL));
|
||||
ASSERT (mFvbModuleGlobal != NULL);
|
||||
|
||||
BaseAddress = (UINTN) PcdGet32 (PcdOvmfFdBaseAddress);
|
||||
Length = PcdGet32 (PcdOvmfFirmwareFdSize);
|
||||
BaseAddress = (UINTN)PcdGet32 (PcdOvmfFdBaseAddress);
|
||||
Length = PcdGet32 (PcdOvmfFirmwareFdSize);
|
||||
|
||||
Status = InitializeVariableFvHeader ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_INFO,
|
||||
"QEMU Flash: Unable to initialize variable FV header\n"));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"QEMU Flash: Unable to initialize variable FV header\n"
|
||||
));
|
||||
return EFI_WRITE_PROTECTED;
|
||||
}
|
||||
|
||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;
|
||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;
|
||||
Status = ValidateFvHeader (FwVolHeader);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
@@ -973,24 +1030,28 @@ FvbInitialize (
|
||||
|
||||
FwhInstance = mFvbModuleGlobal->FvInstance;
|
||||
|
||||
mFvbModuleGlobal->NumFv = 0;
|
||||
MaxLbaSize = 0;
|
||||
mFvbModuleGlobal->NumFv = 0;
|
||||
MaxLbaSize = 0;
|
||||
|
||||
FwVolHeader =
|
||||
(EFI_FIRMWARE_VOLUME_HEADER *) (UINTN)
|
||||
PcdGet32 (PcdOvmfFlashNvStorageVariableBase);
|
||||
(EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)
|
||||
PcdGet32 (PcdOvmfFlashNvStorageVariableBase);
|
||||
|
||||
FwhInstance->FvBase = (UINTN) BaseAddress;
|
||||
FwhInstance->FvBase = (UINTN)BaseAddress;
|
||||
|
||||
CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader,
|
||||
FwVolHeader->HeaderLength);
|
||||
CopyMem (
|
||||
(UINTN *)&(FwhInstance->VolumeHeader),
|
||||
(UINTN *)FwVolHeader,
|
||||
FwVolHeader->HeaderLength
|
||||
);
|
||||
FwVolHeader = &(FwhInstance->VolumeHeader);
|
||||
|
||||
NumOfBlocks = 0;
|
||||
|
||||
for (PtrBlockMapEntry = FwVolHeader->BlockMap;
|
||||
PtrBlockMapEntry->NumBlocks != 0;
|
||||
PtrBlockMapEntry++) {
|
||||
PtrBlockMapEntry++)
|
||||
{
|
||||
//
|
||||
// Get the maximum size of a block.
|
||||
//
|
||||
@@ -1021,22 +1082,26 @@ FvbInitialize (
|
||||
// Set up the devicepath
|
||||
//
|
||||
if (FwVolHeader->ExtHeaderOffset == 0) {
|
||||
FV_MEMMAP_DEVICE_PATH *FvMemmapDevicePath;
|
||||
FV_MEMMAP_DEVICE_PATH *FvMemmapDevicePath;
|
||||
|
||||
//
|
||||
// FV does not contains extension header, then produce MEMMAP_DEVICE_PATH
|
||||
//
|
||||
FvMemmapDevicePath = AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH),
|
||||
&mFvMemmapDevicePathTemplate);
|
||||
FvMemmapDevicePath = AllocateCopyPool (
|
||||
sizeof (FV_MEMMAP_DEVICE_PATH),
|
||||
&mFvMemmapDevicePathTemplate
|
||||
);
|
||||
FvMemmapDevicePath->MemMapDevPath.StartingAddress = BaseAddress;
|
||||
FvMemmapDevicePath->MemMapDevPath.EndingAddress =
|
||||
BaseAddress + FwVolHeader->FvLength - 1;
|
||||
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)FvMemmapDevicePath;
|
||||
} else {
|
||||
FV_PIWG_DEVICE_PATH *FvPiwgDevicePath;
|
||||
FV_PIWG_DEVICE_PATH *FvPiwgDevicePath;
|
||||
|
||||
FvPiwgDevicePath = AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH),
|
||||
&mFvPIWGDevicePathTemplate);
|
||||
FvPiwgDevicePath = AllocateCopyPool (
|
||||
sizeof (FV_PIWG_DEVICE_PATH),
|
||||
&mFvPIWGDevicePathTemplate
|
||||
);
|
||||
CopyGuid (
|
||||
&FvPiwgDevicePath->FvDevPath.FvName,
|
||||
(GUID *)(UINTN)(BaseAddress + FwVolHeader->ExtHeaderOffset)
|
||||
@@ -1054,10 +1119,10 @@ FvbInitialize (
|
||||
SetPcdFlashNvStorageBaseAddresses ();
|
||||
|
||||
FwhInstance = (EFI_FW_VOL_INSTANCE *)
|
||||
(
|
||||
(UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength +
|
||||
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
|
||||
);
|
||||
(
|
||||
(UINTN)((UINT8 *)FwhInstance) + FwVolHeader->HeaderLength +
|
||||
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
|
||||
);
|
||||
|
||||
//
|
||||
// Module type specific hook.
|
||||
|
@@ -18,32 +18,32 @@
|
||||
#define _FW_BLOCK_SERVICE_H
|
||||
|
||||
typedef struct {
|
||||
UINTN FvBase;
|
||||
UINTN NumOfBlocks;
|
||||
EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
|
||||
UINTN FvBase;
|
||||
UINTN NumOfBlocks;
|
||||
EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
|
||||
} EFI_FW_VOL_INSTANCE;
|
||||
|
||||
typedef struct {
|
||||
UINT32 NumFv;
|
||||
EFI_FW_VOL_INSTANCE *FvInstance;
|
||||
UINT32 NumFv;
|
||||
EFI_FW_VOL_INSTANCE *FvInstance;
|
||||
} ESAL_FWB_GLOBAL;
|
||||
|
||||
extern ESAL_FWB_GLOBAL *mFvbModuleGlobal;
|
||||
extern ESAL_FWB_GLOBAL *mFvbModuleGlobal;
|
||||
|
||||
//
|
||||
// Fvb Protocol instance data
|
||||
//
|
||||
#define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, \
|
||||
#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, \
|
||||
#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', 'N')
|
||||
#define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N')
|
||||
|
||||
typedef struct {
|
||||
MEDIA_FW_VOL_DEVICE_PATH FvDevPath;
|
||||
EFI_DEVICE_PATH_PROTOCOL EndDevPath;
|
||||
MEDIA_FW_VOL_DEVICE_PATH FvDevPath;
|
||||
EFI_DEVICE_PATH_PROTOCOL EndDevPath;
|
||||
} FV_PIWG_DEVICE_PATH;
|
||||
|
||||
typedef struct {
|
||||
@@ -52,62 +52,61 @@ typedef struct {
|
||||
} FV_MEMMAP_DEVICE_PATH;
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN Instance;
|
||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
|
||||
UINTN Signature;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN Instance;
|
||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
|
||||
} EFI_FW_VOL_BLOCK_DEVICE;
|
||||
|
||||
EFI_STATUS
|
||||
GetFvbInfo (
|
||||
IN UINT64 FvLength,
|
||||
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
|
||||
IN UINT64 FvLength,
|
||||
OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
FvbSetVolumeAttributes (
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
FvbGetVolumeAttributes (
|
||||
IN UINTN Instance,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
IN UINTN Instance,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
FvbGetPhysicalAddress (
|
||||
IN UINTN Instance,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Address,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
IN UINTN Instance,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Address,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbInitialize (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
FvbClassAddressChangeEvent (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
FvbGetLbaAddress (
|
||||
IN UINTN Instance,
|
||||
IN EFI_LBA Lba,
|
||||
OUT UINTN *LbaAddress,
|
||||
OUT UINTN *LbaLength,
|
||||
OUT UINTN *NumOfBlocks,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
IN UINTN Instance,
|
||||
IN EFI_LBA Lba,
|
||||
OUT UINTN *LbaAddress,
|
||||
OUT UINTN *LbaLength,
|
||||
OUT UINTN *NumOfBlocks,
|
||||
IN ESAL_FWB_GLOBAL *Global
|
||||
);
|
||||
|
||||
//
|
||||
@@ -116,57 +115,57 @@ FvbGetLbaAddress (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolGetAttributes (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
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
|
||||
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
|
||||
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 CONST EFI_LBA Lba,
|
||||
OUT UINTN *BlockSize,
|
||||
OUT UINTN *NumOfBlocks
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN CONST EFI_LBA Lba,
|
||||
OUT UINTN *BlockSize,
|
||||
OUT UINTN *NumOfBlocks
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbProtocolRead (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN CONST EFI_LBA Lba,
|
||||
IN CONST UINTN Offset,
|
||||
IN OUT UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
IN CONST EFI_LBA Lba,
|
||||
IN CONST UINTN Offset,
|
||||
IN OUT UINTN *NumBytes,
|
||||
IN 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
|
||||
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,
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
|
||||
...
|
||||
);
|
||||
|
||||
@@ -176,7 +175,7 @@ FvbProtocolEraseBlocks (
|
||||
//
|
||||
VOID
|
||||
InstallProtocolInterfaces (
|
||||
IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice
|
||||
IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice
|
||||
);
|
||||
|
||||
VOID
|
||||
@@ -186,8 +185,8 @@ InstallVirtualAddressChangeHandler (
|
||||
|
||||
EFI_STATUS
|
||||
MarkIoMemoryRangeForRuntimeAccess (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN Length
|
||||
);
|
||||
|
||||
VOID
|
||||
|
@@ -24,12 +24,12 @@
|
||||
|
||||
VOID
|
||||
InstallProtocolInterfaces (
|
||||
IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice
|
||||
IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE FwbHandle;
|
||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE FwbHandle;
|
||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface;
|
||||
|
||||
ASSERT (!FeaturePcdGet (PcdSmmSmramRequire));
|
||||
|
||||
@@ -37,8 +37,11 @@ InstallProtocolInterfaces (
|
||||
// Find a handle with a matching device path that has supports FW Block
|
||||
// protocol
|
||||
//
|
||||
Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid,
|
||||
&FvbDevice->DevicePath, &FwbHandle);
|
||||
Status = gBS->LocateDevicePath (
|
||||
&gEfiFirmwareVolumeBlockProtocolGuid,
|
||||
&FvbDevice->DevicePath,
|
||||
&FwbHandle
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// LocateDevicePath fails so install a new interface and device path
|
||||
@@ -61,7 +64,7 @@ InstallProtocolInterfaces (
|
||||
Status = gBS->HandleProtocol (
|
||||
FwbHandle,
|
||||
&gEfiFirmwareVolumeBlockProtocolGuid,
|
||||
(VOID**)&OldFwbInterface
|
||||
(VOID **)&OldFwbInterface
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
@@ -81,14 +84,14 @@ InstallProtocolInterfaces (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
FvbVirtualAddressChangeEvent (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -107,39 +110,38 @@ FvbVirtualAddressChangeEvent (
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
UINTN Index;
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
UINTN Index;
|
||||
|
||||
FwhInstance = mFvbModuleGlobal->FvInstance;
|
||||
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance);
|
||||
EfiConvertPointer (0x0, (VOID **)&mFvbModuleGlobal->FvInstance);
|
||||
|
||||
//
|
||||
// Convert the base address of all the instances
|
||||
//
|
||||
Index = 0;
|
||||
Index = 0;
|
||||
while (Index < mFvbModuleGlobal->NumFv) {
|
||||
EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase);
|
||||
EfiConvertPointer (0x0, (VOID **)&FwhInstance->FvBase);
|
||||
FwhInstance = (EFI_FW_VOL_INSTANCE *)
|
||||
(
|
||||
(UINTN) ((UINT8 *) FwhInstance) +
|
||||
FwhInstance->VolumeHeader.HeaderLength +
|
||||
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
|
||||
);
|
||||
(
|
||||
(UINTN)((UINT8 *)FwhInstance) +
|
||||
FwhInstance->VolumeHeader.HeaderLength +
|
||||
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
|
||||
);
|
||||
Index++;
|
||||
}
|
||||
|
||||
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);
|
||||
EfiConvertPointer (0x0, (VOID **)&mFvbModuleGlobal);
|
||||
QemuFlashConvertPointers ();
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
InstallVirtualAddressChangeHandler (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT VirtualAddressChangeEvent;
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT VirtualAddressChangeEvent;
|
||||
|
||||
Status = gBS->CreateEventEx (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
@@ -154,12 +156,12 @@ InstallVirtualAddressChangeHandler (
|
||||
|
||||
EFI_STATUS
|
||||
MarkIoMemoryRangeForRuntimeAccess (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
|
||||
EFI_STATUS Status;
|
||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
|
||||
|
||||
//
|
||||
// Mark flash region as runtime memory
|
||||
@@ -221,24 +223,24 @@ SetPcdFlashNvStorageBaseAddresses (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
RETURN_STATUS PcdStatus;
|
||||
RETURN_STATUS PcdStatus;
|
||||
|
||||
//
|
||||
// Set several PCD values to point to flash
|
||||
//
|
||||
PcdStatus = PcdSet64S (
|
||||
PcdFlashNvStorageVariableBase64,
|
||||
(UINTN) PcdGet32 (PcdOvmfFlashNvStorageVariableBase)
|
||||
);
|
||||
PcdFlashNvStorageVariableBase64,
|
||||
(UINTN)PcdGet32 (PcdOvmfFlashNvStorageVariableBase)
|
||||
);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
PcdStatus = PcdSet32S (
|
||||
PcdFlashNvStorageFtwWorkingBase,
|
||||
PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase)
|
||||
);
|
||||
PcdFlashNvStorageFtwWorkingBase,
|
||||
PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase)
|
||||
);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
PcdStatus = PcdSet32S (
|
||||
PcdFlashNvStorageFtwSpareBase,
|
||||
PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase)
|
||||
);
|
||||
PcdFlashNvStorageFtwSpareBase,
|
||||
PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase)
|
||||
);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
}
|
||||
|
@@ -18,11 +18,11 @@
|
||||
|
||||
VOID
|
||||
InstallProtocolInterfaces (
|
||||
IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice
|
||||
IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice
|
||||
)
|
||||
{
|
||||
EFI_HANDLE FvbHandle;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE FvbHandle;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (FeaturePcdGet (PcdSmmSmramRequire));
|
||||
|
||||
@@ -64,8 +64,8 @@ InstallVirtualAddressChangeHandler (
|
||||
|
||||
EFI_STATUS
|
||||
MarkIoMemoryRangeForRuntimeAccess (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN Length
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
//
|
||||
|
@@ -24,23 +24,21 @@
|
||||
|
||||
#define CLEARED_ARRAY_STATUS 0x00
|
||||
|
||||
UINT8 *mFlashBase;
|
||||
|
||||
UINT8 *mFlashBase;
|
||||
|
||||
STATIC UINTN mFdBlockSize = 0;
|
||||
STATIC UINTN mFdBlockCount = 0;
|
||||
STATIC UINTN mFdBlockSize = 0;
|
||||
STATIC UINTN mFdBlockCount = 0;
|
||||
|
||||
STATIC
|
||||
volatile UINT8*
|
||||
volatile UINT8 *
|
||||
QemuFlashPtr (
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset
|
||||
)
|
||||
{
|
||||
return mFlashBase + ((UINTN)Lba * mFdBlockSize) + Offset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Determines if the QEMU flash memory device is present.
|
||||
|
||||
@@ -54,22 +52,23 @@ QemuFlashDetected (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
BOOLEAN FlashDetected;
|
||||
BOOLEAN FlashDetected;
|
||||
volatile UINT8 *Ptr;
|
||||
|
||||
UINTN Offset;
|
||||
UINT8 OriginalUint8;
|
||||
UINT8 ProbeUint8;
|
||||
UINTN Offset;
|
||||
UINT8 OriginalUint8;
|
||||
UINT8 ProbeUint8;
|
||||
|
||||
FlashDetected = FALSE;
|
||||
Ptr = QemuFlashPtr (0, 0);
|
||||
Ptr = QemuFlashPtr (0, 0);
|
||||
|
||||
for (Offset = 0; Offset < mFdBlockSize; Offset++) {
|
||||
Ptr = QemuFlashPtr (0, Offset);
|
||||
Ptr = QemuFlashPtr (0, Offset);
|
||||
ProbeUint8 = *Ptr;
|
||||
if (ProbeUint8 != CLEAR_STATUS_CMD &&
|
||||
ProbeUint8 != READ_STATUS_CMD &&
|
||||
ProbeUint8 != CLEARED_ARRAY_STATUS) {
|
||||
if ((ProbeUint8 != CLEAR_STATUS_CMD) &&
|
||||
(ProbeUint8 != READ_STATUS_CMD) &&
|
||||
(ProbeUint8 != CLEARED_ARRAY_STATUS))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -91,20 +90,23 @@ QemuFlashDetected (
|
||||
// the FD appears as ROM and not as FLASH, but report FLASH anyway because
|
||||
// FLASH behavior can be simulated using VMGEXIT.
|
||||
//
|
||||
DEBUG ((DEBUG_INFO,
|
||||
"QEMU Flash: SEV-ES enabled, assuming FD behaves as FLASH\n"));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"QEMU Flash: SEV-ES enabled, assuming FD behaves as FLASH\n"
|
||||
));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
OriginalUint8 = *Ptr;
|
||||
*Ptr = CLEAR_STATUS_CMD;
|
||||
ProbeUint8 = *Ptr;
|
||||
if (OriginalUint8 != CLEAR_STATUS_CMD &&
|
||||
ProbeUint8 == CLEAR_STATUS_CMD) {
|
||||
*Ptr = CLEAR_STATUS_CMD;
|
||||
ProbeUint8 = *Ptr;
|
||||
if ((OriginalUint8 != CLEAR_STATUS_CMD) &&
|
||||
(ProbeUint8 == CLEAR_STATUS_CMD))
|
||||
{
|
||||
DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as RAM\n"));
|
||||
*Ptr = OriginalUint8;
|
||||
} else {
|
||||
*Ptr = READ_STATUS_CMD;
|
||||
*Ptr = READ_STATUS_CMD;
|
||||
ProbeUint8 = *Ptr;
|
||||
if (ProbeUint8 == OriginalUint8) {
|
||||
DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as ROM\n"));
|
||||
@@ -114,16 +116,18 @@ QemuFlashDetected (
|
||||
} else if (ProbeUint8 == CLEARED_ARRAY_STATUS) {
|
||||
DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH\n"));
|
||||
FlashDetected = TRUE;
|
||||
*Ptr = READ_ARRAY_CMD;
|
||||
*Ptr = READ_ARRAY_CMD;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "QemuFlashDetected => %a\n",
|
||||
FlashDetected ? "Yes" : "No"));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"QemuFlashDetected => %a\n",
|
||||
FlashDetected ? "Yes" : "No"
|
||||
));
|
||||
return FlashDetected;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read from QEMU Flash
|
||||
|
||||
@@ -136,10 +140,10 @@ QemuFlashDetected (
|
||||
**/
|
||||
EFI_STATUS
|
||||
QemuFlashRead (
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
)
|
||||
{
|
||||
UINT8 *Ptr;
|
||||
@@ -155,14 +159,13 @@ QemuFlashRead (
|
||||
//
|
||||
// Get flash address
|
||||
//
|
||||
Ptr = (UINT8*) QemuFlashPtr (Lba, Offset);
|
||||
Ptr = (UINT8 *)QemuFlashPtr (Lba, Offset);
|
||||
|
||||
CopyMem (Buffer, Ptr, *NumBytes);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write to QEMU Flash
|
||||
|
||||
@@ -175,10 +178,10 @@ QemuFlashRead (
|
||||
**/
|
||||
EFI_STATUS
|
||||
QemuFlashWrite (
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
)
|
||||
{
|
||||
volatile UINT8 *Ptr;
|
||||
@@ -213,7 +216,6 @@ QemuFlashWrite (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Erase a QEMU Flash block
|
||||
|
||||
@@ -222,7 +224,7 @@ QemuFlashWrite (
|
||||
**/
|
||||
EFI_STATUS
|
||||
QemuFlashEraseBlock (
|
||||
IN EFI_LBA Lba
|
||||
IN EFI_LBA Lba
|
||||
)
|
||||
{
|
||||
volatile UINT8 *Ptr;
|
||||
@@ -237,7 +239,6 @@ QemuFlashEraseBlock (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initializes QEMU flash memory support
|
||||
|
||||
@@ -250,16 +251,16 @@ QemuFlashInitialize (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
mFlashBase = (UINT8*)(UINTN) PcdGet32 (PcdOvmfFdBaseAddress);
|
||||
mFlashBase = (UINT8 *)(UINTN)PcdGet32 (PcdOvmfFdBaseAddress);
|
||||
mFdBlockSize = PcdGet32 (PcdOvmfFirmwareBlockSize);
|
||||
ASSERT(PcdGet32 (PcdOvmfFirmwareFdSize) % mFdBlockSize == 0);
|
||||
ASSERT (PcdGet32 (PcdOvmfFirmwareFdSize) % mFdBlockSize == 0);
|
||||
mFdBlockCount = PcdGet32 (PcdOvmfFirmwareFdSize) / mFdBlockSize;
|
||||
|
||||
//
|
||||
// execute module specific hooks before probing the flash
|
||||
//
|
||||
QemuFlashBeforeProbe (
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN) mFlashBase,
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)mFlashBase,
|
||||
mFdBlockSize,
|
||||
mFdBlockCount
|
||||
);
|
||||
@@ -271,4 +272,3 @@ QemuFlashInitialize (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <Protocol/FirmwareVolumeBlock.h>
|
||||
|
||||
extern UINT8 *mFlashBase;
|
||||
extern UINT8 *mFlashBase;
|
||||
|
||||
/**
|
||||
Read from QEMU Flash
|
||||
@@ -26,13 +26,12 @@ extern UINT8 *mFlashBase;
|
||||
**/
|
||||
EFI_STATUS
|
||||
QemuFlashRead (
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Write to QEMU Flash
|
||||
|
||||
@@ -45,13 +44,12 @@ QemuFlashRead (
|
||||
**/
|
||||
EFI_STATUS
|
||||
QemuFlashWrite (
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
IN UINTN *NumBytes,
|
||||
IN UINT8 *Buffer
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Erase a QEMU Flash block
|
||||
|
||||
@@ -60,10 +58,9 @@ QemuFlashWrite (
|
||||
**/
|
||||
EFI_STATUS
|
||||
QemuFlashEraseBlock (
|
||||
IN EFI_LBA Lba
|
||||
IN EFI_LBA Lba
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Initializes QEMU flash memory support
|
||||
|
||||
@@ -76,7 +73,6 @@ QemuFlashInitialize (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
VOID
|
||||
QemuFlashConvertPointers (
|
||||
VOID
|
||||
@@ -84,9 +80,9 @@ QemuFlashConvertPointers (
|
||||
|
||||
VOID
|
||||
QemuFlashBeforeProbe (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN FdBlockSize,
|
||||
IN UINTN FdBlockCount
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN FdBlockSize,
|
||||
IN UINTN FdBlockCount
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -98,9 +94,8 @@ QemuFlashBeforeProbe (
|
||||
**/
|
||||
VOID
|
||||
QemuFlashPtrWrite (
|
||||
IN volatile UINT8 *Ptr,
|
||||
IN UINT8 Value
|
||||
IN volatile UINT8 *Ptr,
|
||||
IN UINT8 Value
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "QemuFlash.h"
|
||||
|
||||
STATIC EFI_PHYSICAL_ADDRESS mSevEsFlashPhysBase;
|
||||
STATIC EFI_PHYSICAL_ADDRESS mSevEsFlashPhysBase;
|
||||
|
||||
VOID
|
||||
QemuFlashConvertPointers (
|
||||
@@ -24,17 +24,17 @@ QemuFlashConvertPointers (
|
||||
)
|
||||
{
|
||||
if (MemEncryptSevEsIsEnabled ()) {
|
||||
mSevEsFlashPhysBase = (UINTN) mFlashBase;
|
||||
mSevEsFlashPhysBase = (UINTN)mFlashBase;
|
||||
}
|
||||
|
||||
EfiConvertPointer (0x0, (VOID **) &mFlashBase);
|
||||
EfiConvertPointer (0x0, (VOID **)&mFlashBase);
|
||||
}
|
||||
|
||||
VOID
|
||||
QemuFlashBeforeProbe (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN FdBlockSize,
|
||||
IN UINTN FdBlockCount
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN FdBlockSize,
|
||||
IN UINTN FdBlockCount
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -51,8 +51,8 @@ QemuFlashBeforeProbe (
|
||||
**/
|
||||
VOID
|
||||
QemuFlashPtrWrite (
|
||||
IN volatile UINT8 *Ptr,
|
||||
IN UINT8 Value
|
||||
IN volatile UINT8 *Ptr,
|
||||
IN UINT8 Value
|
||||
)
|
||||
{
|
||||
if (MemEncryptSevEsIsEnabled ()) {
|
||||
@@ -62,7 +62,7 @@ QemuFlashPtrWrite (
|
||||
BOOLEAN InterruptState;
|
||||
|
||||
Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);
|
||||
Ghcb = Msr.Ghcb;
|
||||
Ghcb = Msr.Ghcb;
|
||||
|
||||
//
|
||||
// The MMIO write needs to be to the physical address of the flash pointer.
|
||||
@@ -70,7 +70,7 @@ QemuFlashPtrWrite (
|
||||
// account for a non-identity mapped VA after SetVirtualAddressMap().
|
||||
//
|
||||
if (mSevEsFlashPhysBase == 0) {
|
||||
PhysAddr = (UINTN) Ptr;
|
||||
PhysAddr = (UINTN)Ptr;
|
||||
} else {
|
||||
PhysAddr = mSevEsFlashPhysBase + (Ptr - mFlashBase);
|
||||
}
|
||||
@@ -83,8 +83,8 @@ QemuFlashPtrWrite (
|
||||
// to perform the update.
|
||||
//
|
||||
VmgInit (Ghcb, &InterruptState);
|
||||
Ghcb->SharedBuffer[0] = Value;
|
||||
Ghcb->SaveArea.SwScratch = (UINT64) (UINTN) Ghcb->SharedBuffer;
|
||||
Ghcb->SharedBuffer[0] = Value;
|
||||
Ghcb->SaveArea.SwScratch = (UINT64)(UINTN)Ghcb->SharedBuffer;
|
||||
VmgSetOffsetValid (Ghcb, GhcbSwScratch);
|
||||
VmgExit (Ghcb, SVM_EXIT_MMIO_WRITE, PhysAddr, 1);
|
||||
VmgDone (Ghcb, InterruptState);
|
||||
|
@@ -16,12 +16,12 @@
|
||||
|
||||
VOID
|
||||
QemuFlashBeforeProbe (
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN FdBlockSize,
|
||||
IN UINTN FdBlockCount
|
||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||
IN UINTN FdBlockSize,
|
||||
IN UINTN FdBlockCount
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (FeaturePcdGet (PcdSmmSmramRequire));
|
||||
|
||||
@@ -55,8 +55,8 @@ QemuFlashBeforeProbe (
|
||||
**/
|
||||
VOID
|
||||
QemuFlashPtrWrite (
|
||||
IN volatile UINT8 *Ptr,
|
||||
IN UINT8 Value
|
||||
IN volatile UINT8 *Ptr,
|
||||
IN UINT8 Value
|
||||
)
|
||||
{
|
||||
*Ptr = Value;
|
||||
|
Reference in New Issue
Block a user