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; Copyright (c) 2019, Citrix Systems, Inc. 7; 8; SPDX-License-Identifier: BSD-2-Clause-Patent 9; 10;------------------------------------------------------------------------------ 11 12;#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \ 13; { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } } 14%define FFS_GUID_DWORD0 0x8c8ce578 15%define FFS_GUID_DWORD1 0x4f1c8a3d 16%define FFS_GUID_DWORD2 0x61893599 17%define FFS_GUID_DWORD3 0xd32dc385 18 19BITS 32 20 21; 22; Modified: EAX, EBX, ECX 23; Preserved: EDI, ESP 24; 25; @param[in] EAX Start search from here 26; @param[out] EBP Address of Boot Firmware Volume (BFV) 27; 28Flat32SearchForBfvBase: 29 30 mov ecx, eax 31searchingForBfvHeaderLoop: 32 ; 33 ; We check for a firmware volume at every 4KB address in the 16MB 34 ; just below where we started, ECX. 35 ; 36 sub eax, 0x1000 37 mov ebx, ecx 38 sub ebx, eax 39 cmp ebx, 0x01000000 40 ; if ECX-EAX > 16MB; jump notfound 41 ja searchedForBfvHeaderButNotFound 42 43 ; 44 ; Check FFS GUID 45 ; 46 cmp dword [eax + 0x10], FFS_GUID_DWORD0 47 jne searchingForBfvHeaderLoop 48 cmp dword [eax + 0x14], FFS_GUID_DWORD1 49 jne searchingForBfvHeaderLoop 50 cmp dword [eax + 0x18], FFS_GUID_DWORD2 51 jne searchingForBfvHeaderLoop 52 cmp dword [eax + 0x1c], FFS_GUID_DWORD3 53 jne searchingForBfvHeaderLoop 54 55 ; 56 ; Check FV Length 57 ; 58 cmp dword [eax + 0x24], 0 59 jne searchingForBfvHeaderLoop 60 mov ebx, eax 61 add ebx, dword [eax + 0x20] 62 cmp ebx, ecx 63 jnz searchingForBfvHeaderLoop 64 65 jmp searchedForBfvHeaderAndItWasFound 66 67searchedForBfvHeaderButNotFound: 68 ; 69 ; Hang if the SEC entry point was not found 70 ; 71 debugShowPostCode POSTCODE_BFV_NOT_FOUND 72 73 ; 74 ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed 75 ; for debugging purposes. 76 ; 77 mov eax, 0xBFBFBFBF 78 mov ebp, eax 79 jmp $ 80 81searchedForBfvHeaderAndItWasFound: 82 mov ebp, eax 83 84 debugShowPostCode POSTCODE_BFV_FOUND 85 86 OneTimeCallRet Flat32SearchForBfvBase 87 88