]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/ResetVector/Main.asm
OvmfPkg/PlatformInitLib: Implement multi-core accept memory for TDVF
[mirror_edk2.git] / OvmfPkg / ResetVector / Main.asm
1 ;------------------------------------------------------------------------------
2 ; @file
3 ; Main routine of the pre-SEC code up through the jump into SEC
4 ;
5 ; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
6 ; SPDX-License-Identifier: BSD-2-Clause-Patent
7 ;
8 ;------------------------------------------------------------------------------
9
10
11 BITS 16
12
13 ;
14 ; Modified: EBX, ECX, EDX, EBP
15 ;
16 ; @param[in,out] RAX/EAX Initial value of the EAX register
17 ; (BIST: Built-in Self Test)
18 ; @param[in,out] DI 'BP': boot-strap processor, or
19 ; 'AP': application processor
20 ; @param[out] RBP/EBP Address of Boot Firmware Volume (BFV)
21 ; @param[out] DS Selector allowing flat access to all addresses
22 ; @param[out] ES Selector allowing flat access to all addresses
23 ; @param[out] FS Selector allowing flat access to all addresses
24 ; @param[out] GS Selector allowing flat access to all addresses
25 ; @param[out] SS Selector allowing flat access to all addresses
26 ;
27 ; @return None This routine jumps to SEC and does not return
28 ;
29 Main16:
30 OneTimeCall EarlyInit16
31
32 ;
33 ; Transition the processor from 16-bit real mode to 32-bit flat mode
34 ;
35 OneTimeCall TransitionFromReal16To32BitFlat
36
37 BITS 32
38
39 ; Clear the WorkArea header. The SEV probe routines will populate the
40 ; work area when detected.
41 mov byte[WORK_AREA_GUEST_TYPE], 0
42
43 %ifdef ARCH_X64
44
45 jmp SearchBfv
46
47 ;
48 ; Entry point of Main32
49 ;
50 Main32:
51 OneTimeCall InitTdx
52
53 SearchBfv:
54
55 %endif
56
57 ;
58 ; Search for the Boot Firmware Volume (BFV)
59 ;
60 OneTimeCall Flat32SearchForBfvBase
61
62 ;
63 ; EBP - Start of BFV
64 ;
65
66 ;
67 ; Search for the SEC entry point
68 ;
69 OneTimeCall Flat32SearchForSecEntryPoint
70
71 ;
72 ; ESI - SEC Core entry point
73 ; EBP - Start of BFV
74 ;
75
76 %ifdef ARCH_IA32
77
78 ;
79 ; SEV support can be built and run using the Ia32/X64 split environment.
80 ; Set the OVMF/SEV work area as appropriate.
81 ;
82 OneTimeCall CheckSevFeatures
83
84 ;
85 ; Restore initial EAX value into the EAX register
86 ;
87 mov eax, esp
88
89 ;
90 ; Jump to the 32-bit SEC entry point
91 ;
92 jmp esi
93
94 %else
95
96 ;
97 ; Transition the processor from 32-bit flat mode to 64-bit flat mode
98 ;
99 OneTimeCall Transition32FlatTo64Flat
100
101 BITS 64
102
103 ;
104 ; Some values were calculated in 32-bit mode. Make sure the upper
105 ; 32-bits of 64-bit registers are zero for these values.
106 ;
107 mov rax, 0x00000000ffffffff
108 and rsi, rax
109 and rbp, rax
110 and rsp, rax
111
112 ;
113 ; RSI - SEC Core entry point
114 ; RBP - Start of BFV
115 ;
116
117 ;
118 ; Restore initial EAX value into the RAX register
119 ;
120 mov rax, rsp
121
122 ;
123 ; Jump to the 64-bit SEC entry point
124 ;
125 jmp rsi
126
127 %endif