]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
To fix
[mirror_edk2.git] / EdkModulePkg / Universal / EmuVariable / RuntimeDxe / EmuVariable.c
index d39ecd2ce07bac010d13938e3430ebad911acf12..741116ae3f99cc5154ef1d9fac8684655fd92ca9 100644 (file)
@@ -27,10 +27,11 @@ Revision History
 ESAL_VARIABLE_GLOBAL  *mVariableModuleGlobal;\r
 \r
 //\r
-// This is a temperary function which will be removed \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
+STATIC\r
 VOID\r
 AcquireLockOnlyAtBootTime (\r
   IN EFI_LOCK  *Lock\r
@@ -42,10 +43,11 @@ AcquireLockOnlyAtBootTime (
 }\r
 \r
 //\r
-// This is a temperary function which will be removed \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
+STATIC\r
 VOID\r
 ReleaseLockOnlyAtBootTime (\r
   IN EFI_LOCK  *Lock\r
@@ -56,44 +58,6 @@ ReleaseLockOnlyAtBootTime (
   }\r
 }\r
 \r
-\r
-STATIC\r
-UINT32\r
-EFIAPI\r
-ArrayLength (\r
-  IN CHAR16 *String\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Determine the length of null terminated char16 array.\r
-\r
-Arguments:\r
-\r
-  String    Null-terminated CHAR16 array pointer.\r
-\r
-Returns:\r
-\r
-  UINT32    Number of bytes in the string, including the double NULL at the end;\r
-\r
---*/\r
-{\r
-  UINT32  Count;\r
-\r
-  if (NULL == String) {\r
-    return 0;\r
-  }\r
-\r
-  Count = 0;\r
-\r
-  while (0 != String[Count]) {\r
-    Count++;\r
-  }\r
-\r
-  return (Count * 2) + 2;\r
-}\r
-\r
 STATIC\r
 UINT8 *\r
 EFIAPI\r
@@ -267,7 +231,7 @@ Returns:
             return EFI_SUCCESS;\r
           } else {\r
             if (CompareGuid (VendorGuid, &Variable[Index]->VendorGuid)) {\r
-              if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), ArrayLength (VariableName))) {\r
+              if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), Variable[Index]->NameSize)) {\r
                 PtrTrack->CurrPtr   = Variable[Index];\r
                 PtrTrack->Volatile  = (BOOLEAN) Index;\r
                 return EFI_SUCCESS;\r
@@ -462,7 +426,7 @@ Returns:
 Done:\r
   ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
   return Status;\r
\r
+\r
 }\r
 \r
 EFI_STATUS\r
@@ -521,13 +485,13 @@ Returns:
     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
+    // 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
     Status = EFI_WRITE_PROTECTED;\r
     goto Done;\r
-  } else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {\r
+  } else if (sizeof (VARIABLE_HEADER) + (StrSize (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
@@ -588,7 +552,7 @@ Returns:
     // Create a new variable and copy the data.\r
     //\r
     VarNameOffset = sizeof (VARIABLE_HEADER);\r
-    VarNameSize   = ArrayLength (VariableName);\r
+    VarNameSize   = StrSize (VariableName);\r
     VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize);\r
     VarSize       = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize);\r
 \r
@@ -658,7 +622,6 @@ Done:
   return Status;\r
 }\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
 EFI_STATUS\r
 EFIAPI\r
 QueryVariableInfo (\r
@@ -729,7 +692,7 @@ Returns:
   }\r
 \r
   AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
-  \r
+\r
   if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
     //\r
     // Query is Volatile related.\r
@@ -783,7 +746,6 @@ Returns:
   ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
   return EFI_SUCCESS;\r
 }\r
-#endif\r
 \r
 STATIC\r
 EFI_STATUS\r
@@ -862,8 +824,8 @@ Returns:
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_CALLBACK);\r
-  \r
+  EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_NOTIFY);\r
+\r
   //\r
   // Intialize volatile variable store\r
   //\r