--- /dev/null
+;------------------------------------------------------------------------------\r
+; @file\r
+; Intel TDX APs\r
+;\r
+; Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.<BR>\r
+; SPDX-License-Identifier: BSD-2-Clause-Patent\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+%include "TdxCommondefs.inc"\r
+\r
+ ;\r
+ ; Note: BSP never gets here. APs will be unblocked by DXE\r
+ ;\r
+ ; R8 [31:0] NUM_VCPUS\r
+ ; [63:32] MAX_VCPUS\r
+ ; R9 [31:0] VCPU_INDEX\r
+ ;\r
+ParkAp:\r
+\r
+do_wait_loop:\r
+ ;\r
+ ; register itself in [rsp + CpuArrivalOffset]\r
+ ;\r
+ mov rax, 1\r
+ lock xadd dword [rsp + CpuArrivalOffset], eax\r
+ inc eax\r
+\r
+.check_arrival_cnt:\r
+ cmp eax, r8d\r
+ je .check_command\r
+ mov eax, dword[rsp + CpuArrivalOffset]\r
+ jmp .check_arrival_cnt\r
+\r
+.check_command:\r
+ mov eax, dword[rsp + CommandOffset]\r
+ cmp eax, MpProtectedModeWakeupCommandNoop\r
+ je .check_command\r
+\r
+ cmp eax, MpProtectedModeWakeupCommandWakeup\r
+ je .do_wakeup\r
+\r
+ ; Don't support this command, so ignore\r
+ jmp .check_command\r
+\r
+.do_wakeup:\r
+ ;\r
+ ; BSP sets these variables before unblocking APs\r
+ ; RAX: WakeupVectorOffset\r
+ ; RBX: Relocated mailbox address\r
+ ; RBP: vCpuId\r
+ ;\r
+ mov rax, 0\r
+ mov eax, dword[rsp + WakeupVectorOffset]\r
+ mov rbx, [rsp + WakeupArgsRelocatedMailBox]\r
+ nop\r
+ jmp rax\r
+ jmp $\r