]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/XenResetVector/Ia32/SearchForBfvBase.asm
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / OvmfPkg / XenResetVector / Ia32 / SearchForBfvBase.asm
CommitLineData
f198e254
AP
1;------------------------------------------------------------------------------\r
2; @file\r
3; Search for the Boot Firmware Volume (BFV) base address\r
4;\r
5; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>\r
6; Copyright (c) 2019, Citrix Systems, Inc.\r
7;\r
8; SPDX-License-Identifier: BSD-2-Clause-Patent\r
9;\r
10;------------------------------------------------------------------------------\r
11\r
12;#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \\r
13; { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } }\r
14%define FFS_GUID_DWORD0 0x8c8ce578\r
15%define FFS_GUID_DWORD1 0x4f1c8a3d\r
16%define FFS_GUID_DWORD2 0x61893599\r
17%define FFS_GUID_DWORD3 0xd32dc385\r
18\r
19BITS 32\r
20\r
21;\r
22; Modified: EAX, EBX, ECX\r
23; Preserved: EDI, ESP\r
24;\r
25; @param[in] EAX Start search from here\r
26; @param[out] EBP Address of Boot Firmware Volume (BFV)\r
27;\r
28Flat32SearchForBfvBase:\r
29\r
30 mov ecx, eax\r
31searchingForBfvHeaderLoop:\r
32 ;\r
33 ; We check for a firmware volume at every 4KB address in the 16MB\r
34 ; just below where we started, ECX.\r
35 ;\r
36 sub eax, 0x1000\r
37 mov ebx, ecx\r
38 sub ebx, eax\r
39 cmp ebx, 0x01000000\r
40 ; if ECX-EAX > 16MB; jump notfound\r
41 ja searchedForBfvHeaderButNotFound\r
42\r
43 ;\r
44 ; Check FFS GUID\r
45 ;\r
46 cmp dword [eax + 0x10], FFS_GUID_DWORD0\r
47 jne searchingForBfvHeaderLoop\r
48 cmp dword [eax + 0x14], FFS_GUID_DWORD1\r
49 jne searchingForBfvHeaderLoop\r
50 cmp dword [eax + 0x18], FFS_GUID_DWORD2\r
51 jne searchingForBfvHeaderLoop\r
52 cmp dword [eax + 0x1c], FFS_GUID_DWORD3\r
53 jne searchingForBfvHeaderLoop\r
54\r
55 ;\r
56 ; Check FV Length\r
57 ;\r
58 cmp dword [eax + 0x24], 0\r
59 jne searchingForBfvHeaderLoop\r
60 mov ebx, eax\r
61 add ebx, dword [eax + 0x20]\r
62 cmp ebx, ecx\r
63 jnz searchingForBfvHeaderLoop\r
64\r
65 jmp searchedForBfvHeaderAndItWasFound\r
66\r
67searchedForBfvHeaderButNotFound:\r
68 ;\r
69 ; Hang if the SEC entry point was not found\r
70 ;\r
71 debugShowPostCode POSTCODE_BFV_NOT_FOUND\r
72\r
73 ;\r
74 ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed\r
75 ; for debugging purposes.\r
76 ;\r
77 mov eax, 0xBFBFBFBF\r
78 mov ebp, eax\r
79 jmp $\r
80\r
81searchedForBfvHeaderAndItWasFound:\r
82 mov ebp, eax\r
83\r
84 debugShowPostCode POSTCODE_BFV_FOUND\r
85\r
86 OneTimeCallRet Flat32SearchForBfvBase\r
87\r