]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c
Remove some unused internal functions.
[mirror_edk2.git] / EdkModulePkg / Universal / EmuVariable / RuntimeDxe / EmuVariable.c
index bfb499ab653277f574c00936f9dcfc675e7db3bb..208f3b427682c4bac482867044f144398c064bf9 100644 (file)
@@ -26,6 +26,7 @@ Revision History
 //\r
 ESAL_VARIABLE_GLOBAL  *mVariableModuleGlobal;\r
 \r
+STATIC\r
 UINT32\r
 EFIAPI\r
 ArrayLength (\r
@@ -62,47 +63,7 @@ Returns:
   return (Count * 2) + 2;\r
 }\r
 \r
-VARIABLE_STORE_STATUS\r
-EFIAPI\r
-GetVariableStoreStatus (\r
-  IN VARIABLE_STORE_HEADER *VarStoreHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This code gets the pointer to the variable name.\r
-\r
-Arguments:\r
-\r
-  VarStoreHeader  Pointer to the Variable Store Header.\r
-\r
-Returns:\r
-\r
-  EfiHealthy    Variable store is healthy\r
-  EfiRaw        Variable store is raw\r
-  EfiInvalid    Variable store is invalid\r
-\r
---*/\r
-{\r
-  if (VarStoreHeader->Signature == VARIABLE_STORE_SIGNATURE &&\r
-      VarStoreHeader->Format == VARIABLE_STORE_FORMATTED &&\r
-      VarStoreHeader->State == VARIABLE_STORE_HEALTHY\r
-      ) {\r
-\r
-    return EfiValid;\r
-  } else if (VarStoreHeader->Signature == 0xffffffff &&\r
-           VarStoreHeader->Size == 0xffffffff &&\r
-           VarStoreHeader->Format == 0xff &&\r
-           VarStoreHeader->State == 0xff\r
-          ) {\r
-\r
-    return EfiRaw;\r
-  } else {\r
-    return EfiInvalid;\r
-  }\r
-}\r
-\r
+STATIC\r
 UINT8 *\r
 EFIAPI\r
 GetVariableDataPtr (\r
@@ -133,6 +94,7 @@ Returns:
   return (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (Variable) + Variable->NameSize + GET_PAD_SIZE (Variable->NameSize));\r
 }\r
 \r
+STATIC\r
 VARIABLE_HEADER *\r
 EFIAPI\r
 GetNextVariablePtr (\r
@@ -173,6 +135,7 @@ Returns:
   return VarHeader;\r
 }\r
 \r
+STATIC\r
 VARIABLE_HEADER *\r
 EFIAPI\r
 GetEndPointer (\r
@@ -200,6 +163,7 @@ Returns:
   return (VARIABLE_HEADER *) ((UINTN) VolHeader + VolHeader->Size);\r
 }\r
 \r
+STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 FindVariable (\r
@@ -336,8 +300,12 @@ Returns:
   //\r
   VarDataSize = Variable.CurrPtr->DataSize;\r
   if (*DataSize >= VarDataSize) {\r
+    if (Data == NULL) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
     CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr), VarDataSize);\r
-    if (Attributes) {\r
+    if (Attributes != NULL) {\r
       *Attributes = Variable.CurrPtr->Attributes;\r
     }\r
 \r
@@ -382,7 +350,7 @@ Returns:
   UINTN                   VarNameSize;\r
   EFI_STATUS              Status;\r
 \r
-  if (VariableNameSize == NULL || VendorGuid == NULL) {\r
+  if (VariableNameSize == NULL || VariableName == NULL || VendorGuid == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -409,7 +377,7 @@ 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
-        return EFI_NOT_FOUND;\r
+        goto Error;\r
       }\r
 \r
       Variable.CurrPtr = Variable.StartPtr;\r
@@ -445,6 +413,7 @@ Returns:
     }\r
   }\r
 \r
+Error:\r
   return EFI_NOT_FOUND;\r
 }\r
 \r
@@ -502,38 +471,40 @@ Returns:
 \r
   if (Status == EFI_INVALID_PARAMETER) {\r
     return Status;\r
-  }\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
-  else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {\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
+  } 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
-  }\r
-  //\r
-  //  Make sure if runtime bit is set, boot service bit is set also\r
-  //\r
-  else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS\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
-  }\r
-  //\r
-  // Runtime but Attribute is not Runtime\r
-  //\r
-  else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {\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
-  }\r
-  //\r
-  // Cannot set volatile variable in Runtime\r
-  //\r
-  else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {\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
-  }\r
-  //\r
-  // Setting a data variable with no access, or zero DataSize attributes\r
-  // specified causes it to be deleted.\r
-  //\r
-  else if (DataSize == 0 || Attributes == 0) {\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
+    // specified causes it to be deleted.\r
+    //\r
     if (!EFI_ERROR (Status)) {\r
       Variable.CurrPtr->State &= VAR_DELETED;\r
       return EFI_SUCCESS;\r
@@ -688,6 +659,11 @@ Returns:
     //   Make sure RT Attribute is set if we are in Runtime phase.\r
     //\r
     return EFI_INVALID_PARAMETER;\r
+  } else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {\r
+    //\r
+    // Cannot Query volatile variable in Runtime\r
+    //\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
@@ -744,6 +720,7 @@ Returns:
 }\r
 #endif\r
 \r
+STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 InitializeVariableStore (\r