From 9ae0edbfa90b6e19765c407d950bed44ee6c01ef Mon Sep 17 00:00:00 2001 From: gdong1 Date: Fri, 31 Dec 2010 04:31:42 +0000 Subject: [PATCH] =?UTF-8?q?1.=20Invoke=20InstallConfigurationTable=20()=20?= =?UTF-8?q?in=20OnReadyToBoot()=20to=20avoid=20the=20new=20registered=20ta?= =?UTF-8?q?ble=20may=20be=20NULL.=202.=20For=20SMM=20variable=20driver,=20?= =?UTF-8?q?it=20doesn=E2=80=99t=20need=20to=20mark=20the=20variable=20stor?= =?UTF-8?q?age=20region=20of=20the=20FLASH=20as=20RUNTIME,=20so=20only=20k?= =?UTF-8?q?eep=20it=20for=20non-SMM=20variable=20driver.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11212 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/Variable/RuntimeDxe/Variable.c | 23 ------------- .../Variable/RuntimeDxe/VariableDxe.c | 34 +++++++++++++++++-- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 8bf585a72a..9da00f1275 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -2259,9 +2259,6 @@ VariableWriteServiceInitialize ( VARIABLE_STORE_HEADER *VariableStoreHeader; UINTN Index; UINT8 Data; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; - EFI_PHYSICAL_ADDRESS BaseAddress; - UINT64 Length; EFI_PHYSICAL_ADDRESS VariableStoreBase; UINT64 VariableStoreLength; @@ -2291,26 +2288,6 @@ VariableWriteServiceInitialize ( } } - // - // Mark the variable storage region of the FLASH as RUNTIME. - // - BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK); - Length = VariableStoreLength + (VariableStoreBase - BaseAddress); - Length = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK); - - Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n")); - } else { - Status = gDS->SetMemorySpaceAttributes ( - BaseAddress, - Length, - GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n")); - } - } return EFI_SUCCESS; } diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c index 70723b320f..86028beca9 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c @@ -255,6 +255,9 @@ OnReadyToBoot ( ) { ReclaimForOS (); + if (FeaturePcdGet (PcdVariableCollectStatistics)) { + gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo); + } } @@ -279,6 +282,11 @@ FtwNotificationEvent ( EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol; EFI_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol; EFI_PHYSICAL_ADDRESS NvStorageVariableBase; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; + EFI_PHYSICAL_ADDRESS BaseAddress; + UINT64 Length; + EFI_PHYSICAL_ADDRESS VariableStoreBase; + UINT64 VariableStoreLength; // // Ensure FTW protocol is installed. @@ -300,6 +308,29 @@ FtwNotificationEvent ( return ; } mVariableModuleGlobal->FvbInstance = FvbProtocol; + + // + // Mark the variable storage region of the FLASH as RUNTIME. + // + VariableStoreBase = mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase; + VariableStoreLength = ((VARIABLE_STORE_HEADER *)(UINTN)VariableStoreBase)->Size; + BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK); + Length = VariableStoreLength + (VariableStoreBase - BaseAddress); + Length = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK); + + Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n")); + } else { + Status = gDS->SetMemorySpaceAttributes ( + BaseAddress, + Length, + GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n")); + } + } Status = VariableWriteServiceInitialize (); ASSERT_EFI_ERROR (Status); @@ -395,9 +426,6 @@ VariableServiceInitialize ( &ReadyToBootEvent ); - if (FeaturePcdGet (PcdVariableCollectStatistics)) { - gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo); - } return EFI_SUCCESS; }