]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm
Add missing EFIAPI instances on several functions.
[mirror_edk2.git] / OvmfPkg / ResetVector / Ia32 / SearchForSecAndPeiEntries.asm
CommitLineData
49ba9447 1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2008, Intel Corporation\r
4; All rights reserved. This program and the accompanying materials\r
5; are licensed and made available under the terms and conditions of the BSD License\r
6; which accompanies this distribution. The full text of the license may be found at\r
7; http://opensource.org/licenses/bsd-license.php\r
8;\r
9; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11;\r
12; Module Name:\r
13;\r
14; SearchForSecAndPeiEntry.asm\r
15;\r
16; Abstract:\r
17;\r
18; Search for the SEC Core and PEI Core entry points\r
19;\r
20;------------------------------------------------------------------------------\r
21\r
22BITS 32\r
23\r
24%define EFI_FV_FILETYPE_SECURITY_CORE 0x03\r
25%define EFI_FV_FILETYPE_PEI_CORE 0x04\r
26\r
27;\r
28; Input:\r
29; EBP - BFV Base Address\r
30;\r
31; Output:\r
32; ESI - SEC Core Entry Point Address (or 0 if not found)\r
33; EDI - PEI Core Entry Point Address (or 0 if not found)\r
34;\r
35; Modified:\r
36; EAX, EBX, ECX\r
37;\r
38Flat32SearchForSecAndPeiEntries:\r
39\r
40 ;\r
41 ; Initialize EBP and ESI to 0\r
42 ;\r
43 xor ebx, ebx\r
44 mov esi, ebx\r
45 mov edi, ebx\r
46\r
47 ;\r
48 ; Pass over the BFV header\r
49 ;\r
50 mov eax, ebp\r
51 mov bx, [ebp + 0x30]\r
52 add eax, ebx\r
53 jc doneSeachingForSecAndPeiEntries\r
54\r
55 jmp searchingForFfsFileHeaderLoop\r
56\r
57moveForwardWhileSearchingForFfsFileHeaderLoop:\r
58 ;\r
59 ; Make forward progress in the search\r
60 ;\r
61 inc eax\r
62 jc doneSeachingForSecAndPeiEntries\r
63\r
64searchingForFfsFileHeaderLoop:\r
65 test eax, eax\r
66 jz doneSeachingForSecAndPeiEntries\r
67\r
68 ;\r
69 ; Ensure 8 byte alignment\r
70 ;\r
71 add eax, 7\r
72 jc doneSeachingForSecAndPeiEntries\r
73 and al, 0xf8\r
74\r
75 ;\r
76 ; Look to see if there is an FFS file at eax\r
77 ;\r
78 mov bl, [eax + 0x17]\r
79 test bl, 0x20\r
80 jz moveForwardWhileSearchingForFfsFileHeaderLoop\r
81 mov ecx, [eax + 0x14]\r
82 and ecx, 0x00ffffff\r
83 or ecx, ecx\r
84 jz moveForwardWhileSearchingForFfsFileHeaderLoop\r
85; jmp $\r
86 add ecx, eax\r
87 jz jumpSinceWeFoundTheLastFfsFile\r
88 jc moveForwardWhileSearchingForFfsFileHeaderLoop\r
89jumpSinceWeFoundTheLastFfsFile:\r
90\r
91 ;\r
92 ; There seems to be a valid file at eax\r
93 ;\r
94 mov bl, [eax + 0x12] ; BL - File Type\r
95 cmp bl, EFI_FV_FILETYPE_PEI_CORE\r
96 je fileTypeIsPeiCore\r
97 cmp bl, EFI_FV_FILETYPE_SECURITY_CORE\r
98 jne readyToTryFfsFileAtEcx\r
99\r
100fileTypeIsSecCore:\r
101 callEdx GetEntryPointOfFfsFileReturnEdx\r
102 test eax, eax\r
103 jz readyToTryFfsFileAtEcx\r
104\r
105 mov esi, eax\r
106 jmp readyToTryFfsFileAtEcx\r
107\r
108fileTypeIsPeiCore:\r
109 callEdx GetEntryPointOfFfsFileReturnEdx\r
110 test eax, eax\r
111 jz readyToTryFfsFileAtEcx\r
112\r
113 mov edi, eax\r
114\r
115readyToTryFfsFileAtEcx:\r
116 mov eax, ecx\r
117 jmp searchingForFfsFileHeaderLoop\r
118\r
119doneSeachingForSecAndPeiEntries:\r
120\r
121 test esi, esi\r
122 jnz secCoreEntryPointWasFound\r
123 writeToSerialPort '!'\r
124secCoreEntryPointWasFound:\r
125 writeToSerialPort 'S'\r
126 writeToSerialPort 'E'\r
127 writeToSerialPort 'C'\r
128 writeToSerialPort ' '\r
129\r
130 test edi, edi\r
131 jnz peiCoreEntryPointWasFound\r
132 writeToSerialPort '!'\r
133peiCoreEntryPointWasFound:\r
134 writeToSerialPort 'P'\r
135 writeToSerialPort 'E'\r
136 writeToSerialPort 'I'\r
137 writeToSerialPort ' '\r
138\r
139 OneTimeCallRet Flat32SearchForSecAndPeiEntries\r
140\r
141\r
142%define EFI_SECTION_PE32 0x10\r
143\r
144;\r
145; Input:\r
146; EAX - Start of FFS file\r
9337cf8c 147; ECX - End of FFS file\r
49ba9447 148;\r
149; Output:\r
150; EAX - Entry point of PE32 (or 0 if not found)\r
151;\r
152; Modified:\r
153; EBX\r
154;\r
155GetEntryPointOfFfsFileReturnEdx:\r
156 test eax, eax\r
157 jz getEntryPointOfFfsFileErrorReturn\r
9337cf8c 158 add eax, 0x18 ; EAX = Start of section\r
49ba9447 159\r
9337cf8c 160getEntryPointOfFfsFileLoopForSections:\r
161 cmp eax, ecx\r
162 jae getEntryPointOfFfsFileErrorReturn\r
49ba9447 163\r
9337cf8c 164 cmp byte [eax + 3], EFI_SECTION_PE32\r
165 je getEntryPointOfFfsFileFoundPe32Section\r
166\r
167 ;\r
168 ; The section type was not PE32, so move to next section\r
169 ;\r
170 mov ebx, dword [eax]\r
171 and ebx, 0x00ffffff\r
172 add eax, ebx\r
173 jc getEntryPointOfFfsFileErrorReturn\r
174\r
175 ;\r
176 ; Ensure that FFS section is 32-bit aligned\r
177 ;\r
178 add eax, 3\r
179 jc getEntryPointOfFfsFileErrorReturn\r
180 and al, 0xfc\r
181 jmp getEntryPointOfFfsFileLoopForSections\r
182\r
183getEntryPointOfFfsFileFoundPe32Section:\r
184 add eax, 4 ; EAX = Start of PE32 image\r
49ba9447 185\r
186 mov ebx, eax\r
187 cmp word [eax], 'MZ'\r
188 jne thereIsNotAnMzSignature\r
189 movzx ebx, word [eax + 0x3c]\r
190 add ebx, eax\r
191thereIsNotAnMzSignature:\r
192\r
193 ; if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE)\r
194 cmp word [ebx], 'VZ'\r
195 jne thereIsNoVzSignature\r
196 ; *EntryPoint = (VOID *)((UINTN)Pe32Data +\r
197 ; (UINTN)(Hdr.Te->AddressOfEntryPoint & 0x0ffffffff) +\r
198 ; sizeof(EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize);\r
199 add eax, [ebx + 0x8]\r
200 add eax, 0x28\r
201 movzx ebx, word [ebx + 0x6]\r
202 sub eax, ebx\r
203 jmp getEntryPointOfFfsFileReturn\r
204\r
205thereIsNoVzSignature:\r
206\r
207 ; if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)\r
208 cmp dword [ebx], `PE\x00\x00`\r
209 jne getEntryPointOfFfsFileErrorReturn\r
210\r
211 ; *EntryPoint = (VOID *)((UINTN)Pe32Data +\r
212 ; (UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));\r
213 add eax, [ebx + 0x4 + 0x14 + 0x10]\r
214 jmp getEntryPointOfFfsFileReturn\r
215\r
216getEntryPointOfFfsFileErrorReturn:\r
217 mov eax, 0\r
218\r
219getEntryPointOfFfsFileReturn:\r
220 jmp edx\r
221\r
222\r