]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/ResetVector/Vtf0/Main.asm
UefiCpuPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / UefiCpuPkg / ResetVector / Vtf0 / Main.asm
CommitLineData
bc252e8e
EB
1;------------------------------------------------------------------------------\r
2; @file\r
3; Main routine of the pre-SEC code up through the jump into SEC\r
4;\r
01a1c0fc 5; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>\r
0acd8697 6; SPDX-License-Identifier: BSD-2-Clause-Patent\r
bc252e8e
EB
7;\r
8;------------------------------------------------------------------------------\r
9\r
10\r
11BITS 16\r
12\r
13;\r
14; Modified: EBX, ECX, EDX, EBP\r
15;\r
16; @param[in,out] RAX/EAX Initial value of the EAX register\r
17; (BIST: Built-in Self Test)\r
18; @param[in,out] DI 'BP': boot-strap processor, or\r
19; 'AP': application processor\r
20; @param[out] RBP/EBP Address of Boot Firmware Volume (BFV)\r
9f75aacc
LE
21; @param[out] DS Selector allowing flat access to all addresses\r
22; @param[out] ES Selector allowing flat access to all addresses\r
23; @param[out] FS Selector allowing flat access to all addresses\r
24; @param[out] GS Selector allowing flat access to all addresses\r
25; @param[out] SS Selector allowing flat access to all addresses\r
bc252e8e
EB
26;\r
27; @return None This routine jumps to SEC and does not return\r
28;\r
29Main16:\r
30 OneTimeCall EarlyInit16\r
31\r
32 ;\r
33 ; Transition the processor from 16-bit real mode to 32-bit flat mode\r
34 ;\r
35 OneTimeCall TransitionFromReal16To32BitFlat\r
36\r
37BITS 32\r
38\r
39 ;\r
40 ; Search for the Boot Firmware Volume (BFV)\r
41 ;\r
42 OneTimeCall Flat32SearchForBfvBase\r
43\r
44 ;\r
45 ; EBP - Start of BFV\r
46 ;\r
47\r
48 ;\r
49 ; Search for the SEC entry point\r
50 ;\r
51 OneTimeCall Flat32SearchForSecEntryPoint\r
52\r
53 ;\r
54 ; ESI - SEC Core entry point\r
55 ; EBP - Start of BFV\r
56 ;\r
57\r
58%ifdef ARCH_IA32\r
59\r
60 ;\r
61 ; Restore initial EAX value into the EAX register\r
62 ;\r
63 mov eax, esp\r
64\r
65 ;\r
66 ; Jump to the 32-bit SEC entry point\r
67 ;\r
68 jmp esi\r
69\r
70%else\r
71\r
72 ;\r
73 ; Transition the processor from 32-bit flat mode to 64-bit flat mode\r
74 ;\r
75 OneTimeCall Transition32FlatTo64Flat\r
76\r
77BITS 64\r
78\r
79 ;\r
80 ; Some values were calculated in 32-bit mode. Make sure the upper\r
81 ; 32-bits of 64-bit registers are zero for these values.\r
82 ;\r
83 mov rax, 0x00000000ffffffff\r
84 and rsi, rax\r
85 and rbp, rax\r
86 and rsp, rax\r
87\r
88 ;\r
89 ; RSI - SEC Core entry point\r
90 ; RBP - Start of BFV\r
91 ;\r
92\r
93 ;\r
94 ; Restore initial EAX value into the RAX register\r
95 ;\r
96 mov rax, rsp\r
97\r
98 ;\r
99 ; Jump to the 64-bit SEC entry point\r
100 ;\r
101 jmp rsi\r
102\r
103%endif\r
104\r
105\r