3 Copyright (c) 2006 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Library function to find fv by hob.
26 #include "PeiHobLib.h"
27 #include "EfiCommonLib.h"
28 #include EFI_GUID_DEFINITION (FirmwareFileSystem)
40 This function returns the first instance of a HOB type in a HOB list.
44 Type The HOB type to return.
45 HobStart The first HOB in the HOB list.
49 HobStart There were no HOBs found with the requested type.
50 else Returns the first HOB with the matching type.
54 EFI_PEI_HOB_POINTERS Hob
;
58 // Return input if not found
60 if (HobStart
== NULL
) {
65 // Parse the HOB list, stop if end of list or matching type found.
67 while (!END_OF_HOB_LIST (Hob
)) {
69 if (Hob
.Header
->HobType
== Type
) {
73 Hob
.Raw
= GET_NEXT_HOB (Hob
);
77 // Return input if not found
79 if (END_OF_HOB_LIST (Hob
)) {
83 return (VOID
*) (Hob
.Raw
);
89 IN EFI_FIND_FV_PPI
*This
,
90 IN EFI_PEI_SERVICES
**PeiServices
,
91 IN OUT UINT8
*FvNumber
,
92 IN OUT EFI_FIRMWARE_VOLUME_HEADER
**FvAddress
98 Search Fv which supports FFS.
102 This - Interface pointer that implement the Find Fv PPI
104 PeiServices - Pointer to the PEI Service Table
106 FvNumber - On input, the number of the fireware volume which supports FFS to locate
107 On output, the next FV number which supports FFS.
109 FVAddress - The address of the volume which supports FFS to discover
113 EFI_SUCCESS - An addtional FV which supports FFS found
114 EFI_OUT_OF_RESOURCES - There are no fireware volume which supports FFS for given fvnumber
115 EFI_INVALID_PARAMETER - FvAddress is NULL
120 EFI_PEI_HOB_POINTERS HobStart
;
121 EFI_PEI_HOB_POINTERS Hob
;
122 EFI_HOB_FIRMWARE_VOLUME
*FvHob
;
125 if (FvAddress
== NULL
){
126 return EFI_INVALID_PARAMETER
;
133 // Get the Hob table pointer
135 Status
= (*PeiServices
)->GetHobList (
137 (VOID
**) &HobStart
.Raw
140 if (EFI_ERROR (Status
)) {
141 return EFI_OUT_OF_RESOURCES
;
145 // Loop to search the wanted FirmwareVolume which supports FFS
148 while (FvIndex
<= *FvNumber
) {
150 Hob
.Raw
= FindFvGetHob (EFI_HOB_TYPE_FV
, HobStart
.Raw
);
153 // If the Hob is not EFI_HOB_TYPE_FV, it indicates that
154 // we have finished all FV volumes search, and there is no
155 // the FFS FV specified by FvNumber.
157 if (Hob
.Header
->HobType
!= EFI_HOB_TYPE_FV
) {
159 return EFI_OUT_OF_RESOURCES
;
162 HobStart
.Raw
= Hob
.Raw
+ Hob
.Header
->HobLength
;
163 FvHob
= Hob
.FirmwareVolume
;
164 *FvAddress
= (EFI_FIRMWARE_VOLUME_HEADER
*) ((UINTN
) FvHob
->BaseAddress
);
166 // Check if the FV supports FFS
168 if (EfiCompareGuid (&((*FvAddress
)->FileSystemGuid
), &gEfiFirmwareFileSystemGuid
)) {
174 // Return the next FV number which supports FFS.