mirror of https://github.com/acidanthera/audk.git
1. retire the FvbServiceLib. Directly locating FVB protocol to access interfaces.
2. modify the method of getting right FVB protocol interface. move the notification event of FVB installation into variable driver. and also move ExitBootService event into variable driver. 3. use EFI_FVB2_WRITE_STATUS flag to distinct whether the FVB protocol supports writing operation or not.Currently, DxeCore installs FVB which has ~EFI_FVB2_WRITE_STATUS(that is, disable write) attrbiute. FvbRuntimeDxe driver should provide a full FVB protocol, which returns EFI_FVB2_WRITE_STATUS attribute to signify itself provide writable FVB protocol. So other modules which need write data by FVB protocol can locate it correctly. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7835 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
242d687699
commit
8a9e0b7274
|
@ -86,7 +86,7 @@ FwVolBlockGetAttributes (
|
||||||
//
|
//
|
||||||
// Since we are read only, it's safe to get attributes data from our in-memory copy.
|
// Since we are read only, it's safe to get attributes data from our in-memory copy.
|
||||||
//
|
//
|
||||||
*Attributes = FvbDevice->FvbAttributes;
|
*Attributes = FvbDevice->FvbAttributes & ~EFI_FVB2_WRITE_STATUS;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ GetFvbHandleByAddress (
|
||||||
EFI_PHYSICAL_ADDRESS FvbBaseAddress;
|
EFI_PHYSICAL_ADDRESS FvbBaseAddress;
|
||||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
|
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||||
|
EFI_FVB_ATTRIBUTES_2 Attributes;
|
||||||
|
|
||||||
*FvbHandle = NULL;
|
*FvbHandle = NULL;
|
||||||
//
|
//
|
||||||
|
@ -72,6 +73,11 @@ GetFvbHandleByAddress (
|
||||||
Status = EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = Fvb->GetAttributes (Fvb, &Attributes);
|
||||||
|
if (EFI_ERROR (Status) || ((Attributes & EFI_FVB2_WRITE_STATUS) == 0)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Compare the address and select the right one
|
// Compare the address and select the right one
|
||||||
//
|
//
|
||||||
|
|
|
@ -37,6 +37,8 @@ VARIABLE_CACHE_ENTRY mVariableCache[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
|
VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
|
||||||
|
EFI_EVENT mFvbRegistration = NULL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Acquires lock only at boot time. Simply returns at runtime.
|
Acquires lock only at boot time. Simply returns at runtime.
|
||||||
|
@ -213,7 +215,7 @@ IsValidVariableHeader (
|
||||||
@param Volatile Point out the Variable is Volatile or Non-Volatile
|
@param Volatile Point out the Variable is Volatile or Non-Volatile
|
||||||
@param SetByIndex TRUE if target pointer is given as index
|
@param SetByIndex TRUE if target pointer is given as index
|
||||||
FALSE if target pointer is absolute
|
FALSE if target pointer is absolute
|
||||||
@param Instance Instance of FV Block services
|
@param Fvb Pointer to the writable FVB protocol
|
||||||
@param DataPtrIndex Pointer to the Data from the end of VARIABLE_STORE_HEADER
|
@param DataPtrIndex Pointer to the Data from the end of VARIABLE_STORE_HEADER
|
||||||
structure
|
structure
|
||||||
@param DataSize Size of data to be written
|
@param DataSize Size of data to be written
|
||||||
|
@ -228,7 +230,7 @@ UpdateVariableStore (
|
||||||
IN VARIABLE_GLOBAL *Global,
|
IN VARIABLE_GLOBAL *Global,
|
||||||
IN BOOLEAN Volatile,
|
IN BOOLEAN Volatile,
|
||||||
IN BOOLEAN SetByIndex,
|
IN BOOLEAN SetByIndex,
|
||||||
IN UINTN Instance,
|
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
|
||||||
IN UINTN DataPtrIndex,
|
IN UINTN DataPtrIndex,
|
||||||
IN UINT32 DataSize,
|
IN UINT32 DataSize,
|
||||||
IN UINT8 *Buffer
|
IN UINT8 *Buffer
|
||||||
|
@ -255,7 +257,9 @@ UpdateVariableStore (
|
||||||
// Check if the Data is Volatile
|
// Check if the Data is Volatile
|
||||||
//
|
//
|
||||||
if (!Volatile) {
|
if (!Volatile) {
|
||||||
EfiFvbGetPhysicalAddress (Instance, &FvVolHdr);
|
Status = Fvb->GetPhysicalAddress(Fvb, &FvVolHdr);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvVolHdr);
|
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvVolHdr);
|
||||||
//
|
//
|
||||||
// Data Pointer should point to the actual Address where data is to be
|
// Data Pointer should point to the actual Address where data is to be
|
||||||
|
@ -310,8 +314,8 @@ UpdateVariableStore (
|
||||||
//
|
//
|
||||||
if ((CurrWritePtr >= LinearOffset) && (CurrWritePtr < LinearOffset + PtrBlockMapEntry->Length)) {
|
if ((CurrWritePtr >= LinearOffset) && (CurrWritePtr < LinearOffset + PtrBlockMapEntry->Length)) {
|
||||||
if ((CurrWritePtr + CurrWriteSize) <= (LinearOffset + PtrBlockMapEntry->Length)) {
|
if ((CurrWritePtr + CurrWriteSize) <= (LinearOffset + PtrBlockMapEntry->Length)) {
|
||||||
Status = EfiFvbWriteBlock (
|
Status = Fvb->Write (
|
||||||
Instance,
|
Fvb,
|
||||||
LbaNumber,
|
LbaNumber,
|
||||||
(UINTN) (CurrWritePtr - LinearOffset),
|
(UINTN) (CurrWritePtr - LinearOffset),
|
||||||
&CurrWriteSize,
|
&CurrWriteSize,
|
||||||
|
@ -320,8 +324,8 @@ UpdateVariableStore (
|
||||||
return Status;
|
return Status;
|
||||||
} else {
|
} else {
|
||||||
Size = (UINT32) (LinearOffset + PtrBlockMapEntry->Length - CurrWritePtr);
|
Size = (UINT32) (LinearOffset + PtrBlockMapEntry->Length - CurrWritePtr);
|
||||||
Status = EfiFvbWriteBlock (
|
Status = Fvb->Write (
|
||||||
Instance,
|
Fvb,
|
||||||
LbaNumber,
|
LbaNumber,
|
||||||
(UINTN) (CurrWritePtr - LinearOffset),
|
(UINTN) (CurrWritePtr - LinearOffset),
|
||||||
&Size,
|
&Size,
|
||||||
|
@ -1209,7 +1213,7 @@ RuntimeServiceSetVariable (
|
||||||
BOOLEAN Reclaimed;
|
BOOLEAN Reclaimed;
|
||||||
UINTN *VolatileOffset;
|
UINTN *VolatileOffset;
|
||||||
UINTN *NonVolatileOffset;
|
UINTN *NonVolatileOffset;
|
||||||
UINT32 Instance;
|
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
|
||||||
BOOLEAN Volatile;
|
BOOLEAN Volatile;
|
||||||
EFI_PHYSICAL_ADDRESS Point;
|
EFI_PHYSICAL_ADDRESS Point;
|
||||||
|
|
||||||
|
@ -1250,7 +1254,7 @@ RuntimeServiceSetVariable (
|
||||||
AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
||||||
|
|
||||||
Reclaimed = FALSE;
|
Reclaimed = FALSE;
|
||||||
Instance = mVariableModuleGlobal->FvbInstance;
|
Fvb = mVariableModuleGlobal->FvbInstance;
|
||||||
VolatileOffset = &mVariableModuleGlobal->VolatileLastVariableOffset;
|
VolatileOffset = &mVariableModuleGlobal->VolatileLastVariableOffset;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1312,7 +1316,7 @@ RuntimeServiceSetVariable (
|
||||||
&mVariableModuleGlobal->VariableGlobal,
|
&mVariableModuleGlobal->VariableGlobal,
|
||||||
Variable.Volatile,
|
Variable.Volatile,
|
||||||
FALSE,
|
FALSE,
|
||||||
Instance,
|
Fvb,
|
||||||
(UINTN) &Variable.CurrPtr->State,
|
(UINTN) &Variable.CurrPtr->State,
|
||||||
sizeof (UINT8),
|
sizeof (UINT8),
|
||||||
&State
|
&State
|
||||||
|
@ -1346,7 +1350,7 @@ RuntimeServiceSetVariable (
|
||||||
&mVariableModuleGlobal->VariableGlobal,
|
&mVariableModuleGlobal->VariableGlobal,
|
||||||
Variable.Volatile,
|
Variable.Volatile,
|
||||||
FALSE,
|
FALSE,
|
||||||
Instance,
|
Fvb,
|
||||||
(UINTN) &Variable.CurrPtr->State,
|
(UINTN) &Variable.CurrPtr->State,
|
||||||
sizeof (UINT8),
|
sizeof (UINT8),
|
||||||
&State
|
&State
|
||||||
|
@ -1475,7 +1479,7 @@ RuntimeServiceSetVariable (
|
||||||
&mVariableModuleGlobal->VariableGlobal,
|
&mVariableModuleGlobal->VariableGlobal,
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
Instance,
|
Fvb,
|
||||||
*NonVolatileOffset,
|
*NonVolatileOffset,
|
||||||
sizeof (VARIABLE_HEADER),
|
sizeof (VARIABLE_HEADER),
|
||||||
(UINT8 *) NextVariable
|
(UINT8 *) NextVariable
|
||||||
|
@ -1493,7 +1497,7 @@ RuntimeServiceSetVariable (
|
||||||
&mVariableModuleGlobal->VariableGlobal,
|
&mVariableModuleGlobal->VariableGlobal,
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
Instance,
|
Fvb,
|
||||||
*NonVolatileOffset,
|
*NonVolatileOffset,
|
||||||
sizeof (VARIABLE_HEADER),
|
sizeof (VARIABLE_HEADER),
|
||||||
(UINT8 *) NextVariable
|
(UINT8 *) NextVariable
|
||||||
|
@ -1509,7 +1513,7 @@ RuntimeServiceSetVariable (
|
||||||
&mVariableModuleGlobal->VariableGlobal,
|
&mVariableModuleGlobal->VariableGlobal,
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
Instance,
|
Fvb,
|
||||||
*NonVolatileOffset + sizeof (VARIABLE_HEADER),
|
*NonVolatileOffset + sizeof (VARIABLE_HEADER),
|
||||||
(UINT32) VarSize - sizeof (VARIABLE_HEADER),
|
(UINT32) VarSize - sizeof (VARIABLE_HEADER),
|
||||||
(UINT8 *) NextVariable + sizeof (VARIABLE_HEADER)
|
(UINT8 *) NextVariable + sizeof (VARIABLE_HEADER)
|
||||||
|
@ -1526,7 +1530,7 @@ RuntimeServiceSetVariable (
|
||||||
&mVariableModuleGlobal->VariableGlobal,
|
&mVariableModuleGlobal->VariableGlobal,
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
Instance,
|
Fvb,
|
||||||
*NonVolatileOffset,
|
*NonVolatileOffset,
|
||||||
sizeof (VARIABLE_HEADER),
|
sizeof (VARIABLE_HEADER),
|
||||||
(UINT8 *) NextVariable
|
(UINT8 *) NextVariable
|
||||||
|
@ -1571,7 +1575,7 @@ RuntimeServiceSetVariable (
|
||||||
&mVariableModuleGlobal->VariableGlobal,
|
&mVariableModuleGlobal->VariableGlobal,
|
||||||
TRUE,
|
TRUE,
|
||||||
TRUE,
|
TRUE,
|
||||||
Instance,
|
Fvb,
|
||||||
*VolatileOffset,
|
*VolatileOffset,
|
||||||
(UINT32) VarSize,
|
(UINT32) VarSize,
|
||||||
(UINT8 *) NextVariable
|
(UINT8 *) NextVariable
|
||||||
|
@ -1594,7 +1598,7 @@ RuntimeServiceSetVariable (
|
||||||
&mVariableModuleGlobal->VariableGlobal,
|
&mVariableModuleGlobal->VariableGlobal,
|
||||||
Variable.Volatile,
|
Variable.Volatile,
|
||||||
FALSE,
|
FALSE,
|
||||||
Instance,
|
Fvb,
|
||||||
(UINTN) &Variable.CurrPtr->State,
|
(UINTN) &Variable.CurrPtr->State,
|
||||||
sizeof (UINT8),
|
sizeof (UINT8),
|
||||||
&State
|
&State
|
||||||
|
@ -1792,7 +1796,6 @@ ReclaimForOS(
|
||||||
/**
|
/**
|
||||||
Initializes variable store area for non-volatile and volatile variable.
|
Initializes variable store area for non-volatile and volatile variable.
|
||||||
|
|
||||||
@param ImageHandle The Image handle of this driver.
|
|
||||||
@param SystemTable The pointer of EFI_SYSTEM_TABLE.
|
@param SystemTable The pointer of EFI_SYSTEM_TABLE.
|
||||||
|
|
||||||
@retval EFI_SUCCESS Function successfully executed.
|
@retval EFI_SUCCESS Function successfully executed.
|
||||||
|
@ -1801,25 +1804,20 @@ ReclaimForOS(
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
VariableCommonInitialize (
|
VariableCommonInitialize (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
|
||||||
CHAR8 *CurrPtr;
|
|
||||||
VARIABLE_STORE_HEADER *VolatileVariableStore;
|
VARIABLE_STORE_HEADER *VolatileVariableStore;
|
||||||
VARIABLE_STORE_HEADER *VariableStoreHeader;
|
VARIABLE_STORE_HEADER *VariableStoreHeader;
|
||||||
VARIABLE_HEADER *NextVariable;
|
VARIABLE_HEADER *NextVariable;
|
||||||
UINT32 Instance;
|
EFI_PHYSICAL_ADDRESS TempVariableStoreHeader;
|
||||||
EFI_PHYSICAL_ADDRESS FvVolHdr;
|
|
||||||
UINT64 TempVariableStoreHeader;
|
|
||||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
|
||||||
UINT64 BaseAddress;
|
EFI_PHYSICAL_ADDRESS BaseAddress;
|
||||||
UINT64 Length;
|
UINT64 Length;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINT8 Data;
|
UINT8 Data;
|
||||||
UINT64 VariableStoreBase;
|
EFI_PHYSICAL_ADDRESS VariableStoreBase;
|
||||||
UINT64 VariableStoreLength;
|
UINT64 VariableStoreLength;
|
||||||
EFI_EVENT ReadyToBootEvent;
|
EFI_EVENT ReadyToBootEvent;
|
||||||
|
|
||||||
|
@ -1851,6 +1849,7 @@ VariableCommonInitialize (
|
||||||
//
|
//
|
||||||
mVariableModuleGlobal->VariableGlobal.VolatileVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) VolatileVariableStore;
|
mVariableModuleGlobal->VariableGlobal.VolatileVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) VolatileVariableStore;
|
||||||
mVariableModuleGlobal->VolatileLastVariableOffset = (UINTN) GetStartPointer (VolatileVariableStore) - (UINTN) VolatileVariableStore;
|
mVariableModuleGlobal->VolatileLastVariableOffset = (UINTN) GetStartPointer (VolatileVariableStore) - (UINTN) VolatileVariableStore;
|
||||||
|
mVariableModuleGlobal->FvbInstance = FvbProtocol;
|
||||||
|
|
||||||
CopyGuid (&VolatileVariableStore->Signature, &gEfiVariableGuid);
|
CopyGuid (&VolatileVariableStore->Signature, &gEfiVariableGuid);
|
||||||
VolatileVariableStore->Size = FixedPcdGet32(PcdVariableStoreSize);
|
VolatileVariableStore->Size = FixedPcdGet32(PcdVariableStoreSize);
|
||||||
|
@ -1863,11 +1862,11 @@ VariableCommonInitialize (
|
||||||
// Get non volatile varaible store
|
// Get non volatile varaible store
|
||||||
//
|
//
|
||||||
|
|
||||||
TempVariableStoreHeader = (UINT64) PcdGet32 (PcdFlashNvStorageVariableBase);
|
TempVariableStoreHeader = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);
|
||||||
VariableStoreBase = TempVariableStoreHeader + \
|
VariableStoreBase = TempVariableStoreHeader + \
|
||||||
(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength);
|
(((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)(TempVariableStoreHeader)) -> HeaderLength);
|
||||||
VariableStoreLength = (UINT64) PcdGet32 (PcdFlashNvStorageVariableSize) - \
|
VariableStoreLength = (UINT64) PcdGet32 (PcdFlashNvStorageVariableSize) - \
|
||||||
(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength);
|
(((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)(TempVariableStoreHeader)) -> HeaderLength);
|
||||||
//
|
//
|
||||||
// Mark the variable storage region of the FLASH as RUNTIME
|
// Mark the variable storage region of the FLASH as RUNTIME
|
||||||
//
|
//
|
||||||
|
@ -1892,26 +1891,7 @@ VariableCommonInitialize (
|
||||||
// Get address of non volatile variable store base
|
// Get address of non volatile variable store base
|
||||||
//
|
//
|
||||||
mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;
|
mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;
|
||||||
|
VariableStoreHeader = (VARIABLE_STORE_HEADER *)(UINTN)VariableStoreBase;
|
||||||
//
|
|
||||||
// Check Integrity
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Find the Correct Instance of the FV Block Service.
|
|
||||||
//
|
|
||||||
Instance = 0;
|
|
||||||
CurrPtr = (CHAR8 *) ((UINTN) mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase);
|
|
||||||
while (EfiFvbGetPhysicalAddress (Instance, &FvVolHdr) == EFI_SUCCESS) {
|
|
||||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvVolHdr);
|
|
||||||
if (CurrPtr >= (CHAR8 *) FwVolHeader && CurrPtr < (((CHAR8 *) FwVolHeader) + FwVolHeader->FvLength)) {
|
|
||||||
mVariableModuleGlobal->FvbInstance = Instance;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Instance++;
|
|
||||||
}
|
|
||||||
|
|
||||||
VariableStoreHeader = (VARIABLE_STORE_HEADER *) CurrPtr;
|
|
||||||
if (GetVariableStoreStatus (VariableStoreHeader) == EfiValid) {
|
if (GetVariableStoreStatus (VariableStoreHeader) == EfiValid) {
|
||||||
if (~VariableStoreHeader->Size == 0) {
|
if (~VariableStoreHeader->Size == 0) {
|
||||||
Status = UpdateVariableStore (
|
Status = UpdateVariableStore (
|
||||||
|
@ -1938,18 +1918,17 @@ VariableCommonInitialize (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = (EFI_PHYSICAL_ADDRESS) ((UINTN) CurrPtr);
|
|
||||||
//
|
//
|
||||||
// Parse non-volatile variable data and get last variable offset
|
// Parse non-volatile variable data and get last variable offset
|
||||||
//
|
//
|
||||||
NextVariable = GetStartPointer ((VARIABLE_STORE_HEADER *) CurrPtr);
|
NextVariable = GetStartPointer ((VARIABLE_STORE_HEADER *)(UINTN)VariableStoreBase);
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
while (IsValidVariableHeader (NextVariable)) {
|
while (IsValidVariableHeader (NextVariable)) {
|
||||||
NextVariable = GetNextVariablePtr (NextVariable);
|
NextVariable = GetNextVariablePtr (NextVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) NextVariable - (UINTN) CurrPtr;
|
mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) NextVariable - (UINTN) VariableStoreBase;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if the free area is really free.
|
// Check if the free area is really free.
|
||||||
|
@ -2015,6 +1994,14 @@ VariableClassAddressChangeEvent (
|
||||||
IN VOID *Context
|
IN VOID *Context
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetBlockSize);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetPhysicalAddress);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->GetAttributes);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->SetAttributes);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->Read);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->Write);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance->EraseBlocks);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->FvbInstance);
|
||||||
EfiConvertPointer (
|
EfiConvertPointer (
|
||||||
0x0,
|
0x0,
|
||||||
(VOID **) &mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase
|
(VOID **) &mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase
|
||||||
|
@ -2026,29 +2013,84 @@ VariableClassAddressChangeEvent (
|
||||||
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
/**
|
|
||||||
Variable Driver main entry point. The Variable driver places the 4 EFI
|
|
||||||
runtime services in the EFI System Table and installs arch protocols
|
|
||||||
for variable read and write services being availible. It also registers
|
|
||||||
notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
|
|
||||||
|
|
||||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
|
||||||
@param[in] SystemTable A pointer to the EFI System Table.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Variable service successfully initialized.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
EFIAPI
|
||||||
VariableServiceInitialize (
|
FvbNotificationEvent (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_EVENT Event,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN VOID *Context
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_HANDLE *HandleBuffer;
|
||||||
|
EFI_HANDLE FvbHandle;
|
||||||
|
UINTN HandleCount;
|
||||||
|
UINTN Index;
|
||||||
|
EFI_PHYSICAL_ADDRESS FvbBaseAddress;
|
||||||
|
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
|
||||||
|
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||||
|
EFI_FVB_ATTRIBUTES_2 Attributes;
|
||||||
|
EFI_SYSTEM_TABLE *SystemTable;
|
||||||
|
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
|
||||||
|
|
||||||
Status = VariableCommonInitialize (ImageHandle, SystemTable);
|
SystemTable = (EFI_SYSTEM_TABLE *)Context;
|
||||||
|
Fvb = NULL;
|
||||||
|
FvbHandle = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Locate all handles of Fvb protocol
|
||||||
|
//
|
||||||
|
Status = gBS->LocateHandleBuffer (
|
||||||
|
ByProtocol,
|
||||||
|
&gEfiFirmwareVolumeBlockProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
&HandleCount,
|
||||||
|
&HandleBuffer
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get the FVB to access variable store
|
||||||
|
//
|
||||||
|
for (Index = 0; Index < HandleCount; Index += 1, Status = EFI_NOT_FOUND) {
|
||||||
|
Status = gBS->HandleProtocol (
|
||||||
|
HandleBuffer[Index],
|
||||||
|
&gEfiFirmwareVolumeBlockProtocolGuid,
|
||||||
|
(VOID **) &Fvb
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
Status = EFI_NOT_FOUND;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Ensure this FVB protocol supported Write operation.
|
||||||
|
//
|
||||||
|
Status = Fvb->GetAttributes (Fvb, &Attributes);
|
||||||
|
if (EFI_ERROR (Status) || ((Attributes & EFI_FVB2_WRITE_STATUS) == 0)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Compare the address and select the right one
|
||||||
|
//
|
||||||
|
Status = Fvb->GetPhysicalAddress (Fvb, &FvbBaseAddress);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvbBaseAddress);
|
||||||
|
NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);
|
||||||
|
if ((NvStorageVariableBase >= FvbBaseAddress) && (NvStorageVariableBase < (FvbBaseAddress + FwVolHeader->FvLength))) {
|
||||||
|
FvbHandle = HandleBuffer[Index];
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FreePool (HandleBuffer);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Status = VariableCommonInitialize (Fvb);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
SystemTable->RuntimeServices->GetVariable = RuntimeServiceGetVariable;
|
SystemTable->RuntimeServices->GetVariable = RuntimeServiceGetVariable;
|
||||||
|
@ -2076,6 +2118,39 @@ VariableServiceInitialize (
|
||||||
&mVirtualAddressChangeEvent
|
&mVirtualAddressChangeEvent
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Variable Driver main entry point. The Variable driver places the 4 EFI
|
||||||
|
runtime services in the EFI System Table and installs arch protocols
|
||||||
|
for variable read and write services being availible. It also registers
|
||||||
|
notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
|
||||||
|
|
||||||
|
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||||
|
@param[in] SystemTable A pointer to the EFI System Table.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Variable service successfully initialized.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
VariableServiceInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Register FvbNotificationEvent () notify function.
|
||||||
|
//
|
||||||
|
EfiCreateProtocolNotifyEvent (
|
||||||
|
&gEfiFirmwareVolumeBlockProtocolGuid,
|
||||||
|
TPL_CALLBACK,
|
||||||
|
FvbNotificationEvent,
|
||||||
|
(VOID *)SystemTable,
|
||||||
|
&mFvbRegistration
|
||||||
|
);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ typedef struct {
|
||||||
VARIABLE_GLOBAL VariableGlobal;
|
VARIABLE_GLOBAL VariableGlobal;
|
||||||
UINTN VolatileLastVariableOffset;
|
UINTN VolatileLastVariableOffset;
|
||||||
UINTN NonVolatileLastVariableOffset;
|
UINTN NonVolatileLastVariableOffset;
|
||||||
UINT32 FvbInstance;
|
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbInstance;
|
||||||
} VARIABLE_MODULE_GLOBAL;
|
} VARIABLE_MODULE_GLOBAL;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
SynchronizationLib
|
SynchronizationLib
|
||||||
UefiLib
|
UefiLib
|
||||||
UefiBootServicesTableLib
|
UefiBootServicesTableLib
|
||||||
FvbServiceLib
|
|
||||||
BaseMemoryLib
|
BaseMemoryLib
|
||||||
DebugLib
|
DebugLib
|
||||||
UefiRuntimeLib
|
UefiRuntimeLib
|
||||||
|
|
Loading…
Reference in New Issue