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
|
||||||
|
@ -225,13 +227,13 @@ IsValidVariableHeader (
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
UpdateVariableStore (
|
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
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;
|
EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;
|
||||||
|
@ -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,18 +314,18 @@ 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,
|
||||||
CurrBuffer
|
CurrBuffer
|
||||||
);
|
);
|
||||||
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,
|
||||||
|
@ -1198,20 +1202,20 @@ RuntimeServiceSetVariable (
|
||||||
IN VOID *Data
|
IN VOID *Data
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VARIABLE_POINTER_TRACK Variable;
|
VARIABLE_POINTER_TRACK Variable;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
VARIABLE_HEADER *NextVariable;
|
VARIABLE_HEADER *NextVariable;
|
||||||
UINTN VarNameSize;
|
UINTN VarNameSize;
|
||||||
UINTN VarNameOffset;
|
UINTN VarNameOffset;
|
||||||
UINTN VarDataOffset;
|
UINTN VarDataOffset;
|
||||||
UINTN VarSize;
|
UINTN VarSize;
|
||||||
UINT8 State;
|
UINT8 State;
|
||||||
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;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check input parameters
|
// Check input parameters
|
||||||
|
@ -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,6 +2013,114 @@ VariableClassAddressChangeEvent (
|
||||||
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
FvbNotificationEvent (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
SystemTable->RuntimeServices->GetVariable = RuntimeServiceGetVariable;
|
||||||
|
SystemTable->RuntimeServices->GetNextVariableName = RuntimeServiceGetNextVariableName;
|
||||||
|
SystemTable->RuntimeServices->SetVariable = RuntimeServiceSetVariable;
|
||||||
|
SystemTable->RuntimeServices->QueryVariableInfo = RuntimeServiceQueryVariableInfo;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Now install the Variable Runtime Architectural Protocol on a new handle
|
||||||
|
//
|
||||||
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
|
&mHandle,
|
||||||
|
&gEfiVariableArchProtocolGuid, NULL,
|
||||||
|
&gEfiVariableWriteArchProtocolGuid, NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
Status = gBS->CreateEventEx (
|
||||||
|
EVT_NOTIFY_SIGNAL,
|
||||||
|
TPL_NOTIFY,
|
||||||
|
VariableClassAddressChangeEvent,
|
||||||
|
NULL,
|
||||||
|
&gEfiEventVirtualAddressChangeGuid,
|
||||||
|
&mVirtualAddressChangeEvent
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Variable Driver main entry point. The Variable driver places the 4 EFI
|
Variable Driver main entry point. The Variable driver places the 4 EFI
|
||||||
|
@ -2046,36 +2141,16 @@ VariableServiceInitialize (
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
|
||||||
|
|
||||||
Status = VariableCommonInitialize (ImageHandle, SystemTable);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
SystemTable->RuntimeServices->GetVariable = RuntimeServiceGetVariable;
|
|
||||||
SystemTable->RuntimeServices->GetNextVariableName = RuntimeServiceGetNextVariableName;
|
|
||||||
SystemTable->RuntimeServices->SetVariable = RuntimeServiceSetVariable;
|
|
||||||
SystemTable->RuntimeServices->QueryVariableInfo = RuntimeServiceQueryVariableInfo;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now install the Variable Runtime Architectural Protocol on a new handle
|
// Register FvbNotificationEvent () notify function.
|
||||||
//
|
//
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
EfiCreateProtocolNotifyEvent (
|
||||||
&mHandle,
|
&gEfiFirmwareVolumeBlockProtocolGuid,
|
||||||
&gEfiVariableArchProtocolGuid, NULL,
|
TPL_CALLBACK,
|
||||||
&gEfiVariableWriteArchProtocolGuid, NULL,
|
FvbNotificationEvent,
|
||||||
NULL
|
(VOID *)SystemTable,
|
||||||
);
|
&mFvbRegistration
|
||||||
ASSERT_EFI_ERROR (Status);
|
);
|
||||||
|
|
||||||
Status = gBS->CreateEventEx (
|
|
||||||
EVT_NOTIFY_SIGNAL,
|
|
||||||
TPL_NOTIFY,
|
|
||||||
VariableClassAddressChangeEvent,
|
|
||||||
NULL,
|
|
||||||
&gEfiEventVirtualAddressChangeGuid,
|
|
||||||
&mVirtualAddressChangeEvent
|
|
||||||
);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
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