The volatile 'NvVars' variable indicates that the variables do
not need to be loaded from the file again. After we write the
variables out to the file, there is clearly no need to load
them back from the file.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <[email protected]>
Cc: Michael Chang <[email protected]>
Cc: Laszlo Ersek <[email protected]>
---
Michael,

Does this patch fix the issue you highlighted (way back) on June
21st in your patch:
* OvmfPkg/NvVarsFileLib: handle the inital file not found

It is a bit of a guess on my part if this will fix the issue you are
seeing, but it sounds like it might based on your patch. If it does
fix the issue, then I would prefer this patch.

-Jordan

 OvmfPkg/Library/NvVarsFileLib/FsAccess.c |   54 +++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 12 deletions(-)

diff --git a/OvmfPkg/Library/NvVarsFileLib/FsAccess.c 
b/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
index 190a564..937e4ab 100644
--- a/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
+++ b/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
@@ -1,7 +1,7 @@
 /** @file
   File System Access for NvVarsFileLib
 
-  Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   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
@@ -276,6 +276,39 @@ ReadNvVarsFile (
 
 
 /**
+  Writes a variable to indicate that the NV variables
+  have been loaded from the file system.
+
+**/
+STATIC
+VOID
+SetNvVarsVariable (
+  VOID
+  )
+{
+  BOOLEAN                        VarData;
+  UINTN                          Size;
+
+  //
+  // Write a variable to indicate we've already loaded the
+  // variable data.  If it is found, we skip the loading on
+  // subsequent attempts.
+  //
+  Size = sizeof (VarData);
+  VarData = TRUE;
+  gRT->SetVariable (
+         L"NvVars",
+         &gEfiSimpleFileSystemProtocolGuid,
+         EFI_VARIABLE_NON_VOLATILE |
+           EFI_VARIABLE_BOOTSERVICE_ACCESS |
+           EFI_VARIABLE_RUNTIME_ACCESS,
+         Size,
+         (VOID*) &VarData
+         );
+}
+
+
+/**
   Loads the non-volatile variables from the NvVars file on the
   given file system.
 
@@ -332,17 +365,7 @@ LoadNvVarsFromFs (
   // variable data.  If it is found, we skip the loading on
   // subsequent attempts.
   //
-  Size = sizeof (VarData);
-  VarData = TRUE;
-  gRT->SetVariable (
-         L"NvVars",
-         &gEfiSimpleFileSystemProtocolGuid,
-         EFI_VARIABLE_NON_VOLATILE |
-           EFI_VARIABLE_BOOTSERVICE_ACCESS |
-           EFI_VARIABLE_RUNTIME_ACCESS,
-         Size,
-         (VOID*) &VarData
-         );
+  SetNvVarsVariable();
 
   DEBUG ((
     EFI_D_INFO,
@@ -475,6 +498,13 @@ SaveNvVarsToFs (
   FileHandleClose (File);
 
   if (!EFI_ERROR (Status)) {
+    //
+    // Write a variable to indicate we've already loaded the
+    // variable data.  If it is found, we skip the loading on
+    // subsequent attempts.
+    //
+    SetNvVarsVariable();
+
     DEBUG ((EFI_D_INFO, "Saved NV Variables to NvVars file\n"));
   }
 
-- 
1.7.10.4


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to