]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / S3SaveStateDxe / S3SaveState.c
index 32263c96c56be3e7279f6cf5f084ef4b40ed5304..e94d15772d786fbf7beec9d143fd672433759928 100644 (file)
@@ -1,16 +1,9 @@
 /** @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
-  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 "InternalS3SaveState.h"\r
@@ -46,7 +39,7 @@ BootScriptWriteIoWrite (
   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
@@ -68,12 +61,12 @@ BootScriptWriteIoReadWrite (
   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
-  \r
+\r
   return S3BootScriptSaveIoReadWrite (Width, Address, Data, DataMask);\r
 }\r
 \r
@@ -96,7 +89,7 @@ BootScriptWriteMemWrite (
   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
@@ -124,7 +117,7 @@ BootScriptWriteMemReadWrite (
   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
@@ -210,10 +203,10 @@ BootScriptWritePciCfg2Write (
   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
-  Segment     = VA_ARG (Marker, UINT16);\r
 \r
   return S3BootScriptSavePciCfg2Write (Width, Segment, Address, Count, Buffer);\r
 }\r
@@ -238,13 +231,13 @@ BootScriptWritePciCfg2ReadWrite (
   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
   Segment     = VA_ARG (Marker, UINT16);\r
+  Address     = VA_ARG (Marker, UINT64);\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
@@ -269,15 +262,15 @@ BootScriptWriteSmbusExecute (
   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
-  DataSize                        = VA_ARG (Marker, UINTN *);    \r
+  DataSize                        = VA_ARG (Marker, UINTN *);\r
   Buffer                          = VA_ARG (Marker, VOID *);\r
\r
+\r
   return S3BootScriptSaveSmbusExecute (SmBusAddress, Operation, DataSize, Buffer);\r
 }\r
 /**\r
@@ -303,7 +296,7 @@ BootScriptWriteStall (
 }\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
@@ -325,8 +318,8 @@ BootScriptWriteDispatch (
 }\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
@@ -339,19 +332,19 @@ BootScriptWriteMemPoll (
   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
-  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
@@ -359,7 +352,7 @@ BootScriptWriteMemPoll (
   // 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
@@ -375,7 +368,7 @@ BootScriptWriteMemPoll (
 }\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
@@ -391,7 +384,7 @@ BootScriptWriteDispatch2 (
   )\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
@@ -414,7 +407,7 @@ BootScriptWriteInformation (
   )\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
@@ -435,17 +428,17 @@ BootScriptWriteIoPoll (
   )\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
@@ -469,13 +462,13 @@ BootScriptWritePciConfigPoll (
    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
@@ -499,14 +492,14 @@ BootScriptWritePciConfig2Poll (
    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
@@ -515,25 +508,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
-  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
-  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
-  @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
-                                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
@@ -542,12 +535,12 @@ EFI_STATUS
 EFIAPI\r
 BootScriptWrite (\r
   IN CONST EFI_S3_SAVE_STATE_PROTOCOL      *This,\r
-  IN       UINT16                           OpCode,\r
+  IN       UINT                           OpCode,\r
   ...\r
   )\r
 {\r
   EFI_STATUS                Status;\r
-  VA_LIST                   Marker;  \r
+  VA_LIST                   Marker;\r
   //\r
   // Build script according to opcode\r
   //\r
@@ -568,7 +561,7 @@ BootScriptWrite (
   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
@@ -599,7 +592,7 @@ BootScriptWrite (
     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
@@ -638,23 +631,23 @@ BootScriptWrite (
     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
-    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
-    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
-    break;    \r
+    break;\r
 \r
   default:\r
     Status = EFI_INVALID_PARAMETER;\r
@@ -683,7 +676,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
-  @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
@@ -697,12 +690,12 @@ BootScriptInsert (
   IN CONST EFI_S3_SAVE_STATE_PROTOCOL     *This,\r
   IN       BOOLEAN                        BeforeOrAfter,\r
   IN OUT   EFI_S3_BOOT_SCRIPT_POSITION    *Position OPTIONAL,\r
-  IN       UINT16                         OpCode,\r
+  IN       UINT                         OpCode,\r
   ...\r
   )\r
 {\r
   EFI_STATUS                Status;\r
-  VA_LIST                   Marker;  \r
+  VA_LIST                   Marker;\r
   //\r
   // Build script according to opcode\r
   //\r
@@ -723,7 +716,7 @@ BootScriptInsert (
   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
@@ -754,7 +747,7 @@ BootScriptInsert (
     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
@@ -792,30 +785,30 @@ BootScriptInsert (
     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
-    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
-    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
-    break;    \r
+    break;\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
@@ -846,7 +839,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
-  \r
+\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -858,27 +851,27 @@ BootScriptLabel (
   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
   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
-  @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
-EFIAPI \r
+EFIAPI\r
 BootScriptCompare (\r
   IN CONST EFI_S3_SAVE_STATE_PROTOCOL      *This,\r
   IN       EFI_S3_BOOT_SCRIPT_POSITION      Position1,\r
@@ -886,7 +879,7 @@ BootScriptCompare (
   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