]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/FvFileLoaderToLoadFileThunk/FvFileLoaderToLoadFileThunk.c
Add in a temp fix to make UEFI HII SCT can pass with platform built with FrameworkHii...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FvFileLoaderToLoadFileThunk / FvFileLoaderToLoadFileThunk.c
1 /** @file
2 Module produce Framework's EFI_PEI_FV_FILE_LOADER_PPI top of EFI_PEI_LOAD_FILE_PPI.
3
4 UEFI PI Spec supersedes Intel's Framework Specs.
5 EFI_PEI_FV_FILE_LOADER_PPI defined in Intel Framework Pkg is replaced by EFI_PEI_LOAD_FILE_PPI
6 in MdePkg.
7 This module produces EFI_PEI_FV_FILE_LOADER_PPI on top of EFI_PEI_LOAD_FILE_PPI .
8 This module is used on platform when both of these two conditions are true:
9 1) Framework module consumes EFI_PEI_FV_FILE_LOADER_PPI is present.
10 2) The platform has PI modules that produce EFI_PEI_LOAD_FILE_PPI.
11
12 Copyright (c) 2008, Intel Corporation
13
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/LoadFile.h>
27 #include <Ppi/FvLoadFile.h>
28 #include <Library/DebugLib.h>
29 #include <Library/PeiServicesLib.h>
30
31 /**
32
33 Wrap the call to PI's EFI_PEI_LOAD_FILE_PPI.
34
35 @param This A pointer to EFI_PEI_FV_FILE_LOADER_PPI.
36 @param FileHeader The pointer to the file header to be loaded by the Pe/Coff loader.
37 @param ImageAddress The loaded address of the Image.
38 @param ImageSize Pointer to the size of the loaded image.
39 @param EntryPoint Pointer to the entry point of the image.
40
41 @retval EFI_SUCCESS The image was loaded successfully.
42 @retval EFI_OUT_OF_RESOURCE There was not enought memory.
43 @retval EFI_INVALID_PARAMETER The contents of the FFS file did not contain a valid PE/COFF image that could be loaded.
44 --*/
45 EFI_STATUS
46 EFIAPI
47 FrameworkLoadFile (
48 IN EFI_PEI_FV_FILE_LOADER_PPI *This,
49 IN EFI_FFS_FILE_HEADER *FfsHeader,
50 OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
51 OUT UINT64 *ImageSize,
52 OUT EFI_PHYSICAL_ADDRESS *EntryPoint
53 );
54
55 EFI_PEI_FV_FILE_LOADER_PPI mLoadFilePpi = {
56 FrameworkLoadFile
57 };
58
59 EFI_PEI_PPI_DESCRIPTOR mPpiFrameworkLoadFile = {
60 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
61 &gEfiPeiFvFileLoaderPpiGuid,
62 &mLoadFilePpi
63 };
64
65 /**
66 Standard entry point of a PEIM.
67
68 @param FfsHeadher The FFS file header
69 @param PeiServices General purpose services available to every PEIM.
70
71 @retval EFI_SUCCESS If the gEfiPeiReadOnlyVariablePpiGuid interface could be successfully installed.
72
73 --*/
74 EFI_STATUS
75 EFIAPI
76 InitPeim (
77 IN EFI_FFS_FILE_HEADER *FfsHeader,
78 IN CONST EFI_PEI_SERVICES **PeiServices
79 )
80 {
81 return (*PeiServices)->InstallPpi (PeiServices, &mPpiFrameworkLoadFile);
82 }
83
84
85 /**
86
87 Wrap the call to PI's EFI_PEI_LOAD_FILE_PPI.
88
89 @param This A pointer to EFI_PEI_FV_FILE_LOADER_PPI.
90 @param FileHeader The pointer to the file header to be loaded by the Pe/Coff loader.
91 @param ImageAddress The loaded address of the Image.
92 @param ImageSize Pointer to the size of the loaded image.
93 @param EntryPoint Pointer to the entry point of the image.
94
95 @retval EFI_SUCCESS The image was loaded successfully.
96 @retval EFI_OUT_OF_RESOURCE There was not enought memory.
97 @retval EFI_INVALID_PARAMETER The contents of the FFS file did not contain a valid PE/COFF image that could be loaded.
98 --*/
99 EFI_STATUS
100 EFIAPI
101 FrameworkLoadFile (
102 IN EFI_PEI_FV_FILE_LOADER_PPI *This,
103 IN EFI_FFS_FILE_HEADER *FfsHeader,
104 OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
105 OUT UINT64 *ImageSize,
106 OUT EFI_PHYSICAL_ADDRESS *EntryPoint
107 )
108 {
109 EFI_STATUS Status;
110 EFI_PEI_LOAD_FILE_PPI *PiLoadFile;
111 UINT32 AuthenticationState;
112
113 Status = PeiServicesLocatePpi (
114 &gEfiPeiLoadFilePpiGuid,
115 0,
116 NULL,
117 (VOID **) &PiLoadFile
118 );
119 ASSERT_EFI_ERROR (Status);
120
121 return PiLoadFile->LoadFile (
122 PiLoadFile,
123 (EFI_PEI_FILE_HANDLE) FfsHeader,
124 ImageAddress,
125 ImageSize,
126 EntryPoint,
127 &AuthenticationState
128 );
129
130 }
131