]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/FvHobToFvInfoThunk/FvInfoToFvHobThunk.c
a98331edc0edf0cdf3d8001f12245823e6f192a1
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FvHobToFvInfoThunk / FvInfoToFvHobThunk.c
1 /** @file
2 Module produces EFI_FIRMWARE_VOLUME_INFO_PPI based on each FV HOB if no such PPI exist for the FV.
3
4 UEFI PI Spec supersedes Intel's Framework Specs.
5 EFI_FIRMWARE_VOLUME_INFO_PPI defined in PI spec is required by PI PEI core to dispatch PEIMs or find DXE core
6 in the FV.
7 This module produces produces EFI_FIRMWARE_VOLUME_INFO_PPI based on each FV HOB if no such PPI exist for the FV.
8 This module is used on platform when both of these two conditions are true:
9 1) Framework platform module produces FV HOB but does not build EFI_FIRMWARE_VOLUME_INFO_PPI.
10 2) The platform has PI PEI core that cosumes EFI_FIRMWARE_VOLUME_INFO_PPI to dispatch PEIMs or DXE core
11 in FVs other than Boot Fimware Volume.
12
13 Copyright (c) 2008 Intel Corporation. <BR>
14 All rights reserved. This program and the accompanying materials
15 are licensed and made available under the terms and conditions of the BSD License
16 which accompanies this distribution. The full text of the license may be found at
17 http://opensource.org/licenses/bsd-license.php
18
19 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
20 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 Module Name:
22
23 **/
24
25 #include <PiPei.h>
26 #include <Ppi/FirmwareVolumeInfo.h>
27 #include <Library/DebugLib.h>
28 #include <Library/PeiServicesTablePointerLib.h>
29 #include <Library/PeiServicesLib.h>
30 #include <Library/HobLib.h>
31 #include <Library/PeiPiLib.h>
32
33
34 /**
35 Check if there is a matching EFI_PEI_FIRMWARE_VOLUME_INFO_PPI for the FV described by FvHob.
36
37 This function located all existing instance of EFI_PEI_FIRMWARE_VOLUME_INFO_PPI in the platform.
38 Then it compare the base address of the FVs found with that of FvHob. If a matching base address is
39 found, the function return TRUE. Otherwise, FALSE is returned.
40
41 If a matching base address of FV is found but the length of FV does not match, then ASSERT ().
42
43 @param FvHob The FV Hob.
44
45 @retval TRUE A instance of EFI_PEI_FIRMWARE_VOLUME_INFO_PPI is already installed.
46
47 **/
48 BOOLEAN
49 FvInfoPpiInstalled (
50 EFI_HOB_FIRMWARE_VOLUME * FvHob
51 )
52 {
53 EFI_STATUS Status;
54 UINTN Idx;
55 EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;
56
57 for (Idx = 0; ; Idx++) {
58 Status = PeiServicesLocatePpi (
59 &gEfiPeiFirmwareVolumeInfoPpiGuid,
60 Idx,
61 NULL,
62 (VOID **) &FvInfoPpi
63 );
64 if (!EFI_ERROR (Status)) {
65 if (FvHob->BaseAddress == (EFI_PHYSICAL_ADDRESS) (UINTN) FvInfoPpi->FvInfo) {
66 ASSERT (FvHob->Length == (UINT64) FvInfoPpi->FvInfoSize);
67 return TRUE;
68 }
69 } else {
70 break;
71 }
72 }
73
74 return FALSE;
75 }
76
77 /**
78 PEIM's standard entry point.
79
80 @param FfsHeader Image's header
81 @param PeiServices Pointer of EFI_PEI_SERVICES
82 @return EFI_SUCESS This entry point always return successfully.
83
84 **/
85 EFI_STATUS
86 EFIAPI
87 PeimEntry (
88 IN EFI_PEI_FILE_HANDLE FfsHeader,
89 IN CONST EFI_PEI_SERVICES **PeiServices
90 )
91 {
92 EFI_PEI_HOB_POINTERS HobPointer;
93
94 for (HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_FV, GetHobList ());
95 HobPointer.Raw != NULL;
96 HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_FV, GET_NEXT_HOB (HobPointer))) {
97 if (!FvInfoPpiInstalled (HobPointer.FirmwareVolume)) {
98 PiLibInstallFvInfoPpi (
99 &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) HobPointer.FirmwareVolume->BaseAddress)->FileSystemGuid),
100 (VOID *) (UINTN) HobPointer.FirmwareVolume->BaseAddress,
101 (UINT32) HobPointer.FirmwareVolume->Length,
102 NULL,
103 NULL
104 );
105 }
106 }
107
108 return EFI_SUCCESS;
109 }
110