+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-\r
-Module Name:\r
- \r
- FindFv.c\r
- \r
-Abstract:\r
-\r
- Library function to find fv by hob.\r
-\r
---*/\r
-\r
-#include "Tiano.h"\r
-#include "Pei.h"\r
-#include "PeiLib.h"\r
-#include "PeiHobLib.h"\r
-#include "EfiCommonLib.h"\r
-#include EFI_GUID_DEFINITION (FirmwareFileSystem)\r
-\r
-static\r
-VOID *\r
-FindFvGetHob (\r
- IN UINT16 Type,\r
- IN VOID *HobStart\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This function returns the first instance of a HOB type in a HOB list.\r
- \r
-Arguments:\r
-\r
- Type The HOB type to return.\r
- HobStart The first HOB in the HOB list.\r
- \r
-Returns:\r
-\r
- HobStart There were no HOBs found with the requested type.\r
- else Returns the first HOB with the matching type.\r
-\r
---*/\r
-{\r
- EFI_PEI_HOB_POINTERS Hob;\r
-\r
- Hob.Raw = HobStart;\r
- //\r
- // Return input if not found\r
- //\r
- if (HobStart == NULL) {\r
- return HobStart;\r
- }\r
-\r
- //\r
- // Parse the HOB list, stop if end of list or matching type found.\r
- //\r
- while (!END_OF_HOB_LIST (Hob)) {\r
-\r
- if (Hob.Header->HobType == Type) {\r
- break;\r
- }\r
-\r
- Hob.Raw = GET_NEXT_HOB (Hob);\r
- }\r
- \r
- //\r
- // Return input if not found\r
- //\r
- if (END_OF_HOB_LIST (Hob)) {\r
- return HobStart;\r
- }\r
-\r
- return (VOID *) (Hob.Raw);\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FindFv (\r
- IN EFI_FIND_FV_PPI *This,\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN OUT UINT8 *FvNumber,\r
- IN OUT EFI_FIRMWARE_VOLUME_HEADER **FvAddress\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Search Fv which supports FFS.\r
-\r
-Arguments:\r
- \r
- This - Interface pointer that implement the Find Fv PPI\r
- \r
- PeiServices - Pointer to the PEI Service Table\r
- \r
- FvNumber - On input, the number of the fireware volume which supports FFS to locate\r
- On output, the next FV number which supports FFS.\r
- \r
- FVAddress - The address of the volume which supports FFS to discover\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - An addtional FV which supports FFS found\r
- EFI_OUT_OF_RESOURCES - There are no fireware volume which supports FFS for given fvnumber\r
- EFI_INVALID_PARAMETER - FvAddress is NULL\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- EFI_PEI_HOB_POINTERS HobStart;\r
- EFI_PEI_HOB_POINTERS Hob;\r
- EFI_HOB_FIRMWARE_VOLUME *FvHob;\r
- UINT8 FvIndex;\r
-\r
- if (FvAddress == NULL){\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Hob.Raw = NULL;\r
- FvIndex = 0;\r
-\r
- //\r
- // Get the Hob table pointer\r
- //\r
- Status = (*PeiServices)->GetHobList (\r
- PeiServices,\r
- (VOID **) &HobStart.Raw\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- \r
- //\r
- // Loop to search the wanted FirmwareVolume which supports FFS\r
- //\r
- //\r
- while (FvIndex <= *FvNumber) {\r
- \r
- Hob.Raw = FindFvGetHob (EFI_HOB_TYPE_FV, HobStart.Raw); \r
- \r
- //\r
- // If the Hob is not EFI_HOB_TYPE_FV, it indicates that\r
- // we have finished all FV volumes search, and there is no\r
- // the FFS FV specified by FvNumber.\r
- //\r
- if (Hob.Header->HobType != EFI_HOB_TYPE_FV) {\r
- *FvNumber = 0;\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- \r
- HobStart.Raw = Hob.Raw + Hob.Header->HobLength;\r
- FvHob = Hob.FirmwareVolume;\r
- *FvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvHob->BaseAddress);\r
- //\r
- // Check if the FV supports FFS\r
- //\r
- if (EfiCompareGuid (&((*FvAddress)->FileSystemGuid), &gEfiFirmwareFileSystemGuid)) {\r
- FvIndex++;\r
- }\r
- }\r
- \r
- //\r
- // Return the next FV number which supports FFS.\r
- //\r
- (*FvNumber)++;\r
- \r
- return EFI_SUCCESS;\r
-\r
-}\r