]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
MdeModulePkg: Refine casting expression result to bigger size
[mirror_edk2.git] / MdeModulePkg / Library / PiDxeS3BootScriptLib / BootScriptExecute.c
index 914e7a518c28e811b97043789253b3ba8bed7dc9..b865d4452fc823ee681a02bfdb695ce6e7c366a2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
-  Interpret and execute the S3 data in S3 boot script. \r
+  Interpret and execute the S3 data in S3 boot script.\r
 \r
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2016, 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
 **/\r
 #include "InternalBootScriptLib.h"\r
 \r
-/**\r
-  Checks the parameter of SmbusExecute().\r
-\r
-  This function checks the input parameters of SmbusExecute().  If the input parameters are valid\r
-  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
-                                  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
-                                  hardware protocol is defined by the SMBus Specification and is\r
-                                  not related to EFI.\r
-  @param  Length                  Signifies the number of bytes that this operation will do. The\r
-                                  maximum number of bytes can be revision specific and operation\r
-                                  specific. This field will contain the actual number of bytes that\r
-                                  are executed for this operation. Not all operations require this\r
-                                  argument.\r
-  @param  Buffer                  Contains the value of data to execute to the SMBus slave device.\r
-                                  Not all operations require this argument. The length of this\r
-                                  buffer is identified by Length.\r
-\r
-  @retval EFI_SUCCESS             All the parameters are valid for the corresponding SMBus bus\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
-                                  values.\r
-  @retval EFI_UNSUPPORTED         The SMBus operation or PEC is not supported.\r
-  @retval EFI_BUFFER_TOO_SMALL    Buffer is not sufficient for this operation.\r
-\r
-**/\r
-EFI_STATUS\r
-CheckParameters (\r
-  IN     UINTN                    SmBusAddress,\r
-  IN     EFI_SMBUS_OPERATION      Operation,\r
-  IN OUT UINTN                    *Length,\r
-  IN OUT VOID                     *Buffer\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       RequiredLen;\r
-  EFI_SMBUS_DEVICE_COMMAND Command;\r
-  BOOLEAN                  PecCheck;\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
-  //\r
-  RequiredLen = 2;\r
-  Status      = EFI_SUCCESS;\r
-  switch (Operation) {\r
-    case EfiSmbusQuickRead:\r
-    case EfiSmbusQuickWrite:\r
-      if (PecCheck || Command != 0) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-      break;\r
-    case EfiSmbusReceiveByte:\r
-    case EfiSmbusSendByte:\r
-      if (Command != 0) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-      //\r
-      // Cascade to check length parameter.\r
-      //\r
-    case EfiSmbusReadByte:\r
-    case EfiSmbusWriteByte:\r
-      RequiredLen = 1;\r
-      //\r
-      // Cascade to check length parameter.\r
-      //\r
-    case EfiSmbusReadWord:\r
-    case EfiSmbusWriteWord:\r
-    case EfiSmbusProcessCall:\r
-      if (Buffer == NULL || Length == NULL) {\r
-        return EFI_INVALID_PARAMETER;\r
-      } else if (*Length < RequiredLen) {\r
-        Status = EFI_BUFFER_TOO_SMALL;\r
-      }\r
-      *Length = RequiredLen;\r
-      break;\r
-    case EfiSmbusReadBlock:\r
-    case EfiSmbusWriteBlock:\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
-      } \r
-      break;\r
-    case EfiSmbusBWBRProcessCall:\r
-      return EFI_UNSUPPORTED;\r
-    default:\r
-      return EFI_INVALID_PARAMETER;\r
-  }\r
-  return Status;\r
-}\r
-\r
 /**\r
   Executes an SMBus operation to an SMBus controller. Returns when either the command has been\r
   executed or an error is encountered in doing the operation.\r
@@ -124,7 +23,7 @@ CheckParameters (
   Management Bus (SMBus) Specification. The resulting transaction will be either that the SMBus\r
   slave devices accept this transaction or that this function returns with error.\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
@@ -166,14 +65,8 @@ SmbusExecute (
   )\r
 {\r
   EFI_STATUS                      Status;\r
-  UINTN                           WorkBufferLen;\r
   UINT8                           WorkBuffer[MAX_SMBUS_BLOCK_LEN];\r
 \r
-  Status = CheckParameters (SmbusAddress, Operation, Length, Buffer);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
   switch (Operation) {\r
     case EfiSmbusQuickRead:\r
       DEBUG ((EFI_D_INFO, "EfiSmbusQuickRead - 0x%08x\n", SmbusAddress));\r
@@ -185,15 +78,15 @@ SmbusExecute (
       break;\r
     case EfiSmbusReceiveByte:\r
       DEBUG ((EFI_D_INFO, "EfiSmbusReceiveByte - 0x%08x\n", SmbusAddress));\r
-      *(UINT8 *) Buffer = SmBusReceiveByte (SmbusAddress, &Status);\r
+      SmBusReceiveByte (SmbusAddress, &Status);\r
       break;\r
     case EfiSmbusSendByte:\r
-      DEBUG ((EFI_D_INFO, "EfiSmbusReceiveByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));\r
+      DEBUG ((EFI_D_INFO, "EfiSmbusSendByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));\r
       SmBusSendByte (SmbusAddress, *(UINT8 *) Buffer, &Status);\r
       break;\r
     case EfiSmbusReadByte:\r
       DEBUG ((EFI_D_INFO, "EfiSmbusReadByte - 0x%08x\n", SmbusAddress));\r
-      *(UINT8 *) Buffer = SmBusReadDataByte (SmbusAddress, &Status);\r
+      SmBusReadDataByte (SmbusAddress, &Status);\r
       break;\r
     case EfiSmbusWriteByte:\r
       DEBUG ((EFI_D_INFO, "EfiSmbusWriteByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));\r
@@ -201,44 +94,33 @@ SmbusExecute (
       break;\r
     case EfiSmbusReadWord:\r
       DEBUG ((EFI_D_INFO, "EfiSmbusReadWord - 0x%08x\n", SmbusAddress));\r
-      *(UINT16 *) Buffer = SmBusReadDataWord (SmbusAddress, &Status);\r
+      SmBusReadDataWord (SmbusAddress, &Status);\r
       break;\r
     case EfiSmbusWriteWord:\r
-      DEBUG ((EFI_D_INFO, "EfiSmbusWriteByte - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));\r
+      DEBUG ((EFI_D_INFO, "EfiSmbusWriteWord - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));\r
       SmBusWriteDataWord (SmbusAddress, *(UINT16 *) Buffer, &Status);\r
       break;\r
     case EfiSmbusProcessCall:\r
       DEBUG ((EFI_D_INFO, "EfiSmbusProcessCall - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));\r
-      *(UINT16 *) Buffer = SmBusProcessCall (SmbusAddress, *(UINT16 *) Buffer, &Status);\r
+      SmBusProcessCall (SmbusAddress, *(UINT16 *) Buffer, &Status);\r
       break;\r
     case EfiSmbusReadBlock:\r
       DEBUG ((EFI_D_INFO, "EfiSmbusReadBlock - 0x%08x\n", SmbusAddress));\r
-      WorkBufferLen = SmBusReadBlock (SmbusAddress, WorkBuffer, &Status);\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Read block transaction is complete successfully, and then\r
-        // check whether the output buffer is large enough.  \r
-        //\r
-        if (*Length >= WorkBufferLen) {\r
-          CopyMem (Buffer, WorkBuffer, WorkBufferLen);\r
-        } else {\r
-          Status = EFI_BUFFER_TOO_SMALL;\r
-        }\r
-        *Length = WorkBufferLen;\r
-      }\r
+      SmBusReadBlock (SmbusAddress, WorkBuffer, &Status);\r
       break;\r
     case EfiSmbusWriteBlock:\r
-      DEBUG ((EFI_D_INFO, "EfiSmbusWriteBlock - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));\r
-      SmBusWriteBlock ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE))  , Buffer, &Status);\r
+      DEBUG ((EFI_D_INFO, "EfiSmbusWriteBlock - 0x%08x\n", SmbusAddress));\r
+      SmBusWriteBlock ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)), Buffer, &Status);\r
       break;\r
     case EfiSmbusBWBRProcessCall:\r
-      //\r
-      // BUGBUG: Should this case be handled?\r
-      //\r
+      DEBUG ((EFI_D_INFO, "EfiSmbusBWBRProcessCall - 0x%08x\n", SmbusAddress));\r
+      SmBusBlockProcessCall ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)), Buffer, WorkBuffer, &Status);\r
       break;\r
+    default:\r
+      return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  return Status;  \r
+  return Status;\r
 }\r
 \r
 /**\r
@@ -248,7 +130,7 @@ SmbusExecute (
   @param Width          Width of the operation.\r
   @param Address        Address of the operation.\r
   @param AddressStride  Instride for stepping input buffer.\r
-  @param BufferStride   Outstride for stepping output buffer.  \r
+  @param BufferStride   Outstride for stepping output buffer.\r
 \r
   @retval EFI_SUCCESS  Successful translation.\r
   @retval EFI_INVALID_PARAMETER Width or Address is invalid.\r
@@ -288,18 +170,18 @@ BuildLoopData (
 \r
 /**\r
   Perform IO read operation\r
-  \r
+\r
   @param[in]  Width   Width of the operation.\r
   @param[in]  Address Address of the operation.\r
   @param[in]  Count   Count of the number of accesses to perform.\r
-  @param[out] Buffer  Pointer to the buffer to read from I/O space.  \r
+  @param[out] Buffer  Pointer to the buffer to read from I/O space.\r
 \r
   @retval EFI_SUCCESS The data was written to the EFI System.\r
   @retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.\r
                                 Buffer is NULL.\r
                                 The Buffer is not aligned for the given Width.\r
-                                Address is outside the legal range of I/O ports.  \r
-                                \r
+                                Address is outside the legal range of I/O ports.\r
+\r
 **/\r
 EFI_STATUS\r
 ScriptIoRead (\r
@@ -392,18 +274,18 @@ ScriptIoRead (
 \r
 /**\r
   Perform IO write operation\r
-  \r
+\r
   @param[in]  Width Width of the operation.\r
   @param[in]  Address Address of the operation.\r
   @param[in]  Count Count of the number of accesses to perform.\r
-  @param[in]  Buffer Pointer to the buffer to write to I/O space.  \r
+  @param[in]  Buffer Pointer to the buffer to write to I/O space.\r
 \r
   @retval EFI_SUCCESS The data was written to the EFI System.\r
   @retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.\r
                                 Buffer is NULL.\r
                                 The Buffer is not aligned for the given Width.\r
-                                Address is outside the legal range of I/O ports.  \r
-                                \r
+                                Address is outside the legal range of I/O ports.\r
+\r
 **/\r
 EFI_STATUS\r
 ScriptIoWrite (\r
@@ -440,11 +322,11 @@ ScriptIoWrite (
       case S3BootScriptWidthUint8:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));\r
         IoWrite8 ((UINTN) Address, *In.Uint8);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFifoUint8:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8));\r
         IoWrite8 ((UINTN) OriginalAddress, *In.Uint8);\r
-        break;       \r
+        break;\r
       case S3BootScriptWidthFillUint8:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));\r
         IoWrite8 ((UINTN) Address, *OriginalIn.Uint8);\r
@@ -452,11 +334,11 @@ ScriptIoWrite (
       case S3BootScriptWidthUint16:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));\r
         IoWrite16 ((UINTN) Address, *In.Uint16);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFifoUint16:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16));\r
         IoWrite16 ((UINTN) OriginalAddress, *In.Uint16);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFillUint16:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));\r
         IoWrite16 ((UINTN) Address, *OriginalIn.Uint16);\r
@@ -464,7 +346,7 @@ ScriptIoWrite (
       case S3BootScriptWidthUint32:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));\r
         IoWrite32 ((UINTN) Address, *In.Uint32);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFifoUint32:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32));\r
         IoWrite32 ((UINTN) OriginalAddress, *In.Uint32);\r
@@ -476,11 +358,11 @@ ScriptIoWrite (
       case S3BootScriptWidthUint64:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));\r
         IoWrite64 ((UINTN) Address, *In.Uint64);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFifoUint64:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));\r
         IoWrite64 ((UINTN) OriginalAddress, *In.Uint64);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFillUint64:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));\r
         IoWrite64 ((UINTN) Address, *OriginalIn.Uint64);\r
@@ -489,25 +371,25 @@ ScriptIoWrite (
         return EFI_INVALID_PARAMETER;\r
     }\r
   }\r
-  \r
+\r
 \r
   return EFI_SUCCESS;\r
 }\r
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_IO_WRITE OP code.\r
-  \r
+\r
   @param Script       Pointer to the node which is to be interpreted.\r
 \r
   @retval EFI_SUCCESS The data was written to the EFI System.\r
   @retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.\r
                                 Buffer is NULL.\r
                                 The Buffer is not aligned for the given Width.\r
-                                Address is outside the legal range of I/O ports.  \r
-                                \r
+                                Address is outside the legal range of I/O ports.\r
+\r
 **/\r
 EFI_STATUS\r
 BootScriptExecuteIoWrite (\r
-  IN UINT8                    *Script    \r
+  IN UINT8                    *Script\r
   )\r
 {\r
   S3_BOOT_SCRIPT_LIB_WIDTH   Width;\r
@@ -515,7 +397,7 @@ BootScriptExecuteIoWrite (
   UINTN                      Count;\r
   VOID                      *Buffer;\r
   EFI_BOOT_SCRIPT_IO_WRITE   IoWrite;\r
-  \r
+\r
   CopyMem ((VOID*)&IoWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_WRITE));\r
   Width = (S3_BOOT_SCRIPT_LIB_WIDTH) IoWrite.Width;\r
   Address = IoWrite.Address;\r
@@ -527,19 +409,19 @@ BootScriptExecuteIoWrite (
 }\r
 /**\r
   Perform memory read operation\r
-  \r
+\r
   @param  Width Width of the operation.\r
   @param  Address Address of the operation.\r
   @param  Count Count of the number of accesses to perform.\r
-  @param  Buffer Pointer to the buffer read from memory.  \r
+  @param  Buffer Pointer to the buffer read from memory.\r
 \r
   @retval EFI_SUCCESS The data was written to the EFI System.\r
   @retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.\r
                                 Buffer is NULL.\r
                                 The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count \r
-                          is not valid for this EFI System.  \r
-                                \r
+  @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count\r
+                          is not valid for this EFI System.\r
+\r
 **/\r
 EFI_STATUS\r
 ScriptMemoryRead (\r
@@ -626,19 +508,19 @@ ScriptMemoryRead (
 }\r
 /**\r
   Perform memory write operation\r
-  \r
+\r
   @param   Width   Width of the operation.\r
   @param   Address Address of the operation.\r
   @param   Count   Count of the number of accesses to perform.\r
-  @param   Buffer  Pointer to the buffer write to memory.      \r
+  @param   Buffer  Pointer to the buffer write to memory.\r
 \r
   @retval EFI_SUCCESS The data was written to the EFI System.\r
   @retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.\r
                                 Buffer is NULL.\r
                                 The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count \r
-                          is not valid for this EFI System.  \r
-                                \r
+  @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count\r
+                          is not valid for this EFI System.\r
+\r
 **/\r
 EFI_STATUS\r
 ScriptMemoryWrite (\r
@@ -650,7 +532,7 @@ ScriptMemoryWrite (
 {\r
   EFI_STATUS  Status;\r
   UINTN       AddressStride;\r
-  UINT64      OriginalAddress;  \r
+  UINT64      OriginalAddress;\r
   UINTN       BufferStride;\r
   PTR         In;\r
   PTR         OriginalIn;\r
@@ -665,17 +547,17 @@ ScriptMemoryWrite (
   // Loop for each iteration and move the data\r
   //\r
   OriginalAddress = Address;\r
-  OriginalIn.Buf = In.Buf;  \r
+  OriginalIn.Buf = In.Buf;\r
   for (; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {\r
     switch (Width) {\r
       case S3BootScriptWidthUint8:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));\r
         MmioWrite8 ((UINTN) Address, *In.Uint8);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFifoUint8:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8));\r
         MmioWrite8 ((UINTN) OriginalAddress, *In.Uint8);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFillUint8:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));\r
         MmioWrite8 ((UINTN) Address, *OriginalIn.Uint8);\r
@@ -683,11 +565,11 @@ ScriptMemoryWrite (
       case S3BootScriptWidthUint16:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));\r
         MmioWrite16 ((UINTN) Address, *In.Uint16);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFifoUint16:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16));\r
         MmioWrite16 ((UINTN) OriginalAddress, *In.Uint16);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFillUint16:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));\r
         MmioWrite16 ((UINTN) Address, *OriginalIn.Uint16);\r
@@ -695,11 +577,11 @@ ScriptMemoryWrite (
       case S3BootScriptWidthUint32:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));\r
         MmioWrite32 ((UINTN) Address, *In.Uint32);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFifoUint32:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32));\r
         MmioWrite32 ((UINTN) OriginalAddress, *In.Uint32);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFillUint32:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));\r
         MmioWrite32 ((UINTN) Address, *OriginalIn.Uint32);\r
@@ -707,11 +589,11 @@ ScriptMemoryWrite (
       case S3BootScriptWidthUint64:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));\r
         MmioWrite64 ((UINTN) Address, *In.Uint64);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFifoUint64:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));\r
         MmioWrite64 ((UINTN) OriginalAddress, *In.Uint64);\r
-        break;      \r
+        break;\r
       case S3BootScriptWidthFillUint64:\r
         DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));\r
         MmioWrite64 ((UINTN) Address, *OriginalIn.Uint64);\r
@@ -726,14 +608,14 @@ ScriptMemoryWrite (
   Interprete the boot script node with EFI_BOOT_SCRIPT_MEM_WRITE OP code.\r
 \r
   @param[in]  Script Pointer to the node which is to be interpreted.\r
-  \r
+\r
   @retval EFI_SUCCESS The data was written to the EFI System.\r
   @retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.\r
                                 Buffer is NULL.\r
                                 The Buffer is not aligned for the given Width.\r
-  @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count \r
-                          is not valid for this EFI System.  \r
-                                \r
+  @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count\r
+                          is not valid for this EFI System.\r
+\r
 **/\r
 EFI_STATUS\r
 BootScriptExecuteMemoryWrite (\r
@@ -745,7 +627,7 @@ BootScriptExecuteMemoryWrite (
   UINT64           Address;\r
   UINTN            Count;\r
   EFI_BOOT_SCRIPT_MEM_WRITE  MemWrite;\r
-  \r
+\r
   CopyMem((VOID*)&MemWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_WRITE));\r
   Width   = (S3_BOOT_SCRIPT_LIB_WIDTH)MemWrite.Width;\r
   Address = MemWrite.Address;\r
@@ -754,23 +636,26 @@ BootScriptExecuteMemoryWrite (
 \r
   DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width));\r
   return ScriptMemoryWrite (Width,Address, Count,  Buffer);\r
-  \r
-}  \r
+\r
+}\r
 /**\r
-  Performance PCI configuration read operation\r
+  Performance PCI configuration read operation\r
 \r
   @param  Width   Width of the operation.\r
+  @param  Segment Pci segment number\r
   @param  Address Address of the operation.\r
   @param  Count   Count of the number of accesses to perform.\r
   @param  Buffer  Pointer to the buffer read from PCI config space\r
-  \r
+\r
   @retval EFI_SUCCESS The read succeed.\r
-  @retval EFI_INVALID_PARAMETER if Width is not defined  \r
-                                \r
+  @retval EFI_INVALID_PARAMETER if Width is not defined\r
+  @note  A known Limitations in the implementation which is 64bits operations are not supported.\r
+\r
 **/\r
 EFI_STATUS\r
-ScriptPciCfgRead (\r
+ScriptPciCfg2Read (\r
   IN  S3_BOOT_SCRIPT_LIB_WIDTH    Width,\r
+  IN  UINT16                       Segment,\r
   IN  UINT64                       Address,\r
   IN  UINTN                        Count,\r
   OUT VOID                        *Buffer\r
@@ -780,11 +665,11 @@ ScriptPciCfgRead (
   UINTN       AddressStride;\r
   UINTN       BufferStride;\r
   PTR         Out;\r
-  UINT      PciAddress;\r
+  UINT64      PciAddress;\r
 \r
   Out.Buf = (UINT8 *) Buffer;\r
 \r
-  PciAddress = PCI_ADDRESS_ENCODE (Address);\r
+  PciAddress = PCI_ADDRESS_ENCODE (Segment, Address);\r
 \r
   Status = BuildLoopData (Width, PciAddress, &AddressStride, &BufferStride);\r
   if (EFI_ERROR (Status)) {\r
@@ -796,42 +681,42 @@ ScriptPciCfgRead (
   for (; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += BufferStride) {\r
     switch (Width) {\r
     case S3BootScriptWidthUint8:\r
-      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", PciAddress));\r
-      *Out.Uint8 = PciRead8 (PciAddress);\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", PciAddress));\r
+      *Out.Uint8 = PciSegmentRead8 (PciAddress);\r
       break;\r
     case S3BootScriptWidthFifoUint8:\r
-      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", PciAddress));\r
-      *Out.Uint8 = PciRead8 (PciAddress);\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx\n", PciAddress));\r
+      *Out.Uint8 = PciSegmentRead8 (PciAddress);\r
       break;\r
     case S3BootScriptWidthFillUint8:\r
-      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", PciAddress));\r
-      *Out.Uint8 = PciRead8 (PciAddress);\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx\n", PciAddress));\r
+      *Out.Uint8 = PciSegmentRead8 (PciAddress);\r
       break;\r
 \r
     case S3BootScriptWidthUint16:\r
-      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", PciAddress));\r
-      *Out.Uint16 = PciRead16 (PciAddress);\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", PciAddress));\r
+      *Out.Uint16 = PciSegmentRead16 (PciAddress);\r
       break;\r
     case S3BootScriptWidthFifoUint16:\r
-      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", PciAddress));\r
-      *Out.Uint16 = PciRead16 (PciAddress);\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx\n", PciAddress));\r
+      *Out.Uint16 = PciSegmentRead16 (PciAddress);\r
       break;\r
     case S3BootScriptWidthFillUint16:\r
-      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", PciAddress));\r
-      *Out.Uint16 = PciRead16 (PciAddress);\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx\n", PciAddress));\r
+      *Out.Uint16 = PciSegmentRead16 (PciAddress);\r
       break;\r
 \r
     case S3BootScriptWidthUint32:\r
-      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", PciAddress));\r
-      *Out.Uint32 = PciRead32 (PciAddress);\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", PciAddress));\r
+      *Out.Uint32 = PciSegmentRead32 (PciAddress);\r
       break;\r
     case S3BootScriptWidthFifoUint32:\r
-      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", PciAddress));\r
-      *Out.Uint32 = PciRead32 (PciAddress);\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx\n", PciAddress));\r
+      *Out.Uint32 = PciSegmentRead32 (PciAddress);\r
       break;\r
     case S3BootScriptWidthFillUint32:\r
-      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", PciAddress));\r
-      *Out.Uint32 = PciRead32 (PciAddress);\r
+      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx\n", PciAddress));\r
+      *Out.Uint32 = PciSegmentRead32 (PciAddress);\r
       break;\r
 \r
     default:\r
@@ -842,20 +727,23 @@ ScriptPciCfgRead (
 }\r
 \r
 /**\r
-  Performance PCI configuration write operation\r
+  Performance PCI configuration write operation\r
 \r
   @param  Width   Width of the operation.\r
+  @param  Segment Pci segment number\r
   @param  Address Address of the operation.\r
   @param  Count   Count of the number of accesses to perform.\r
   @param  Buffer  Pointer to the buffer write to PCI config space\r
-  \r
+\r
   @retval EFI_SUCCESS The write succeed.\r
-  @retval EFI_INVALID_PARAMETER if Width is not defined  \r
-                                \r
+  @retval EFI_INVALID_PARAMETER if Width is not defined\r
+  @note  A known Limitations in the implementation which is 64bits operations are not supported.\r
+\r
 **/\r
 EFI_STATUS\r
-ScriptPciCfgWrite (\r
+ScriptPciCfg2Write (\r
   IN  S3_BOOT_SCRIPT_LIB_WIDTH     Width,\r
+  IN  UINT16                       Segment,\r
   IN  UINT64                       Address,\r
   IN  UINTN                        Count,\r
   IN  VOID                         *Buffer\r
@@ -864,14 +752,14 @@ ScriptPciCfgWrite (
   EFI_STATUS  Status;\r
   UINTN       AddressStride;\r
   UINTN       BufferStride;\r
-  UINT      OriginalPciAddress;\r
+  UINT64      OriginalPciAddress;\r
   PTR         In;\r
   PTR         OriginalIn;\r
-  UINT      PciAddress;\r
+  UINT64      PciAddress;\r
 \r
   In.Buf = (UINT8 *) Buffer;\r
 \r
-  PciAddress = PCI_ADDRESS_ENCODE (Address);\r
+  PciAddress = PCI_ADDRESS_ENCODE (Segment, Address);\r
 \r
   Status = BuildLoopData (Width, PciAddress, &AddressStride, &BufferStride);\r
   if (EFI_ERROR (Status)) {\r
@@ -885,40 +773,40 @@ ScriptPciCfgWrite (
   for (; Count > 0; Count--, PciAddress += AddressStride, In.Buf += BufferStride) {\r
     switch (Width) {\r
       case S3BootScriptWidthUint8:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", PciAddress, (UINTN)*In.Uint8));\r
-        PciWrite8 (PciAddress, *In.Uint8);\r
-        break;      \r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*In.Uint8));\r
+        PciSegmentWrite8 (PciAddress, *In.Uint8);\r
+        break;\r
       case S3BootScriptWidthFifoUint8:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", OriginalPciAddress, (UINTN)*In.Uint8));\r
-        PciWrite8 (OriginalPciAddress, *In.Uint8);\r
-        break;      \r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx (0x%02x)\n", OriginalPciAddress, (UINTN)*In.Uint8));\r
+        PciSegmentWrite8 (OriginalPciAddress, *In.Uint8);\r
+        break;\r
       case S3BootScriptWidthFillUint8:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", PciAddress, (UINTN)*OriginalIn.Uint8));\r
-        PciWrite8 (PciAddress, *OriginalIn.Uint8);\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*OriginalIn.Uint8));\r
+        PciSegmentWrite8 (PciAddress, *OriginalIn.Uint8);\r
         break;\r
       case S3BootScriptWidthUint16:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", PciAddress, (UINTN)*In.Uint16));\r
-        PciWrite16 (PciAddress, *In.Uint16);\r
-        break;      \r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx (0x%04x)\n", PciAddress, (UINTN)*In.Uint16));\r
+        PciSegmentWrite16 (PciAddress, *In.Uint16);\r
+        break;\r
       case S3BootScriptWidthFifoUint16:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", OriginalPciAddress, (UINTN)*In.Uint16));\r
-        PciWrite16 (OriginalPciAddress, *In.Uint16);\r
-        break;      \r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx (0x%04x)\n", OriginalPciAddress, (UINTN)*In.Uint16));\r
+        PciSegmentWrite16 (OriginalPciAddress, *In.Uint16);\r
+        break;\r
       case S3BootScriptWidthFillUint16:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", PciAddress, (UINTN)*OriginalIn.Uint16));\r
-        PciWrite16 (PciAddress, *OriginalIn.Uint16);\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx (0x%04x)\n", PciAddress, (UINTN)*OriginalIn.Uint16));\r
+        PciSegmentWrite16 (PciAddress, *OriginalIn.Uint16);\r
         break;\r
       case S3BootScriptWidthUint32:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", PciAddress, (UINTN)*In.Uint32));\r
-        PciWrite32 (PciAddress, *In.Uint32);\r
-        break;      \r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx (0x%08x)\n", PciAddress, (UINTN)*In.Uint32));\r
+        PciSegmentWrite32 (PciAddress, *In.Uint32);\r
+        break;\r
       case S3BootScriptWidthFifoUint32:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", OriginalPciAddress, (UINTN)*In.Uint32));\r
-        PciWrite32 (OriginalPciAddress, *In.Uint32);\r
-        break;      \r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx (0x%08x)\n", OriginalPciAddress, (UINTN)*In.Uint32));\r
+        PciSegmentWrite32 (OriginalPciAddress, *In.Uint32);\r
+        break;\r
       case S3BootScriptWidthFillUint32:\r
-        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)PciAddress, (UINTN)*OriginalIn.Uint32));\r
-        PciWrite32 (PciAddress, *OriginalIn.Uint32);\r
+        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx (0x%08x)\n", (UINTN)PciAddress, (UINTN)*OriginalIn.Uint32));\r
+        PciSegmentWrite32 (PciAddress, *OriginalIn.Uint32);\r
         break;\r
       default:\r
         return EFI_INVALID_PARAMETER;\r
@@ -927,10 +815,9 @@ ScriptPciCfgWrite (
   return EFI_SUCCESS;\r
 }\r
 /**\r
-  Performance PCI configuration read operation\r
-  \r
+  Performance PCI configuration read operation\r
+\r
   @param     Width                      Width of the operation.\r
-  @param     Segment                    Pci segment number\r
   @param     Address                    Address of the operation.\r
   @param     Count                      Count of the number of accesses to perform.\r
   @param     Buffer                     Pointer to the buffer to read from PCI config space.\r
@@ -940,27 +827,22 @@ ScriptPciCfgWrite (
                                         Buffer is NULL.\r
                                         The Buffer is not aligned for the given Width.\r
                                         Address is outside the legal range of I/O ports.\r
-  @note  A known Limitations in the implementation which is the 'Segment' parameter is assumed as \r
-         Zero, or else, assert.\r
+\r
 **/\r
 EFI_STATUS\r
-ScriptPciCfg2Read (\r
+ScriptPciCfgRead (\r
   IN  S3_BOOT_SCRIPT_LIB_WIDTH    Width,\r
-  IN  UINT16                   Segment,  \r
   IN  UINT64                   Address,\r
   IN  UINTN                    Count,\r
   OUT VOID                     *Buffer\r
   )\r
 {\r
-  ASSERT (Segment==0);\r
-  \r
-  return ScriptPciCfgRead (Width, Address, Count, Buffer);\r
+  return ScriptPciCfg2Read (Width, 0, Address, Count, Buffer);\r
 }\r
 /**\r
-  Performance PCI configuration write operation\r
-  \r
+  Performance PCI configuration write operation\r
+\r
   @param     Width                      Width of the operation.\r
-  @param     Segment                    Pci segment number\r
   @param     Address                    Address of the operation.\r
   @param     Count                      Count of the number of accesses to perform.\r
   @param     Buffer                     Pointer to the buffer to write to PCI config space.\r
@@ -970,28 +852,24 @@ ScriptPciCfg2Read (
                                         Buffer is NULL.\r
                                         The Buffer is not aligned for the given Width.\r
                                         Address is outside the legal range of I/O ports.\r
-  @note  A known Limitations in the implementation which is the 'Segment' parameter is assumed as \r
-         Zero, or else, assert.\r
-                                \r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-ScriptPciCfg2Write (\r
+ScriptPciCfgWrite (\r
   IN  S3_BOOT_SCRIPT_LIB_WIDTH    Width,\r
-  IN  UINT16                   Segment,  \r
   IN  UINT64                   Address,\r
   IN  UINTN                    Count,\r
   IN  VOID                     *Buffer\r
   )\r
 {\r
-  ASSERT (Segment==0);\r
-  return ScriptPciCfgWrite (Width, Address, Count, Buffer);\r
+  return ScriptPciCfg2Write (Width, 0, Address, Count, Buffer);\r
 }\r
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE OP code.\r
-  \r
-  @param  Script        The pointer of typed node in boot script table \r
-  \r
+\r
+  @param  Script        The pointer of typed node in boot script table\r
+\r
   @retval EFI_SUCCESS  The operation was executed successfully\r
 **/\r
 EFI_STATUS\r
@@ -1012,13 +890,13 @@ BootScriptExecutePciCfgWrite (
   Count   = PciCfgWrite.Count;\r
   Buffer  = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);\r
 \r
-  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgWrite - 0x%08x, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Address), Count, (UINTN)Width));\r
+  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgWrite - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (0, Address), Count, (UINTN)Width));\r
   return ScriptPciCfgWrite (Width, Address, Count, Buffer);\r
 }\r
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_IO_READ_WRITE OP code.\r
 \r
-  @param Script   The pointer of typed node in boot script table \r
+  @param Script   The pointer of typed node in boot script table\r
   @param AndMask  Mask value for 'and' operation\r
   @param OrMask   Mask value for 'or' operation\r
 \r
@@ -1035,9 +913,9 @@ BootScriptExecuteIoReadWrite (
   EFI_STATUS  Status;\r
   UINT64      Data;\r
   EFI_BOOT_SCRIPT_IO_READ_WRITE IoReadWrite;\r
-  \r
+\r
   Data = 0;\r
-  \r
+\r
   CopyMem((VOID*)&IoReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_READ_WRITE));\r
 \r
   DEBUG ((EFI_D_INFO, "BootScriptExecuteIoReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoReadWrite.Address, AndMask, OrMask));\r
@@ -1062,7 +940,7 @@ BootScriptExecuteIoReadWrite (
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_MEM_READ_WRITE OP code.\r
 \r
-  @param Script    The pointer of typed node in boot script table \r
+  @param Script    The pointer of typed node in boot script table\r
   @param AndMask   Mask value for 'and' operation\r
   @param OrMask    Mask value for 'or' operation\r
 \r
@@ -1079,13 +957,13 @@ BootScriptExecuteMemoryReadWrite (
   EFI_STATUS  Status;\r
   UINT64      Data;\r
   EFI_BOOT_SCRIPT_MEM_READ_WRITE  MemReadWrite;\r
-  \r
+\r
   Data = 0;\r
-  \r
+\r
   CopyMem((VOID*)&MemReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_READ_WRITE));\r
 \r
   DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemReadWrite.Address, AndMask, OrMask));\r
-  \r
+\r
   Status = ScriptMemoryRead (\r
              (S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width,\r
              MemReadWrite.Address,\r
@@ -1106,7 +984,7 @@ BootScriptExecuteMemoryReadWrite (
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CFG_READ_WRITE OP code.\r
 \r
-  @param Script   The pointer of typed node in boot script table \r
+  @param Script   The pointer of typed node in boot script table\r
   @param AndMask  Mask value for 'and' operation\r
   @param OrMask   Mask value for 'or' operation\r
 \r
@@ -1123,11 +1001,13 @@ BootScriptExecutePciCfgReadWrite (
   EFI_STATUS  Status;\r
   UINT64      Data;\r
   EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE  PciCfgReadWrite;\r
-  \r
+\r
+  Data = 0;\r
+\r
   CopyMem((VOID*)&PciCfgReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));\r
 \r
-  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfgReadWrite.Address), AndMask, OrMask));\r
-  \r
+  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgReadWrite.Address), AndMask, OrMask));\r
+\r
   Status = ScriptPciCfgRead (\r
              (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,\r
              PciCfgReadWrite.Address,\r
@@ -1152,11 +1032,11 @@ BootScriptExecutePciCfgReadWrite (
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_SMBUS_EXECUTE OP code.\r
 \r
-  @param Script  The pointer of typed node in boot script table \r
\r
+  @param Script  The pointer of typed node in boot script table\r
+\r
   @retval EFI_SUCCESS      The operation was executed successfully\r
   @retval EFI_UNSUPPORTED  Cannot locate smbus ppi or occur error of script execution\r
-  @retval Others           Result of script execution \r
+  @retval Others           Result of script execution\r
 **/\r
 EFI_STATUS\r
 BootScriptExecuteSmbusExecute (\r
@@ -1166,7 +1046,7 @@ BootScriptExecuteSmbusExecute (
   UINTN                    SmBusAddress;\r
   UINTN                    DataSize;\r
   EFI_BOOT_SCRIPT_SMBUS_EXECUTE SmbusExecuteEntry;\r
-  \r
+\r
   CopyMem ((VOID*)&SmbusExecuteEntry, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_SMBUS_EXECUTE ));\r
 \r
   DEBUG ((EFI_D_INFO, "BootScriptExecuteSmbusExecute - 0x%08x, 0x%08x\n", (UINTN)SmbusExecuteEntry.SmBusAddress, (UINTN)SmbusExecuteEntry.Operation));\r
@@ -1183,8 +1063,8 @@ BootScriptExecuteSmbusExecute (
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_STALL OP code.\r
 \r
-  @param Script      The pointer of typed node in boot script table \r
-  \r
+  @param Script      The pointer of typed node in boot script table\r
+\r
   @retval EFI_SUCCESS The operation was executed successfully\r
 **/\r
 EFI_STATUS\r
@@ -1193,7 +1073,7 @@ BootScriptExecuteStall (
   )\r
 {\r
   EFI_BOOT_SCRIPT_STALL    Stall;\r
-  \r
+\r
   CopyMem ((VOID*)&Stall, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_STALL));\r
 \r
   DEBUG ((EFI_D_INFO, "BootScriptExecuteStall - 0x%08x\n", (UINTN)Stall.Duration));\r
@@ -1203,8 +1083,8 @@ BootScriptExecuteStall (
 }\r
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_DISPATCH OP code.\r
-  \r
-  @param Script  The pointer of typed node in boot script table \r
+\r
+  @param Script  The pointer of typed node in boot script table\r
   @retval EFI_SUCCESS  The operation was executed successfully\r
 **/\r
 EFI_STATUS\r
@@ -1215,7 +1095,7 @@ BootScriptExecuteDispatch (
   EFI_STATUS                Status;\r
   DISPATCH_ENTRYPOINT_FUNC  EntryFunc;\r
   EFI_BOOT_SCRIPT_DISPATCH  ScriptDispatch;\r
-  \r
+\r
   CopyMem ((VOID*)&ScriptDispatch, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_DISPATCH));\r
   EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (ScriptDispatch.EntryPoint);\r
 \r
@@ -1228,7 +1108,7 @@ BootScriptExecuteDispatch (
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_DISPATCH_2 OP code.\r
 \r
-  @param  Script       The pointer of typed node in boot script table \r
+  @param  Script       The pointer of typed node in boot script table\r
   @retval EFI_SUCCESS  The operation was executed successfully\r
 **/\r
 EFI_STATUS\r
@@ -1239,11 +1119,11 @@ BootScriptExecuteDispatch2 (
   EFI_STATUS                Status;\r
   DISPATCH_ENTRYPOINT_FUNC  EntryFunc;\r
   EFI_BOOT_SCRIPT_DISPATCH_2  ScriptDispatch2;\r
-  \r
+\r
   CopyMem ((VOID*)&ScriptDispatch2, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_DISPATCH_2));\r
 \r
   DEBUG ((EFI_D_INFO, "BootScriptExecuteDispatch2 - 0x%08x(0x%08x)\n", (UINTN)ScriptDispatch2.EntryPoint, (UINTN)ScriptDispatch2.Context));\r
-  \r
+\r
   EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (ScriptDispatch2.EntryPoint);\r
 \r
   Status    = EntryFunc (NULL, (VOID *) (UINTN) ScriptDispatch2.Context);\r
@@ -1253,11 +1133,11 @@ BootScriptExecuteDispatch2 (
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_MEM_POLL OP code.\r
 \r
-  @param  Script  The pointer of typed node in boot script table \r
+  @param  Script  The pointer of typed node in boot script table\r
   @param  AndMask  Mask value for 'and' operation\r
   @param  OrMask   Mask value for 'or' operation\r
-  \r
-  @retval EFI_DEVICE_ERROR Data polled from memory does not equal to \r
+\r
+  @retval EFI_DEVICE_ERROR Data polled from memory does not equal to\r
                            the epecting data within the Loop Times.\r
   @retval EFI_SUCCESS      The operation was executed successfully\r
 **/\r
@@ -1265,15 +1145,15 @@ EFI_STATUS
 BootScriptExecuteMemPoll (\r
   IN UINT8                        *Script,\r
   IN UINT64                        AndMask,\r
-  IN UINT64                        OrMask  \r
+  IN UINT64                        OrMask\r
   )\r
 {\r
-  \r
+\r
   UINT64        Data;\r
   UINT64        LoopTimes;\r
   EFI_STATUS    Status;\r
   EFI_BOOT_SCRIPT_MEM_POLL       MemPoll;\r
-  \r
+\r
   CopyMem ((VOID*)&MemPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_POLL));\r
 \r
   DEBUG ((EFI_D_INFO, "BootScriptExecuteMemPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemPoll.Address, AndMask, OrMask));\r
@@ -1290,7 +1170,7 @@ BootScriptExecuteMemPoll (
   }\r
 \r
   for (LoopTimes = 0; LoopTimes < MemPoll.LoopTimes; LoopTimes++) {\r
-    NanoSecondDelay ((UINTN)MemPoll.Duration);\r
+    MicroSecondDelay ((UINTN)MemPoll.Duration);\r
 \r
     Data = 0;\r
     Status = ScriptMemoryRead (\r
@@ -1314,8 +1194,8 @@ BootScriptExecuteMemPoll (
   Execute the boot script to interpret the Store arbitrary information.\r
   This opcode is a no-op on dispatch and is only used for debugging script issues.\r
 \r
-  @param Script       The pointer of node in boot script table \r
\r
+  @param Script       The pointer of node in boot script table\r
+\r
 **/\r
 VOID\r
 BootScriptExecuteInformation (\r
@@ -1340,10 +1220,10 @@ BootScriptExecuteInformation (
 }\r
 \r
 /**\r
-  Execute the boot script to interpret the Label information. \r
+  Execute the boot script to interpret the Label information.\r
+\r
+  @param Script       The pointer of node in boot script table\r
 \r
-  @param Script       The pointer of node in boot script table \r
\r
 **/\r
 VOID\r
 BootScriptExecuteLabel (\r
@@ -1369,7 +1249,7 @@ BootScriptExecuteLabel (
 \r
 /**\r
   calculate the mask value for 'and' and 'or' operation\r
-  @param ScriptHeader   The pointer of header of node in boot script table \r
+  @param ScriptHeader   The pointer of header of node in boot script table\r
   @param AndMask  The Mask value for 'and' operation\r
   @param OrMask   The Mask value for 'or' operation\r
   @param Script   Pointer to the entry.\r
@@ -1401,32 +1281,32 @@ CheckAndOrMask (
   case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:\r
     Size = sizeof (EFI_BOOT_SCRIPT_MEM_POLL);\r
     break;\r
-  \r
+\r
   case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:\r
     Size = sizeof (EFI_BOOT_SCRIPT_IO_POLL);\r
-    break;    \r
-  \r
+    break;\r
+\r
   case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:\r
     Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE);\r
     break;\r
-  \r
+\r
   case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:\r
     Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL);\r
     break;\r
-  \r
+\r
   case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:\r
     Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL);\r
     break;\r
-  \r
+\r
   default:\r
     return;\r
   }\r
-  \r
+\r
   DataPtr = Script + Size;\r
 \r
   switch (ScriptHeader->Width) {\r
   case S3BootScriptWidthUint8:\r
-    *AndMask  = (UINT64) *(DataPtr + 1);\r
+    *AndMask  = (UINT64) (*(UINT8*) (DataPtr + 1));\r
     *OrMask   = (UINT64) (*DataPtr);\r
     break;\r
 \r
@@ -1454,11 +1334,11 @@ CheckAndOrMask (
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_IO_POLL OP code.\r
 \r
-  @param  Script  The pointer of typed node in boot script table \r
+  @param  Script  The pointer of typed node in boot script table\r
   @param  AndMask  Mask value for 'and' operation\r
   @param  OrMask   Mask value for 'or' operation\r
-  \r
-  @retval EFI_DEVICE_ERROR Data polled from memory does not equal to \r
+\r
+  @retval EFI_DEVICE_ERROR Data polled from memory does not equal to\r
                            the epecting data within the Loop Times.\r
   @retval EFI_SUCCESS      The operation was executed successfully\r
 **/\r
@@ -1473,7 +1353,7 @@ BootScriptExecuteIoPoll (
   UINT64        Data;\r
   UINT64        LoopTimes;\r
   EFI_BOOT_SCRIPT_IO_POLL       IoPoll;\r
-  \r
+\r
   CopyMem ((VOID*)&IoPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_POLL));\r
 \r
   DEBUG ((EFI_D_INFO, "BootScriptExecuteIoPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoPoll.Address, AndMask, OrMask));\r
@@ -1499,7 +1379,7 @@ BootScriptExecuteIoPoll (
                );\r
     if ((!EFI_ERROR (Status)) &&(Data & AndMask) == OrMask) {\r
       return EFI_SUCCESS;\r
-    } \r
+    }\r
   }\r
 \r
   if (LoopTimes < IoPoll.Delay) {\r
@@ -1527,7 +1407,7 @@ BootScriptExecutePciCfg2Write (
   UINT64                            Address;\r
   UINTN                             Count;\r
   EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE PciCfg2Write;\r
-  \r
+\r
   CopyMem ((VOID*)&PciCfg2Write, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));\r
 \r
   Width   = (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2Write.Width;\r
@@ -1536,14 +1416,14 @@ BootScriptExecutePciCfg2Write (
   Count   = PciCfg2Write.Count;\r
   Buffer  = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE);\r
 \r
-  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2Write - 0x%04x, 0x%08x, 0x%08x, 0x%08x\n", Segment, PCI_ADDRESS_ENCODE (Address), Count, (UINTN)Width));\r
+  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2Write - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Segment, Address), Count, (UINTN)Width));\r
   return ScriptPciCfg2Write (Width, Segment, Address, Count, Buffer);\r
 }\r
 \r
 \r
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE OP code.\r
-  \r
+\r
   @param     Script                     The pointer of S3 boot script\r
   @param     AndMask                    Mask value for 'and' operation\r
   @param     OrMask                     Mask value for 'or' operation\r
@@ -1561,10 +1441,13 @@ BootScriptExecutePciCfg2ReadWrite (
   UINT64      Data;\r
   EFI_STATUS  Status;\r
   EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE PciCfg2ReadWrite;\r
+\r
+  Data = 0;\r
+\r
   CopyMem ((VOID*)&PciCfg2ReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));\r
 \r
-  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%04x, 0x%08x, 0x%016lx, 0x%016lx\n", PciCfg2ReadWrite.Segment, PCI_ADDRESS_ENCODE (PciCfg2ReadWrite.Address), AndMask, OrMask));\r
-  \r
+  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2ReadWrite.Segment, PciCfg2ReadWrite.Address), AndMask, OrMask));\r
+\r
   Status = ScriptPciCfg2Read (\r
              (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,\r
              PciCfg2ReadWrite.Segment,\r
@@ -1588,20 +1471,20 @@ BootScriptExecutePciCfg2ReadWrite (
 }\r
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_POLL OP code.\r
-  \r
+\r
   @param     Script                     The pointer of S3 boot script\r
   @param     AndMask                    Mask value for 'and' operation\r
   @param     OrMask                     Mask value for 'or' operation\r
 \r
   @retval    EFI_SUCCESS                The operation was executed successfully\r
-  @retval    EFI_DEVICE_ERROR           Data polled from Pci configuration space does not equal to \r
+  @retval    EFI_DEVICE_ERROR           Data polled from Pci configuration space does not equal to\r
                                         epecting data within the Loop Times.\r
 **/\r
 EFI_STATUS\r
 BootScriptPciCfgPoll (\r
   IN UINT8                         *Script,\r
   IN UINT64                        AndMask,\r
-  IN UINT64                        OrMask  \r
+  IN UINT64                        OrMask\r
   )\r
 {\r
   UINT64        Data;\r
@@ -1610,8 +1493,8 @@ BootScriptPciCfgPoll (
   EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll;\r
   CopyMem ((VOID*)&PciCfgPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));\r
 \r
-  DEBUG ((EFI_D_INFO, "BootScriptPciCfgPoll - 0x%08x, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfgPoll.Address), AndMask, OrMask));\r
-  \r
+  DEBUG ((EFI_D_INFO, "BootScriptPciCfgPoll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgPoll.Address), AndMask, OrMask));\r
+\r
   Data = 0;\r
   Status = ScriptPciCfgRead (\r
              (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,\r
@@ -1647,13 +1530,13 @@ BootScriptPciCfgPoll (
 \r
 /**\r
   Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL OP code.\r
-  \r
+\r
   @param     Script                     The pointer of S3 Boot Script\r
   @param     AndMask                    Mask value for 'and' operation\r
   @param     OrMask                     Mask value for 'or' operation\r
 \r
   @retval    EFI_SUCCESS                The operation was executed successfully\r
-  @retval    EFI_DEVICE_ERROR           Data polled from Pci configuration space does not equal to \r
+  @retval    EFI_DEVICE_ERROR           Data polled from Pci configuration space does not equal to\r
                                         epecting data within the Loop Times.\r
 \r
 **/\r
@@ -1661,7 +1544,7 @@ EFI_STATUS
 BootScriptPciCfg2Poll (\r
   IN UINT8                        *Script,\r
   IN UINT64                        AndMask,\r
-  IN UINT64                        OrMask  \r
+  IN UINT64                        OrMask\r
   )\r
 {\r
   EFI_STATUS    Status;\r
@@ -1672,8 +1555,8 @@ BootScriptPciCfg2Poll (
   Data = 0;\r
   CopyMem ((VOID*)&PciCfg2Poll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));\r
 \r
-  DEBUG ((EFI_D_INFO, "BootScriptPciCfg2Poll - 0x%04x, 0x%08x, 0x%016lx, 0x%016lx\n", PciCfg2Poll.Segment, PCI_ADDRESS_ENCODE (PciCfg2Poll.Address), AndMask, OrMask));\r
\r
+  DEBUG ((EFI_D_INFO, "BootScriptPciCfg2Poll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2Poll.Segment, PciCfg2Poll.Address), AndMask, OrMask));\r
+\r
   Status = ScriptPciCfg2Read (\r
              (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,\r
              PciCfg2Poll.Segment,\r
@@ -1691,7 +1574,7 @@ BootScriptPciCfg2Poll (
     Data = 0;\r
     Status = ScriptPciCfg2Read (\r
                (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,\r
-               PciCfg2Poll.Segment,               \r
+               PciCfg2Poll.Segment,\r
                PciCfg2Poll.Address,\r
                1,\r
                &Data\r
@@ -1706,18 +1589,15 @@ BootScriptPciCfg2Poll (
   } else {\r
     return EFI_DEVICE_ERROR;\r
   }\r
-  \r
+\r
 }\r
 \r
 /**\r
   Executes the S3 boot script table.\r
\r
+\r
   @retval RETURN_SUCCESS           The boot script table was executed successfully.\r
-  @retval RETURN_UNSUPPORTED       Invalid script table or opcode.  \r
-  \r
-  @note  A known Limitations in the implementation: When interpreting the opcode  EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE\r
-         EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE and EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE, the 'Segment' parameter is assumed as \r
-         Zero, or else, assert.\r
+  @retval RETURN_UNSUPPORTED       Invalid script table or opcode.\r
+\r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
@@ -1734,7 +1614,7 @@ S3BootScriptExecute (
   EFI_BOOT_SCRIPT_COMMON_HEADER  ScriptHeader;\r
   EFI_BOOT_SCRIPT_TABLE_HEADER   TableHeader;\r
   Script = mS3BootScriptTablePtr->TableBase;\r
-  if (Script != 0) {    \r
+  if (Script != 0) {\r
     CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));\r
   } else {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1746,7 +1626,7 @@ S3BootScriptExecute (
   }\r
 \r
   DEBUG ((EFI_D_INFO, "TableHeader - 0x%08x\n", Script));\r
-  \r
+\r
   StartAddress  = (UINTN) Script;\r
   TableLength   = TableHeader.TableLength;\r
   Script    =    Script + TableHeader.Length;\r
@@ -1754,11 +1634,12 @@ S3BootScriptExecute (
   AndMask       = 0;\r
   OrMask        = 0;\r
 \r
+  DEBUG ((EFI_D_INFO, "TableHeader.Version - 0x%04x\n", (UINTN)TableHeader.Version));\r
   DEBUG ((EFI_D_INFO, "TableHeader.TableLength - 0x%08x\n", (UINTN)TableLength));\r
 \r
   while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {\r
     DEBUG ((EFI_D_INFO, "ExecuteBootScript - %08x\n", (UINTN)Script));\r
-    \r
+\r
     CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));\r
     switch (ScriptHeader.OpCode) {\r
 \r
@@ -1823,7 +1704,7 @@ S3BootScriptExecute (
     case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:\r
       DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_INFORMATION_OPCODE\n"));\r
       BootScriptExecuteInformation (Script);\r
-      break;    \r
+      break;\r
 \r
     case S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE:\r
       DEBUG ((EFI_D_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n"));\r
@@ -1854,21 +1735,21 @@ S3BootScriptExecute (
       DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_MEM_POLL_OPCODE\n"));\r
       CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);\r
       Status = BootScriptExecuteMemPoll (Script, AndMask, OrMask);\r
-      \r
+\r
       break;\r
-    \r
+\r
     case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:\r
       DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_IO_POLL_OPCODE\n"));\r
       CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);\r
       Status = BootScriptExecuteIoPoll (Script, AndMask, OrMask);\r
       break;\r
-      \r
+\r
     case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:\r
       DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE\n"));\r
       CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);\r
       Status = BootScriptPciCfgPoll (Script, AndMask, OrMask);\r
       break;\r
-      \r
+\r
     case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:\r
      DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE\n"));\r
      CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);\r