]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Library / PiDxeS3BootScriptLib / BootScriptSave.c
index 0ff73211acc44a7de6aba29bc45485bca3a1b761..c116727531d27ce882ec47f260608fb37fd050f2 100644 (file)
@@ -1,16 +1,9 @@
 /** @file\r
   Save the S3 data to S3 boot script.\r
 \r
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions\r
-  of the BSD License which accompanies this distribution.  The\r
-  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
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 #include "InternalBootScriptLib.h"\r
@@ -130,13 +123,13 @@ VOID                             *mRegistrationSmmLegacyBoot = NULL;
 VOID                             *mRegistrationSmmReadyToLock = NULL;\r
 BOOLEAN                          mS3BootScriptTableAllocated = FALSE;\r
 BOOLEAN                          mS3BootScriptTableSmmAllocated = FALSE;\r
-EFI_SMM_SYSTEM_TABLE2            *mSmst = NULL;\r
+EFI_SMM_SYSTEM_TABLE2            *mBootScriptSmst = NULL;\r
 \r
 /**\r
-  This is an internal function to add a terminate node the entry, recalculate the table \r
-  length and fill into the table. \r
-  \r
-  @return the base address of the boot script table.   \r
+  This is an internal function to add a terminate node the entry, recalculate the table\r
+  length and fill into the table.\r
+\r
+  @return the base address of the boot script table.\r
  **/\r
 UINT8*\r
 S3BootScriptInternalCloseTable (\r
@@ -147,7 +140,7 @@ S3BootScriptInternalCloseTable (
   EFI_BOOT_SCRIPT_TERMINATE      ScriptTerminate;\r
   EFI_BOOT_SCRIPT_TABLE_HEADER   *ScriptTableInfo;\r
   S3TableBase = mS3BootScriptTablePtr->TableBase;\r
-  \r
+\r
   if (S3TableBase == NULL) {\r
     //\r
     // the table is not exist\r
@@ -165,17 +158,17 @@ S3BootScriptInternalCloseTable (
   //\r
   ScriptTableInfo                = (EFI_BOOT_SCRIPT_TABLE_HEADER*)(mS3BootScriptTablePtr->TableBase);\r
   ScriptTableInfo->TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE);\r
-  \r
\r
-  \r
+\r
+\r
+\r
   return S3TableBase;\r
   //\r
-  // NOTE: Here we did NOT adjust the mS3BootScriptTablePtr->TableLength to \r
+  // NOTE: Here we did NOT adjust the mS3BootScriptTablePtr->TableLength to\r
   // mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE).\r
   // Because maybe after SmmReadyToLock, we still need add entries into the table,\r
   // and the entry should be added start before this TERMINATE node.\r
   //\r
-}  \r
+}\r
 \r
 /**\r
   This function save boot script data to LockBox.\r
@@ -220,9 +213,9 @@ SaveBootScriptDataToLockBox (
 /**\r
   This is the Event call back function to notify the Library the system is entering\r
   SmmLocked phase.\r
-  \r
+\r
   @param  Event   Pointer to this event\r
-  @param  Context Event handler private data \r
+  @param  Context Event handler private data\r
  **/\r
 VOID\r
 EFIAPI\r
@@ -419,8 +412,8 @@ S3BootScriptSmmAtRuntimeCallBack (
 \r
 /**\r
   Library Constructor.\r
-  this function just identify it is a smm driver or non-smm driver linked against \r
-  with the library   \r
+  this function just identify it is a smm driver or non-smm driver linked against\r
+  with the library\r
 \r
   @param  ImageHandle   The firmware allocated handle for the EFI image.\r
   @param  SystemTable   A pointer to the EFI System Table.\r
@@ -493,7 +486,7 @@ S3BootScriptLibInitialize (
   //\r
   // Good, we are in SMM\r
   //\r
-  Status = SmmBase2->GetSmstLocation (SmmBase2, &mSmst);\r
+  Status = SmmBase2->GetSmstLocation (SmmBase2, &mBootScriptSmst);\r
   if (EFI_ERROR (Status)) {\r
     return RETURN_SUCCESS;\r
   }\r
@@ -503,11 +496,11 @@ S3BootScriptLibInitialize (
   // The Boot script private data in SMM is not be initialized. create it\r
   //\r
   if (S3TableSmmPtr == 0) {\r
-    Status = mSmst->SmmAllocatePool (\r
-                     EfiRuntimeServicesData,\r
-                     sizeof(SCRIPT_TABLE_PRIVATE_DATA),\r
-                     (VOID **) &S3TableSmmPtr\r
-                     );\r
+    Status = mBootScriptSmst->SmmAllocatePool (\r
+                                EfiRuntimeServicesData,\r
+                                sizeof(SCRIPT_TABLE_PRIVATE_DATA),\r
+                                (VOID **) &S3TableSmmPtr\r
+                                );\r
     ASSERT_EFI_ERROR (Status);\r
     mS3BootScriptTableSmmAllocated = TRUE;\r
 \r
@@ -518,18 +511,18 @@ S3BootScriptLibInitialize (
     //\r
     // Register SmmExitBootServices and SmmLegacyBoot notification.\r
     //\r
-    Status = mSmst->SmmRegisterProtocolNotify (\r
-                     &gEdkiiSmmExitBootServicesProtocolGuid,\r
-                     S3BootScriptSmmAtRuntimeCallBack,\r
-                     &mRegistrationSmmExitBootServices\r
-                     );\r
+    Status = mBootScriptSmst->SmmRegisterProtocolNotify (\r
+                                &gEdkiiSmmExitBootServicesProtocolGuid,\r
+                                S3BootScriptSmmAtRuntimeCallBack,\r
+                                &mRegistrationSmmExitBootServices\r
+                                );\r
     ASSERT_EFI_ERROR (Status);\r
 \r
-    Status = mSmst->SmmRegisterProtocolNotify (\r
-                     &gEdkiiSmmLegacyBootProtocolGuid,\r
-                     S3BootScriptSmmAtRuntimeCallBack,\r
-                     &mRegistrationSmmLegacyBoot\r
-                     );\r
+    Status = mBootScriptSmst->SmmRegisterProtocolNotify (\r
+                                &gEdkiiSmmLegacyBootProtocolGuid,\r
+                                S3BootScriptSmmAtRuntimeCallBack,\r
+                                &mRegistrationSmmLegacyBoot\r
+                                );\r
     ASSERT_EFI_ERROR (Status);\r
   }\r
   mS3BootScriptTableSmmPtr = S3TableSmmPtr;\r
@@ -537,11 +530,11 @@ S3BootScriptLibInitialize (
   //\r
   // Register SmmReadyToLock notification.\r
   //\r
-  Status = mSmst->SmmRegisterProtocolNotify (\r
-                   &gEfiSmmReadyToLockProtocolGuid,\r
-                   S3BootScriptSmmEventCallBack,\r
-                   &mRegistrationSmmReadyToLock\r
-                   );\r
+  Status = mBootScriptSmst->SmmRegisterProtocolNotify (\r
+                              &gEfiSmmReadyToLockProtocolGuid,\r
+                              S3BootScriptSmmEventCallBack,\r
+                              &mRegistrationSmmReadyToLock\r
+                              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   return RETURN_SUCCESS;\r
@@ -579,38 +572,38 @@ S3BootScriptLibDeinitialize (
     ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
-  if (mSmst != NULL) {\r
+  if (mBootScriptSmst != NULL) {\r
     if (mRegistrationSmmExitBootServices != NULL) {\r
       //\r
       // Unregister SmmExitBootServices notification.\r
       //\r
-      Status = mSmst->SmmRegisterProtocolNotify (\r
-                       &gEdkiiSmmExitBootServicesProtocolGuid,\r
-                       NULL,\r
-                       &mRegistrationSmmExitBootServices\r
-                       );\r
+      Status = mBootScriptSmst->SmmRegisterProtocolNotify (\r
+                                  &gEdkiiSmmExitBootServicesProtocolGuid,\r
+                                  NULL,\r
+                                  &mRegistrationSmmExitBootServices\r
+                                  );\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
     if (mRegistrationSmmLegacyBoot != NULL) {\r
       //\r
       // Unregister SmmLegacyBoot notification.\r
       //\r
-      Status = mSmst->SmmRegisterProtocolNotify (\r
-                       &gEdkiiSmmLegacyBootProtocolGuid,\r
-                       NULL,\r
-                       &mRegistrationSmmLegacyBoot\r
-                       );\r
+      Status = mBootScriptSmst->SmmRegisterProtocolNotify (\r
+                                  &gEdkiiSmmLegacyBootProtocolGuid,\r
+                                  NULL,\r
+                                  &mRegistrationSmmLegacyBoot\r
+                                  );\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
     if (mRegistrationSmmReadyToLock != NULL) {\r
       //\r
       // Unregister SmmReadyToLock notification.\r
       //\r
-      Status = mSmst->SmmRegisterProtocolNotify (\r
-                       &gEfiSmmReadyToLockProtocolGuid,\r
-                       NULL,\r
-                       &mRegistrationSmmReadyToLock\r
-                       );\r
+      Status = mBootScriptSmst->SmmRegisterProtocolNotify (\r
+                                  &gEfiSmmReadyToLockProtocolGuid,\r
+                                  NULL,\r
+                                  &mRegistrationSmmReadyToLock\r
+                                  );\r
       ASSERT_EFI_ERROR (Status);\r
     }\r
   }\r
@@ -624,8 +617,8 @@ S3BootScriptLibDeinitialize (
     Status = PcdSet64S (PcdS3BootScriptTablePrivateDataPtr, 0);\r
     ASSERT_EFI_ERROR (Status);\r
   }\r
-  if ((mSmst != NULL) && mS3BootScriptTableSmmAllocated) {\r
-    Status = mSmst->SmmFreePool (mS3BootScriptTableSmmPtr);\r
+  if ((mBootScriptSmst != NULL) && mS3BootScriptTableSmmAllocated) {\r
+    Status = mBootScriptSmst->SmmFreePool (mS3BootScriptTableSmmPtr);\r
     ASSERT_EFI_ERROR (Status);\r
     Status = PcdSet64S (PcdS3BootScriptTablePrivateSmmDataPtr, 0);\r
     ASSERT_EFI_ERROR (Status);\r
@@ -637,12 +630,12 @@ S3BootScriptLibDeinitialize (
 /**\r
   To get the start address from which a new boot time s3 boot script entry will write into.\r
   If the table is not exist, the functio will first allocate a buffer for the table\r
-  If the table buffer is not enough for the new entry, in non-smm mode, the funtion will \r
+  If the table buffer is not enough for the new entry, in non-smm mode, the funtion will\r
   invoke reallocate to enlarge buffer.\r
-  \r
+\r
   @param EntryLength      the new entry length.\r
-  \r
-  @retval the address from which the a new s3 boot script entry will write into \r
+\r
+  @retval the address from which the a new s3 boot script entry will write into\r
  **/\r
 UINT8*\r
 S3BootScriptGetBootTimeEntryAddAddress (\r
@@ -656,11 +649,11 @@ S3BootScriptGetBootTimeEntryAddAddress (
    UINT16                            PageNumber;\r
    EFI_STATUS                        Status;\r
    EFI_BOOT_SCRIPT_TABLE_HEADER      *ScriptTableInfo;\r
-   \r
+\r
    S3TableBase = (EFI_PHYSICAL_ADDRESS)(UINTN)(mS3BootScriptTablePtr->TableBase);\r
    if (S3TableBase == 0) {\r
      //\r
-     // The table is not exist. This is the first to add entry. \r
+     // The table is not exist. This is the first to add entry.\r
      // Allocate ACPI script table space under 4G memory.\r
      //\r
      S3TableBase = 0xffffffff;\r
@@ -670,7 +663,7 @@ S3BootScriptGetBootTimeEntryAddAddress (
                   2 + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber),\r
                   (EFI_PHYSICAL_ADDRESS*)&S3TableBase\r
                   );\r
-     \r
+\r
      if (EFI_ERROR(Status)) {\r
        ASSERT_EFI_ERROR (Status);\r
        return 0;\r
@@ -687,12 +680,12 @@ S3BootScriptGetBootTimeEntryAddAddress (
      mS3BootScriptTablePtr->TableBase = (UINT8*)(UINTN)S3TableBase;\r
      mS3BootScriptTablePtr->TableMemoryPageNumber = (UINT16)(2 + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));\r
    }\r
-     \r
+\r
    // Here we do not count the reserved memory for runtime script table.\r
    PageNumber = (UINT16) (mS3BootScriptTablePtr->TableMemoryPageNumber - PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));\r
    TableLength =  mS3BootScriptTablePtr->TableLength;\r
-   if ((UINTN) EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (UINTN) (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {\r
-     // \r
+   if (EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {\r
+     //\r
      // The buffer is too small to hold the table, Reallocate the buffer\r
      //\r
      NewS3TableBase = 0xffffffff;\r
@@ -702,43 +695,43 @@ S3BootScriptGetBootTimeEntryAddAddress (
                   2 + PageNumber + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber),\r
                   (EFI_PHYSICAL_ADDRESS*)&NewS3TableBase\r
                   );\r
-   \r
+\r
      if (EFI_ERROR(Status)) {\r
        ASSERT_EFI_ERROR (Status);\r
        return 0;\r
      }\r
-     \r
+\r
      CopyMem ((VOID*)(UINTN)NewS3TableBase, (VOID*)(UINTN)S3TableBase, TableLength);\r
      gBS->FreePages (S3TableBase, mS3BootScriptTablePtr->TableMemoryPageNumber);\r
-         \r
+\r
      mS3BootScriptTablePtr->TableBase = (UINT8*)(UINTN)NewS3TableBase;\r
-     mS3BootScriptTablePtr->TableMemoryPageNumber =  (UINT16) (2 + PageNumber + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber)); \r
+     mS3BootScriptTablePtr->TableMemoryPageNumber =  (UINT16) (2 + PageNumber + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));\r
    }\r
    //\r
-   // calculate the the start address for the new entry. \r
+   // calculate the the start address for the new entry.\r
    //\r
    NewEntryPtr = mS3BootScriptTablePtr->TableBase + TableLength;\r
-   \r
+\r
    //\r
    // update the table lenghth\r
    //\r
    mS3BootScriptTablePtr->TableLength =  TableLength + EntryLength;\r
-   \r
+\r
    //\r
    // In the boot time, we will not append the termination entry to the boot script\r
-   // table until the callers think there is no boot time data that should be added and \r
-   // it is caller's responsibility to explicit call the CloseTable. \r
+   // table until the callers think there is no boot time data that should be added and\r
+   // it is caller's responsibility to explicit call the CloseTable.\r
    //\r
    //\r
-  \r
-   return NewEntryPtr;    \r
+\r
+   return NewEntryPtr;\r
 }\r
 /**\r
   To get the start address from which a new runtime(after SmmReadyToLock) s3 boot script entry will write into.\r
   In this case, it should be ensured that there is enough buffer to hold the entry.\r
-  \r
+\r
   @param EntryLength      the new entry length.\r
-  \r
+\r
   @retval the address from which the a new s3 runtime(after SmmReadyToLock) script entry will write into\r
  **/\r
 UINT8*\r
@@ -747,20 +740,20 @@ S3BootScriptGetRuntimeEntryAddAddress (
   )\r
 {\r
    UINT8     *NewEntryPtr;\r
-   \r
-   NewEntryPtr = NULL;   \r
+\r
+   NewEntryPtr = NULL;\r
    //\r
-   // Check if the memory range reserved for S3 Boot Script table is large enough to hold the node. \r
+   // Check if the memory range reserved for S3 Boot Script table is large enough to hold the node.\r
    //\r
-   if ((UINTN) (mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= (UINTN) EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) {\r
-     NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength;   \r
+   if ((mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) {\r
+     NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength;\r
      mS3BootScriptTablePtr->TableLength = mS3BootScriptTablePtr->TableLength + EntryLength;\r
      //\r
      // Append a terminate node on every insert\r
      //\r
      S3BootScriptInternalCloseTable ();\r
    }\r
-   return (UINT8*)NewEntryPtr;    \r
+   return (UINT8*)NewEntryPtr;\r
 }\r
 \r
 /**\r
@@ -805,12 +798,12 @@ RestoreBootTimeDataFromLockBox (
 \r
 /**\r
   To get the start address from which a new s3 boot script entry will write into.\r
-  \r
+\r
   @param EntryLength      the new entry length.\r
-  \r
-  @retval the address from which the a new s3 boot script entry will write into \r
- **/ \r
-UINT8* \r
+\r
+  @retval the address from which the a new s3 boot script entry will write into\r
+ **/\r
+UINT8*\r
 S3BootScriptGetEntryAddAddress (\r
   UINT8  EntryLength\r
   )\r
@@ -842,10 +835,10 @@ S3BootScriptGetEntryAddAddress (
     NewEntryPtr  = S3BootScriptGetRuntimeEntryAddAddress (EntryLength);\r
   } else {\r
     NewEntryPtr  = S3BootScriptGetBootTimeEntryAddAddress (EntryLength);\r
-  }  \r
+  }\r
   return NewEntryPtr;\r
-  \r
-}  \r
+\r
+}\r
 \r
 /**\r
   Sync BootScript LockBox data.\r
@@ -899,28 +892,28 @@ SyncBootScript (
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
-/** \r
-  This is an function to close the S3 boot script table. The function could only be called in \r
-  BOOT time phase. To comply with the Framework spec definition on \r
+/**\r
+  This is an function to close the S3 boot script table. The function could only be called in\r
+  BOOT time phase. To comply with the Framework spec definition on\r
   EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable(), this function will fulfill following things:\r
   1. Closes the specified boot script table\r
-  2. It allocates a new memory pool to duplicate all the boot scripts in the specified table. \r
-     Once this function is called, the table maintained by the library will be destroyed \r
+  2. It allocates a new memory pool to duplicate all the boot scripts in the specified table.\r
+     Once this function is called, the table maintained by the library will be destroyed\r
      after it is copied into the allocated pool.\r
-  3. Any attempts to add a script record after calling this function will cause a new table \r
+  3. Any attempts to add a script record after calling this function will cause a new table\r
      to be created by the library.\r
-  4. The base address of the allocated pool will be returned in Address. Note that after \r
+  4. The base address of the allocated pool will be returned in Address. Note that after\r
      using the boot script table, the CALLER is responsible for freeing the pool that is allocated\r
-     by this function. \r
+     by this function.\r
 \r
-  In Spec PI1.1, this EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable() is retired. To provides this API for now is \r
+  In Spec PI1.1, this EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable() is retired. To provides this API for now is\r
   for Framework Spec compatibility.\r
-  \r
-  If anyone does call CloseTable() on a real platform, then the caller is responsible for figuring out \r
-  how to get the script to run at S3 resume because the boot script maintained by the lib will be \r
+\r
+  If anyone does call CloseTable() on a real platform, then the caller is responsible for figuring out\r
+  how to get the script to run at S3 resume because the boot script maintained by the lib will be\r
   destroyed.\r
\r
-  @return the base address of the new copy of the boot script table.   \r
+\r
+  @return the base address of the new copy of the boot script table.\r
   @note this function could only called in boot time phase\r
 \r
 **/\r
@@ -935,10 +928,10 @@ S3BootScriptCloseTable (
   UINT8                          *Buffer;\r
   EFI_STATUS                      Status;\r
   EFI_BOOT_SCRIPT_TABLE_HEADER      *ScriptTableInfo;\r
-  \r
-  S3TableBase =    mS3BootScriptTablePtr->TableBase;    \r
+\r
+  S3TableBase =    mS3BootScriptTablePtr->TableBase;\r
   if (S3TableBase == 0) {\r
-    return 0; \r
+    return 0;\r
   }\r
   //\r
   // Append the termination record the S3 boot script table\r
@@ -946,7 +939,7 @@ S3BootScriptCloseTable (
   S3BootScriptInternalCloseTable();\r
   TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE);\r
   //\r
-  // Allocate the buffer and copy the boot script to the buffer. \r
+  // Allocate the buffer and copy the boot script to the buffer.\r
   //\r
   Status = gBS->AllocatePool (\r
                   EfiBootServicesData,\r
@@ -954,12 +947,12 @@ S3BootScriptCloseTable (
                   (VOID **) &Buffer\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-        return 0; \r
+        return 0;\r
   }\r
   CopyMem (Buffer, S3TableBase, TableLength);\r
-  \r
+\r
   //\r
-  // Destroy the table maintained by the library so that the next write operation \r
+  // Destroy the table maintained by the library so that the next write operation\r
   // will write the record to the first entry of the table.\r
   //\r
   // Fill the table header.\r
@@ -967,12 +960,12 @@ S3BootScriptCloseTable (
   ScriptTableInfo->OpCode      = S3_BOOT_SCRIPT_LIB_TABLE_OPCODE;\r
   ScriptTableInfo->Length      = (UINT8) sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);\r
   ScriptTableInfo->TableLength = 0;   // will be calculate at close the table\r
-  \r
+\r
   mS3BootScriptTablePtr->TableLength = sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);\r
   return Buffer;\r
 }\r
 /**\r
-  Save I/O write to boot script \r
+  Save I/O write to boot script\r
 \r
   @param Width   The width of the I/O operations.Enumerated in S3_BOOT_SCRIPT_LIB_WIDTH.\r
   @param Address The base address of the I/O operations.\r
@@ -999,7 +992,7 @@ S3BootScriptSaveIoWrite (
 \r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_WRITE) + (WidthInByte * Count));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
@@ -1047,7 +1040,7 @@ S3BootScriptSaveIoReadWrite (
 \r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + (WidthInByte * 2));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
@@ -1059,7 +1052,7 @@ S3BootScriptSaveIoReadWrite (
   ScriptIoReadWrite.Length  = Length;\r
   ScriptIoReadWrite.Width   = Width;\r
   ScriptIoReadWrite.Address = Address;\r
-  \r
+\r
   CopyMem ((VOID*)Script, (VOID*)&ScriptIoReadWrite, sizeof(EFI_BOOT_SCRIPT_IO_READ_WRITE));\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE)), Data, WidthInByte);\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + WidthInByte), DataMask, WidthInByte);\r
@@ -1092,14 +1085,14 @@ S3BootScriptSaveMemWrite (
   UINT8                *Script;\r
   UINT8                 WidthInByte;\r
   EFI_BOOT_SCRIPT_MEM_WRITE  ScriptMemWrite;\r
-  \r
+\r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_WRITE) + (WidthInByte * Count));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  }  \r
+  }\r
   //\r
   // Build script data\r
   //\r
@@ -1108,10 +1101,10 @@ S3BootScriptSaveMemWrite (
   ScriptMemWrite.Width    = Width;\r
   ScriptMemWrite.Address  = Address;\r
   ScriptMemWrite.Count    = (UINT32) Count;\r
-  \r
+\r
   CopyMem ((VOID*)Script, (VOID*)&ScriptMemWrite, sizeof(EFI_BOOT_SCRIPT_MEM_WRITE));\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_WRITE)), Buffer, WidthInByte * Count);\r
-  \r
+\r
   SyncBootScript (Script);\r
 \r
   return RETURN_SUCCESS;\r
@@ -1140,22 +1133,22 @@ S3BootScriptSaveMemReadWrite (
   UINT8                *Script;\r
   UINT8                 WidthInByte;\r
   EFI_BOOT_SCRIPT_MEM_READ_WRITE  ScriptMemReadWrite;\r
\r
+\r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + (WidthInByte * 2));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  } \r
+  }\r
   //\r
   // Build script data\r
-  //    \r
+  //\r
   ScriptMemReadWrite.OpCode   = EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE;\r
   ScriptMemReadWrite.Length   = Length;\r
   ScriptMemReadWrite.Width    = Width;\r
   ScriptMemReadWrite.Address  = Address;\r
-  \r
+\r
   CopyMem ((VOID*)Script, (VOID*)&ScriptMemReadWrite , sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE));\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE)), Data, WidthInByte);\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + WidthInByte), DataMask, WidthInByte);\r
@@ -1199,11 +1192,11 @@ S3BootScriptSavePciCfgWrite (
 \r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE) + (WidthInByte * Count));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  } \r
+  }\r
   //\r
   // Build script data\r
   //\r
@@ -1212,10 +1205,10 @@ S3BootScriptSavePciCfgWrite (
   ScriptPciWrite.Width    = Width;\r
   ScriptPciWrite.Address  = Address;\r
   ScriptPciWrite.Count    = (UINT32) Count;\r
-  \r
+\r
   CopyMem ((VOID*)Script, (VOID*)&ScriptPciWrite,  sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE)), Buffer, WidthInByte * Count);\r
-  \r
+\r
   SyncBootScript (Script);\r
 \r
   return RETURN_SUCCESS;\r
@@ -1255,19 +1248,19 @@ S3BootScriptSavePciCfgReadWrite (
 \r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE) + (WidthInByte * 2));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  }  \r
+  }\r
   //\r
   // Build script data\r
-  // \r
+  //\r
   ScriptPciReadWrite.OpCode   = EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE;\r
   ScriptPciReadWrite.Length   = Length;\r
   ScriptPciReadWrite.Width    = Width;\r
   ScriptPciReadWrite.Address  = Address;\r
-  \r
+\r
   CopyMem ((VOID*)Script, (VOID*)&ScriptPciReadWrite, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE)), Data, WidthInByte);\r
   CopyMem (\r
@@ -1291,7 +1284,7 @@ S3BootScriptSavePciCfgReadWrite (
 \r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
-  @note  A known Limitations in the implementation which is non-zero Segment and 64bits operations are not supported.\r
+  @note  A known Limitations in the implementation which is 64bits operations are not supported.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -1309,8 +1302,7 @@ S3BootScriptSavePciCfg2Write (
   UINT8                 WidthInByte;\r
   EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE  ScriptPciWrite2;\r
 \r
-  if (Segment != 0 ||\r
-      Width == S3BootScriptWidthUint64 ||\r
+  if (Width == S3BootScriptWidthUint64 ||\r
       Width == S3BootScriptWidthFifoUint64 ||\r
       Width == S3BootScriptWidthFillUint64) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1318,11 +1310,11 @@ S3BootScriptSavePciCfg2Write (
 \r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE) + (WidthInByte * Count));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  }  \r
+  }\r
   //\r
   // Build script data\r
   //\r
@@ -1332,7 +1324,7 @@ S3BootScriptSavePciCfg2Write (
   ScriptPciWrite2.Address  = Address;\r
   ScriptPciWrite2.Segment  = Segment;\r
   ScriptPciWrite2.Count    = (UINT32)Count;\r
-  \r
+\r
   CopyMem ((VOID*)Script, (VOID*)&ScriptPciWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE)), Buffer, WidthInByte * Count);\r
 \r
@@ -1351,7 +1343,7 @@ S3BootScriptSavePciCfg2Write (
 \r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
-  @note  A known Limitations in the implementation which is non-zero Segment and 64bits operations are not supported.\r
+  @note  A known Limitations in the implementation which is 64bits operations are not supported.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -1369,20 +1361,19 @@ S3BootScriptSavePciCfg2ReadWrite (
   UINT8                 WidthInByte;\r
   EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE  ScriptPciReadWrite2;\r
 \r
-  if (Segment != 0 ||\r
-      Width == S3BootScriptWidthUint64 ||\r
+  if (Width == S3BootScriptWidthUint64 ||\r
       Width == S3BootScriptWidthFifoUint64 ||\r
       Width == S3BootScriptWidthFillUint64) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE) + (WidthInByte * 2));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  }  \r
+  }\r
   //\r
   // Build script data\r
   //\r
@@ -1391,7 +1382,7 @@ S3BootScriptSavePciCfg2ReadWrite (
   ScriptPciReadWrite2.Width    = Width;\r
   ScriptPciReadWrite2.Segment  = Segment;\r
   ScriptPciReadWrite2.Address  = Address;\r
-  \r
+\r
   CopyMem ((VOID*)Script, (VOID*)&ScriptPciReadWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE)), Data, WidthInByte);\r
   CopyMem (\r
@@ -1399,7 +1390,7 @@ S3BootScriptSavePciCfg2ReadWrite (
     DataMask,\r
     WidthInByte\r
     );\r
-  \r
+\r
   SyncBootScript (Script);\r
 \r
   return RETURN_SUCCESS;\r
@@ -1412,7 +1403,7 @@ S3BootScriptSavePciCfg2ReadWrite (
   for certain SMBus bus protocol, it will return EFI_SUCCESS; otherwise, it will return certain\r
   error code based on the input SMBus bus protocol.\r
 \r
-  @param  SmBusAddress            Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, \r
+  @param  SmBusAddress            Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length,\r
                                   and PEC.\r
   @param  Operation               Signifies which particular SMBus hardware protocol instance that\r
                                   it will use to execute the SMBus transactions. This SMBus\r
@@ -1428,7 +1419,7 @@ S3BootScriptSavePciCfg2ReadWrite (
                                   buffer is identified by Length.\r
 \r
   @retval EFI_SUCCESS             All the parameters are valid for the corresponding SMBus bus\r
-                                  protocol. \r
+                                  protocol.\r
   @retval EFI_INVALID_PARAMETER   Operation is not defined in EFI_SMBUS_OPERATION.\r
   @retval EFI_INVALID_PARAMETER   Length/Buffer is NULL for operations except for EfiSmbusQuickRead\r
                                   and EfiSmbusQuickWrite. Length is outside the range of valid\r
@@ -1449,12 +1440,12 @@ CheckParameters (
   UINTN       RequiredLen;\r
   EFI_SMBUS_DEVICE_COMMAND Command;\r
   BOOLEAN                  PecCheck;\r
\r
+\r
   Command      = SMBUS_LIB_COMMAND (SmBusAddress);\r
   PecCheck     = SMBUS_LIB_PEC (SmBusAddress);\r
   //\r
   // Set default value to be 2:\r
-  // for SmbusReadWord, SmbusWriteWord and SmbusProcessCall. \r
+  // for SmbusReadWord, SmbusWriteWord and SmbusProcessCall.\r
   //\r
   RequiredLen = 2;\r
   Status      = EFI_SUCCESS;\r
@@ -1492,8 +1483,8 @@ CheckParameters (
     case EfiSmbusReadBlock:\r
     case EfiSmbusWriteBlock:\r
     case EfiSmbusBWBRProcessCall:\r
-      if ((Buffer == NULL) || \r
-          (Length == NULL) || \r
+      if ((Buffer == NULL) ||\r
+          (Length == NULL) ||\r
           (*Length < MIN_SMBUS_BLOCK_LEN) ||\r
           (*Length > MAX_SMBUS_BLOCK_LEN)) {\r
         return EFI_INVALID_PARAMETER;\r
@@ -1513,14 +1504,14 @@ CheckParameters (
                         transactions.\r
   @param Length         A pointer to signify the number of bytes that this operation will do.\r
   @param Buffer         Contains the value of data to execute to the SMBUS slave device.\r
-  \r
+\r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
 S3BootScriptSaveSmbusExecute (\r
-  IN  UINTN                             SmBusAddress, \r
+  IN  UINTN                             SmBusAddress,\r
   IN  EFI_SMBUS_OPERATION               Operation,\r
   IN  UINTN                             *Length,\r
   IN  VOID                              *Buffer\r
@@ -1544,7 +1535,7 @@ S3BootScriptSaveSmbusExecute (
   }\r
 \r
   DataSize = (UINT8)(sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE) + BufferLength);\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (DataSize);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
@@ -1573,7 +1564,7 @@ S3BootScriptSaveSmbusExecute (
   Adds a record for an execution stall on the processor into a specified boot script table.\r
 \r
   @param Duration   Duration in microseconds of the stall\r
-  \r
+\r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
 **/\r
@@ -1588,20 +1579,20 @@ S3BootScriptSaveStall (
   EFI_BOOT_SCRIPT_STALL  ScriptStall;\r
 \r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_STALL));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  }  \r
+  }\r
   //\r
   // Build script data\r
   //\r
   ScriptStall.OpCode    = EFI_BOOT_SCRIPT_STALL_OPCODE;\r
   ScriptStall.Length    = Length;\r
   ScriptStall.Duration  = Duration;\r
-  \r
+\r
   CopyMem ((VOID*)Script, (VOID*)&ScriptStall, sizeof (EFI_BOOT_SCRIPT_STALL));\r
-  \r
+\r
   SyncBootScript (Script);\r
 \r
   return RETURN_SUCCESS;\r
@@ -1611,7 +1602,7 @@ S3BootScriptSaveStall (
 \r
   @param EntryPoint   Entry point of the code to be dispatched.\r
   @param Context      Argument to be passed into the EntryPoint of the code to be dispatched.\r
-  \r
+\r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
 **/\r
@@ -1626,11 +1617,11 @@ S3BootScriptSaveDispatch2 (
   UINT8                 *Script;\r
   EFI_BOOT_SCRIPT_DISPATCH_2  ScriptDispatch2;\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  }  \r
+  }\r
   //\r
   // Build script data\r
   //\r
@@ -1638,9 +1629,9 @@ S3BootScriptSaveDispatch2 (
   ScriptDispatch2.Length     = Length;\r
   ScriptDispatch2.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;\r
   ScriptDispatch2.Context =   (EFI_PHYSICAL_ADDRESS)(UINTN)Context;\r
-  \r
+\r
   CopyMem ((VOID*)Script, (VOID*)&ScriptDispatch2, sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));\r
-  \r
+\r
   SyncBootScript (Script);\r
 \r
   return RETURN_SUCCESS;\r
@@ -1674,18 +1665,18 @@ S3BootScriptSaveMemPoll (
   IN  VOID                              *BitMask,\r
   IN  VOID                              *BitValue,\r
   IN  UINTN                             Duration,\r
-  IN  UINT                            LoopTimes\r
+  IN  UINT64                            LoopTimes\r
   )\r
 {\r
   UINT8                 Length;\r
   UINT8                *Script;\r
-  UINT8                 WidthInByte; \r
-  EFI_BOOT_SCRIPT_MEM_POLL      ScriptMemPoll; \r
+  UINT8                 WidthInByte;\r
+  EFI_BOOT_SCRIPT_MEM_POLL      ScriptMemPoll;\r
 \r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
-  \r
+\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_POLL) + (WidthInByte * 2));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
@@ -1695,14 +1686,14 @@ S3BootScriptSaveMemPoll (
   //\r
   ScriptMemPoll.OpCode   = EFI_BOOT_SCRIPT_MEM_POLL_OPCODE;\r
   ScriptMemPoll.Length   = Length;\r
-  ScriptMemPoll.Width    = Width;  \r
+  ScriptMemPoll.Width    = Width;\r
   ScriptMemPoll.Address  = Address;\r
   ScriptMemPoll.Duration = Duration;\r
   ScriptMemPoll.LoopTimes = LoopTimes;\r
 \r
   CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL)), BitValue, WidthInByte);\r
   CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL) + WidthInByte), BitMask, WidthInByte);\r
-  CopyMem ((VOID*)Script, (VOID*)&ScriptMemPoll, sizeof (EFI_BOOT_SCRIPT_MEM_POLL)); \r
+  CopyMem ((VOID*)Script, (VOID*)&ScriptMemPoll, sizeof (EFI_BOOT_SCRIPT_MEM_POLL));\r
 \r
   SyncBootScript (Script);\r
 \r
@@ -1711,10 +1702,10 @@ S3BootScriptSaveMemPoll (
 /**\r
   Store arbitrary information in the boot script table. This opcode is a no-op on dispatch and is only\r
   used for debugging script issues.\r
-  \r
+\r
   @param InformationLength   Length of the data in bytes\r
   @param Information       Information to be logged in the boot scrpit\r
\r
+\r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
 \r
@@ -1722,7 +1713,7 @@ S3BootScriptSaveMemPoll (
 RETURN_STATUS\r
 EFIAPI\r
 S3BootScriptSaveInformation (\r
-  IN  UINT32                                InformationLength, \r
+  IN  UINT32                                InformationLength,\r
   IN  VOID                                 *Information\r
   )\r
 {\r
@@ -1743,7 +1734,7 @@ S3BootScriptSaveInformation (
   ScriptInformation.Length     = Length;\r
 \r
 \r
-  ScriptInformation.InformationLength = InformationLength;  \r
+  ScriptInformation.InformationLength = InformationLength;\r
 \r
   CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) Information, (UINTN) InformationLength);\r
@@ -1756,9 +1747,9 @@ S3BootScriptSaveInformation (
 /**\r
   Store a string in the boot script table. This opcode is a no-op on dispatch and is only\r
   used for debugging script issues.\r
-  \r
+\r
   @param String            The string to save to boot script table\r
-  \r
+\r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
 \r
@@ -1769,8 +1760,8 @@ S3BootScriptSaveInformationAsciiString (
   IN  CONST CHAR8               *String\r
   )\r
 {\r
-  return S3BootScriptSaveInformation (      \r
-           (UINT32) AsciiStrLen (String) + 1, \r
+  return S3BootScriptSaveInformation (\r
+           (UINT32) AsciiStrLen (String) + 1,\r
            (VOID*) String\r
            );\r
 }\r
@@ -1778,7 +1769,7 @@ S3BootScriptSaveInformationAsciiString (
   Adds a record for dispatching specified arbitrary code into a specified boot script table.\r
 \r
   @param EntryPoint   Entry point of the code to be dispatched.\r
-  \r
+\r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
 **/\r
@@ -1791,22 +1782,22 @@ S3BootScriptSaveDispatch (
   UINT8                 Length;\r
   UINT8                *Script;\r
   EFI_BOOT_SCRIPT_DISPATCH  ScriptDispatch;\r
-  \r
+\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_DISPATCH));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  }  \r
+  }\r
   //\r
   // Build script data\r
   //\r
   ScriptDispatch.OpCode     = EFI_BOOT_SCRIPT_DISPATCH_OPCODE;\r
   ScriptDispatch.Length     = Length;\r
   ScriptDispatch.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;\r
-  \r
-  CopyMem ((VOID*)Script, (VOID*)&ScriptDispatch, sizeof (EFI_BOOT_SCRIPT_DISPATCH)); \r
-  \r
+\r
+  CopyMem ((VOID*)Script, (VOID*)&ScriptDispatch, sizeof (EFI_BOOT_SCRIPT_DISPATCH));\r
+\r
   SyncBootScript (Script);\r
 \r
   return RETURN_SUCCESS;\r
@@ -1815,8 +1806,8 @@ S3BootScriptSaveDispatch (
 /**\r
   Adds a record for I/O reads the I/O location and continues when the exit criteria is satisfied or after a\r
   defined duration.\r
-  \r
-  @param  Width                 The width of the I/O operations. \r
+\r
+  @param  Width                 The width of the I/O operations.\r
   @param  Address               The base address of the I/O operations.\r
   @param  Data                  The comparison value used for the polling exit criteria.\r
   @param  DataMask              Mask used for the polling criteria. The bits in the bytes below Width which are zero\r
@@ -1834,36 +1825,36 @@ S3BootScriptSaveIoPoll (
   IN S3_BOOT_SCRIPT_LIB_WIDTH       Width,\r
   IN UINT64                     Address,\r
   IN VOID                      *Data,\r
-  IN VOID                      *DataMask, \r
-  IN UINT64                     Delay   \r
+  IN VOID                      *DataMask,\r
+  IN UINT64                     Delay\r
   )\r
 {\r
-  UINT8                 WidthInByte;  \r
+  UINT8                 WidthInByte;\r
   UINT8                *Script;\r
   UINT8                 Length;\r
   EFI_BOOT_SCRIPT_IO_POLL  ScriptIoPoll;\r
-  \r
 \r
-  WidthInByte = (UINT8) (0x01 << (Width & 0x03));  \r
+\r
+  WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));\r
\r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  } \r
+  }\r
   //\r
   // Build script data\r
   //\r
   ScriptIoPoll.OpCode   = EFI_BOOT_SCRIPT_IO_POLL_OPCODE;\r
   ScriptIoPoll.Length   = (UINT8) (sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));\r
-  ScriptIoPoll.Width    = Width;  \r
+  ScriptIoPoll.Width    = Width;\r
   ScriptIoPoll.Address  = Address;\r
   ScriptIoPoll.Delay    = Delay;\r
 \r
-  CopyMem ((VOID*)Script, (VOID*)&ScriptIoPoll, sizeof (EFI_BOOT_SCRIPT_IO_POLL));  \r
+  CopyMem ((VOID*)Script, (VOID*)&ScriptIoPoll, sizeof (EFI_BOOT_SCRIPT_IO_POLL));\r
   CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL)), Data, WidthInByte);\r
   CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL) + WidthInByte), DataMask, WidthInByte);\r
-  \r
+\r
   SyncBootScript (Script);\r
 \r
   return RETURN_SUCCESS;\r
@@ -1873,7 +1864,7 @@ S3BootScriptSaveIoPoll (
   Adds a record for PCI configuration space reads and continues when the exit criteria is satisfied or\r
   after a defined duration.\r
 \r
-  @param  Width                 The width of the I/O operations. \r
+  @param  Width                 The width of the I/O operations.\r
   @param  Address               The address within the PCI configuration space.\r
   @param  Data                  The comparison value used for the polling exit criteria.\r
   @param  DataMask              Mask used for the polling criteria. The bits in the bytes below Width which are zero\r
@@ -1897,7 +1888,7 @@ S3BootScriptSavePciPoll (
 )\r
 {\r
   UINT8                   *Script;\r
-  UINT8                    WidthInByte;  \r
+  UINT8                    WidthInByte;\r
   UINT8                    Length;\r
   EFI_BOOT_SCRIPT_PCI_CONFIG_POLL  ScriptPciPoll;\r
 \r
@@ -1909,7 +1900,7 @@ S3BootScriptSavePciPoll (
 \r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
@@ -1919,14 +1910,14 @@ S3BootScriptSavePciPoll (
   //\r
   ScriptPciPoll.OpCode   = EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE;\r
   ScriptPciPoll.Length   = (UINT8) (sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));\r
-  ScriptPciPoll.Width    = Width;  \r
+  ScriptPciPoll.Width    = Width;\r
   ScriptPciPoll.Address  = Address;\r
   ScriptPciPoll.Delay    = Delay;\r
 \r
   CopyMem ((VOID*)Script, (VOID*)&ScriptPciPoll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));\r
   CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL)), Data, WidthInByte);\r
   CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + WidthInByte), DataMask, WidthInByte);\r
-  \r
+\r
   SyncBootScript (Script);\r
 \r
   return RETURN_SUCCESS;\r
@@ -1935,7 +1926,7 @@ S3BootScriptSavePciPoll (
   Adds a record for PCI configuration space reads and continues when the exit criteria is satisfied or\r
   after a defined duration.\r
 \r
-  @param  Width                 The width of the I/O operations. \r
+  @param  Width                 The width of the I/O operations.\r
   @param  Segment               The PCI segment number for Address.\r
   @param  Address               The address within the PCI configuration space.\r
   @param  Data                  The comparison value used for the polling exit criteria.\r
@@ -1946,7 +1937,7 @@ S3BootScriptSavePciPoll (
 \r
  @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
  @retval RETURN_SUCCESS           Opcode is added.\r
-  @note  A known Limitations in the implementation which is non-zero Segment and 64bits operations are not supported.\r
+  @note  A known Limitations in the implementation which is 64bits operations are not supported.\r
 \r
 **/\r
 RETURN_STATUS\r
@@ -1960,13 +1951,12 @@ S3BootScriptSavePci2Poll (
   IN UINT64                         Delay\r
 )\r
 {\r
-  UINT8                    WidthInByte;  \r
+  UINT8                    WidthInByte;\r
   UINT8                   *Script;\r
   UINT8                    Length;\r
   EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL  ScriptPci2Poll;\r
 \r
-  if (Segment != 0 ||\r
-      Width == S3BootScriptWidthUint64 ||\r
+  if (Width == S3BootScriptWidthUint64 ||\r
       Width == S3BootScriptWidthFifoUint64 ||\r
       Width == S3BootScriptWidthFillUint64) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1974,17 +1964,17 @@ S3BootScriptSavePci2Poll (
 \r
   WidthInByte = (UINT8) (0x01 << (Width & 0x03));\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
-  } \r
+  }\r
   //\r
   // Build script data\r
   //\r
   ScriptPci2Poll.OpCode   = EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE;\r
   ScriptPci2Poll.Length   = (UINT8) (sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));\r
-  ScriptPci2Poll.Width    = Width; \r
+  ScriptPci2Poll.Width    = Width;\r
   ScriptPci2Poll.Segment  = Segment;\r
   ScriptPci2Poll.Address  = Address;\r
   ScriptPci2Poll.Delay    = Delay;\r
@@ -1992,17 +1982,17 @@ S3BootScriptSavePci2Poll (
   CopyMem ((VOID*)Script, (VOID*)&ScriptPci2Poll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));\r
   CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL)), Data, WidthInByte);\r
   CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + WidthInByte), DataMask, WidthInByte);\r
-  \r
+\r
   SyncBootScript (Script);\r
 \r
   return RETURN_SUCCESS;\r
 }\r
 /**\r
   Do the calculation of start address from which a new s3 boot script entry will write into.\r
-  \r
+\r
   @param EntryLength      The new entry length.\r
   @param Position         specifies the position in the boot script table where the opcode will be\r
-                          inserted, either before or after, depending on BeforeOrAfter. \r
+                          inserted, either before or after, depending on BeforeOrAfter.\r
   @param BeforeOrAfter    The flag to indicate to insert the nod before or after the position.\r
                           This parameter is effective when InsertFlag is TRUE\r
   @param Script           return out the position from which the a new s3 boot script entry will write into\r
@@ -2012,58 +2002,58 @@ S3BootScriptCalculateInsertAddress (
   IN  UINT8     EntryLength,\r
   IN  VOID     *Position OPTIONAL,\r
   IN  BOOLEAN   BeforeOrAfter OPTIONAL,\r
-  OUT UINT8   **Script   \r
+  OUT UINT8   **Script\r
   )\r
 {\r
    UINTN                            TableLength;\r
    UINT8                            *S3TableBase;\r
-   UINTN                            PositionOffset; \r
+   UINTN                            PositionOffset;\r
    EFI_BOOT_SCRIPT_COMMON_HEADER     ScriptHeader;\r
    //\r
    // The entry inserting to table is already added to the end of the table\r
    //\r
    TableLength =  mS3BootScriptTablePtr->TableLength - EntryLength;\r
    S3TableBase = mS3BootScriptTablePtr->TableBase ;\r
-   // \r
+   //\r
    // calculate the Position offset\r
    //\r
    if (Position != NULL) {\r
-     PositionOffset = (UINTN) ((UINT8 *)Position - S3TableBase);\r
-   \r
+     PositionOffset = (UINTN)Position - (UINTN)S3TableBase;\r
+\r
      //\r
      // If the BeforeOrAfter is FALSE, that means to insert the node right after the node.\r
      //\r
      if (!BeforeOrAfter) {\r
-        CopyMem ((VOID*)&ScriptHeader, Position, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));  \r
+        CopyMem ((VOID*)&ScriptHeader, Position, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));\r
         PositionOffset += (ScriptHeader.Length);\r
      }\r
-     //     \r
+     //\r
      // Insert the node before the adjusted Position\r
      //\r
-     CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);  \r
+     CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);\r
      //\r
-     // calculate the the start address for the new entry. \r
+     // calculate the the start address for the new entry.\r
      //\r
      *Script = S3TableBase + PositionOffset;\r
-       \r
+\r
    } else {\r
      if (!BeforeOrAfter) {\r
        //\r
        //  Insert the node to the end of the table\r
        //\r
-       *Script = S3TableBase + TableLength; \r
+       *Script = S3TableBase + TableLength;\r
      } else {\r
-       // \r
+       //\r
        // Insert the node to the beginning of the table\r
        //\r
        PositionOffset = (UINTN) sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER);\r
-       CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset); \r
-       *Script = S3TableBase + PositionOffset; \r
+       CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);\r
+       *Script = S3TableBase + PositionOffset;\r
      }\r
-   }       \r
+   }\r
 }\r
 /**\r
-  Move the last boot script entry to the position \r
+  Move the last boot script entry to the position\r
 \r
   @param  BeforeOrAfter         Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position\r
                                 in the boot script table specified by Position. If Position is NULL or points to\r
@@ -2085,14 +2075,14 @@ S3BootScriptMoveLastOpcode (
 )\r
 {\r
   UINT8*                Script;\r
-  VOID                  *TempPosition;  \r
+  VOID                  *TempPosition;\r
   UINTN                 StartAddress;\r
   UINT32                TableLength;\r
   EFI_BOOT_SCRIPT_COMMON_HEADER  ScriptHeader;\r
   BOOLEAN               ValidatePosition;\r
   UINT8*                LastOpcode;\r
   UINT8                 TempBootScriptEntry[BOOT_SCRIPT_NODE_MAX_LENGTH];\r
-  \r
+\r
   ValidatePosition = FALSE;\r
   TempPosition = (Position == NULL) ? NULL:(*Position);\r
 \r
@@ -2112,17 +2102,17 @@ S3BootScriptMoveLastOpcode (
   //\r
   // Find the last boot Script Entry which is not the terminate node\r
   //\r
-  while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {    \r
-    CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));   \r
+  while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {\r
+    CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));\r
     if (TempPosition != NULL && TempPosition == Script) {\r
       //\r
-      // If the position is specified, the position must be pointed to a boot script entry start address. \r
+      // If the position is specified, the position must be pointed to a boot script entry start address.\r
       //\r
       ValidatePosition = TRUE;\r
     }\r
     if (ScriptHeader.OpCode != S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE) {\r
       LastOpcode = Script;\r
-    } \r
+    }\r
     Script  = Script + ScriptHeader.Length;\r
   }\r
   //\r
@@ -2131,10 +2121,10 @@ S3BootScriptMoveLastOpcode (
   if (TempPosition != NULL && !ValidatePosition) {\r
     return RETURN_INVALID_PARAMETER;\r
   }\r
-  \r
-  CopyMem ((VOID*)&ScriptHeader, LastOpcode, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER)); \r
-  \r
-  CopyMem((VOID*)TempBootScriptEntry, LastOpcode, ScriptHeader.Length); \r
+\r
+  CopyMem ((VOID*)&ScriptHeader, LastOpcode, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));\r
+\r
+  CopyMem((VOID*)TempBootScriptEntry, LastOpcode, ScriptHeader.Length);\r
   //\r
   // Find the right position to write the node in\r
   //\r
@@ -2142,7 +2132,7 @@ S3BootScriptMoveLastOpcode (
     ScriptHeader.Length,\r
     TempPosition,\r
     BeforeOrAfter,\r
-    &Script   \r
+    &Script\r
   );\r
   //\r
   // Copy the node to Boot script table\r
@@ -2160,18 +2150,18 @@ S3BootScriptMoveLastOpcode (
   return RETURN_SUCCESS;\r
 }\r
 /**\r
-  Create a Label node in the boot script table. \r
-  \r
+  Create a Label node in the boot script table.\r
+\r
   @param  BeforeOrAfter         Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position\r
                                 in the boot script table specified by Position. If Position is NULL or points to\r
                                 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end\r
                                 of the table (if FALSE).\r
   @param  Position              On entry, specifies the position in the boot script table where the opcode will be\r
                                 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies\r
-                                the position of the inserted opcode in the boot script table.  \r
+                                the position of the inserted opcode in the boot script table.\r
   @param InformationLength      Length of the label in bytes\r
   @param Information            Label to be logged in the boot scrpit\r
\r
+\r
   @retval RETURN_INVALID_PARAMETER The Position is not a valid position in the boot script table.\r
   @retval RETURN_OUT_OF_RESOURCES  Not enough memory for the table do operation.\r
   @retval RETURN_SUCCESS           Opcode is added.\r
@@ -2181,17 +2171,17 @@ RETURN_STATUS
 EFIAPI\r
 S3BootScriptLabelInternal (\r
   IN        BOOLEAN                        BeforeOrAfter,\r
-  IN OUT    VOID                         **Position OPTIONAL, \r
-  IN        UINT32                         InformationLength, \r
+  IN OUT    VOID                         **Position OPTIONAL,\r
+  IN        UINT32                         InformationLength,\r
   IN CONST  CHAR8                          *Information\r
   )\r
 {\r
   UINT8                 Length;\r
   UINT8                 *Script;\r
   EFI_BOOT_SCRIPT_INFORMATION  ScriptInformation;\r
\r
+\r
   Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength);\r
-  \r
+\r
   Script = S3BootScriptGetEntryAddAddress (Length);\r
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
@@ -2203,7 +2193,7 @@ S3BootScriptLabelInternal (
   ScriptInformation.Length     = Length;\r
 \r
 \r
-  ScriptInformation.InformationLength = InformationLength;  \r
+  ScriptInformation.InformationLength = InformationLength;\r
 \r
   CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));\r
   CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) Information, (UINTN) InformationLength);\r
@@ -2217,9 +2207,9 @@ S3BootScriptLabelInternal (
   Find a label within the boot script table and, if not present, optionally create it.\r
 \r
   @param  BeforeOrAfter         Specifies whether the opcode is stored before (TRUE)\r
-                                or after (FALSE) the position in the boot script table \r
+                                or after (FALSE) the position in the boot script table\r
                                 specified by Position.\r
-  @param  CreateIfNotFound      Specifies whether the label will be created if the label \r
+  @param  CreateIfNotFound      Specifies whether the label will be created if the label\r
                                 does not exists (TRUE) or not (FALSE).\r
   @param  Position              On entry, specifies the position in the boot script table\r
                                 where the opcode will be inserted, either before or after,\r
@@ -2230,13 +2220,13 @@ S3BootScriptLabelInternal (
   @retval EFI_SUCCESS           The operation succeeded. A record was added into the\r
                                 specified script table.\r
   @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.\r
-                                If the opcode is unknow or not supported because of the PCD \r
+                                If the opcode is unknow or not supported because of the PCD\r
                                 Feature Flags.\r
   @retval EFI_OUT_OF_RESOURCES  There is insufficient memory to store the boot script.\r
 \r
 **/\r
 RETURN_STATUS\r
-EFIAPI \r
+EFIAPI\r
 S3BootScriptLabel (\r
   IN       BOOLEAN                      BeforeOrAfter,\r
   IN       BOOLEAN                      CreateIfNotFound,\r
@@ -2262,7 +2252,7 @@ S3BootScriptLabel (
   if (Label[0] == '\0') {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   //\r
   // Check that the script is initialized and synced without adding an entry to the script.\r
   // The code must search for the label first before it knows if a new entry needs\r
@@ -2272,10 +2262,10 @@ S3BootScriptLabel (
   if (Script == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
   }\r
-  \r
+\r
   //\r
   // Check the header and search for existing label.\r
-  // \r
+  //\r
   Script = mS3BootScriptTablePtr->TableBase;\r
   CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));\r
   if (TableHeader.OpCode != S3_BOOT_SCRIPT_LIB_TABLE_OPCODE) {\r
@@ -2285,22 +2275,22 @@ S3BootScriptLabel (
   TableLength   = mS3BootScriptTablePtr->TableLength;\r
   Script    =     Script + TableHeader.Length;\r
   while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {\r
-    \r
-    CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));   \r
+\r
+    CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));\r
     if (ScriptHeader.OpCode == S3_BOOT_SCRIPT_LIB_LABEL_OPCODE) {\r
       if (AsciiStrCmp ((CHAR8 *)(UINTN)(Script+sizeof(EFI_BOOT_SCRIPT_INFORMATION)), Label) == 0) {\r
-        (*Position) = Script; \r
+        (*Position) = Script;\r
         return EFI_SUCCESS;\r
       }\r
-    } \r
+    }\r
     Script  = Script + ScriptHeader.Length;\r
   }\r
   if (CreateIfNotFound) {\r
     LabelLength = (UINT32)AsciiStrSize(Label);\r
-    return S3BootScriptLabelInternal (BeforeOrAfter,Position, LabelLength, Label);     \r
+    return S3BootScriptLabelInternal (BeforeOrAfter,Position, LabelLength, Label);\r
   } else {\r
     return EFI_NOT_FOUND;\r
-  }   \r
+  }\r
 }\r
 \r
 /**\r
@@ -2312,13 +2302,13 @@ S3BootScriptLabel (
   @retval EFI_SUCCESS           The operation succeeded. A record was added into the\r
                                 specified script table.\r
   @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.\r
-                                If the opcode is unknow or not supported because of the PCD \r
+                                If the opcode is unknow or not supported because of the PCD\r
                                 Feature Flags.\r
   @retval EFI_OUT_OF_RESOURCES  There is insufficient memory to store the boot script.\r
 \r
 **/\r
 RETURN_STATUS\r
-EFIAPI \r
+EFIAPI\r
 S3BootScriptCompare (\r
   IN  UINT8                       *Position1,\r
   IN  UINT8                       *Position2,\r
@@ -2326,7 +2316,7 @@ S3BootScriptCompare (
   )\r
 {\r
   UINT8*                    Script;\r
-  UINT32                    TableLength; \r
+  UINT32                    TableLength;\r
 \r
   if (RelativePosition == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -2352,7 +2342,7 @@ S3BootScriptCompare (
     return EFI_INVALID_PARAMETER;\r
   }\r
   *RelativePosition = (Position1 < Position2)?-1:((Position1 == Position2)?0:1);\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r