Update the copyright notice format
[mirror_edk2.git] / UefiCpuPkg / ResetVector / Vtf0 / Ia32 / SearchForBfvBase.asm
CommitLineData
bc252e8e
EB
1;------------------------------------------------------------------------------\r
2; @file\r
3; Search for the Boot Firmware Volume (BFV) base address\r
4;\r
01a1c0fc
HT
5; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>\r
6; This program and the accompanying materials\r
bc252e8e
EB
7; are licensed and made available under the terms and conditions of the BSD License\r
8; which accompanies this distribution. The full text of the license may be found at\r
9; http://opensource.org/licenses/bsd-license.php\r
10;\r
11; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13;\r
14;------------------------------------------------------------------------------\r
15\r
16;#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \\r
17; { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } }\r
18%define FFS_GUID_DWORD0 0x8c8ce578\r
19%define FFS_GUID_DWORD1 0x4f1c8a3d\r
20%define FFS_GUID_DWORD2 0x61893599\r
21%define FFS_GUID_DWORD3 0xd32dc385\r
22\r
23BITS 32\r
24\r
25;\r
26; Modified: EAX, EBX\r
27; Preserved: EDI, ESP\r
28;\r
29; @param[out] EBP Address of Boot Firmware Volume (BFV)\r
30;\r
31Flat32SearchForBfvBase:\r
32\r
33 xor eax, eax\r
34searchingForBfvHeaderLoop:\r
35 ;\r
36 ; We check for a firmware volume at every 4KB address in the top 16MB\r
37 ; just below 4GB. (Addresses at 0xffHHH000 where H is any hex digit.)\r
38 ;\r
39 sub eax, 0x1000\r
40 cmp eax, 0xff000000\r
41 jb searchedForBfvHeaderButNotFound\r
42\r
43 ;\r
44 ; Check FFS GUID\r
45 ;\r
46 cmp dword [eax + 0x10], FFS_GUID_DWORD0\r
47 jne searchingForBfvHeaderLoop\r
48 cmp dword [eax + 0x14], FFS_GUID_DWORD1\r
49 jne searchingForBfvHeaderLoop\r
50 cmp dword [eax + 0x18], FFS_GUID_DWORD2\r
51 jne searchingForBfvHeaderLoop\r
52 cmp dword [eax + 0x1c], FFS_GUID_DWORD3\r
53 jne searchingForBfvHeaderLoop\r
54\r
55 ;\r
56 ; Check FV Length\r
57 ;\r
58 cmp dword [eax + 0x24], 0\r
59 jne searchingForBfvHeaderLoop\r
60 mov ebx, eax\r
61 add ebx, dword [eax + 0x20]\r
62 jnz searchingForBfvHeaderLoop\r
63\r
64 jmp searchedForBfvHeaderAndItWasFound\r
65\r
66searchedForBfvHeaderButNotFound:\r
67 ;\r
68 ; Hang if the SEC entry point was not found\r
69 ;\r
70 debugShowPostCode POSTCODE_BFV_NOT_FOUND\r
71\r
72 ;\r
73 ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed\r
74 ; for debugging purposes.\r
75 ;\r
76 mov eax, 0xBFBFBFBF\r
77 mov ebp, eax\r
78 jmp $\r
79\r
80searchedForBfvHeaderAndItWasFound:\r
81 mov ebp, eax\r
82\r
83 debugShowPostCode POSTCODE_BFV_FOUND\r
84\r
85 OneTimeCallRet Flat32SearchForBfvBase\r
86\r