]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
MdeModulePkg/Universal: Fix typos in comments
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / SmmS3SaveState / SmmS3SaveState.c
index 9879143e4b4df54effe82a61a7d2c75a80b4d46e..739f19eac437445c743544a228566795552f154f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation for S3 SMM Boot Script Saver state driver.\r
 \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 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
@@ -247,7 +247,7 @@ BootScriptWritePciCfg2ReadWrite (
   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
@@ -343,16 +343,33 @@ BootScriptWriteMemPoll (
   VOID                      *Data;                                       \r
   VOID                      *DataMask;                                   \r
   UINTN                      Delay;                                       \r
-                                                                         \r
+  UINTN                      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
   //\r
-  // According to the spec, the interval between 2 pools is 100ns\r
-  //                                                                       \r
-  return S3BootScriptSaveMemPoll (Width, Address, DataMask, Data, 100, Delay); \r
+  // According to the spec, the interval between 2 polls is 100ns,\r
+  // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).\r
+  // Duration * 1000ns * LoopTimes = Delay * 100ns\r
+  // Duration will be minimum 1(microsecond) to be minimum deviation,\r
+  // so LoopTimes = Delay / 10.\r
+  //\r
+  LoopTimes = (UINTN) DivU64x32Remainder (\r
+                Delay,\r
+                10,\r
+                &Remainder\r
+                );\r
+  if (Remainder != 0) {\r
+    //\r
+    // If Remainder is not zero, LoopTimes will be rounded up by 1.\r
+    //\r
+    LoopTimes +=1;\r
+  }\r
+  return S3BootScriptSaveMemPoll (Width, Address, DataMask, Data, 1, LoopTimes); \r
 \r
 }\r
 \r
@@ -825,7 +842,8 @@ BootScriptInsert (
   @param  Label                 Points to the label which will be inserted in the boot script table.\r
 \r
   @retval EFI_SUCCESS           The label already exists or was inserted.\r
-  @retval EFI_INVALID_PARAMETER The Opcode is an invalid opcode value or the Position is not a valid position in the boot script table..\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
 EFI_STATUS\r
@@ -854,6 +872,7 @@ BootScriptLabel (
 \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
@@ -886,7 +905,10 @@ InitializeSmmS3SaveState (
   )\r
 {\r
   EFI_HANDLE   Handle;\r
-  \r
+\r
+  if (!PcdGetBool (PcdAcpiS3Enable)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
 \r
   Handle  = NULL;\r
   return  gSmst->SmmInstallProtocolInterface (\r