]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add a lock to protect the critical region in Service APIs for UEFI Runtime Variable...
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 12 Mar 2007 07:56:16 +0000 (07:56 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 12 Mar 2007 07:56:16 +0000 (07:56 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2444 6f19259b-4bc3-4df7-8a09-765794883524

12 files changed:
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.msa
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariableIpf.msa
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/InitVariable.c
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Ipf/InitVariable.c
EdkModulePkg/Universal/EmuVariable/RuntimeDxe/Variable.h
EdkModulePkg/Universal/Variable/RuntimeDxe/InitVariable.c
EdkModulePkg/Universal/Variable/RuntimeDxe/Ipf/InitVariable.c
EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c
EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h
EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa
EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa

index 208f3b427682c4bac482867044f144398c064bf9..d39ecd2ce07bac010d13938e3430ebad911acf12 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -26,6 +26,37 @@ Revision History
 //\r
 ESAL_VARIABLE_GLOBAL  *mVariableModuleGlobal;\r
 \r
+//\r
+// This is a temperary function which will be removed \r
+// when EfiAcquireLock in UefiLib can handle the\r
+// the call in UEFI Runtimer driver in RT phase.\r
+//\r
+VOID\r
+AcquireLockOnlyAtBootTime (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+{\r
+  if (!EfiAtRuntime ()) {\r
+    EfiAcquireLock (Lock);\r
+  }\r
+}\r
+\r
+//\r
+// This is a temperary function which will be removed \r
+// when EfiAcquireLock in UefiLib can handle the\r
+// the call in UEFI Runtimer driver in RT phase.\r
+//\r
+VOID\r
+ReleaseLockOnlyAtBootTime (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+{\r
+  if (!EfiAtRuntime ()) {\r
+    EfiReleaseLock (Lock);\r
+  }\r
+}\r
+\r
+\r
 STATIC\r
 UINT32\r
 EFIAPI\r
@@ -197,6 +228,13 @@ Returns:
   VARIABLE_STORE_HEADER *VariableStoreHeader[2];\r
   UINTN                 Index;\r
 \r
+  //\r
+  // We aquire the lock at the entry of FindVariable as GetVariable, GetNextVariableName\r
+  // SetVariable all call FindVariable at entry point. Please move "Aquire Lock" to\r
+  // the correct places if this assumption does not hold TRUE anymore.\r
+  //\r
+  AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
+\r
   //\r
   // 0: Non-Volatile, 1: Volatile\r
   //\r
@@ -293,7 +331,7 @@ Returns:
   Status = FindVariable (VariableName, VendorGuid, &Variable, Global);\r
 \r
   if (Variable.CurrPtr == NULL || EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto Done;\r
   }\r
   //\r
   // Get data size\r
@@ -301,7 +339,8 @@ Returns:
   VarDataSize = Variable.CurrPtr->DataSize;\r
   if (*DataSize >= VarDataSize) {\r
     if (Data == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
+      Status = EFI_INVALID_PARAMETER;\r
+      goto Done;\r
     }\r
 \r
     CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr), VarDataSize);\r
@@ -310,11 +349,17 @@ Returns:
     }\r
 \r
     *DataSize = VarDataSize;\r
-    return EFI_SUCCESS;\r
+    Status = EFI_SUCCESS;\r
+    goto Done;\r
   } else {\r
     *DataSize = VarDataSize;\r
-    return EFI_BUFFER_TOO_SMALL;\r
+    Status = EFI_BUFFER_TOO_SMALL;\r
+    goto Done;\r
   }\r
+\r
+Done:\r
+  ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r
@@ -357,7 +402,7 @@ Returns:
   Status = FindVariable (VariableName, VendorGuid, &Variable, Global);\r
 \r
   if (Variable.CurrPtr == NULL || EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto Done;\r
   }\r
 \r
   while (TRUE) {\r
@@ -377,7 +422,8 @@ Returns:
         Variable.StartPtr = (VARIABLE_HEADER *) ((UINTN) (Global->VolatileVariableBase + sizeof (VARIABLE_STORE_HEADER)));\r
         Variable.EndPtr = (VARIABLE_HEADER *) GetEndPointer ((VARIABLE_STORE_HEADER *) ((UINTN) Global->VolatileVariableBase));\r
       } else {\r
-        goto Error;\r
+        Status = EFI_NOT_FOUND;\r
+        goto Done;\r
       }\r
 \r
       Variable.CurrPtr = Variable.StartPtr;\r
@@ -408,13 +454,15 @@ Returns:
         }\r
 \r
         *VariableNameSize = VarNameSize;\r
-        return Status;\r
+        goto Done;\r
       }\r
     }\r
   }\r
 \r
-Error:\r
-  return EFI_NOT_FOUND;\r
+Done:\r
+  ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
+  return Status;\r
\r
 }\r
 \r
 EFI_STATUS\r
@@ -470,36 +518,41 @@ Returns:
   Status = FindVariable (VariableName, VendorGuid, &Variable, Global);\r
 \r
   if (Status == EFI_INVALID_PARAMETER) {\r
-    return Status;\r
+    goto Done;\r
   } else if (!EFI_ERROR (Status) && Variable.Volatile && EfiAtRuntime()) {\r
     //\r
     // If EfiAtRuntime and the variable is Volatile and Runtime Access,  \r
     // the volatile is ReadOnly, and SetVariable should be aborted and \r
     // return EFI_WRITE_PROTECTED.\r
     //\r
-    return EFI_WRITE_PROTECTED;\r
+    Status = EFI_WRITE_PROTECTED;\r
+    goto Done;\r
   } else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {\r
     //\r
     //  The size of the VariableName, including the Unicode Null in bytes plus\r
     //  the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.\r
     //\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS\r
           ) {\r
     //\r
     //  Make sure if runtime bit is set, boot service bit is set also\r
     //\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {\r
     //\r
     // Runtime but Attribute is not Runtime\r
     //\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {\r
     //\r
     // Cannot set volatile variable in Runtime\r
     //\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   } else if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {\r
     //\r
     // Setting a data variable with no access, or zero DataSize attributes\r
@@ -507,10 +560,12 @@ Returns:
     //\r
     if (!EFI_ERROR (Status)) {\r
       Variable.CurrPtr->State &= VAR_DELETED;\r
-      return EFI_SUCCESS;\r
+      Status = EFI_SUCCESS;\r
+      goto Done;\r
     }\r
 \r
-    return EFI_NOT_FOUND;\r
+    Status = EFI_NOT_FOUND;\r
+    goto Done;\r
   } else {\r
     if (!EFI_ERROR (Status)) {\r
       //\r
@@ -520,7 +575,8 @@ Returns:
       if (Variable.CurrPtr->DataSize == DataSize &&\r
           !CompareMem (Data, GetVariableDataPtr (Variable.CurrPtr), DataSize)\r
             ) {\r
-        return EFI_SUCCESS;\r
+        Status = EFI_SUCCESS;\r
+        goto Done;\r
       } else if (Variable.CurrPtr->State == VAR_ADDED) {\r
         //\r
         // Mark the old variable as in delete transition\r
@@ -540,20 +596,23 @@ Returns:
       if ((UINT32) (VarSize +*NonVolatileOffset) >\r
             ((VARIABLE_STORE_HEADER *) ((UINTN) (Global->NonVolatileVariableBase)))->Size\r
             ) {\r
-        return EFI_OUT_OF_RESOURCES;\r
+        Status = EFI_OUT_OF_RESOURCES;\r
+        goto Done;\r
       }\r
 \r
       NextVariable        = (VARIABLE_HEADER *) (UINT8 *) (*NonVolatileOffset + (UINTN) Global->NonVolatileVariableBase);\r
       *NonVolatileOffset  = *NonVolatileOffset + VarSize;\r
     } else {\r
       if (EfiAtRuntime ()) {\r
-        return EFI_INVALID_PARAMETER;\r
+        Status = EFI_INVALID_PARAMETER;\r
+        goto Done;\r
       }\r
 \r
       if ((UINT32) (VarSize +*VolatileOffset) >\r
             ((VARIABLE_STORE_HEADER *) ((UINTN) (Global->VolatileVariableBase)))->Size\r
             ) {\r
-        return EFI_OUT_OF_RESOURCES;\r
+        Status = EFI_OUT_OF_RESOURCES;\r
+        goto Done;\r
       }\r
 \r
       NextVariable    = (VARIABLE_HEADER *) (UINT8 *) (*VolatileOffset + (UINTN) Global->VolatileVariableBase);\r
@@ -593,7 +652,10 @@ Returns:
     }\r
   }\r
 \r
-  return EFI_SUCCESS;\r
+  Status = EFI_SUCCESS;\r
+Done:\r
+  ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
+  return Status;\r
 }\r
 \r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
@@ -666,6 +728,8 @@ Returns:
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
+  \r
   if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
     //\r
     // Query is Volatile related.\r
@@ -716,6 +780,7 @@ Returns:
     Variable = NextVariable;\r
   }\r
 \r
+  ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
   return EFI_SUCCESS;\r
 }\r
 #endif\r
@@ -796,11 +861,14 @@ Returns:
   if (NULL == mVariableModuleGlobal) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
+\r
+  EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_CALLBACK);\r
+  \r
   //\r
   // Intialize volatile variable store\r
   //\r
   Status = InitializeVariableStore (\r
-            &mVariableModuleGlobal->VariableBase[Physical].VolatileVariableBase,\r
+            &mVariableModuleGlobal->VariableGlobal[Physical].VolatileVariableBase,\r
             &mVariableModuleGlobal->VolatileLastVariableOffset\r
             );\r
 \r
@@ -811,7 +879,7 @@ Returns:
   // Intialize non volatile variable store\r
   //\r
   Status = InitializeVariableStore (\r
-            &mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase,\r
+            &mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase,\r
             &mVariableModuleGlobal->NonVolatileLastVariableOffset\r
             );\r
 \r
index a4ae482a0eae7f014b03d28df501b46315f6bfc2..7acd1ba81954e5622f72c31d9f8d4f808bb9ae31 100644 (file)
@@ -8,11 +8,11 @@
     <Abstract>Emulation Variable for EFI_RUNTIME_SERVICES.</Abstract>\r
     <Description>This module provides three EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName</Description>\r
     <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
-    <License>All rights reserved. This program and the accompanying materials\r
-      are licensed and made available under the terms and conditions of the BSD License\r
-      which accompanies this distribution.  The full text of the license may be found at\r
-      http://opensource.org/licenses/bsd-license.php\r
-      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    <License>All rights reserved. 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
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
     <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
   </MsaHeader>\r
@@ -40,6 +40,9 @@
     <LibraryClass Usage="ALWAYS_CONSUMED">\r
       <Keyword>UefiBootServicesTableLib</Keyword>\r
     </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
   </LibraryClassDefinitions>\r
   <SourceFiles>\r
     <Filename>Variable.h</Filename>\r
index 770fa78d683eeec8ac568600935d3c4afe25062d..9264ffacda8b861fc4d169e57a2571c52657f81f 100644 (file)
@@ -8,11 +8,11 @@
     <Abstract>Emulation Variable for EFI_RUNTIME_SERVICES.</Abstract>\r
     <Description>This module provides three EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName</Description>\r
     <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
-    <License>All rights reserved. This program and the accompanying materials\r
-      are licensed and made available under the terms and conditions of the BSD License\r
-      which accompanies this distribution.  The full text of the license may be found at\r
-      http://opensource.org/licenses/bsd-license.php\r
-      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    <License>All rights reserved. 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
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
     <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
   </MsaHeader>\r
@@ -43,6 +43,9 @@
     <LibraryClass Usage="ALWAYS_CONSUMED">\r
       <Keyword>UefiBootServicesTableLib</Keyword>\r
     </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
   </LibraryClassDefinitions>\r
   <SourceFiles>\r
     <Filename>Variable.h</Filename>\r
index 477869cf009b8b405de24e60f8f1963a5517ba03..570ba7257ef46e9bc85cf58585a6180a0a41c91b 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -51,7 +51,7 @@ Returns:
           Attributes OPTIONAL,\r
           DataSize,\r
           Data,\r
-          &mVariableModuleGlobal->VariableBase[Physical],\r
+          &mVariableModuleGlobal->VariableGlobal[Physical],\r
           mVariableModuleGlobal->FvbInstance\r
           );\r
 }\r
@@ -77,7 +77,7 @@ Returns:
           VariableNameSize,\r
           VariableName,\r
           VendorGuid,\r
-          &mVariableModuleGlobal->VariableBase[Physical],\r
+          &mVariableModuleGlobal->VariableGlobal[Physical],\r
           mVariableModuleGlobal->FvbInstance\r
           );\r
 }\r
@@ -107,7 +107,7 @@ Returns:
           Attributes,\r
           DataSize,\r
           Data,\r
-          &mVariableModuleGlobal->VariableBase[Physical],\r
+          &mVariableModuleGlobal->VariableGlobal[Physical],\r
           &mVariableModuleGlobal->VolatileLastVariableOffset,\r
           &mVariableModuleGlobal->NonVolatileLastVariableOffset,\r
           mVariableModuleGlobal->FvbInstance\r
@@ -138,7 +138,7 @@ Returns:
           MaximumVariableStorageSize,\r
           RemainingVariableStorageSize,\r
           MaximumVariableSize,\r
-          &mVariableModuleGlobal->VariableBase[Physical],\r
+          &mVariableModuleGlobal->VariableGlobal[Physical],\r
           mVariableModuleGlobal->FvbInstance\r
           );\r
 }\r
@@ -162,11 +162,11 @@ Returns:
 {\r
   EfiConvertPointer (\r
     0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase\r
+    (VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase\r
     );\r
   EfiConvertPointer (\r
     0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableBase[Physical].VolatileVariableBase\r
+    (VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].VolatileVariableBase\r
     );\r
   EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);\r
 }\r
index b4b29cf7c6bb6b93748fa34e7f85d37b3fbc3518..cbf5aecb88e6cbeb7be453abe705229b91051bd7 100644 (file)
@@ -60,7 +60,7 @@ Returns:
                         (UINT32 *) Arg4,\r
                         (UINTN *) Arg5,\r
                         (VOID *) Arg6,\r
-                        &Global->VariableBase[VirtualMode],\r
+                        &Global->VariableGlobal[VirtualMode],\r
                         Global->FvbInstance\r
                         );\r
     return ReturnVal;\r
@@ -70,7 +70,7 @@ Returns:
                         (UINTN *) Arg2,\r
                         (CHAR16 *) Arg3,\r
                         (EFI_GUID *) Arg4,\r
-                        &Global->VariableBase[VirtualMode],\r
+                        &Global->VariableGlobal[VirtualMode],\r
                         Global->FvbInstance\r
                         );\r
     return ReturnVal;\r
@@ -82,7 +82,7 @@ Returns:
                         (UINT32) Arg4,\r
                         (UINTN) Arg5,\r
                         (VOID *) Arg6,\r
-                        &Global->VariableBase[VirtualMode],\r
+                        &Global->VariableGlobal[VirtualMode],\r
                         (UINTN *) &Global->VolatileLastVariableOffset,\r
                         (UINTN *) &Global->NonVolatileLastVariableOffset,\r
                         Global->FvbInstance\r
@@ -96,7 +96,7 @@ Returns:
                         (UINT64 *) Arg3,\r
                         (UINT64 *) Arg4,\r
                         (UINT64 *) Arg5,\r
-                        &Global->VariableBase[VirtualMode],\r
+                        &Global->VariableGlobal[VirtualMode],\r
                         Global->FvbInstance\r
                         );\r
     return ReturnVal;\r
@@ -125,18 +125,18 @@ Returns:
 --*/\r
 {\r
   CopyMem (\r
-    &mVariableModuleGlobal->VariableBase[Virtual],\r
-    &mVariableModuleGlobal->VariableBase[Physical],\r
+    &mVariableModuleGlobal->VariableGlobal[Virtual],\r
+    &mVariableModuleGlobal->VariableGlobal[Physical],\r
     sizeof (VARIABLE_GLOBAL)\r
     );\r
 \r
   EfiConvertPointer (\r
     0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableBase[Virtual].NonVolatileVariableBase\r
+    (VOID **) &mVariableModuleGlobal->VariableGlobal[Virtual].NonVolatileVariableBase\r
     );\r
   EfiConvertPointer (\r
     0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableBase[Virtual].VolatileVariableBase\r
+    (VOID **) &mVariableModuleGlobal->VariableGlobal[Virtual].VolatileVariableBase\r
     );\r
   EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);\r
 }\r
index bf21a3e86d96ea8ed6735c6c39af04f95bfa56af..4c2a468c4d55672b3d127c1ac1d1b31dcfc56464 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -65,10 +65,11 @@ typedef struct {
 typedef struct {\r
   EFI_PHYSICAL_ADDRESS  VolatileVariableBase;\r
   EFI_PHYSICAL_ADDRESS  NonVolatileVariableBase;\r
+  EFI_LOCK              VariableServicesLock;\r
 } VARIABLE_GLOBAL;\r
 \r
 typedef struct {\r
-  VARIABLE_GLOBAL VariableBase[2];\r
+  VARIABLE_GLOBAL VariableGlobal[2];\r
   UINTN           VolatileLastVariableOffset;\r
   UINTN           NonVolatileLastVariableOffset;\r
   UINT32          FvbInstance;\r
index 477869cf009b8b405de24e60f8f1963a5517ba03..570ba7257ef46e9bc85cf58585a6180a0a41c91b 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -51,7 +51,7 @@ Returns:
           Attributes OPTIONAL,\r
           DataSize,\r
           Data,\r
-          &mVariableModuleGlobal->VariableBase[Physical],\r
+          &mVariableModuleGlobal->VariableGlobal[Physical],\r
           mVariableModuleGlobal->FvbInstance\r
           );\r
 }\r
@@ -77,7 +77,7 @@ Returns:
           VariableNameSize,\r
           VariableName,\r
           VendorGuid,\r
-          &mVariableModuleGlobal->VariableBase[Physical],\r
+          &mVariableModuleGlobal->VariableGlobal[Physical],\r
           mVariableModuleGlobal->FvbInstance\r
           );\r
 }\r
@@ -107,7 +107,7 @@ Returns:
           Attributes,\r
           DataSize,\r
           Data,\r
-          &mVariableModuleGlobal->VariableBase[Physical],\r
+          &mVariableModuleGlobal->VariableGlobal[Physical],\r
           &mVariableModuleGlobal->VolatileLastVariableOffset,\r
           &mVariableModuleGlobal->NonVolatileLastVariableOffset,\r
           mVariableModuleGlobal->FvbInstance\r
@@ -138,7 +138,7 @@ Returns:
           MaximumVariableStorageSize,\r
           RemainingVariableStorageSize,\r
           MaximumVariableSize,\r
-          &mVariableModuleGlobal->VariableBase[Physical],\r
+          &mVariableModuleGlobal->VariableGlobal[Physical],\r
           mVariableModuleGlobal->FvbInstance\r
           );\r
 }\r
@@ -162,11 +162,11 @@ Returns:
 {\r
   EfiConvertPointer (\r
     0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase\r
+    (VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase\r
     );\r
   EfiConvertPointer (\r
     0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableBase[Physical].VolatileVariableBase\r
+    (VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].VolatileVariableBase\r
     );\r
   EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);\r
 }\r
index b4b29cf7c6bb6b93748fa34e7f85d37b3fbc3518..bc74a6712161c5026525dc826e4e8bb827c113c4 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -60,7 +60,7 @@ Returns:
                         (UINT32 *) Arg4,\r
                         (UINTN *) Arg5,\r
                         (VOID *) Arg6,\r
-                        &Global->VariableBase[VirtualMode],\r
+                        &Global->VariableGlobal[VirtualMode],\r
                         Global->FvbInstance\r
                         );\r
     return ReturnVal;\r
@@ -70,7 +70,7 @@ Returns:
                         (UINTN *) Arg2,\r
                         (CHAR16 *) Arg3,\r
                         (EFI_GUID *) Arg4,\r
-                        &Global->VariableBase[VirtualMode],\r
+                        &Global->VariableGlobal[VirtualMode],\r
                         Global->FvbInstance\r
                         );\r
     return ReturnVal;\r
@@ -82,7 +82,7 @@ Returns:
                         (UINT32) Arg4,\r
                         (UINTN) Arg5,\r
                         (VOID *) Arg6,\r
-                        &Global->VariableBase[VirtualMode],\r
+                        &Global->VariableGlobal[VirtualMode],\r
                         (UINTN *) &Global->VolatileLastVariableOffset,\r
                         (UINTN *) &Global->NonVolatileLastVariableOffset,\r
                         Global->FvbInstance\r
@@ -96,7 +96,7 @@ Returns:
                         (UINT64 *) Arg3,\r
                         (UINT64 *) Arg4,\r
                         (UINT64 *) Arg5,\r
-                        &Global->VariableBase[VirtualMode],\r
+                        &Global->VariableGlobal[VirtualMode],\r
                         Global->FvbInstance\r
                         );\r
     return ReturnVal;\r
@@ -125,18 +125,18 @@ Returns:
 --*/\r
 {\r
   CopyMem (\r
-    &mVariableModuleGlobal->VariableBase[Virtual],\r
-    &mVariableModuleGlobal->VariableBase[Physical],\r
+    &mVariableModuleGlobal->VariableGlobal[Virtual],\r
+    &mVariableModuleGlobal->VariableGlobal[Physical],\r
     sizeof (VARIABLE_GLOBAL)\r
     );\r
 \r
   EfiConvertPointer (\r
     0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableBase[Virtual].NonVolatileVariableBase\r
+    (VOID **) &mVariableModuleGlobal->VariableGlobal[Virtual].NonVolatileVariableBase\r
     );\r
   EfiConvertPointer (\r
     0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableBase[Virtual].VolatileVariableBase\r
+    (VOID **) &mVariableModuleGlobal->VariableGlobal[Virtual].VolatileVariableBase\r
     );\r
   EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);\r
 }\r
index aa0742364e9f8a0e83a875ec6378c793e064c8d5..46ffc7ddbb0f8f9ba9650afb327389eb4c138783 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -27,6 +27,36 @@ Revision History
 //\r
 ESAL_VARIABLE_GLOBAL  *mVariableModuleGlobal;\r
 \r
+//\r
+// This is a temperary function which will be removed \r
+// when EfiAcquireLock in UefiLib can handle the\r
+// the call in UEFI Runtimer driver in RT phase.\r
+//\r
+VOID\r
+AcquireLockOnlyAtBootTime (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+{\r
+  if (!EfiAtRuntime ()) {\r
+    EfiAcquireLock (Lock);\r
+  }\r
+}\r
+\r
+//\r
+// This is a temperary function which will be removed \r
+// when EfiAcquireLock in UefiLib can handle the\r
+// the call in UEFI Runtimer driver in RT phase.\r
+//\r
+VOID\r
+ReleaseLockOnlyAtBootTime (\r
+  IN EFI_LOCK  *Lock\r
+  )\r
+{\r
+  if (!EfiAtRuntime ()) {\r
+    EfiReleaseLock (Lock);\r
+  }\r
+}\r
+\r
 STATIC\r
 UINT32\r
 EFIAPI\r
@@ -529,6 +559,13 @@ Returns:
   VARIABLE_STORE_HEADER *VariableStoreHeader[2];\r
   UINTN                 Index;\r
 \r
+  //\r
+  // We aquire the lock at the entry of FindVariable as GetVariable, GetNextVariableName\r
+  // SetVariable all call FindVariable at entry point. Please move "Aquire Lock" to\r
+  // the correct places if this assumption does not hold TRUE anymore.\r
+  //\r
+  AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
+\r
   //\r
   // 0: Non-Volatile, 1: Volatile\r
   //\r
@@ -631,7 +668,7 @@ Returns:
   Status = FindVariable (VariableName, VendorGuid, &Variable, Global);\r
 \r
   if (Variable.CurrPtr == NULL || EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto Done;\r
   }\r
   //\r
   // Get data size\r
@@ -639,7 +676,8 @@ Returns:
   VarDataSize = Variable.CurrPtr->DataSize;\r
   if (*DataSize >= VarDataSize) {\r
     if (Data == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
+      Status = EFI_INVALID_PARAMETER;\r
+      goto Done;\r
     }\r
 \r
     CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr), VarDataSize);\r
@@ -648,11 +686,17 @@ Returns:
     }\r
 \r
     *DataSize = VarDataSize;\r
-    return EFI_SUCCESS;\r
+    Status = EFI_SUCCESS;\r
+    goto Done;\r
   } else {\r
     *DataSize = VarDataSize;\r
-    return EFI_BUFFER_TOO_SMALL;\r
+    Status = EFI_BUFFER_TOO_SMALL;\r
+    goto Done;\r
   }\r
+\r
+Done:\r
+  ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r
@@ -695,7 +739,7 @@ Returns:
   Status = FindVariable (VariableName, VendorGuid, &Variable, Global);\r
 \r
   if (Variable.CurrPtr == NULL || EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto Done;\r
   }\r
 \r
   if (VariableName[0] != 0) {\r
@@ -716,7 +760,8 @@ Returns:
         Variable.StartPtr = (VARIABLE_HEADER *) ((UINTN) (Global->VolatileVariableBase + sizeof (VARIABLE_STORE_HEADER)));\r
         Variable.EndPtr = (VARIABLE_HEADER *) GetEndPointer ((VARIABLE_STORE_HEADER *) ((UINTN) Global->VolatileVariableBase));\r
       } else {\r
-        goto Error;\r
+        Status = EFI_NOT_FOUND;\r
+        goto Done;\r
       }\r
 \r
       Variable.CurrPtr = Variable.StartPtr;\r
@@ -747,15 +792,16 @@ Returns:
         }\r
 \r
         *VariableNameSize = VarNameSize;\r
-        return Status;\r
+        goto Done;\r
       }\r
     }\r
 \r
     Variable.CurrPtr = GetNextVariablePtr (Variable.CurrPtr);\r
   }\r
 \r
-Error:\r
-  return EFI_NOT_FOUND;\r
+Done:\r
+  ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r
@@ -819,41 +865,47 @@ Returns:
   Status = FindVariable (VariableName, VendorGuid, &Variable, Global);\r
 \r
   if (Status == EFI_INVALID_PARAMETER) {\r
-    return Status;\r
+    goto Done;\r
   } else if (!EFI_ERROR (Status) && Variable.Volatile && EfiAtRuntime()) {\r
     //\r
     // If EfiAtRuntime and the variable is Volatile and Runtime Access,  \r
     // the volatile is ReadOnly, and SetVariable should be aborted and \r
     // return EFI_WRITE_PROTECTED.\r
     //\r
-    return EFI_WRITE_PROTECTED;\r
+    Status = EFI_WRITE_PROTECTED;\r
+    goto Done;\r
   } else if (sizeof (VARIABLE_HEADER) + ArrayLength (VariableName) + DataSize > MAX_VARIABLE_SIZE) {\r
     //\r
     //  The size of the VariableName, including the Unicode Null in bytes plus\r
     //  the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.\r
     //\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   } else if (Attributes == EFI_VARIABLE_NON_VOLATILE) {\r
     //\r
     //  Make sure not only EFI_VARIABLE_NON_VOLATILE is set \r
     //\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == \r
                 EFI_VARIABLE_RUNTIME_ACCESS) {\r
     //\r
     //  Make sure if runtime bit is set, boot service bit is set also\r
     //\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {\r
     //\r
     // Runtime but Attribute is not Runtime\r
     //\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {\r
     //\r
     // Cannot set volatile variable in Runtime\r
     //\r
-    return EFI_INVALID_PARAMETER;\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto Done;\r
   } else if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {\r
     //\r
     // Setting a data variable with no access, or zero DataSize attributes\r
@@ -873,13 +925,15 @@ Returns:
                 &State\r
                 );\r
       if (EFI_ERROR (Status)) {\r
-        return Status;\r
+        goto Done;\r
       }\r
 \r
-      return EFI_SUCCESS;\r
+      Status = EFI_SUCCESS;\r
+      goto Done;\r
     }\r
 \r
-    return EFI_NOT_FOUND;\r
+    Status = EFI_NOT_FOUND;\r
+    goto Done;\r
   } else {\r
     if (!EFI_ERROR (Status)) {\r
       //\r
@@ -889,7 +943,8 @@ Returns:
       if (Variable.CurrPtr->DataSize == DataSize &&\r
           !CompareMem (Data, GetVariableDataPtr (Variable.CurrPtr), DataSize)\r
             ) {\r
-        return EFI_SUCCESS;\r
+        Status = EFI_SUCCESS;\r
+        goto Done;\r
       } else if (Variable.CurrPtr->State == VAR_ADDED) {\r
         //\r
         // Mark the old variable as in delete transition\r
@@ -907,7 +962,7 @@ Returns:
                   &State\r
                   );\r
         if (EFI_ERROR (Status)) {\r
-          return Status;\r
+          goto Done;\r
         }\r
       }\r
     }\r
@@ -959,14 +1014,15 @@ Returns:
             ((VARIABLE_STORE_HEADER *) ((UINTN) (Global->NonVolatileVariableBase)))->Size\r
             ) {\r
         if (EfiAtRuntime ()) {\r
-          return EFI_OUT_OF_RESOURCES;\r
+          Status = EFI_OUT_OF_RESOURCES;\r
+          goto Done;\r
         }\r
         //\r
         // Perform garbage collection & reclaim operation\r
         //\r
         Status = Reclaim (Global->NonVolatileVariableBase, NonVolatileOffset, FALSE);\r
         if (EFI_ERROR (Status)) {\r
-          return Status;\r
+          goto Done;\r
         }\r
         //\r
         // If still no enough space, return out of resources\r
@@ -974,7 +1030,8 @@ Returns:
         if ((UINT32) (VarSize +*NonVolatileOffset) >\r
               ((VARIABLE_STORE_HEADER *) ((UINTN) (Global->NonVolatileVariableBase)))->Size\r
               ) {\r
-          return EFI_OUT_OF_RESOURCES;\r
+          Status = EFI_OUT_OF_RESOURCES;\r
+          goto Done;\r
         }\r
         \r
         Reclaimed = TRUE;\r
@@ -999,7 +1056,7 @@ Returns:
                 );\r
 \r
       if (EFI_ERROR (Status)) {\r
-        return Status;\r
+        goto Done;\r
       }\r
       //\r
       // Step 2:\r
@@ -1015,7 +1072,7 @@ Returns:
                 );\r
 \r
       if (EFI_ERROR (Status)) {\r
-        return Status;\r
+        goto Done;\r
       }\r
       //\r
       // Step 3:\r
@@ -1032,14 +1089,15 @@ Returns:
                 );\r
 \r
       if (EFI_ERROR (Status)) {\r
-        return Status;\r
+        goto Done;\r
       }\r
 \r
       *NonVolatileOffset = *NonVolatileOffset + VarSize;\r
 \r
     } else {\r
       if (EfiAtRuntime ()) {\r
-        return EFI_INVALID_PARAMETER;\r
+        Status = EFI_INVALID_PARAMETER;\r
+        goto Done;\r
       }\r
 \r
       if ((UINT32) (VarSize +*VolatileOffset) >\r
@@ -1050,7 +1108,7 @@ Returns:
         //\r
         Status = Reclaim (Global->VolatileVariableBase, VolatileOffset, TRUE);\r
         if (EFI_ERROR (Status)) {\r
-          return Status;\r
+          goto Done;\r
         }\r
         //\r
         // If still no enough space, return out of resources\r
@@ -1058,7 +1116,8 @@ Returns:
         if ((UINT32) (VarSize +*VolatileOffset) >\r
               ((VARIABLE_STORE_HEADER *) ((UINTN) (Global->VolatileVariableBase)))->Size\r
               ) {\r
-          return EFI_OUT_OF_RESOURCES;\r
+          Status = EFI_OUT_OF_RESOURCES;\r
+          goto Done;\r
         }\r
         \r
         Reclaimed = TRUE;\r
@@ -1076,7 +1135,7 @@ Returns:
                 );\r
 \r
       if (EFI_ERROR (Status)) {\r
-        return Status;\r
+        goto Done;\r
       }\r
 \r
       *VolatileOffset = *VolatileOffset + VarSize;\r
@@ -1099,12 +1158,15 @@ Returns:
                 );\r
 \r
       if (EFI_ERROR (Status)) {\r
-        return Status;\r
+        goto Done;\r
       }\r
     }\r
   }\r
 \r
-  return EFI_SUCCESS;\r
+  Status = EFI_SUCCESS;\r
+Done:\r
+  ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
+  return Status;\r
 }\r
 \r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
@@ -1150,7 +1212,7 @@ Returns:
   VARIABLE_HEADER        *NextVariable;\r
   UINT64                 VariableSize;\r
   VARIABLE_STORE_HEADER  *VariableStoreHeader;\r
-  \r
+\r
   if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -1172,6 +1234,8 @@ Returns:
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
+  \r
   if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
     //\r
     // Query is Volatile related.\r
@@ -1232,6 +1296,7 @@ Returns:
     Variable = NextVariable;\r
   }\r
  \r
+  ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
   return EFI_SUCCESS;\r
 }\r
 #endif\r
@@ -1289,6 +1354,9 @@ Returns:
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+\r
+  EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_CALLBACK);\r
+  \r
   //\r
   // Allocate memory for volatile variable store\r
   //\r
@@ -1308,7 +1376,7 @@ Returns:
   //\r
   //  Variable Specific Data\r
   //\r
-  mVariableModuleGlobal->VariableBase[Physical].VolatileVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) VolatileVariableStore;\r
+  mVariableModuleGlobal->VariableGlobal[Physical].VolatileVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) VolatileVariableStore;\r
   mVariableModuleGlobal->VolatileLastVariableOffset = sizeof (VARIABLE_STORE_HEADER);\r
 \r
   VolatileVariableStore->Signature                  = VARIABLE_STORE_SIGNATURE;\r
@@ -1354,7 +1422,7 @@ Returns:
   //\r
   // Get address of non volatile variable store base\r
   //\r
-  mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase = VariableStoreEntry.Base;\r
+  mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase = VariableStoreEntry.Base;\r
 \r
   //\r
   // Check Integrity\r
@@ -1363,7 +1431,7 @@ Returns:
   // Find the Correct Instance of the FV Block Service.\r
   //\r
   Instance  = 0;\r
-  CurrPtr   = (CHAR8 *) ((UINTN) mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase);\r
+  CurrPtr   = (CHAR8 *) ((UINTN) mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase);\r
   while (EfiFvbGetPhysicalAddress (Instance, &FvVolHdr) == EFI_SUCCESS) {\r
     FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvVolHdr);\r
     if (CurrPtr >= (CHAR8 *) FwVolHeader && CurrPtr < (((CHAR8 *) FwVolHeader) + FwVolHeader->FvLength)) {\r
@@ -1378,7 +1446,7 @@ Returns:
   if (GetVariableStoreStatus (VariableStoreHeader) == EfiValid) {\r
     if (~VariableStoreHeader->Size == 0) {\r
       Status = UpdateVariableStore (\r
-                &mVariableModuleGlobal->VariableBase[Physical],\r
+                &mVariableModuleGlobal->VariableGlobal[Physical],\r
                 FALSE,\r
                 FALSE,\r
                 mVariableModuleGlobal->FvbInstance,\r
@@ -1392,7 +1460,7 @@ Returns:
       }\r
     }\r
 \r
-    mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase = (EFI_PHYSICAL_ADDRESS) ((UINTN) CurrPtr);\r
+    mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase = (EFI_PHYSICAL_ADDRESS) ((UINTN) CurrPtr);\r
     //\r
     // Parse non-volatile variable data and get last variable offset\r
     //\r
@@ -1410,7 +1478,7 @@ Returns:
     //\r
     if ((((VARIABLE_STORE_HEADER *)((UINTN) CurrPtr))->Size - mVariableModuleGlobal->NonVolatileLastVariableOffset) < VARIABLE_RECLAIM_THRESHOLD) {\r
       Status = Reclaim (\r
-                mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase,\r
+                mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase,\r
                 &mVariableModuleGlobal->NonVolatileLastVariableOffset,\r
                 FALSE\r
                 );\r
@@ -1426,13 +1494,13 @@ Returns:
     // Check if the free area is really free.\r
     //\r
     for (Index = mVariableModuleGlobal->NonVolatileLastVariableOffset; Index < VariableStoreHeader->Size; Index++) {\r
-      Data = ((UINT8 *) (UINTN) mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase)[Index];\r
+      Data = ((UINT8 *) (UINTN) mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase)[Index];\r
       if (Data != 0xff) {\r
         //\r
         // There must be something wrong in variable store, do reclaim operation.\r
         //\r
         Status = Reclaim (\r
-                  mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase,\r
+                  mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase,\r
                   &mVariableModuleGlobal->NonVolatileLastVariableOffset,\r
                   FALSE\r
                   );\r
index 3d0264de7867a774fd77be1f6f6b8d66327319d3..790b3dc50a2aeda1207403b5cdfde20373ae24a4 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -66,10 +66,11 @@ typedef struct {
 typedef struct {\r
   EFI_PHYSICAL_ADDRESS  VolatileVariableBase;\r
   EFI_PHYSICAL_ADDRESS  NonVolatileVariableBase;\r
+  EFI_LOCK              VariableServicesLock;\r
 } VARIABLE_GLOBAL;\r
 \r
 typedef struct {\r
-  VARIABLE_GLOBAL VariableBase[2];\r
+  VARIABLE_GLOBAL VariableGlobal[2];\r
   UINTN           VolatileLastVariableOffset;\r
   UINTN           NonVolatileLastVariableOffset;\r
   UINT32          FvbInstance;\r
index 50a53ed19efee1ef24598fee367fec743bc7b168..227d8a1344451d3c71ddba4c069fadd872889b80 100644 (file)
@@ -8,11 +8,11 @@
     <Abstract>Component description file for Variable module.</Abstract>\r
     <Description>This module installs three EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName.</Description>\r
     <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
-    <License>All rights reserved. This program and the accompanying materials\r
-      are licensed and made available under the terms and conditions of the BSD License\r
-      which accompanies this distribution.  The full text of the license may be found at\r
-      http://opensource.org/licenses/bsd-license.php\r
-      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    <License>All rights reserved. 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
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
     <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
   </MsaHeader>\r
@@ -46,6 +46,9 @@
     <LibraryClass Usage="ALWAYS_CONSUMED">\r
       <Keyword>UefiBootServicesTableLib</Keyword>\r
     </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
   </LibraryClassDefinitions>\r
   <SourceFiles>\r
     <Filename>Variable.h</Filename>\r
@@ -87,7 +90,7 @@
     <PcdEntry PcdItemType="DYNAMIC">\r
       <C_Name>PcdFlashNvStorageVariableBase</C_Name>\r
       <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
-      <HelpText>The driver gets the Variable store base address from this PCD.  This base address point to\r
+      <HelpText>The driver gets the Variable store base address from this PCD.  This base address point to
         an EFI_FIRMWARE_VOLUMN_HEADER struct.</HelpText>\r
     </PcdEntry>\r
     <PcdEntry PcdItemType="DYNAMIC">\r
index 68c51c07ceb86d4709546ce2c014f6ddf62a38c3..cbc60df38ebf8b70776b58fe86f512ecf1c5b6e8 100644 (file)
@@ -8,11 +8,11 @@
     <Abstract>Component description file for Variable module.</Abstract>\r
     <Description>This module installs three EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName.</Description>\r
     <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
-    <License>All rights reserved. This program and the accompanying materials\r
-      are licensed and made available under the terms and conditions of the BSD License\r
-      which accompanies this distribution.  The full text of the license may be found at\r
-      http://opensource.org/licenses/bsd-license.php\r
-      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    <License>All rights reserved. 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
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
       WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
     <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
   </MsaHeader>\r
@@ -49,6 +49,9 @@
     <LibraryClass Usage="ALWAYS_CONSUMED">\r
       <Keyword>UefiBootServicesTableLib</Keyword>\r
     </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiLib</Keyword>\r
+    </LibraryClass>\r
   </LibraryClassDefinitions>\r
   <SourceFiles>\r
     <Filename>Variable.h</Filename>\r
@@ -87,7 +90,7 @@
     <PcdEntry PcdItemType="DYNAMIC">\r
       <C_Name>PcdFlashNvStorageVariableBase</C_Name>\r
       <TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>\r
-      <HelpText>The driver gets the Variable store base address from this PCD.  This base address point to\r
+      <HelpText>The driver gets the Variable store base address from this PCD.  This base address point to
         an EFI_FIRMWARE_VOLUMN_HEADER struct.</HelpText>\r
     </PcdEntry>\r
     <PcdEntry PcdItemType="DYNAMIC">\r