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