summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c')
-rw-r--r--MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
index 249fb8ca..60cd9b1b 100644
--- a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
+++ b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
@@ -1,7 +1,7 @@
/** @file
Implementation for S3 Boot Script Saver state driver.
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -344,16 +344,33 @@ BootScriptWriteMemPoll (
VOID *Data;
VOID *DataMask;
UINTN Delay;
-
+ UINTN LoopTimes;
+ UINT32 Remainder;
+
Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH);
Address = VA_ARG (Marker, UINT64);
Data = VA_ARG (Marker, VOID *);
DataMask = VA_ARG (Marker, VOID *);
Delay = (UINTN)VA_ARG (Marker, UINT64);
//
- // According to the spec, the interval between 2 pools is 100ns
- //
- return S3BootScriptSaveMemPoll (Width, Address, DataMask, Data, 100, Delay);
+ // According to the spec, the interval between 2 polls is 100ns,
+ // but the unit of Duration for S3BootScriptSaveMemPoll() is microsecond(1000ns).
+ // Duration * 1000ns * LoopTimes = Delay * 100ns
+ // Duration will be minimum 1(microsecond) to be minimum deviation,
+ // so LoopTimes = Delay / 10.
+ //
+ LoopTimes = (UINTN) DivU64x32Remainder (
+ Delay,
+ 10,
+ &Remainder
+ );
+ if (Remainder != 0) {
+ //
+ // If Remainder is not zero, LoopTimes will be rounded up by 1.
+ //
+ LoopTimes +=1;
+ }
+ return S3BootScriptSaveMemPoll (Width, Address, DataMask, Data, 1, LoopTimes);
}