]> 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 - 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 FFS_GUID_DWORD0 0x8c8ce578
13 %define FFS_GUID_DWORD1 0x4f1c8a3d
14 %define FFS_GUID_DWORD2 0x61893599
15 %define FFS_GUID_DWORD3 0xd32dc385
16
17 BITS 32
18
19 ;
20 ; Modified: EAX, EBX
21 ; Preserved: EDI, ESP
22 ;
23 ; @param[out] EBP Address of Boot Firmware Volume (BFV)
24 ;
25 Flat32SearchForBfvBase:
26
27 xor eax, eax
28 searchingForBfvHeaderLoop:
29 ;
30 ; We check for a firmware volume at every 4KB address in the top 16MB
31 ; just below 4GB. (Addresses at 0xffHHH000 where H is any hex digit.)
32 ;
33 sub eax, 0x1000
34 cmp eax, 0xff000000
35 jb searchedForBfvHeaderButNotFound
36
37 ;
38 ; Check FFS GUID
39 ;
40 cmp dword [eax + 0x10], FFS_GUID_DWORD0
41 jne searchingForBfvHeaderLoop
42 cmp dword [eax + 0x14], FFS_GUID_DWORD1
43 jne searchingForBfvHeaderLoop
44 cmp dword [eax + 0x18], FFS_GUID_DWORD2
45 jne searchingForBfvHeaderLoop
46 cmp dword [eax + 0x1c], FFS_GUID_DWORD3
47 jne searchingForBfvHeaderLoop
48
49 ;
50 ; Check FV Length
51 ;
52 cmp dword [eax + 0x24], 0
53 jne searchingForBfvHeaderLoop
54 mov ebx, eax
55 add ebx, dword [eax + 0x20]
56 jnz searchingForBfvHeaderLoop
57
58 jmp searchedForBfvHeaderAndItWasFound
59
60 searchedForBfvHeaderButNotFound:
61 ;
62 ; Hang if the SEC entry point was not found
63 ;
64 debugShowPostCode POSTCODE_BFV_NOT_FOUND
65
66 ;
67 ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed
68 ; for debugging purposes.
69 ;
70 mov eax, 0xBFBFBFBF
71 mov ebp, eax
72 jmp $
73
74 searchedForBfvHeaderAndItWasFound:
75 mov ebp, eax
76
77 debugShowPostCode POSTCODE_BFV_FOUND
78
79 OneTimeCallRet Flat32SearchForBfvBase
80