]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/FvFileLoaderToLoadFileThunk/FvFileLoaderToLoadFileThunk.c
1) Add in FvFileLoaderToLoadFileThunk.
[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
56 EFI_PEI_FV_FILE_LOADER_PPI mLoadFilePpi = {
57 FrameworkLoadFile
58 };
59
60 EFI_PEI_PPI_DESCRIPTOR mPpiFrameworkLoadFile = {
61 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
62 &gEfiPeiFvFileLoaderPpiGuid,
63 &mLoadFilePpi
64 };
65
66 /**
67 Standard entry point of a PEIM.
68
69 @param FfsHeadher The FFS file header
70 @param PeiServices General purpose services available to every PEIM.
71
72 @retval EFI_SUCCESS If the gEfiPeiReadOnlyVariablePpiGuid interface could be successfully installed.
73
74 --*/
75 EFI_STATUS
76 EFIAPI
77 InitPeim (
78 IN EFI_FFS_FILE_HEADER *FfsHeader,
79 IN CONST EFI_PEI_SERVICES **PeiServices
80 )
81 {
82 return (*PeiServices)->InstallPpi (PeiServices, &mPpiFrameworkLoadFile);
83 }
84
85
86 /**
87
88 Wrap the call to PI's EFI_PEI_LOAD_FILE_PPI.
89
90 @param This A pointer to EFI_PEI_FV_FILE_LOADER_PPI.
91 @param FileHeader The pointer to the file header to be loaded by the Pe/Coff loader.
92 @param ImageAddress The loaded address of the Image.
93 @param ImageSize Pointer to the size of the loaded image.
94 @param EntryPoint Pointer to the entry point of the image.
95
96 @retval EFI_SUCCESS The image was loaded successfully.
97 @retval EFI_OUT_OF_RESOURCE There was not enought memory.
98 @retval EFI_INVALID_PARAMETER The contents of the FFS file did not contain a valid PE/COFF image that could be loaded.
99 --*/
100 EFI_STATUS
101 EFIAPI
102 FrameworkLoadFile (
103 IN EFI_PEI_FV_FILE_LOADER_PPI *This,
104 IN EFI_FFS_FILE_HEADER *FfsHeader,
105 OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
106 OUT UINT64 *ImageSize,
107 OUT EFI_PHYSICAL_ADDRESS *EntryPoint
108 )
109 {
110 EFI_STATUS Status;
111 EFI_PEI_LOAD_FILE_PPI *PiLoadFile;
112 UINT32 AuthenticationState;
113
114 Status = PeiServicesLocatePpi (
115 &gEfiPeiLoadFilePpiGuid,
116 0,
117 NULL,
118 (VOID **) &PiLoadFile
119 );
120 ASSERT_EFI_ERROR (Status);
121
122 return PiLoadFile->LoadFile (
123 PiLoadFile,
124 (EFI_PEI_FILE_HANDLE) FfsHeader,
125 ImageAddress,
126 ImageSize,
127 EntryPoint,
128 &AuthenticationState
129 );
130
131 }
132