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