mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 15:44:04 +02:00
MdeModulePkg Variable: Not get NV PCD in VariableWriteServiceInitialize
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323 Merge EmuVariable and Real variable driver. Add macro NV_STORAGE_VARIABLE_BASE. Not get NV PCD in VariableWriteServiceInitialize, but in FtwNotificationEvent/SmmFtwNotificationEvent, then VariableWriteServiceInitialize could be not aware the NV storage is real or emulated. This patch prepares for adding emulated variable NV mode support in VariableRuntimeDxe. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao Wu <hao.a.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Tested-by: Julien Grall <julien.grall@arm.com> Acked-by: Julien Grall <julien.grall@arm.com>
This commit is contained in:
parent
5f0871e3d8
commit
904e0ca997
@ -3770,10 +3770,7 @@ InitRealNonVolatileVariableStore (
|
|||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);
|
NvStorageBase = NV_STORAGE_VARIABLE_BASE;
|
||||||
if (NvStorageBase == 0) {
|
|
||||||
NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);
|
|
||||||
}
|
|
||||||
ASSERT (NvStorageBase != 0);
|
ASSERT (NvStorageBase != 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -4027,7 +4024,7 @@ FlushHobVariableToFlash (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes variable write service after FTW was ready.
|
Initializes variable write service.
|
||||||
|
|
||||||
@retval EFI_SUCCESS Function successfully executed.
|
@retval EFI_SUCCESS Function successfully executed.
|
||||||
@retval Others Fail to initialize the variable service.
|
@retval Others Fail to initialize the variable service.
|
||||||
@ -4041,23 +4038,10 @@ VariableWriteServiceInitialize (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINT8 Data;
|
UINT8 Data;
|
||||||
EFI_PHYSICAL_ADDRESS VariableStoreBase;
|
|
||||||
EFI_PHYSICAL_ADDRESS NvStorageBase;
|
|
||||||
VARIABLE_ENTRY_PROPERTY *VariableEntry;
|
VARIABLE_ENTRY_PROPERTY *VariableEntry;
|
||||||
|
|
||||||
AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
||||||
|
|
||||||
NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);
|
|
||||||
if (NvStorageBase == 0) {
|
|
||||||
NvStorageBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);
|
|
||||||
}
|
|
||||||
VariableStoreBase = NvStorageBase + (mNvFvHeaderCache->HeaderLength);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.
|
|
||||||
//
|
|
||||||
mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if the free area is really free.
|
// Check if the free area is really free.
|
||||||
//
|
//
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
The internal header file includes the common header files, defines
|
The internal header file includes the common header files, defines
|
||||||
internal structure and functions used by Variable modules.
|
internal structure and functions used by Variable modules.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -46,6 +46,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include "PrivilegePolymorphic.h"
|
#include "PrivilegePolymorphic.h"
|
||||||
|
|
||||||
|
#define NV_STORAGE_VARIABLE_BASE (EFI_PHYSICAL_ADDRESS) \
|
||||||
|
(PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ? \
|
||||||
|
PcdGet64 (PcdFlashNvStorageVariableBase64) : \
|
||||||
|
PcdGet32 (PcdFlashNvStorageVariableBase))
|
||||||
|
|
||||||
#define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE | \
|
#define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE | \
|
||||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | \
|
EFI_VARIABLE_BOOTSERVICE_ACCESS | \
|
||||||
EFI_VARIABLE_RUNTIME_ACCESS | \
|
EFI_VARIABLE_RUNTIME_ACCESS | \
|
||||||
@ -473,7 +478,7 @@ GetMaxVariableSize (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes variable write service after FVB was ready.
|
Initializes variable write service.
|
||||||
|
|
||||||
@retval EFI_SUCCESS Function successfully executed.
|
@retval EFI_SUCCESS Function successfully executed.
|
||||||
@retval Others Fail to initialize the variable service.
|
@retval Others Fail to initialize the variable service.
|
||||||
|
@ -382,13 +382,17 @@ FtwNotificationEvent (
|
|||||||
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
|
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
|
||||||
|
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.
|
||||||
|
//
|
||||||
|
mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find the proper FVB protocol for variable.
|
// Find the proper FVB protocol for variable.
|
||||||
//
|
//
|
||||||
NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);
|
|
||||||
if (NvStorageVariableBase == 0) {
|
|
||||||
NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);
|
|
||||||
}
|
|
||||||
Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);
|
Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return ;
|
return ;
|
||||||
@ -398,7 +402,6 @@ FtwNotificationEvent (
|
|||||||
//
|
//
|
||||||
// Mark the variable storage region of the FLASH as RUNTIME.
|
// Mark the variable storage region of the FLASH as RUNTIME.
|
||||||
//
|
//
|
||||||
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
|
|
||||||
VariableStoreLength = mNvVariableCache->Size;
|
VariableStoreLength = mNvVariableCache->Size;
|
||||||
BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);
|
BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);
|
||||||
Length = VariableStoreLength + (VariableStoreBase - BaseAddress);
|
Length = VariableStoreLength + (VariableStoreBase - BaseAddress);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
VariableServiceSetVariable(), VariableServiceQueryVariableInfo(), ReclaimForOS(),
|
VariableServiceSetVariable(), VariableServiceQueryVariableInfo(), ReclaimForOS(),
|
||||||
SmmVariableGetStatistics() should also do validation based on its own knowledge.
|
SmmVariableGetStatistics() should also do validation based on its own knowledge.
|
||||||
|
|
||||||
Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
|
||||||
Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
|
Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -862,6 +862,7 @@ SmmFtwNotificationEvent (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_PHYSICAL_ADDRESS VariableStoreBase;
|
||||||
EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;
|
EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;
|
||||||
EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
|
EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
|
||||||
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
|
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
|
||||||
@ -884,13 +885,17 @@ SmmFtwNotificationEvent (
|
|||||||
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
|
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
|
||||||
|
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.
|
||||||
|
//
|
||||||
|
mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase = VariableStoreBase;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find the proper FVB protocol for variable.
|
// Find the proper FVB protocol for variable.
|
||||||
//
|
//
|
||||||
NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet64 (PcdFlashNvStorageVariableBase64);
|
|
||||||
if (NvStorageVariableBase == 0) {
|
|
||||||
NvStorageVariableBase = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageVariableBase);
|
|
||||||
}
|
|
||||||
Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);
|
Status = GetFvbInfoByAddress (NvStorageVariableBase, NULL, &FvbProtocol);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user