/** @file\r
Implementation for S3 SMM Boot Script Saver state driver.\r
\r
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2010 - 2013, 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
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 = 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