Update the copyright notice format
[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 ; This program and the accompanying materials
7 ; are licensed and made available under the terms and conditions of the BSD License
8 ; which accompanies this distribution. The full text of the license may be found at
9 ; http://opensource.org/licenses/bsd-license.php
10 ;
11 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 ;
14 ;------------------------------------------------------------------------------
15
16 ;#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \
17 ; { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } }
18 %define FFS_GUID_DWORD0 0x8c8ce578
19 %define FFS_GUID_DWORD1 0x4f1c8a3d
20 %define FFS_GUID_DWORD2 0x61893599
21 %define FFS_GUID_DWORD3 0xd32dc385
22
23 BITS 32
24
25 ;
26 ; Modified: EAX, EBX
27 ; Preserved: EDI, ESP
28 ;
29 ; @param[out] EBP Address of Boot Firmware Volume (BFV)
30 ;
31 Flat32SearchForBfvBase:
32
33 xor eax, eax
34 searchingForBfvHeaderLoop:
35 ;
36 ; We check for a firmware volume at every 4KB address in the top 16MB
37 ; just below 4GB. (Addresses at 0xffHHH000 where H is any hex digit.)
38 ;
39 sub eax, 0x1000
40 cmp eax, 0xff000000
41 jb 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 jnz searchingForBfvHeaderLoop
63
64 jmp searchedForBfvHeaderAndItWasFound
65
66 searchedForBfvHeaderButNotFound:
67 ;
68 ; Hang if the SEC entry point was not found
69 ;
70 debugShowPostCode POSTCODE_BFV_NOT_FOUND
71
72 ;
73 ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed
74 ; for debugging purposes.
75 ;
76 mov eax, 0xBFBFBFBF
77 mov ebp, eax
78 jmp $
79
80 searchedForBfvHeaderAndItWasFound:
81 mov ebp, eax
82
83 debugShowPostCode POSTCODE_BFV_FOUND
84
85 OneTimeCallRet Flat32SearchForBfvBase
86