]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
SecurityPkg: Clean up source files
[mirror_edk2.git] / SecurityPkg / VariableAuthenticated / EsalVariableDxeSal / Variable.c
index dfa85973f4918128e597eb1aa42dd12be18e4e74..b8a0af4b5cb2c9d088b724ffe581eb4c098cf121 100644 (file)
@@ -1,13 +1,13 @@
 /** @file\r
   The implementation of Extended SAL variable services.\r
 \r
-Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
-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
+Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+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
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
@@ -162,7 +162,7 @@ AccessVariableStore (
     if ((StartAddress + DataSize) > ((UINTN) ((UINT8 *) VolatileBase + VolatileBase->Size))) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
-    \r
+\r
     //\r
     // For volatile variable, a simple memory copy is enough.\r
     //\r
@@ -181,13 +181,13 @@ AccessVariableStore (
   Status = (EFI_STATUS) EsalCall (\r
                           EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
                           EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                          GetPhysicalAddressFunctionId, \r
-                          Instance, \r
-                          (UINT64) &FvVolHdr, \r
-                          0, \r
-                          0, \r
-                          0, \r
-                          0, \r
+                          GetPhysicalAddressFunctionId,\r
+                          Instance,\r
+                          (UINT64) &FvVolHdr,\r
+                          0,\r
+                          0,\r
+                          0,\r
+                          0,\r
                           0\r
                           ).Status;\r
   ASSERT_EFI_ERROR (Status);\r
@@ -199,7 +199,7 @@ AccessVariableStore (
   if ((StartAddress + DataSize) > ((EFI_PHYSICAL_ADDRESS) (UINTN) ((CHAR8 *)VariableStoreHeader + VariableStoreHeader->Size))) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   LinearOffset  = (UINTN) FwVolHeader;\r
   CurrWritePtr  = StartAddress;\r
   CurrWriteSize = DataSize;\r
@@ -227,26 +227,26 @@ AccessVariableStore (
             Status = (EFI_STATUS) EsalCall (\r
                                     EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
                                     EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                                    WriteFunctionId, \r
-                                    Instance, \r
-                                    LbaNumber, \r
-                                    (CurrWritePtr - LinearOffset), \r
-                                    (UINT64) &CurrWriteSize, \r
-                                    (UINT64) CurrBuffer, \r
-                                    0, \r
+                                    WriteFunctionId,\r
+                                    Instance,\r
+                                    LbaNumber,\r
+                                    (CurrWritePtr - LinearOffset),\r
+                                    (UINT64) &CurrWriteSize,\r
+                                    (UINT64) CurrBuffer,\r
+                                    0,\r
                                     0\r
                                     ).Status;\r
           } else {\r
             Status = (EFI_STATUS) EsalCall (\r
                                     EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
                                     EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                                    ReadFunctionId, \r
-                                    Instance, \r
-                                    LbaNumber, \r
-                                    (CurrWritePtr - LinearOffset), \r
-                                    (UINT64) &CurrWriteSize, \r
-                                    (UINT64) CurrBuffer, \r
-                                    0, \r
+                                    ReadFunctionId,\r
+                                    Instance,\r
+                                    LbaNumber,\r
+                                    (CurrWritePtr - LinearOffset),\r
+                                    (UINT64) &CurrWriteSize,\r
+                                    (UINT64) CurrBuffer,\r
+                                    0,\r
                                     0\r
                                     ).Status;\r
           }\r
@@ -260,26 +260,26 @@ AccessVariableStore (
             Status = (EFI_STATUS) EsalCall (\r
                                     EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
                                     EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                                    WriteFunctionId, \r
-                                    Instance, \r
-                                    LbaNumber, \r
-                                    (CurrWritePtr - LinearOffset), \r
-                                    (UINT64) &Size, \r
-                                    (UINT64) CurrBuffer, \r
-                                    0, \r
+                                    WriteFunctionId,\r
+                                    Instance,\r
+                                    LbaNumber,\r
+                                    (CurrWritePtr - LinearOffset),\r
+                                    (UINT64) &Size,\r
+                                    (UINT64) CurrBuffer,\r
+                                    0,\r
                                     0\r
                                     ).Status;\r
           } else {\r
             Status = (EFI_STATUS) EsalCall (\r
                                     EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
                                     EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                                    ReadFunctionId, \r
-                                    Instance, \r
-                                    LbaNumber, \r
-                                    (CurrWritePtr - LinearOffset), \r
-                                    (UINT64) &Size, \r
-                                    (UINT64) CurrBuffer, \r
-                                    0, \r
+                                    ReadFunctionId,\r
+                                    Instance,\r
+                                    LbaNumber,\r
+                                    (CurrWritePtr - LinearOffset),\r
+                                    (UINT64) &Size,\r
+                                    (UINT64) CurrBuffer,\r
+                                    0,\r
                                     0\r
                                     ).Status;\r
           }\r
@@ -332,7 +332,7 @@ GetVarStoreHeader (
              Instance,\r
              VarStoreAddress,\r
              sizeof (VARIABLE_STORE_HEADER),\r
-             VarStoreHeader    \r
+             VarStoreHeader\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
@@ -372,7 +372,7 @@ IsValidVariableHeader (
              Instance,\r
              VariableAddress,\r
              sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
-             &LocalVariableHeader    \r
+             &LocalVariableHeader\r
              );\r
 \r
   if (EFI_ERROR (Status) || LocalVariableHeader.StartId != VARIABLE_DATA) {\r
@@ -520,7 +520,7 @@ GetVariableNamePtr (
              Instance,\r
              Address,\r
              VariableHeader.NameSize,\r
-             VariableName    \r
+             VariableName\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
@@ -571,7 +571,7 @@ GetVariableDataPtr (
              Instance,\r
              Address,\r
              VariableHeader.DataSize,\r
-             VariableData    \r
+             VariableData\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
@@ -626,7 +626,7 @@ GetNextVariablePtr (
 /**\r
   Gets the pointer to the first variable header in given variable store area.\r
 \r
-  This function gets the pointer to the first variable header in given variable \r
+  This function gets the pointer to the first variable header in given variable\r
   store area. The variable store area is given by its start address.\r
 \r
   @param[in] VarStoreHeaderAddress  Pointer to the header of variable store area.\r
@@ -675,7 +675,7 @@ GetEndPointer (
              Instance,\r
              VarStoreHeaderAddress,\r
              sizeof (VARIABLE_STORE_HEADER),\r
-             &VariableStoreHeader    \r
+             &VariableStoreHeader\r
              );\r
 \r
   ASSERT_EFI_ERROR (Status);\r
@@ -685,12 +685,12 @@ GetEndPointer (
 /**\r
   Updates variable info entry in EFI system table for statistical information.\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
-  A read that hits in the cache will have Read and Cache true for \r
+  build flag controls if this feature is enabled.\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
@@ -742,7 +742,7 @@ UpdateVariableInfo (
       gBS->InstallConfigurationTable (&gEfiAuthenticatedVariableGuid, 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
@@ -826,7 +826,7 @@ UpdateVariableCache (
   //\r
   for (Index = 0, Entry = mVariableCache; Index < sizeof (mVariableCache)/sizeof (VARIABLE_CACHE_ENTRY); Index++, Entry++) {\r
     if (CompareGuid (VendorGuid, Entry->Guid)) {\r
-      if (StrCmp (VariableName, Entry->Name) == 0) { \r
+      if (StrCmp (VariableName, Entry->Name) == 0) {\r
         Entry->Attributes = Attributes;\r
         if (DataSize == 0) {\r
           //\r
@@ -928,7 +928,7 @@ FindVariableInCache (
       }\r
     }\r
   }\r
-  \r
+\r
   return EFI_NOT_FOUND;\r
 }\r
 \r
@@ -1003,7 +1003,7 @@ FindVariable (
       Volatile = FALSE;\r
     }\r
     while (IsValidVariableHeader (Variable[Index], Volatile, Global, Instance, &VariableHeader)) {\r
-      if (VariableHeader.State == VAR_ADDED || \r
+      if (VariableHeader.State == VAR_ADDED ||\r
           VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)\r
          ) {\r
         if (!EfiAtRuntime () || ((VariableHeader.Attributes & EFI_VARIABLE_RUNTIME_ACCESS) != 0)) {\r
@@ -1162,7 +1162,7 @@ Reclaim (
     //\r
     // Collect VAR_ADDED variables, and variables in delete transition status.\r
     //\r
-    if (VariableHeader.State == VAR_ADDED || \r
+    if (VariableHeader.State == VAR_ADDED ||\r
         VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)\r
        ) {\r
       VariableSize = NextVariable - Variable;\r
@@ -1173,9 +1173,9 @@ Reclaim (
   }\r
 \r
   //\r
-  // Reserve the 1 Bytes with Oxff to identify the \r
-  // end of the variable buffer. \r
-  // \r
+  // Reserve the 1 Bytes with Oxff to identify the\r
+  // end of the variable buffer.\r
+  //\r
   MaximumBufferSize += 1;\r
   ValidBuffer = AllocatePool (MaximumBufferSize);\r
   if (ValidBuffer == NULL) {\r
@@ -1192,7 +1192,7 @@ Reclaim (
 \r
   //\r
   // Reinstall all ADDED variables\r
-  // \r
+  //\r
   Variable = GetStartPointer (VariableBase);\r
   while (IsValidVariableHeader (Variable, IsVolatile, VariableGlobal, Instance, &VariableHeader)) {\r
     NextVariable = GetNextVariablePtr (Variable, IsVolatile, VariableGlobal, Instance);\r
@@ -1210,17 +1210,17 @@ Reclaim (
   }\r
   //\r
   // Reinstall in delete transition variables\r
-  // \r
+  //\r
   Variable = GetStartPointer (VariableBase);\r
   while (IsValidVariableHeader (Variable, IsVolatile, VariableGlobal, Instance, &VariableHeader)) {\r
     NextVariable = GetNextVariablePtr (Variable, IsVolatile, VariableGlobal, Instance);\r
     if (VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) {\r
 \r
       //\r
-      // Buffer has cached all ADDED variable. \r
+      // Buffer has cached all ADDED variable.\r
       // Per IN_DELETED variable, we have to guarantee that\r
-      // no ADDED one in previous buffer. \r
-      // \r
+      // no ADDED one in previous buffer.\r
+      //\r
       FoundAdded = FALSE;\r
       AddedVariable = GetStartPointer ((EFI_PHYSICAL_ADDRESS) ValidBuffer);\r
       while (IsValidVariableHeader (AddedVariable, IsVolatile, VariableGlobal, Instance, &AddedVariableHeader)) {\r
@@ -1327,7 +1327,7 @@ GetIndexFromSupportedLangCodes(
   IN  CHAR8            *SupportedLang,\r
   IN  CHAR8            *Lang,\r
   IN  BOOLEAN          Iso639Language\r
-  ) \r
+  )\r
 {\r
   UINTN    Index;\r
   UINTN    CompareLength;\r
@@ -1362,8 +1362,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
@@ -1465,10 +1465,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
@@ -1476,37 +1476,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 TRUE, then all language codes are assumed to be\r
                                   in ISO 639-2 format.  If FALSE, then all language\r
                                   codes are assumed to be in RFC 4646 language format.\r
   @param[in]  VirtualMode         Current calling mode for this function.\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
 VariableGetBestLanguage (\r
-  IN CONST CHAR8  *SupportedLanguages, \r
+  IN CONST CHAR8  *SupportedLanguages,\r
   IN BOOLEAN      Iso639Language,\r
   IN BOOLEAN      VirtualMode,\r
   ...\r
@@ -1582,7 +1582,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
@@ -1591,7 +1591,7 @@ VariableGetBestLanguage (
   VA_END (Args);\r
 \r
   //\r
-  // No matches were found \r
+  // No matches were found\r
   //\r
   return NULL;\r
 }\r
@@ -1664,7 +1664,7 @@ AutoUpdateLangVariable(
     ASSERT (Global->PlatformLangCodes[VirtualMode] != 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 (Global->PlatformLang[VirtualMode] != NULL) {\r
@@ -1694,7 +1694,7 @@ AutoUpdateLangVariable(
     ASSERT (Global->LangCodes[VirtualMode] != NULL);\r
   }\r
 \r
-  if (SetLanguageCodes \r
+  if (SetLanguageCodes\r
       && (Global->PlatformLangCodes[VirtualMode] != NULL)\r
       && (Global->LangCodes[VirtualMode] != NULL)) {\r
     //\r
@@ -1732,7 +1732,7 @@ AutoUpdateLangVariable(
                (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable.CurrPtr)->DataSize),\r
                sizeof (DataSize),\r
                &DataSize\r
-               ); \r
+               );\r
     ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
@@ -1811,15 +1811,15 @@ AutoUpdateLangVariable(
         FindVariable (PredefinedVariableName[VAR_PLATFORM_LANG], Global->GlobalVariableGuid[VirtualMode], &Variable, VariableGlobal, Instance);\r
 \r
         Status = UpdateVariable (\r
-                   PredefinedVariableName[VAR_PLATFORM_LANG], \r
-                   Global->GlobalVariableGuid[VirtualMode], \r
-                   BestPlatformLang, \r
-                   AsciiStrSize (BestPlatformLang), \r
-                   Attributes, \r
+                   PredefinedVariableName[VAR_PLATFORM_LANG],\r
+                   Global->GlobalVariableGuid[VirtualMode],\r
+                   BestPlatformLang,\r
+                   AsciiStrSize (BestPlatformLang),\r
+                   Attributes,\r
                    0,\r
                    0,\r
-                   VirtualMode, \r
-                   Global, \r
+                   VirtualMode,\r
+                   Global,\r
                    &Variable\r
                    );\r
 \r
@@ -1831,7 +1831,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
@@ -1840,7 +1840,7 @@ AutoUpdateLangVariable(
   @param[in] DataSize           Size of data. 0 means delete.\r
   @param[in] Attributes         Attributes of the variable.\r
   @param[in] KeyIndex           Index of associated public key.\r
-  @param[in] MonotonicCount     Value of associated monotonic count. \r
+  @param[in] MonotonicCount     Value of associated monotonic count.\r
   @param[in] VirtualMode        Current calling mode for this function.\r
   @param[in] Global             Context of this Extended SAL Variable Services Class call.\r
   @param[in] Variable           The variable information which is used to keep track of variable usage.\r
@@ -1856,7 +1856,7 @@ UpdateVariable (
   IN      EFI_GUID                *VendorGuid,\r
   IN      VOID                    *Data,\r
   IN      UINTN                   DataSize,\r
-  IN      UINT32                  Attributes OPTIONAL,  \r
+  IN      UINT32                  Attributes OPTIONAL,\r
   IN      UINT32                  KeyIndex  OPTIONAL,\r
   IN      UINT64                  MonotonicCount  OPTIONAL,\r
   IN      BOOLEAN                 VirtualMode,\r
@@ -1898,11 +1898,11 @@ UpdateVariable (
     // Update/Delete existing variable\r
     //\r
     Volatile = Variable->Volatile;\r
-    \r
-    if (EfiAtRuntime ()) {        \r
+\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
@@ -1914,14 +1914,14 @@ UpdateVariable (
       //\r
       if ((VariableHeader.Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
         Status = EFI_INVALID_PARAMETER;\r
-        goto Done;      \r
+        goto Done;\r
       }\r
     }\r
     //\r
     // Setting a data variable with no access, or zero DataSize attributes\r
     // specified causes it to be deleted.\r
     //\r
-    if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {    \r
+    if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {\r
       State = VariableHeader.State;\r
       State &= VAR_DELETED;\r
 \r
@@ -1933,12 +1933,12 @@ UpdateVariable (
                  (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
                  sizeof (UINT8),\r
                  &State\r
-                 ); \r
+                 );\r
       if (!EFI_ERROR (Status)) {\r
         UpdateVariableInfo (VariableName, VendorGuid, Volatile, FALSE, FALSE, TRUE, FALSE);\r
         UpdateVariableCache (VariableName, VendorGuid, Attributes, DataSize, Data);\r
       }\r
-      goto Done;     \r
+      goto Done;\r
     }\r
     //\r
     // Logic comes here to update variable.\r
@@ -1971,25 +1971,25 @@ UpdateVariable (
                  (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
                  sizeof (UINT8),\r
                  &State\r
-                 );      \r
+                 );\r
       if (EFI_ERROR (Status)) {\r
-        goto Done;  \r
+        goto Done;\r
       }\r
-    }    \r
+    }\r
   } else {\r
     //\r
     // 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
@@ -1997,7 +1997,7 @@ 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
@@ -2050,11 +2050,11 @@ UpdateVariable (
     // Create a nonvolatile variable\r
     //\r
     Volatile = FALSE;\r
-    \r
+\r
     GetVarStoreHeader (VariableGlobal->NonVolatileVariableBase, FALSE, VariableGlobal, Instance, &VariableStoreHeader);\r
-    if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) \r
+    if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0)\r
              && ((HEADER_ALIGN (VarSize) + Global->HwErrVariableTotalSize) > PcdGet32(PcdHwErrStorageSize)))\r
-             || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0) \r
+             || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0)\r
              && ((HEADER_ALIGN (VarSize) + Global->CommonVariableTotalSize) > VariableStoreHeader.Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize)))) {\r
       if (EfiAtRuntime ()) {\r
         Status = EFI_OUT_OF_RESOURCES;\r
@@ -2072,9 +2072,9 @@ UpdateVariable (
       //\r
       // If still no enough space, return out of resources\r
       //\r
-      if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) \r
+      if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0)\r
                && ((HEADER_ALIGN (VarSize) + Global->HwErrVariableTotalSize) > PcdGet32(PcdHwErrStorageSize)))\r
-               || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0) \r
+               || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0)\r
                && ((HEADER_ALIGN (VarSize) + Global->CommonVariableTotalSize) > VariableStoreHeader.Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize)))) {\r
         Status = EFI_OUT_OF_RESOURCES;\r
         goto Done;\r
@@ -2083,7 +2083,7 @@ UpdateVariable (
     //\r
     // Four steps\r
     // 1. Write variable header\r
-    // 2. Set variable state to header valid  \r
+    // 2. Set variable state to header valid\r
     // 3. Write variable data\r
     // 4. Set variable state to valid\r
     //\r
@@ -2165,7 +2165,7 @@ UpdateVariable (
   } else {\r
     //\r
     // Create a volatile variable\r
-    //      \r
+    //\r
     Volatile = TRUE;\r
 \r
     if ((UINT32) (HEADER_ALIGN(VarSize) + Global->VolatileLastVariableOffset) >\r
@@ -2240,22 +2240,22 @@ Done:
 \r
   This function implements EsalGetVariable function of Extended SAL Variable Services Class.\r
   It is equivalent in functionality to the EFI Runtime Service GetVariable().\r
-  \r
+\r
   @param[in]      VariableName    A Null-terminated Unicode string that is the name of\r
                                   the vendor's variable.\r
   @param[in]      VendorGuid      A unique identifier for the vendor.\r
-  @param[out]     Attributes      If not NULL, a pointer to the memory location to return the \r
+  @param[out]     Attributes      If not NULL, a pointer to the memory location to return the\r
                                   attributes bitmask for the variable.\r
   @param[in, out] DataSize        Size of Data found. If size is less than the\r
                                   data, this value contains the required size.\r
-  @param[out]     Data            On input, the size in bytes of the return Data buffer.  \r
+  @param[out]     Data            On input, the size in bytes of the return Data buffer.\r
                                   On output, the size of data returned in Data.\r
   @param[in]      VirtualMode     Current calling mode for this function.\r
   @param[in]      Global          Context of this Extended SAL Variable Services Class call.\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 is NULL.\r
   @retval EFI_INVALID_PARAMETER  VendorGuid is NULL.\r
@@ -2349,7 +2349,7 @@ EsalGetVariable (
     *DataSize = VarDataSize;\r
     UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE, FALSE, FALSE, FALSE);\r
     UpdateVariableCache (VariableName, VendorGuid, VariableHeader.Attributes, VarDataSize, Data);\r
\r
+\r
     Status = EFI_SUCCESS;\r
     goto Done;\r
   } else {\r
@@ -2371,18 +2371,18 @@ Done:
 \r
   This function implements EsalGetNextVariableName function of Extended SAL Variable Services Class.\r
   It is equivalent in functionality to the EFI Runtime Service GetNextVariableName().\r
-  \r
+\r
   @param[in, out] VariableNameSize Size of the variable\r
   @param[in, out] VariableName     On input, supplies the last VariableName that was returned by GetNextVariableName().\r
                                    On output, returns the Null-terminated Unicode string of the current variable.\r
   @param[in, out] VendorGuid       On input, supplies the last VendorGuid that was returned by GetNextVariableName().\r
-                                   On output, returns the VendorGuid of the current variable.  \r
+                                   On output, returns the VendorGuid of the current variable.\r
   @param[in]      VirtualMode      Current calling mode for this function.\r
   @param[in]      Global           Context of this Extended SAL Variable Services Class call.\r
 \r
-  @retval EFI_SUCCESS             The function completed successfully. \r
+  @retval EFI_SUCCESS             The function completed successfully.\r
   @retval EFI_NOT_FOUND           The next variable was not found.\r
-  @retval EFI_BUFFER_TOO_SMALL    VariableNameSize is too small for the result. \r
+  @retval EFI_BUFFER_TOO_SMALL    VariableNameSize is too small for the result.\r
                                   VariableNameSize has been updated with the size needed to complete the request.\r
   @retval EFI_INVALID_PARAMETER   VariableNameSize is NULL.\r
   @retval EFI_INVALID_PARAMETER   VariableName is NULL.\r
@@ -2512,11 +2512,11 @@ Done:
 \r
   This function implements EsalSetVariable function of Extended SAL Variable Services Class.\r
   It is equivalent in functionality to the EFI Runtime Service SetVariable().\r
-  \r
+\r
   @param[in]  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[in]  VendorGuid         A unique identifier for the vendor.\r
   @param[in]  Attributes         Attributes bitmask to set for the variable.\r
@@ -2526,9 +2526,9 @@ Done:
   @param[in]  VirtualMode        Current calling mode for this function.\r
   @param[in]  Global             Context of this Extended SAL Variable Services Class call.\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
+  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the\r
                                  DataSize exceeds the maximum allowed.\r
   @retval EFI_INVALID_PARAMETER  VariableName is an empty Unicode string.\r
   @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
@@ -2566,7 +2566,7 @@ EsalSetVariable (
   //\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
@@ -2585,17 +2585,17 @@ EsalSetVariable (
       // Try to write Authencated Variable without AuthInfo\r
       //\r
       return EFI_SECURITY_VIOLATION;\r
-    } \r
-    PayloadSize = DataSize - AUTHINFO_SIZE; \r
+    }\r
+    PayloadSize = DataSize - AUTHINFO_SIZE;\r
   } else {\r
-    PayloadSize = DataSize; \r
+    PayloadSize = DataSize;\r
   }\r
 \r
-  \r
+\r
   if ((UINTN)(~0) - PayloadSize < 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
@@ -2625,8 +2625,8 @@ EsalSetVariable (
     //\r
     if (StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxVariableSize) - sizeof (AUTHENTICATED_VARIABLE_HEADER)) {\r
       return EFI_INVALID_PARAMETER;\r
-    }  \r
-  }  \r
+    }\r
+  }\r
 \r
   AcquireLockOnlyAtBootTime(&VariableGlobal->VariableServicesLock);\r
 \r
@@ -2676,31 +2676,31 @@ EsalSetVariable (
         // Cut the certificate size before set\r
         //\r
         Status = UpdateVariable (\r
-                   VariableName, \r
-                   VendorGuid, \r
-                   (UINT8*)Data + AUTHINFO_SIZE, \r
-                   DataSize - AUTHINFO_SIZE, \r
-                   Attributes, \r
-                   KeyIndex, \r
-                   MonotonicCount, \r
-                   VirtualMode, \r
-                   Global, \r
+                   VariableName,\r
+                   VendorGuid,\r
+                   (UINT8*)Data + AUTHINFO_SIZE,\r
+                   DataSize - AUTHINFO_SIZE,\r
+                   Attributes,\r
+                   KeyIndex,\r
+                   MonotonicCount,\r
+                   VirtualMode,\r
+                   Global,\r
                    &Variable\r
                    );\r
       } else {\r
         //\r
-        // Update variable as usual \r
+        // Update variable as usual\r
         //\r
         Status = UpdateVariable (\r
-                   VariableName, \r
-                   VendorGuid, \r
-                   Data, \r
-                   DataSize, \r
-                   Attributes, \r
-                   0, \r
-                   0, \r
-                   VirtualMode, \r
-                   Global, \r
+                   VariableName,\r
+                   VendorGuid,\r
+                   Data,\r
+                   DataSize,\r
+                   Attributes,\r
+                   0,\r
+                   0,\r
+                   VirtualMode,\r
+                   Global,\r
                    &Variable\r
                    );\r
       }\r
@@ -2720,19 +2720,19 @@ EsalSetVariable (
 \r
   @param[in]  Attributes                   Attributes bitmask to specify the type of variables\r
                                            on which to return information.\r
-  @param[out] MaximumVariableStorageSize   On output the maximum size of the storage space available for \r
-                                           the EFI variables associated with the attributes specified.  \r
-  @param[out] RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI \r
+  @param[out] MaximumVariableStorageSize   On output the maximum size of the storage space available for\r
+                                           the EFI variables associated with the attributes specified.\r
+  @param[out] RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI\r
                                            variables associated with the attributes specified.\r
-  @param[out] MaximumVariableSize          Returns the maximum size of an individual EFI variable \r
+  @param[out] MaximumVariableSize          Returns the maximum size of an individual EFI variable\r
                                            associated with the attributes specified.\r
   @param[in]  VirtualMode                  Current calling mode for this function\r
   @param[in]  Global                       Context of this Extended SAL Variable Services Class call\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
 EFI_STATUS\r
@@ -2764,12 +2764,12 @@ EsalQueryVariableInfo (
   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
@@ -2917,20 +2917,20 @@ ReclaimForOS(
   UINTN                           RemainingHwErrVariableSpace;\r
 \r
   VarSize = ((VARIABLE_STORE_HEADER *) ((UINTN) mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase))->Size;\r
-  Status  = EFI_SUCCESS; \r
+  Status  = EFI_SUCCESS;\r
   //\r
   //Allowable max size of common variable storage space\r
   //\r
   CommonVariableSpace = VarSize - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize);\r
 \r
   RemainingCommonVariableSpace = CommonVariableSpace - mVariableModuleGlobal->CommonVariableTotalSize;\r
\r
+\r
   RemainingHwErrVariableSpace = PcdGet32 (PcdHwErrStorageSize) - mVariableModuleGlobal->HwErrVariableTotalSize;\r
   //\r
   // If the free area is below a threshold, then performs reclaim operation.\r
   //\r
   if ((RemainingCommonVariableSpace < PcdGet32 (PcdMaxVariableSize))\r
-    || ((PcdGet32 (PcdHwErrStorageSize) != 0) && \r
+    || ((PcdGet32 (PcdHwErrStorageSize) != 0) &&\r
        (RemainingHwErrVariableSpace < PcdGet32 (PcdMaxHardwareErrorVariableSize)))){\r
     Status = Reclaim (\r
                mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase,\r
@@ -3056,7 +3056,7 @@ VariableCommonInitialize (
   //\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
   // PcdFlashNvStorageVariableSize.\r
   //\r
   ASSERT (PcdGet32(PcdHwErrStorageSize) <= PcdGet32 (PcdFlashNvStorageVariableSize));\r
@@ -3133,13 +3133,13 @@ VariableCommonInitialize (
     Status    = (EFI_STATUS) EsalCall (\r
                                EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
                                EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                               GetPhysicalAddressFunctionId, \r
-                               Instance, \r
-                               (UINT64) &FvVolHdr, \r
-                               0, \r
-                               0, \r
-                               0, \r
-                               0, \r
+                               GetPhysicalAddressFunctionId,\r
+                               Instance,\r
+                               (UINT64) &FvVolHdr,\r
+                               0,\r
+                               0,\r
+                               0,\r
+                               0,\r
                                0\r
                                ).Status;\r
     if (EFI_ERROR (Status)) {\r
@@ -3237,9 +3237,9 @@ VariableCommonInitialize (
     // Register the event handling function to reclaim variable for OS usage.\r
     //\r
     Status = EfiCreateEventReadyToBootEx (\r
-               TPL_NOTIFY, \r
-               ReclaimForOS, \r
-               NULL, \r
+               TPL_NOTIFY,\r
+               ReclaimForOS,\r
+               NULL,\r
                &ReadyToBootEvent\r
                );\r
   } else {\r