1 ;------------------------------------------------------------------------------
3 ;* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
4 ;* SPDX-License-Identifier: BSD-2-Clause-Patent
10 ;------------------------------------------------------------------------------
17 extern ASM_PFX(SecCoreStartupWithStack)
20 db 0x66, 0x0f, 0x01, 0xcc
26 ; Processor is in flat protected mode
28 ; @param[in] RAX Initial value of the EAX register (BIST: Built-in Self Test)
29 ; @param[in] DI 'BP': boot-strap processor, or 'AP': application processor
30 ; @param[in] RBP Pointer to the start of the Boot Firmware Volume
31 ; @param[in] DS Selector allowing flat access to all addresses
32 ; @param[in] ES Selector allowing flat access to all addresses
33 ; @param[in] FS Selector allowing flat access to all addresses
34 ; @param[in] GS Selector allowing flat access to all addresses
35 ; @param[in] SS Selector allowing flat access to all addresses
37 ; @return None This routine does not return
39 global ASM_PFX(_ModuleEntryPoint)
40 ASM_PFX(_ModuleEntryPoint):
43 ; Guest type is stored in OVMF_WORK_AREA
45 %define OVMF_WORK_AREA FixedPcdGet32 (PcdOvmfWorkAreaBase)
46 %define VM_GUEST_TYPE_TDX 2
47 mov eax, OVMF_WORK_AREA
48 cmp byte[eax], VM_GUEST_TYPE_TDX
51 %define TDCALL_TDINFO 1
52 mov rax, TDCALL_TDINFO
58 ; R9 [31:0] VCPU_INDEX
59 ; Td Guest set the VCPU0 as the BSP, others are the APs
60 ; APs jump to spinloop and get released by DXE's MpInitLib
66 mov rsp, FixedPcdGet32 (PcdOvmfSecGhcbBackupBase)
72 ; Fill the temporary RAM with the initial stack value.
73 ; The loop below will seed the heap as well, but that's harmless.
75 mov rax, (FixedPcdGet32 (PcdInitValueInTempStack) << 32) | FixedPcdGet32 (PcdInitValueInTempStack)
77 mov rdi, FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) ; base address,
80 mov rcx, FixedPcdGet32 (PcdOvmfSecPeiTempRamSize) / 8 ; qword count
86 ; Load temporary RAM stack based on PCDs
88 %define SEC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + \
89 FixedPcdGet32 (PcdOvmfSecPeiTempRamSize))
90 mov rsp, SEC_TOP_OF_STACK
94 ; Setup parameters and call SecCoreStartupWithStack
95 ; rcx: BootFirmwareVolumePtr
96 ; rdx: TopOfCurrentStack
101 call ASM_PFX(SecCoreStartupWithStack)
103 %include "../../IntelTdx/Sec/X64/IntelTdxAPs.nasm"