]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm
UefiCpuPkg: Update BFV searching algorithm in VTF0
[mirror_edk2.git] / UefiCpuPkg / ResetVector / Vtf0 / Ia32 / SearchForBfvBase.asm
CommitLineData
bc252e8e
EB
1;------------------------------------------------------------------------------\r
2; @file\r
3; Search for the Boot Firmware Volume (BFV) base address\r
4;\r
3ef20719 5; Copyright (c) 2008 - 2022, 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;#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \\r
11; { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } }\r
52e09dcd
KT
12%define FFS2_GUID_DWORD0 0x8c8ce578\r
13%define FFS2_GUID_DWORD1 0x4f1c8a3d\r
14%define FFS2_GUID_DWORD2 0x61893599\r
15%define FFS2_GUID_DWORD3 0xd32dc385\r
16\r
17;#define EFI_FIRMWARE_FILE_SYSTEM3_GUID \\r
18; { 0x8c8ce578, 0x3dcb, 0x4dca, { 0xbd, 0x6f, 0x1e, 0x96, 0x89, 0xe7, 0x34, 0x9a } }\r
19%define FFS3_GUID_DWORD0 0x5473c07a\r
20%define FFS3_GUID_DWORD1 0x4dca3dcb\r
21%define FFS3_GUID_DWORD2 0x961e6fbd\r
22%define FFS3_GUID_DWORD3 0x9a34e789\r
bc252e8e
EB
23\r
24BITS 32\r
25\r
26;\r
27; Modified: EAX, EBX\r
28; Preserved: EDI, ESP\r
29;\r
30; @param[out] EBP Address of Boot Firmware Volume (BFV)\r
31;\r
32Flat32SearchForBfvBase:\r
33\r
34 xor eax, eax\r
35searchingForBfvHeaderLoop:\r
36 ;\r
37 ; We check for a firmware volume at every 4KB address in the top 16MB\r
38 ; just below 4GB. (Addresses at 0xffHHH000 where H is any hex digit.)\r
39 ;\r
40 sub eax, 0x1000\r
41 cmp eax, 0xff000000\r
3ef20719 42 jb searchedForBfvHeaderButNotFound\r
bc252e8e
EB
43\r
44 ;\r
52e09dcd 45 ; Check FFS3 GUID\r
bc252e8e 46 ;\r
52e09dcd 47 cmp dword [eax + 0x10], FFS3_GUID_DWORD0\r
3ef20719 48 jne searchingForFfs2Guid\r
52e09dcd 49 cmp dword [eax + 0x14], FFS3_GUID_DWORD1\r
3ef20719 50 jne searchingForFfs2Guid\r
52e09dcd 51 cmp dword [eax + 0x18], FFS3_GUID_DWORD2\r
3ef20719 52 jne searchingForFfs2Guid\r
52e09dcd 53 cmp dword [eax + 0x1c], FFS3_GUID_DWORD3\r
3ef20719 54 jne searchingForFfs2Guid\r
52e09dcd 55 jmp checkingFvLength\r
bc252e8e 56\r
52e09dcd
KT
57searchingForFfs2Guid:\r
58 ;\r
59 ; Check FFS2 GUID\r
60 ;\r
61 cmp dword [eax + 0x10], FFS2_GUID_DWORD0\r
62 jne searchingForBfvHeaderLoop\r
63 cmp dword [eax + 0x14], FFS2_GUID_DWORD1\r
64 jne searchingForBfvHeaderLoop\r
65 cmp dword [eax + 0x18], FFS2_GUID_DWORD2\r
66 jne searchingForBfvHeaderLoop\r
67 cmp dword [eax + 0x1c], FFS2_GUID_DWORD3\r
68 jne searchingForBfvHeaderLoop\r
69\r
70checkingFvLength:\r
bc252e8e
EB
71 ;\r
72 ; Check FV Length\r
73 ;\r
74 cmp dword [eax + 0x24], 0\r
75 jne searchingForBfvHeaderLoop\r
76 mov ebx, eax\r
77 add ebx, dword [eax + 0x20]\r
78 jnz searchingForBfvHeaderLoop\r
79\r
80 jmp searchedForBfvHeaderAndItWasFound\r
81\r
82searchedForBfvHeaderButNotFound:\r
83 ;\r
84 ; Hang if the SEC entry point was not found\r
85 ;\r
86 debugShowPostCode POSTCODE_BFV_NOT_FOUND\r
87\r
88 ;\r
89 ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed\r
90 ; for debugging purposes.\r
91 ;\r
92 mov eax, 0xBFBFBFBF\r
93 mov ebp, eax\r
94 jmp $\r
95\r
96searchedForBfvHeaderAndItWasFound:\r
97 mov ebp, eax\r
98\r
99 debugShowPostCode POSTCODE_BFV_FOUND\r
100\r
101 OneTimeCallRet Flat32SearchForBfvBase\r
102\r