]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / EmuRuntimeDxe / EmuVariable.c
index 8202d37daad041830126fed42fdb2ebd23dbc49e..1bcf931b96a670ab1fc66cd66f9d88d68f363e7f 100644 (file)
@@ -29,7 +29,7 @@ VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
 #define ISO_639_2_ENTRY_SIZE    3\r
 \r
 /**\r
-  Update the variable region with Variable information. These are the same \r
+  Update the variable region with Variable information. These are the same\r
   arguments as the EFI Variable services.\r
 \r
   @param[in] VariableName       Name of variable\r
@@ -40,7 +40,7 @@ VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
 \r
   @param[in] DataSize           Size of data. 0 means delete\r
 \r
-  @param[in] Attributes              Attribues of the variable\r
+  @param[in] Attributes         Attribues of the variable\r
 \r
   @param[in] Variable           The variable information which is used to keep track of variable usage.\r
 \r
@@ -272,13 +272,13 @@ GetEndPointer (
 }\r
 \r
 /**\r
-  Routine used to track statistical information about variable usage. \r
+  Routine used to track statistical information about variable usage.\r
   The data is stored in the EFI system table so it can be accessed later.\r
-  VariableInfo.efi can dump out the table. Only Boot Services variable \r
+  VariableInfo.efi can dump out the table. Only Boot Services variable\r
   accesses are tracked by this code. The PcdVariableCollectStatistics\r
-  build flag controls if this feature is enabled. \r
+  build flag controls if this feature is enabled.\r
 \r
-  A read that hits in the cache will have Read and Cache true for \r
+  A read that hits in the cache will have Read and Cache true for\r
   the transaction. Data is allocated by this routine, but never\r
   freed.\r
 \r
@@ -328,7 +328,7 @@ UpdateVariableInfo (
       gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);\r
     }\r
 \r
-    \r
+\r
     for (Entry = gVariableInfo; Entry != NULL; Entry = Entry->Next) {\r
       if (CompareGuid (VendorGuid, &Entry->VendorGuid)) {\r
         if (StrCmp (VariableName, Entry->Name) == 0) {\r
@@ -399,7 +399,7 @@ GetIndexFromSupportedLangCodes(
   IN  CHAR8            *SupportedLang,\r
   IN  CHAR8            *Lang,\r
   IN  BOOLEAN          Iso639Language\r
-  ) \r
+  )\r
 {\r
   UINTN    Index;\r
   UINTN    CompareLength;\r
@@ -434,8 +434,8 @@ GetIndexFromSupportedLangCodes(
       // Determine the length of the next language code in SupportedLang\r
       //\r
       for (CompareLength = 0; SupportedLang[CompareLength] != '\0' && SupportedLang[CompareLength] != ';'; CompareLength++);\r
-      \r
-      if ((CompareLength == LanguageLength) && \r
+\r
+      if ((CompareLength == LanguageLength) &&\r
           (AsciiStrnCmp (Lang, SupportedLang, CompareLength) == 0)) {\r
         //\r
         // Successfully find the index of Lang string in SupportedLang string.\r
@@ -523,7 +523,7 @@ GetLangFromSupportedLangCodes (
         return CopyMem (mVariableModuleGlobal->PlatformLang, Supported - CompareLength, CompareLength);\r
       }\r
       SubIndex++;\r
-      \r
+\r
       //\r
       // Skip ';' characters in Supported\r
       //\r
@@ -533,10 +533,10 @@ GetLangFromSupportedLangCodes (
 }\r
 \r
 /**\r
-  Returns a pointer to an allocated buffer that contains the best matching language \r
-  from a set of supported languages.  \r
-  \r
-  This function supports both ISO 639-2 and RFC 4646 language codes, but language \r
+  Returns a pointer to an allocated buffer that contains the best matching language\r
+  from a set of supported languages.\r
+\r
+  This function supports both ISO 639-2 and RFC 4646 language codes, but language\r
   code types may not be mixed in a single call to this function. This function\r
   supports a variable argument list that allows the caller to pass in a prioritized\r
   list of language codes to test against all the language codes in SupportedLanguages.\r
@@ -544,37 +544,37 @@ GetLangFromSupportedLangCodes (
   If SupportedLanguages is NULL, then ASSERT().\r
 \r
   @param[in]  SupportedLanguages  A pointer to a Null-terminated ASCII string that\r
-                                  contains a set of language codes in the format \r
+                                  contains a set of language codes in the format\r
                                   specified by Iso639Language.\r
   @param[in]  Iso639Language      If not zero, then all language codes are assumed to be\r
                                   in ISO 639-2 format.  If zero, then all language\r
                                   codes are assumed to be in RFC 4646 language format\r
-  @param[in]  ...                 A variable argument list that contains pointers to \r
+  @param[in]  ...                 A variable argument list that contains pointers to\r
                                   Null-terminated ASCII strings that contain one or more\r
                                   language codes in the format specified by Iso639Language.\r
                                   The first language code from each of these language\r
                                   code lists is used to determine if it is an exact or\r
-                                  close match to any of the language codes in \r
+                                  close match to any of the language codes in\r
                                   SupportedLanguages.  Close matches only apply to RFC 4646\r
                                   language codes, and the matching algorithm from RFC 4647\r
-                                  is used to determine if a close match is present.  If \r
+                                  is used to determine if a close match is present.  If\r
                                   an exact or close match is found, then the matching\r
                                   language code from SupportedLanguages is returned.  If\r
                                   no matches are found, then the next variable argument\r
-                                  parameter is evaluated.  The variable argument list \r
+                                  parameter is evaluated.  The variable argument list\r
                                   is terminated by a NULL.\r
 \r
   @retval NULL   The best matching language could not be found in SupportedLanguages.\r
-  @retval NULL   There are not enough resources available to return the best matching \r
+  @retval NULL   There are not enough resources available to return the best matching\r
                  language.\r
-  @retval Other  A pointer to a Null-terminated ASCII string that is the best matching \r
+  @retval Other  A pointer to a Null-terminated ASCII string that is the best matching\r
                  language in SupportedLanguages.\r
 \r
 **/\r
 CHAR8 *\r
 EFIAPI\r
 VariableGetBestLanguage (\r
-  IN CONST CHAR8  *SupportedLanguages, \r
+  IN CONST CHAR8  *SupportedLanguages,\r
   IN UINTN        Iso639Language,\r
   ...\r
   )\r
@@ -649,7 +649,7 @@ VariableGetBestLanguage (
         LanguageLength = 0;\r
       } else {\r
         //\r
-        // If RFC 4646 mode, then trim Language from the right to the next '-' character \r
+        // If RFC 4646 mode, then trim Language from the right to the next '-' character\r
         //\r
         for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--);\r
       }\r
@@ -658,7 +658,7 @@ VariableGetBestLanguage (
   VA_END (Args);\r
 \r
   //\r
-  // No matches were found \r
+  // No matches were found\r
   //\r
   return NULL;\r
 }\r
@@ -723,7 +723,7 @@ AutoUpdateLangVariable(
     ASSERT (mVariableModuleGlobal->PlatformLangCodes != NULL);\r
 \r
     //\r
-    // PlatformLang holds a single language from PlatformLangCodes, \r
+    // PlatformLang holds a single language from PlatformLangCodes,\r
     // so the size of PlatformLangCodes is enough for the PlatformLang.\r
     //\r
     if (mVariableModuleGlobal->PlatformLang != NULL) {\r
@@ -753,7 +753,7 @@ AutoUpdateLangVariable(
     ASSERT (mVariableModuleGlobal->LangCodes != NULL);\r
   }\r
 \r
-  if (SetLanguageCodes \r
+  if (SetLanguageCodes\r
       && (mVariableModuleGlobal->PlatformLangCodes != NULL)\r
       && (mVariableModuleGlobal->LangCodes != NULL)) {\r
     //\r
@@ -785,7 +785,7 @@ AutoUpdateLangVariable(
       }\r
     }\r
   }\r
-  \r
+\r
   //\r
   // According to UEFI spec, "Lang" and "PlatformLang" is NV|BS|RT attributions.\r
   //\r
@@ -849,7 +849,7 @@ AutoUpdateLangVariable(
         //\r
         FindVariable (L"PlatformLang", &gEfiGlobalVariableGuid, &Variable, (VARIABLE_GLOBAL *)mVariableModuleGlobal);\r
 \r
-        Status = UpdateVariable (L"PlatformLang", &gEfiGlobalVariableGuid, BestPlatformLang, \r
+        Status = UpdateVariable (L"PlatformLang", &gEfiGlobalVariableGuid, BestPlatformLang,\r
                                  AsciiStrSize (BestPlatformLang), Attributes, &Variable);\r
 \r
         DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a\n", BestLang, BestPlatformLang));\r
@@ -860,7 +860,7 @@ AutoUpdateLangVariable(
 }\r
 \r
 /**\r
-  Update the variable region with Variable information. These are the same \r
+  Update the variable region with Variable information. These are the same\r
   arguments as the EFI Variable services.\r
 \r
   @param[in] VariableName       Name of variable\r
@@ -907,10 +907,10 @@ UpdateVariable (
     // Update/Delete existing variable\r
     //\r
 \r
-    if (EfiAtRuntime ()) {        \r
+    if (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
       if (Variable->Volatile) {\r
@@ -952,21 +952,21 @@ UpdateVariable (
       //\r
       Variable->CurrPtr->State &= VAR_IN_DELETED_TRANSITION;\r
     }\r
-    \r
+\r
   } else {\r
     //\r
     // No found existing variable, Create a new variable\r
-    //  \r
-    \r
+    //\r
+\r
     //\r
     // Make sure we are trying to create a new variable.\r
-    // Setting a data variable with no access, or zero DataSize attributes means to delete it.    \r
+    // Setting a data variable with no access, or zero DataSize attributes means to delete it.\r
     //\r
     if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {\r
       Status = EFI_NOT_FOUND;\r
       goto Done;\r
     }\r
-        \r
+\r
     //\r
     // Only variable have NV|RT attribute can be created in Runtime\r
     //\r
@@ -974,14 +974,14 @@ UpdateVariable (
         (((Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0) || ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0))) {\r
       Status = EFI_INVALID_PARAMETER;\r
       goto Done;\r
-    }         \r
+    }\r
   }\r
-  \r
+\r
   //\r
   // Function part - create a new variable and copy the data.\r
   // Both update a variable and create a variable will come here.\r
   //\r
-  \r
+\r
   VarNameOffset = sizeof (VARIABLE_HEADER);\r
   VarNameSize   = StrSize (VariableName);\r
   VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize);\r
@@ -989,9 +989,9 @@ UpdateVariable (
 \r
   if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {\r
     NonVolatileVarableStoreSize = ((VARIABLE_STORE_HEADER *)(UINTN)(Global->NonVolatileVariableBase))->Size;\r
-    if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) \r
+    if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0)\r
       && ((HEADER_ALIGN (VarSize) + mVariableModuleGlobal->HwErrVariableTotalSize) > PcdGet32 (PcdHwErrStorageSize)))\r
-      || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0) \r
+      || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0)\r
       && ((HEADER_ALIGN (VarSize) + mVariableModuleGlobal->CommonVariableTotalSize) > NonVolatileVarableStoreSize - sizeof (VARIABLE_STORE_HEADER) - PcdGet32 (PcdHwErrStorageSize)))) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto Done;\r
@@ -1144,21 +1144,21 @@ FindVariable (
 \r
 /**\r
   This code finds variable in storage blocks (Volatile or Non-Volatile).\r
-  \r
+\r
   @param  VariableName           A Null-terminated Unicode string that is the name of\r
                                  the vendor's variable.\r
   @param  VendorGuid             A unique identifier for the vendor.\r
-  @param  Attributes             If not NULL, a pointer to the memory location to return the \r
+  @param  Attributes             If not NULL, a pointer to the memory location to return the\r
                                  attributes bitmask for the variable.\r
   @param  DataSize               Size of Data found. If size is less than the\r
                                  data, this value contains the required size.\r
-  @param  Data                   On input, the size in bytes of the return Data buffer.  \r
+  @param  Data                   On input, the size in bytes of the return Data buffer.\r
                                  On output, the size of data returned in Data.\r
   @param  Global                 Pointer to VARIABLE_GLOBAL structure\r
 \r
-  @retval EFI_SUCCESS            The function completed successfully. \r
+  @retval EFI_SUCCESS            The function completed successfully.\r
   @retval EFI_NOT_FOUND          The variable was not found.\r
-  @retval EFI_BUFFER_TOO_SMALL   DataSize is too small for the result.  DataSize has \r
+  @retval EFI_BUFFER_TOO_SMALL   DataSize is too small for the result.  DataSize has\r
                                  been updated with the size needed to complete the request.\r
   @retval EFI_INVALID_PARAMETER  VariableName or VendorGuid or DataSize is NULL.\r
 \r
@@ -1208,7 +1208,7 @@ EmuGetVariable (
     }\r
     VariableDataPtr = GetVariableDataPtr (Variable.CurrPtr);\r
     ASSERT (VariableDataPtr != NULL);\r
-    \r
+\r
     CopyMem (Data, VariableDataPtr, VarDataSize);\r
     if (Attributes != NULL) {\r
       *Attributes = Variable.CurrPtr->Attributes;\r
@@ -1368,9 +1368,9 @@ Done:
   This code sets variable in storage blocks (Volatile or Non-Volatile).\r
 \r
   @param  VariableName           A Null-terminated Unicode string that is the name of the vendor's\r
-                                 variable.  Each VariableName is unique for each \r
-                                 VendorGuid.  VariableName must contain 1 or more \r
-                                 Unicode characters.  If VariableName is an empty Unicode \r
+                                 variable.  Each VariableName is unique for each\r
+                                 VendorGuid.  VariableName must contain 1 or more\r
+                                 Unicode characters.  If VariableName is an empty Unicode\r
                                  string, then EFI_INVALID_PARAMETER is returned.\r
   @param  VendorGuid             A unique identifier for the vendor\r
   @param  Attributes             Attributes bitmask to set for the variable\r
@@ -1381,10 +1381,10 @@ Done:
   @param  VolatileOffset         The offset of last volatile variable\r
   @param  NonVolatileOffset      The offset of last non-volatile variable\r
 \r
-  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as \r
+  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r
                                  defined by the Attributes.\r
-  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the \r
-                                 DataSize exceeds the maximum allowed, or VariableName is an empty \r
+  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the\r
+                                 DataSize exceeds the maximum allowed, or VariableName is an empty\r
                                  Unicode string, or VendorGuid is NULL.\r
   @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
   @retval EFI_DEVICE_ERROR       The variable could not be saved due to a hardware failure.\r
@@ -1413,7 +1413,7 @@ EmuSetVariable (
   //\r
   if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
-  }  \r
+  }\r
 \r
   if (DataSize != 0 && Data == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1433,11 +1433,11 @@ EmuSetVariable (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  \r
+\r
   if ((UINTN)(~0) - DataSize < StrSize(VariableName)){\r
     //\r
-    // Prevent whole variable size overflow \r
-    // \r
+    // Prevent whole variable size overflow\r
+    //\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1463,7 +1463,7 @@ EmuSetVariable (
   //\r
     if (StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxVariableSize) - sizeof (VARIABLE_HEADER)) {\r
       return EFI_INVALID_PARAMETER;\r
-    }  \r
+    }\r
   }\r
 \r
   AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
@@ -1471,7 +1471,7 @@ EmuSetVariable (
   //\r
   // Check whether the input variable is already existed\r
   //\r
-  \r
+\r
   Status = FindVariable (VariableName, VendorGuid, &Variable, Global);\r
 \r
   //\r
@@ -1491,18 +1491,18 @@ EmuSetVariable (
 \r
   @param  Attributes                   Attributes bitmask to specify the type of variables\r
                                        on which to return information.\r
-  @param  MaximumVariableStorageSize   On output the maximum size of the storage space available for \r
-                                       the EFI variables associated with the attributes specified.  \r
-  @param  RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI \r
+  @param  MaximumVariableStorageSize   On output the maximum size of the storage space available for\r
+                                       the EFI variables associated with the attributes specified.\r
+  @param  RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI\r
                                        variables associated with the attributes specified.\r
-  @param  MaximumVariableSize          Returns the maximum size of an individual EFI variable \r
+  @param  MaximumVariableSize          Returns the maximum size of an individual EFI variable\r
                                        associated with the attributes specified.\r
   @param  Global                       Pointer to VARIABLE_GLOBAL structure.\r
 \r
   @retval EFI_SUCCESS                  Valid answer returned.\r
   @retval EFI_INVALID_PARAMETER        An invalid combination of attribute bits was supplied\r
-  @retval EFI_UNSUPPORTED              The attribute is not supported on this platform, and the \r
-                                       MaximumVariableStorageSize, RemainingVariableStorageSize, \r
+  @retval EFI_UNSUPPORTED              The attribute is not supported on this platform, and the\r
+                                       MaximumVariableStorageSize, RemainingVariableStorageSize,\r
                                        MaximumVariableSize are undefined.\r
 \r
 **/\r
@@ -1529,12 +1529,12 @@ EmuQueryVariableInfo (
   if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL || Attributes == 0) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   if((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == 0) {\r
     //\r
     // Make sure the Attributes combination is supported by the platform.\r
     //\r
-    return EFI_UNSUPPORTED;  \r
+    return EFI_UNSUPPORTED;\r
   } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\r
     //\r
     // Make sure if runtime bit is set, boot service bit is set also.\r
@@ -1633,7 +1633,7 @@ EmuQueryVariableInfo (
   } else if ((*RemainingVariableStorageSize - sizeof (VARIABLE_HEADER)) < *MaximumVariableSize) {\r
     *MaximumVariableSize = *RemainingVariableStorageSize - sizeof (VARIABLE_HEADER);\r
   }\r
-  \r
+\r
   ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
   return EFI_SUCCESS;\r
 }\r
@@ -1674,7 +1674,7 @@ InitializeVariableStore (
   //\r
   // Note that in EdkII variable driver implementation, Hardware Error Record type variable\r
   // is stored with common variable in the same NV region. So the platform integrator should\r
-  // ensure that the value of PcdHwErrStorageSize is less than or equal to the value of \r
+  // ensure that the value of PcdHwErrStorageSize is less than or equal to the value of\r
   // PcdVariableStoreSize.\r
   //\r
   ASSERT (PcdGet32 (PcdHwErrStorageSize) <= PcdGet32 (PcdVariableStoreSize));\r