;------------------------------------------------------------------------------ ;\r
-; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
; This program and the accompanying materials\r
; are licensed and made available under the terms and conditions of the BSD License\r
; which accompanies this distribution. The full text of the license may be found at\r
cmp qword [edi], 1 ; ApInitConfig\r
jnz GetApicId\r
\r
+ ; Increment the number of APs executing here as early as possible\r
+ ; This is decremented in C code when AP is finished executing\r
+ mov edi, esi\r
+ add edi, NumApsExecutingLocation\r
+ lock inc dword [edi]\r
+\r
; AP init\r
mov edi, esi\r
add edi, LockLocation\r
cmp rax, NotVacantFlag\r
jz TestLock\r
\r
- lea ecx, [esi + NumApsExecutingLocation]\r
+ lea ecx, [esi + ApIndexLocation]\r
inc dword [ecx]\r
mov ebx, [ecx]\r
\r
push rbp\r
mov rbp, rsp\r
\r
- mov rax, ASM_PFX(InitializeFloatingPointUnits)\r
+ mov rax, qword [esi + InitializeFloatingPointUnitsAddress]\r
sub rsp, 20h\r
call rax ; Call assembly function to initialize FPU per UEFI spec\r
add rsp, 20h\r
\r
- mov edx, ebx ; edx is NumApsExecuting\r
+ mov edx, ebx ; edx is ApIndex\r
mov ecx, esi\r
add ecx, LockLocation ; rcx is address of exchange info data buffer\r
\r
RendezvousFunnelProcEnd:\r
\r
;-------------------------------------------------------------------------------------\r
-; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack);\r
+; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish);\r
;-------------------------------------------------------------------------------------\r
global ASM_PFX(AsmRelocateApLoop)\r
ASM_PFX(AsmRelocateApLoop):\r
AsmRelocateApLoopStart:\r
+ mov rax, [rsp + 40] ; CountTofinish\r
+ lock dec dword [rax] ; (*CountTofinish)--\r
mov rsp, r9\r
push rcx\r
push rdx\r
xor ecx, ecx ; ecx = 0\r
xor edx, edx ; edx = 0\r
monitor\r
- shl ebx, 4\r
mov eax, ebx ; Mwait Cx, Target C-State per eax[7:4]\r
+ shl eax, 4\r
mwait\r
jmp MwaitLoop\r
HltLoop:\r
cli\r
hlt\r
jmp HltLoop\r
- ret\r
BITS 64\r
AsmRelocateApLoopEnd:\r
\r
;-------------------------------------------------------------------------------------\r
global ASM_PFX(AsmGetAddressMap)\r
ASM_PFX(AsmGetAddressMap):\r
- mov rax, ASM_PFX(RendezvousFunnelProc)\r
+ lea rax, [ASM_PFX(RendezvousFunnelProc)]\r
mov qword [rcx], rax\r
mov qword [rcx + 8h], LongModeStart - RendezvousFunnelProcStart\r
mov qword [rcx + 10h], RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r
- mov rax, ASM_PFX(AsmRelocateApLoop)\r
+ lea rax, [ASM_PFX(AsmRelocateApLoop)]\r
mov qword [rcx + 18h], rax\r
mov qword [rcx + 20h], AsmRelocateApLoopEnd - AsmRelocateApLoopStart\r
ret\r