From 54e4b37e367fe30765de11da424099b481c2e93a Mon Sep 17 00:00:00 2001 From: jyao1 Date: Wed, 27 Apr 2011 07:35:20 +0000 Subject: Fix 2 BootScript thunk issue on MEM_POLL. 1) MEM_POLL stall time is incorrect. Framework version: Duration is used for Stall(), which is Microseconds. Total time is: Duration(Microseconds) * LoopTimes. PI version: Duration is always 100ns. Delay is LoopTimes. Total time is: 100ns * Delay. So Delay = Duration(Microseconds) * LoopTimes / 100ns = Duration * 1000ns * LoopTimes / 100ns = Duration * 10 * LoopTimes 2) MEM_POLL BitMask/BitValue order is incorrect. Framework version: First BitMask, then BitValue PI version: First Data, then DataMask So we revert their order in function call git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11595 6f19259b-4bc3-4df7-8a09-765794883524 --- .../BootScriptSaveOnS3SaveStateThunk/ScriptSave.c | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk') diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c index 3a3b8c8be5..eb8de8ce6d 100644 --- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c +++ b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c @@ -514,15 +514,29 @@ BootScriptMemPoll ( BitValue = VA_ARG (Marker, UINT8 *); Duration = (UINT64)VA_ARG (Marker, UINT64); LoopTimes = (UINT64)VA_ARG (Marker, UINT64); - Delay = MultU64x64 (DivU64x32(Duration, 100), LoopTimes); + // + // Framework version: Duration is used for Stall(), which is Microseconds. + // Total time is: Duration(Microseconds) * LoopTimes. + // PI version: Duration is always 100ns. Delay is LoopTimes. + // Total time is: 100ns * Delay. + // So Delay = Duration(Microseconds) * LoopTimes / 100ns + // = Duration * 1000ns * LoopTimes / 100ns + // = Duration * 10 * LoopTimes + // + Delay = MultU64x64 (MultU64x32 (Duration, 10), LoopTimes); + // + // Framework version: First BitMask, then BitValue + // PI version: First Data, then DataMask + // So we revert their order in function call + // return mS3SaveState->Write ( mS3SaveState, EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, - Width, - Address, - BitMask, - BitValue, + Width, + Address, + BitValue, + BitMask, Delay ); } -- cgit v1.2.3