]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/ResetVector/Vtf0/Main.asm
MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard
[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
HT
5; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>\r
6; This program and the accompanying materials\r
bc252e8e
EB
7; are licensed and made available under the terms and conditions of the BSD License\r
8; which accompanies this distribution. The full text of the license may be found at\r
9; http://opensource.org/licenses/bsd-license.php\r
10;\r
11; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13;\r
14;------------------------------------------------------------------------------\r
15\r
16\r
17BITS 16\r
18\r
19;\r
20; Modified: EBX, ECX, EDX, EBP\r
21;\r
22; @param[in,out] RAX/EAX Initial value of the EAX register\r
23; (BIST: Built-in Self Test)\r
24; @param[in,out] DI 'BP': boot-strap processor, or\r
25; 'AP': application processor\r
26; @param[out] RBP/EBP Address of Boot Firmware Volume (BFV)\r
9f75aacc
LE
27; @param[out] DS Selector allowing flat access to all addresses\r
28; @param[out] ES Selector allowing flat access to all addresses\r
29; @param[out] FS Selector allowing flat access to all addresses\r
30; @param[out] GS Selector allowing flat access to all addresses\r
31; @param[out] SS Selector allowing flat access to all addresses\r
bc252e8e
EB
32;\r
33; @return None This routine jumps to SEC and does not return\r
34;\r
35Main16:\r
36 OneTimeCall EarlyInit16\r
37\r
38 ;\r
39 ; Transition the processor from 16-bit real mode to 32-bit flat mode\r
40 ;\r
41 OneTimeCall TransitionFromReal16To32BitFlat\r
42\r
43BITS 32\r
44\r
45 ;\r
46 ; Search for the Boot Firmware Volume (BFV)\r
47 ;\r
48 OneTimeCall Flat32SearchForBfvBase\r
49\r
50 ;\r
51 ; EBP - Start of BFV\r
52 ;\r
53\r
54 ;\r
55 ; Search for the SEC entry point\r
56 ;\r
57 OneTimeCall Flat32SearchForSecEntryPoint\r
58\r
59 ;\r
60 ; ESI - SEC Core entry point\r
61 ; EBP - Start of BFV\r
62 ;\r
63\r
64%ifdef ARCH_IA32\r
65\r
66 ;\r
67 ; Restore initial EAX value into the EAX register\r
68 ;\r
69 mov eax, esp\r
70\r
71 ;\r
72 ; Jump to the 32-bit SEC entry point\r
73 ;\r
74 jmp esi\r
75\r
76%else\r
77\r
78 ;\r
79 ; Transition the processor from 32-bit flat mode to 64-bit flat mode\r
80 ;\r
81 OneTimeCall Transition32FlatTo64Flat\r
82\r
83BITS 64\r
84\r
85 ;\r
86 ; Some values were calculated in 32-bit mode. Make sure the upper\r
87 ; 32-bits of 64-bit registers are zero for these values.\r
88 ;\r
89 mov rax, 0x00000000ffffffff\r
90 and rsi, rax\r
91 and rbp, rax\r
92 and rsp, rax\r
93\r
94 ;\r
95 ; RSI - SEC Core entry point\r
96 ; RBP - Start of BFV\r
97 ;\r
98\r
99 ;\r
100 ; Restore initial EAX value into the RAX register\r
101 ;\r
102 mov rax, rsp\r
103\r
104 ;\r
105 ; Jump to the 64-bit SEC entry point\r
106 ;\r
107 jmp rsi\r
108\r
109%endif\r
110\r
111\r