]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/ResetVector/Vtf0/Main.asm
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / ResetVector / Vtf0 / 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 ;
40 ; Search for the Boot Firmware Volume (BFV)
41 ;
42 OneTimeCall Flat32SearchForBfvBase
43
44 ;
45 ; EBP - Start of BFV
46 ;
47
48 ;
49 ; Search for the SEC entry point
50 ;
51 OneTimeCall Flat32SearchForSecEntryPoint
52
53 ;
54 ; ESI - SEC Core entry point
55 ; EBP - Start of BFV
56 ;
57
58 %ifdef ARCH_IA32
59
60 ;
61 ; Restore initial EAX value into the EAX register
62 ;
63 mov eax, esp
64
65 ;
66 ; Jump to the 32-bit SEC entry point
67 ;
68 jmp esi
69
70 %else
71
72 ;
73 ; Transition the processor from 32-bit flat mode to 64-bit flat mode
74 ;
75 OneTimeCall Transition32FlatTo64Flat
76
77 BITS 64
78
79 ;
80 ; Some values were calculated in 32-bit mode. Make sure the upper
81 ; 32-bits of 64-bit registers are zero for these values.
82 ;
83 mov rax, 0x00000000ffffffff
84 and rsi, rax
85 and rbp, rax
86 and rsp, rax
87
88 ;
89 ; RSI - SEC Core entry point
90 ; RBP - Start of BFV
91 ;
92
93 ;
94 ; Restore initial EAX value into the RAX register
95 ;
96 mov rax, rsp
97
98 ;
99 ; Jump to the 64-bit SEC entry point
100 ;
101 jmp rsi
102
103 %endif
104
105