]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/ResetVector/Vtf0/Ia32/SearchForBfvBase.asm
UefiCpuPkg: Support FFS3 GUID in SearchForBfvBase.asm
[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
01a1c0fc 5; Copyright (c) 2008 - 2009, 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
52e09dcd 35 mov ecx, 3 ; 3: FFS3 GUID, 2: FFS2 GUID, 1: Not Found\r
bc252e8e
EB
36searchingForBfvHeaderLoop:\r
37 ;\r
38 ; We check for a firmware volume at every 4KB address in the top 16MB\r
39 ; just below 4GB. (Addresses at 0xffHHH000 where H is any hex digit.)\r
40 ;\r
41 sub eax, 0x1000\r
42 cmp eax, 0xff000000\r
52e09dcd
KT
43 jb searchingForBfvWithOtherFfsGuid\r
44 cmp ecx, 3\r
45 jne searchingForFfs2Guid\r
bc252e8e
EB
46\r
47 ;\r
52e09dcd 48 ; Check FFS3 GUID\r
bc252e8e 49 ;\r
52e09dcd 50 cmp dword [eax + 0x10], FFS3_GUID_DWORD0\r
bc252e8e 51 jne searchingForBfvHeaderLoop\r
52e09dcd 52 cmp dword [eax + 0x14], FFS3_GUID_DWORD1\r
bc252e8e 53 jne searchingForBfvHeaderLoop\r
52e09dcd 54 cmp dword [eax + 0x18], FFS3_GUID_DWORD2\r
bc252e8e 55 jne searchingForBfvHeaderLoop\r
52e09dcd 56 cmp dword [eax + 0x1c], FFS3_GUID_DWORD3\r
bc252e8e 57 jne searchingForBfvHeaderLoop\r
52e09dcd 58 jmp checkingFvLength\r
bc252e8e 59\r
52e09dcd
KT
60searchingForFfs2Guid:\r
61 ;\r
62 ; Check FFS2 GUID\r
63 ;\r
64 cmp dword [eax + 0x10], FFS2_GUID_DWORD0\r
65 jne searchingForBfvHeaderLoop\r
66 cmp dword [eax + 0x14], FFS2_GUID_DWORD1\r
67 jne searchingForBfvHeaderLoop\r
68 cmp dword [eax + 0x18], FFS2_GUID_DWORD2\r
69 jne searchingForBfvHeaderLoop\r
70 cmp dword [eax + 0x1c], FFS2_GUID_DWORD3\r
71 jne searchingForBfvHeaderLoop\r
72\r
73checkingFvLength:\r
bc252e8e
EB
74 ;\r
75 ; Check FV Length\r
76 ;\r
77 cmp dword [eax + 0x24], 0\r
78 jne searchingForBfvHeaderLoop\r
79 mov ebx, eax\r
80 add ebx, dword [eax + 0x20]\r
81 jnz searchingForBfvHeaderLoop\r
82\r
83 jmp searchedForBfvHeaderAndItWasFound\r
84\r
52e09dcd
KT
85searchingForBfvWithOtherFfsGuid:\r
86 xor eax, eax\r
87 dec ecx\r
88 cmp ecx, 1\r
89 jne searchingForBfvHeaderLoop\r
90\r
bc252e8e
EB
91searchedForBfvHeaderButNotFound:\r
92 ;\r
93 ; Hang if the SEC entry point was not found\r
94 ;\r
95 debugShowPostCode POSTCODE_BFV_NOT_FOUND\r
96\r
97 ;\r
98 ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed\r
99 ; for debugging purposes.\r
100 ;\r
101 mov eax, 0xBFBFBFBF\r
102 mov ebp, eax\r
103 jmp $\r
104\r
105searchedForBfvHeaderAndItWasFound:\r
106 mov ebp, eax\r
107\r
108 debugShowPostCode POSTCODE_BFV_FOUND\r
109\r
110 OneTimeCallRet Flat32SearchForBfvBase\r
111\r