summaryrefslogtreecommitdiff
path: root/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
diff options
context:
space:
mode:
authorJeff Fan <jeff.fan@intel.com>2016-07-20 22:47:47 +0800
committerJeff Fan <jeff.fan@intel.com>2016-08-17 19:58:56 +0800
commit7615702169b838f9341c312739d29f0795ebd998 (patch)
treeb4a0a7bbd6e822d31422a9dee38a4181e902bc6d /UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
parent5c66d125eaae51945c0a14ef6d5d3fa2ce7d7a66 (diff)
downloadedk2-platforms-7615702169b838f9341c312739d29f0795ebd998.tar.xz
UefiCpuPkg/MpInitLib: Add AsmRelocateApLoop() assembly code
AsmRelocateApLoop() is used to place APs into MWAIT-loop if MonitorMwait feature is supported before hand-off to OS, or place APs into HLT-loop if MonitorMwait feature is not supported. If the current mode is long mode, we will switch APs to protected mode before placing APs in MWAIT-loop or HLT-loop. Thus, once APs wakeup from loop, APs needn't the page table that may be crashed by OS. v3: 1. Rename AsmRellocateApLoop to AsmRelocateApLoop. 2. Fix typo Proteced to Protected. 3. Fix typo segement to segment 4. Use word MONITOR instead of mwait-monitor. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
Diffstat (limited to 'UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm')
-rw-r--r--UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm24
1 files changed, 24 insertions, 0 deletions
diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
index 8bacb42836..49f5503530 100644
--- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
@@ -169,6 +169,30 @@ CProcedureInvoke:
RendezvousFunnelProcEnd:
;-------------------------------------------------------------------------------------
+; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment);
+;-------------------------------------------------------------------------------------
+global ASM_PFX(AsmRelocateApLoop)
+ASM_PFX(AsmRelocateApLoop):
+AsmRelocateApLoopStart:
+ cmp byte [esp + 4], 1
+ jnz HltLoop
+MwaitLoop:
+ mov eax, esp
+ xor ecx, ecx
+ xor edx, edx
+ monitor
+ mov eax, [esp + 8] ; Mwait Cx, Target C-State per eax[7:4]
+ shl eax, 4
+ mwait
+ jmp MwaitLoop
+HltLoop:
+ cli
+ hlt
+ jmp HltLoop
+ ret
+AsmRelocateApLoopEnd:
+
+;-------------------------------------------------------------------------------------
; AsmGetAddressMap (&AddressMap);
;-------------------------------------------------------------------------------------
global ASM_PFX(AsmGetAddressMap)