3 Copyright (c) 2006, 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
);
88 IN EFI_FIND_FV_PPI
*This
,
89 IN EFI_PEI_SERVICES
**PeiServices
,
90 IN OUT UINT8
*FvNumber
,
91 IN OUT EFI_FIRMWARE_VOLUME_HEADER
**FvAddress
97 Search Fv which supports FFS.
101 This - Interface pointer that implement the Find Fv PPI
103 PeiServices - Pointer to the PEI Service Table
105 FvNumber - On input, the number of the fireware volume which supports FFS to locate
106 On output, the next FV number which supports FFS.
108 FVAddress - The address of the volume which supports FFS to discover
112 EFI_SUCCESS - An addtional FV which supports FFS found
113 EFI_OUT_OF_RESOURCES - There are no fireware volume which supports FFS for given fvnumber
114 EFI_INVALID_PARAMETER - FvAddress is NULL
119 EFI_PEI_HOB_POINTERS HobStart
;
120 EFI_PEI_HOB_POINTERS Hob
;
121 EFI_HOB_FIRMWARE_VOLUME
*FvHob
;
124 if (FvAddress
== NULL
){
125 return EFI_INVALID_PARAMETER
;
132 // Get the Hob table pointer
134 Status
= (*PeiServices
)->GetHobList (
139 if (EFI_ERROR (Status
)) {
140 return EFI_OUT_OF_RESOURCES
;
144 // Loop to search the wanted FirmwareVolume which supports FFS
147 while (FvIndex
<= *FvNumber
) {
149 Hob
.Raw
= GetHob (EFI_HOB_TYPE_FV
, HobStart
.Raw
);
152 // If the Hob is not EFI_HOB_TYPE_FV, it indicates that
153 // we have finished all FV volumes search, and there is no
154 // the FFS FV specified by FvNumber.
156 if (Hob
.Header
->HobType
!= EFI_HOB_TYPE_FV
) {
158 return EFI_OUT_OF_RESOURCES
;
161 HobStart
.Raw
= Hob
.Raw
+ Hob
.Header
->HobLength
;
162 FvHob
= Hob
.FirmwareVolume
;
163 *FvAddress
= (EFI_FIRMWARE_VOLUME_HEADER
*) ((UINTN
) FvHob
->BaseAddress
);
165 // Check if the FV supports FFS
167 if (EfiCompareGuid (&((*FvAddress
)->FileSystemGuid
), &gEfiFirmwareFileSystemGuid
)) {
173 // Return the next FV number which supports FFS.