]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / S3SaveStateDxe / S3SaveState.c
index ddf856ec489a60ae317dcb4ed049066fe3b67753..274f3be12c753f59481980bc76def082990b8e9d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation for S3 Boot Script Saver state driver.\r
 \r
 /** @file\r
   Implementation for S3 Boot Script Saver state driver.\r
 \r
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2018, 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
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -46,7 +46,7 @@ BootScriptWriteIoWrite (
   Address     = VA_ARG (Marker, UINT64);\r
   Count       = VA_ARG (Marker, UINTN);\r
   Buffer      = VA_ARG (Marker, UINT8 *);\r
   Address     = VA_ARG (Marker, UINT64);\r
   Count       = VA_ARG (Marker, UINTN);\r
   Buffer      = VA_ARG (Marker, UINT8 *);\r
-  \r
+\r
   return S3BootScriptSaveIoWrite (Width, Address, Count, Buffer);\r
 }\r
 /**\r
   return S3BootScriptSaveIoWrite (Width, Address, Count, Buffer);\r
 }\r
 /**\r
@@ -68,12 +68,12 @@ BootScriptWriteIoReadWrite (
   UINT64                Address;\r
   UINT8                 *Data;\r
   UINT8                 *DataMask;\r
   UINT64                Address;\r
   UINT8                 *Data;\r
   UINT8                 *DataMask;\r
\r
+\r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
   Address     = VA_ARG (Marker, UINT64);\r
   Data        = VA_ARG (Marker, UINT8 *);\r
   DataMask    = VA_ARG (Marker, UINT8 *);\r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
   Address     = VA_ARG (Marker, UINT64);\r
   Data        = VA_ARG (Marker, UINT8 *);\r
   DataMask    = VA_ARG (Marker, UINT8 *);\r
-  \r
+\r
   return S3BootScriptSaveIoReadWrite (Width, Address, Data, DataMask);\r
 }\r
 \r
   return S3BootScriptSaveIoReadWrite (Width, Address, Data, DataMask);\r
 }\r
 \r
@@ -96,7 +96,7 @@ BootScriptWriteMemWrite (
   UINT64                Address;\r
   UINTN                 Count;\r
   UINT8                 *Buffer;\r
   UINT64                Address;\r
   UINTN                 Count;\r
   UINT8                 *Buffer;\r
\r
+\r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
   Address     = VA_ARG (Marker, UINT64);\r
   Count       = VA_ARG (Marker, UINTN);\r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
   Address     = VA_ARG (Marker, UINT64);\r
   Count       = VA_ARG (Marker, UINTN);\r
@@ -124,7 +124,7 @@ BootScriptWriteMemReadWrite (
   UINT64                Address;\r
   UINT8                 *Data;\r
   UINT8                 *DataMask;\r
   UINT64                Address;\r
   UINT8                 *Data;\r
   UINT8                 *DataMask;\r
-  \r
+\r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
   Address     = VA_ARG (Marker, UINT64);\r
   Data        = VA_ARG (Marker, UINT8 *);\r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
   Address     = VA_ARG (Marker, UINT64);\r
   Data        = VA_ARG (Marker, UINT8 *);\r
@@ -210,10 +210,10 @@ BootScriptWritePciCfg2Write (
   UINT16                Segment;\r
 \r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
   UINT16                Segment;\r
 \r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
+  Segment     = VA_ARG (Marker, UINT16);\r
   Address     = VA_ARG (Marker, UINT64);\r
   Count       = VA_ARG (Marker, UINTN);\r
   Buffer      = VA_ARG (Marker, UINT8 *);\r
   Address     = VA_ARG (Marker, UINT64);\r
   Count       = VA_ARG (Marker, UINTN);\r
   Buffer      = VA_ARG (Marker, UINT8 *);\r
-  Segment     = VA_ARG (Marker, UINT16);\r
 \r
   return S3BootScriptSavePciCfg2Write (Width, Segment, Address, Count, Buffer);\r
 }\r
 \r
   return S3BootScriptSavePciCfg2Write (Width, Segment, Address, Count, Buffer);\r
 }\r
@@ -238,17 +238,17 @@ BootScriptWritePciCfg2ReadWrite (
   UINT64                Address;\r
   UINT8                 *Data;\r
   UINT8                 *DataMask;\r
   UINT64                Address;\r
   UINT8                 *Data;\r
   UINT8                 *DataMask;\r
\r
+\r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
   Width       = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
-  Address     = VA_ARG (Marker, UINT64);\r
   Segment     = VA_ARG (Marker, UINT16);\r
   Segment     = VA_ARG (Marker, UINT16);\r
+  Address     = VA_ARG (Marker, UINT64);\r
   Data        = VA_ARG (Marker, UINT8 *);\r
   DataMask    = VA_ARG (Marker, UINT8 *);\r
   Data        = VA_ARG (Marker, UINT8 *);\r
   DataMask    = VA_ARG (Marker, UINT8 *);\r
\r
+\r
   return S3BootScriptSavePciCfg2ReadWrite (Width, Segment, Address, Data, DataMask);\r
 }\r
 /**\r
   return S3BootScriptSavePciCfg2ReadWrite (Width, Segment, Address, Data, DataMask);\r
 }\r
 /**\r
-  Internal function to add smbus excute opcode to the table.\r
+  Internal function to add smbus execute opcode to the table.\r
 \r
   @param  Marker                The variable argument list to get the opcode\r
                                 and associated attributes.\r
 \r
   @param  Marker                The variable argument list to get the opcode\r
                                 and associated attributes.\r
@@ -269,15 +269,15 @@ BootScriptWriteSmbusExecute (
   VOID                     *Buffer;\r
   UINTN                    *DataSize;\r
   UINTN                     SmBusAddress;\r
   VOID                     *Buffer;\r
   UINTN                    *DataSize;\r
   UINTN                     SmBusAddress;\r
-  \r
+\r
   SlaveAddress.SmbusDeviceAddress = VA_ARG (Marker, UINTN);\r
   Command                         = VA_ARG (Marker, EFI_SMBUS_DEVICE_COMMAND);\r
   Operation                       = VA_ARG (Marker, EFI_SMBUS_OPERATION);\r
   PecCheck                        = VA_ARG (Marker, BOOLEAN);\r
   SmBusAddress                    = SMBUS_LIB_ADDRESS (SlaveAddress.SmbusDeviceAddress,Command,0,PecCheck);\r
   SlaveAddress.SmbusDeviceAddress = VA_ARG (Marker, UINTN);\r
   Command                         = VA_ARG (Marker, EFI_SMBUS_DEVICE_COMMAND);\r
   Operation                       = VA_ARG (Marker, EFI_SMBUS_OPERATION);\r
   PecCheck                        = VA_ARG (Marker, BOOLEAN);\r
   SmBusAddress                    = SMBUS_LIB_ADDRESS (SlaveAddress.SmbusDeviceAddress,Command,0,PecCheck);\r
-  DataSize                        = VA_ARG (Marker, UINTN *);    \r
+  DataSize                        = VA_ARG (Marker, UINTN *);\r
   Buffer                          = VA_ARG (Marker, VOID *);\r
   Buffer                          = VA_ARG (Marker, VOID *);\r
\r
+\r
   return S3BootScriptSaveSmbusExecute (SmBusAddress, Operation, DataSize, Buffer);\r
 }\r
 /**\r
   return S3BootScriptSaveSmbusExecute (SmBusAddress, Operation, DataSize, Buffer);\r
 }\r
 /**\r
@@ -303,7 +303,7 @@ BootScriptWriteStall (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Internal function to add Save jmp address according to DISPATCH_OPCODE. \r
+  Internal function to add Save jmp address according to DISPATCH_OPCODE.\r
   We ignore "Context" parameter\r
 \r
   @param  Marker                The variable argument list to get the opcode\r
   We ignore "Context" parameter\r
 \r
   @param  Marker                The variable argument list to get the opcode\r
@@ -325,8 +325,8 @@ BootScriptWriteDispatch (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Internal function to add memory pool operation to the table. \r
\r
+  Internal function to add memory pool operation to the table.\r
+\r
   @param  Marker                The variable argument list to get the opcode\r
                                 and associated attributes.\r
 \r
   @param  Marker                The variable argument list to get the opcode\r
                                 and associated attributes.\r
 \r
@@ -339,19 +339,19 @@ BootScriptWriteMemPoll (
   IN VA_LIST                       Marker\r
   )\r
 {\r
   IN VA_LIST                       Marker\r
   )\r
 {\r
-  S3_BOOT_SCRIPT_LIB_WIDTH   Width;                                    \r
-  UINT64                     Address;                                    \r
-  VOID                      *Data;                                    \r
-  VOID                      *DataMask;                                  \r
-  UINTN                     Delay;                                   \r
-  UINT                    LoopTimes;\r
+  S3_BOOT_SCRIPT_LIB_WIDTH   Width;\r
+  UINT64                     Address;\r
+  VOID                      *Data;\r
+  VOID                      *DataMask;\r
+  UINT64                    Delay;\r
+  UINT64                    LoopTimes;\r
   UINT32                    Remainder;\r
 \r
   UINT32                    Remainder;\r
 \r
-  Width    = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);                  \r
-  Address  = VA_ARG (Marker, UINT64);                                    \r
-  Data     = VA_ARG (Marker, VOID *);                                    \r
-  DataMask = VA_ARG (Marker, VOID *);                                    \r
-  Delay    = (UINTN)VA_ARG (Marker, UINT64);                            \r
+  Width    = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
+  Address  = VA_ARG (Marker, UINT64);\r
+  Data     = VA_ARG (Marker, VOID *);\r
+  DataMask = VA_ARG (Marker, VOID *);\r
+  Delay    = VA_ARG (Marker, UINT64);\r
   //\r
   // According to the spec, the interval between 2 polls is 100ns,\r
   // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).\r
   //\r
   // According to the spec, the interval between 2 polls is 100ns,\r
   // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).\r
@@ -359,7 +359,7 @@ BootScriptWriteMemPoll (
   // Duration will be minimum 1(microsecond) to be minimum deviation,\r
   // so LoopTimes = Delay / 10.\r
   //\r
   // Duration will be minimum 1(microsecond) to be minimum deviation,\r
   // so LoopTimes = Delay / 10.\r
   //\r
-  LoopTimes = (UINTN) DivU64x32Remainder (\r
+  LoopTimes = DivU64x32Remainder (\r
                 Delay,\r
                 10,\r
                 &Remainder\r
                 Delay,\r
                 10,\r
                 &Remainder\r
@@ -375,7 +375,7 @@ BootScriptWriteMemPoll (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Internal function to add Save jmp address according to DISPATCH_OPCODE2. \r
+  Internal function to add Save jmp address according to DISPATCH_OPCODE2.\r
   The "Context" parameter is not ignored.\r
 \r
   @param  Marker                The variable argument list to get the opcode\r
   The "Context" parameter is not ignored.\r
 \r
   @param  Marker                The variable argument list to get the opcode\r
@@ -391,7 +391,7 @@ BootScriptWriteDispatch2 (
   )\r
 {\r
   VOID                  *EntryPoint;\r
   )\r
 {\r
   VOID                  *EntryPoint;\r
-  VOID                  *Context;  \r
+  VOID                  *Context;\r
 \r
   EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
   Context    = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
 \r
   EntryPoint = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
   Context    = (VOID*)(UINTN)VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
@@ -414,7 +414,7 @@ BootScriptWriteInformation (
   )\r
 {\r
   UINT32                InformationLength;\r
   )\r
 {\r
   UINT32                InformationLength;\r
-  EFI_PHYSICAL_ADDRESS  Information;  \r
+  EFI_PHYSICAL_ADDRESS  Information;\r
 \r
   InformationLength = VA_ARG (Marker, UINT32);\r
   Information = VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
 \r
   InformationLength = VA_ARG (Marker, UINT32);\r
   Information = VA_ARG (Marker, EFI_PHYSICAL_ADDRESS);\r
@@ -435,17 +435,17 @@ BootScriptWriteIoPoll (
   )\r
 {\r
    S3_BOOT_SCRIPT_LIB_WIDTH     Width;\r
   )\r
 {\r
    S3_BOOT_SCRIPT_LIB_WIDTH     Width;\r
-   UINT64                     Address;    \r
-   VOID                      *Data;    \r
-   VOID                      *DataMask;   \r
-   UINT64                     Delay;   \r
-   \r
-   Width    = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);  \r
-   Address  = VA_ARG (Marker, UINT64);                    \r
-   Data     = VA_ARG (Marker, VOID *);                   \r
-   DataMask = VA_ARG (Marker, VOID *);                   \r
-   Delay    = (UINT64)VA_ARG (Marker, UINT64);             \r
-   \r
+   UINT64                     Address;\r
+   VOID                      *Data;\r
+   VOID                      *DataMask;\r
+   UINT64                     Delay;\r
+\r
+   Width    = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
+   Address  = VA_ARG (Marker, UINT64);\r
+   Data     = VA_ARG (Marker, VOID *);\r
+   DataMask = VA_ARG (Marker, VOID *);\r
+   Delay    = (UINT64)VA_ARG (Marker, UINT64);\r
+\r
    return S3BootScriptSaveIoPoll (Width, Address, Data, DataMask, Delay);\r
 }\r
 /**\r
    return S3BootScriptSaveIoPoll (Width, Address, Data, DataMask, Delay);\r
 }\r
 /**\r
@@ -469,13 +469,13 @@ BootScriptWritePciConfigPoll (
    VOID                      *DataMask;\r
    UINT64                     Delay;\r
 \r
    VOID                      *DataMask;\r
    UINT64                     Delay;\r
 \r
-   \r
-   Width    = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);  \r
-   Address  = VA_ARG (Marker, UINT64);                    \r
-   Data     = VA_ARG (Marker, VOID *);                   \r
-   DataMask = VA_ARG (Marker, VOID *);                   \r
-   Delay    = (UINT64)VA_ARG (Marker, UINT64);             \r
-   \r
+\r
+   Width    = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
+   Address  = VA_ARG (Marker, UINT64);\r
+   Data     = VA_ARG (Marker, VOID *);\r
+   DataMask = VA_ARG (Marker, VOID *);\r
+   Delay    = (UINT64)VA_ARG (Marker, UINT64);\r
+\r
    return S3BootScriptSavePciPoll (Width, Address, Data, DataMask, Delay);\r
 }\r
 /**\r
    return S3BootScriptSavePciPoll (Width, Address, Data, DataMask, Delay);\r
 }\r
 /**\r
@@ -499,14 +499,14 @@ BootScriptWritePciConfig2Poll (
    VOID                         *Data;\r
    VOID                         *DataMask;\r
    UINT64                        Delay;\r
    VOID                         *Data;\r
    VOID                         *DataMask;\r
    UINT64                        Delay;\r
-  \r
-   Width    = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);  \r
-   Segment  = VA_ARG (Marker, UINT16);      \r
-   Address  = VA_ARG (Marker, UINT64);                    \r
-   Data     = VA_ARG (Marker, VOID *);                   \r
-   DataMask = VA_ARG (Marker, VOID *);                   \r
-   Delay    = (UINT64)VA_ARG (Marker, UINT64);             \r
-   \r
+\r
+   Width    = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);\r
+   Segment  = VA_ARG (Marker, UINT16);\r
+   Address  = VA_ARG (Marker, UINT64);\r
+   Data     = VA_ARG (Marker, VOID *);\r
+   DataMask = VA_ARG (Marker, VOID *);\r
+   Delay    = (UINT64)VA_ARG (Marker, UINT64);\r
+\r
    return S3BootScriptSavePci2Poll (Width, Segment, Address, Data, DataMask, Delay);\r
 }\r
 \r
    return S3BootScriptSavePci2Poll (Width, Segment, Address, Data, DataMask, Delay);\r
 }\r
 \r
@@ -515,25 +515,25 @@ BootScriptWritePciConfig2Poll (
   Adds a record into S3 boot script table.\r
 \r
   This function is used to store a boot script record into a given boot\r
   Adds a record into S3 boot script table.\r
 \r
   This function is used to store a boot script record into a given boot\r
-  script table. If the table specified by TableName is nonexistent in the \r
-  system, a new table will automatically be created and then the script record \r
-  will be added into the new table. This function is responsible for allocating \r
+  script table. If the table specified by TableName is nonexistent in the\r
+  system, a new table will automatically be created and then the script record\r
+  will be added into the new table. This function is responsible for allocating\r
   necessary memory for the script.\r
 \r
   necessary memory for the script.\r
 \r
-  This function has a variable parameter list. The exact parameter list depends on \r
-  the OpCode that is passed into the function. If an unsupported OpCode or illegal \r
+  This function has a variable parameter list. The exact parameter list depends on\r
+  the OpCode that is passed into the function. If an unsupported OpCode or illegal\r
   parameter list is passed in, this function returns EFI_INVALID_PARAMETER.\r
   If there are not enough resources available for storing more scripts, this function returns\r
   EFI_OUT_OF_RESOURCES.\r
 \r
   @param  This                  A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.\r
   @param  OpCode                The operation code (opcode) number.\r
   parameter list is passed in, this function returns EFI_INVALID_PARAMETER.\r
   If there are not enough resources available for storing more scripts, this function returns\r
   EFI_OUT_OF_RESOURCES.\r
 \r
   @param  This                  A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.\r
   @param  OpCode                The operation code (opcode) number.\r
-  @param  ...                   Argument list that is specific to each opcode. \r
-                                \r
+  @param  ...                   Argument list that is specific to each opcode.\r
+\r
   @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
   @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
                                 Feature Flags.\r
   @retval EFI_OUT_OF_RESOURCES  There is insufficient memory to store the boot script.\r
 \r
@@ -547,7 +547,7 @@ BootScriptWrite (
   )\r
 {\r
   EFI_STATUS                Status;\r
   )\r
 {\r
   EFI_STATUS                Status;\r
-  VA_LIST                   Marker;  \r
+  VA_LIST                   Marker;\r
   //\r
   // Build script according to opcode\r
   //\r
   //\r
   // Build script according to opcode\r
   //\r
@@ -568,7 +568,7 @@ BootScriptWrite (
   case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteMemWrite (Marker);\r
   case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteMemWrite (Marker);\r
-    VA_END (Marker); \r
+    VA_END (Marker);\r
     break;\r
 \r
   case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:\r
     break;\r
 \r
   case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:\r
@@ -599,7 +599,7 @@ BootScriptWrite (
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteStall (Marker);\r
     VA_END (Marker);\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteStall (Marker);\r
     VA_END (Marker);\r
-  \r
+\r
     break;\r
 \r
   case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:\r
     break;\r
 \r
   case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:\r
@@ -638,23 +638,23 @@ BootScriptWrite (
     VA_END (Marker);\r
     break;\r
 \r
     VA_END (Marker);\r
     break;\r
 \r
-  case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:  \r
+  case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteIoPoll (Marker);\r
     VA_END (Marker);\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteIoPoll (Marker);\r
     VA_END (Marker);\r
-    break;    \r
-  \r
-  case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE: \r
+    break;\r
+\r
+  case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWritePciConfigPoll (Marker);\r
     VA_END (Marker);\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWritePciConfigPoll (Marker);\r
     VA_END (Marker);\r
-    break;    \r
-  \r
+    break;\r
+\r
   case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWritePciConfig2Poll (Marker);\r
     VA_END (Marker);\r
   case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWritePciConfig2Poll (Marker);\r
     VA_END (Marker);\r
-    break;    \r
+    break;\r
 \r
   default:\r
     Status = EFI_INVALID_PARAMETER;\r
 \r
   default:\r
     Status = EFI_INVALID_PARAMETER;\r
@@ -683,7 +683,7 @@ BootScriptWrite (
                                 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies\r
                                 the position of the inserted opcode in the boot script table.\r
   @param  OpCode                The operation code (opcode) number.\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
   @param  OpCode                The operation code (opcode) number.\r
-  @param  ...                   Argument list that is specific to each opcode. \r
+  @param  ...                   Argument list that is specific to each opcode.\r
 \r
   @retval EFI_SUCCESS           The operation succeeded. A record was added into the\r
                                 specified script table.\r
 \r
   @retval EFI_SUCCESS           The operation succeeded. A record was added into the\r
                                 specified script table.\r
@@ -702,7 +702,7 @@ BootScriptInsert (
   )\r
 {\r
   EFI_STATUS                Status;\r
   )\r
 {\r
   EFI_STATUS                Status;\r
-  VA_LIST                   Marker;  \r
+  VA_LIST                   Marker;\r
   //\r
   // Build script according to opcode\r
   //\r
   //\r
   // Build script according to opcode\r
   //\r
@@ -723,7 +723,7 @@ BootScriptInsert (
   case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteMemWrite (Marker);\r
   case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteMemWrite (Marker);\r
-    VA_END (Marker); \r
+    VA_END (Marker);\r
     break;\r
 \r
   case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:\r
     break;\r
 \r
   case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:\r
@@ -754,7 +754,7 @@ BootScriptInsert (
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteStall (Marker);\r
     VA_END (Marker);\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteStall (Marker);\r
     VA_END (Marker);\r
-  \r
+\r
     break;\r
 \r
   case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:\r
     break;\r
 \r
   case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:\r
@@ -792,30 +792,30 @@ BootScriptInsert (
     Status = BootScriptWritePciCfg2ReadWrite (Marker);\r
     VA_END (Marker);\r
     break;\r
     Status = BootScriptWritePciCfg2ReadWrite (Marker);\r
     VA_END (Marker);\r
     break;\r
-    \r
-  case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:  \r
+\r
+  case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteIoPoll (Marker);\r
     VA_END (Marker);\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWriteIoPoll (Marker);\r
     VA_END (Marker);\r
-    break;    \r
-  \r
-  case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE: \r
+    break;\r
+\r
+  case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWritePciConfigPoll (Marker);\r
     VA_END (Marker);\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWritePciConfigPoll (Marker);\r
     VA_END (Marker);\r
-    break;    \r
-  \r
+    break;\r
+\r
   case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWritePciConfig2Poll (Marker);\r
     VA_END (Marker);\r
   case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:\r
     VA_START (Marker, OpCode);\r
     Status = BootScriptWritePciConfig2Poll (Marker);\r
     VA_END (Marker);\r
-    break;    \r
+    break;\r
 \r
   default:\r
     Status = EFI_INVALID_PARAMETER;\r
     break;\r
   }\r
 \r
   default:\r
     Status = EFI_INVALID_PARAMETER;\r
     break;\r
   }\r
-  \r
+\r
   if (!EFI_ERROR (Status)) {\r
    Status = S3BootScriptMoveLastOpcode (BeforeOrAfter, Position);\r
   }\r
   if (!EFI_ERROR (Status)) {\r
    Status = S3BootScriptMoveLastOpcode (BeforeOrAfter, Position);\r
   }\r
@@ -846,7 +846,7 @@ BootScriptInsert (
   @retval EFI_SUCCESS           The label already exists or was inserted.\r
   @retval EFI_INVALID_PARAMETER The Label is NULL or points to an empty string.\r
   @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.\r
   @retval EFI_SUCCESS           The label already exists or was inserted.\r
   @retval EFI_INVALID_PARAMETER The Label is NULL or points to an empty string.\r
   @retval EFI_INVALID_PARAMETER The Position is not a valid position in the boot script table.\r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -858,27 +858,27 @@ BootScriptLabel (
   IN CONST CHAR8                                *Label\r
   )\r
 {\r
   IN CONST CHAR8                                *Label\r
   )\r
 {\r
-       return S3BootScriptLabel (BeforeOrAfter, CreateIfNotFound, Position, Label);\r
+  return S3BootScriptLabel (BeforeOrAfter, CreateIfNotFound, Position, Label);\r
 }\r
 /**\r
   Compare two positions in the boot script table and return their relative position.\r
 }\r
 /**\r
   Compare two positions in the boot script table and return their relative position.\r
-  \r
+\r
   This function compares two positions in the boot script table and returns their relative positions. If\r
   Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,\r
   then 0 is returned. If Position1 is after Position2, then 1 is returned.\r
   This function compares two positions in the boot script table and returns their relative positions. If\r
   Position1 is before Position2, then -1 is returned. If Position1 is equal to Position2,\r
   then 0 is returned. If Position1 is after Position2, then 1 is returned.\r
-  \r
+\r
   @param  This                  A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.\r
   @param  Position1             The positions in the boot script table to compare\r
   @param  Position2             The positions in the boot script table to compare\r
   @param  RelativePosition      On return, points to the result of the comparison\r
 \r
   @param  This                  A pointer to the EFI_S3_SAVE_STATE_PROTOCOL instance.\r
   @param  Position1             The positions in the boot script table to compare\r
   @param  Position2             The positions in the boot script table to compare\r
   @param  RelativePosition      On return, points to the result of the comparison\r
 \r
-  @retval EFI_SUCCESS           The operation succeeded. \r
+  @retval EFI_SUCCESS           The operation succeeded.\r
   @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.\r
   @retval EFI_INVALID_PARAMETER The RelativePosition is NULL.\r
 \r
 **/\r
 EFI_STATUS\r
   @retval EFI_INVALID_PARAMETER The Position1 or Position2 is not a valid position in the boot script table.\r
   @retval EFI_INVALID_PARAMETER The RelativePosition is NULL.\r
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI \r
+EFIAPI\r
 BootScriptCompare (\r
   IN CONST EFI_S3_SAVE_STATE_PROTOCOL      *This,\r
   IN       EFI_S3_BOOT_SCRIPT_POSITION      Position1,\r
 BootScriptCompare (\r
   IN CONST EFI_S3_SAVE_STATE_PROTOCOL      *This,\r
   IN       EFI_S3_BOOT_SCRIPT_POSITION      Position1,\r
@@ -886,7 +886,7 @@ BootScriptCompare (
   OUT      UINTN                           *RelativePosition\r
   )\r
 {\r
   OUT      UINTN                           *RelativePosition\r
   )\r
 {\r
-       return S3BootScriptCompare (Position1, Position2, RelativePosition);\r
+  return S3BootScriptCompare (Position1, Position2, RelativePosition);\r
 }\r
 /**\r
   This routine is entry point of ScriptSave driver.\r
 }\r
 /**\r
   This routine is entry point of ScriptSave driver.\r
@@ -906,11 +906,23 @@ InitializeS3SaveState (
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
 {\r
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
 {\r
+  EFI_STATUS    Status;\r
+  EFI_EVENT     EndOfDxeEvent;\r
 \r
   if (!PcdGetBool (PcdAcpiS3Enable)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
 \r
   if (!PcdGetBool (PcdAcpiS3Enable)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  AcpiS3ContextSaveOnEndOfDxe,\r
+                  NULL,\r
+                  &gEfiEndOfDxeEventGroupGuid,\r
+                  &EndOfDxeEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   return  gBS->InstallProtocolInterface (\r
                   &mHandle,\r
                   &gEfiS3SaveStateProtocolGuid,\r
   return  gBS->InstallProtocolInterface (\r
                   &mHandle,\r
                   &gEfiS3SaveStateProtocolGuid,\r