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