]>
Commit | Line | Data |
---|---|---|
001d920c | 1 | /** @file\r |
2 | Module produce Framework's EFI_PEI_FV_FILE_LOADER_PPI top of EFI_PEI_LOAD_FILE_PPI.\r | |
3 | \r | |
4 | UEFI PI Spec supersedes Intel's Framework Specs. \r | |
5 | EFI_PEI_FV_FILE_LOADER_PPI defined in Intel Framework Pkg is replaced by EFI_PEI_LOAD_FILE_PPI\r | |
6 | in MdePkg.\r | |
7 | This module produces EFI_PEI_FV_FILE_LOADER_PPI on top of EFI_PEI_LOAD_FILE_PPI . \r | |
8 | This module is used on platform when both of these two conditions are true:\r | |
9 | 1) Framework module consumes EFI_PEI_FV_FILE_LOADER_PPI is present.\r | |
10 | 2) The platform has PI modules that produce EFI_PEI_LOAD_FILE_PPI.\r | |
11 | \r | |
584d5652 | 12 | Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r |
001d920c | 13 | \r |
584d5652 | 14 | This program and the accompanying materials\r |
001d920c | 15 | are licensed and made available under the terms and conditions of the BSD License\r |
16 | which accompanies this distribution. The full text of the license may be found at\r | |
17 | http://opensource.org/licenses/bsd-license.php\r | |
18 | \r | |
19 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
20 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
21 | Module Name:\r | |
22 | \r | |
23 | **/\r | |
24 | \r | |
25 | #include <PiPei.h>\r | |
26 | #include <Ppi/LoadFile.h>\r | |
27 | #include <Ppi/FvLoadFile.h>\r | |
28 | #include <Library/DebugLib.h>\r | |
29 | #include <Library/PeiServicesLib.h>\r | |
30 | \r | |
31 | /**\r | |
32 | \r | |
33 | Wrap the call to PI's EFI_PEI_LOAD_FILE_PPI.\r | |
34 | \r | |
26a76fbc LG |
35 | @param This A pointer to EFI_PEI_FV_FILE_LOADER_PPI.\r |
36 | @param FfsHeader Pointer to the FFS header of the file to load.\r | |
001d920c | 37 | @param ImageAddress The loaded address of the Image.\r |
26a76fbc LG |
38 | @param ImageSize Pointer to the size of the loaded image.\r |
39 | @param EntryPoint Pointer to the entry point of the image.\r | |
001d920c | 40 | \r |
26a76fbc | 41 | @retval EFI_SUCCESS The image was loaded successfully.\r |
001d920c | 42 | @retval EFI_OUT_OF_RESOURCE There was not enought memory.\r |
43 | @retval EFI_INVALID_PARAMETER The contents of the FFS file did not contain a valid PE/COFF image that could be loaded.\r | |
26a76fbc | 44 | **/ \r |
001d920c | 45 | EFI_STATUS\r |
46 | EFIAPI\r | |
47 | FrameworkLoadFile (\r | |
48 | IN EFI_PEI_FV_FILE_LOADER_PPI *This,\r | |
49 | IN EFI_FFS_FILE_HEADER *FfsHeader,\r | |
50 | OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r | |
51 | OUT UINT64 *ImageSize,\r | |
52 | OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r | |
e00e1d46 | 53 | );\r |
001d920c | 54 | \r |
55 | EFI_PEI_FV_FILE_LOADER_PPI mLoadFilePpi = {\r | |
56 | FrameworkLoadFile\r | |
57 | };\r | |
58 | \r | |
59 | EFI_PEI_PPI_DESCRIPTOR mPpiFrameworkLoadFile = {\r | |
60 | (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r | |
61 | &gEfiPeiFvFileLoaderPpiGuid,\r | |
62 | &mLoadFilePpi\r | |
63 | };\r | |
64 | \r | |
65 | /**\r | |
66 | Standard entry point of a PEIM.\r | |
67 | \r | |
26a76fbc | 68 | @param FfsHeader The FFS file header\r |
001d920c | 69 | @param PeiServices General purpose services available to every PEIM.\r |
70 | \r | |
71 | @retval EFI_SUCCESS If the gEfiPeiReadOnlyVariablePpiGuid interface could be successfully installed.\r | |
72 | \r | |
26a76fbc | 73 | **/\r |
001d920c | 74 | EFI_STATUS\r |
75 | EFIAPI\r | |
76 | InitPeim (\r | |
bad2ca8e | 77 | IN EFI_PEI_FILE_HANDLE FfsHeader,\r |
001d920c | 78 | IN CONST EFI_PEI_SERVICES **PeiServices\r |
79 | )\r | |
80 | {\r | |
9d5eaca4 | 81 | //\r |
82 | // This thunk module can only be used together with a PI PEI core, as we \r | |
83 | // assume PeiServices Pointer Table can be located in a standard way defined\r | |
84 | // in PI spec.\r | |
85 | //\r | |
86 | ASSERT ((*PeiServices)->Hdr.Revision >= 0x00010000);\r | |
001d920c | 87 | return (*PeiServices)->InstallPpi (PeiServices, &mPpiFrameworkLoadFile);\r |
88 | }\r | |
89 | \r | |
90 | \r | |
91 | /**\r | |
92 | \r | |
93 | Wrap the call to PI's EFI_PEI_LOAD_FILE_PPI.\r | |
94 | \r | |
26a76fbc LG |
95 | @param This A pointer to EFI_PEI_FV_FILE_LOADER_PPI.\r |
96 | @param FfsHeader The pointer to the file header to be loaded by the Pe/Coff loader.\r | |
001d920c | 97 | @param ImageAddress The loaded address of the Image.\r |
26a76fbc LG |
98 | @param ImageSize Pointer to the size of the loaded image.\r |
99 | @param EntryPoint Pointer to the entry point of the image.\r | |
001d920c | 100 | \r |
26a76fbc | 101 | @retval EFI_SUCCESS The image was loaded successfully.\r |
001d920c | 102 | @retval EFI_OUT_OF_RESOURCE There was not enought memory.\r |
103 | @retval EFI_INVALID_PARAMETER The contents of the FFS file did not contain a valid PE/COFF image that could be loaded.\r | |
26a76fbc | 104 | **/ \r |
001d920c | 105 | EFI_STATUS\r |
106 | EFIAPI\r | |
107 | FrameworkLoadFile (\r | |
108 | IN EFI_PEI_FV_FILE_LOADER_PPI *This,\r | |
109 | IN EFI_FFS_FILE_HEADER *FfsHeader,\r | |
110 | OUT EFI_PHYSICAL_ADDRESS *ImageAddress,\r | |
111 | OUT UINT64 *ImageSize,\r | |
112 | OUT EFI_PHYSICAL_ADDRESS *EntryPoint\r | |
113 | )\r | |
114 | {\r | |
115 | EFI_STATUS Status;\r | |
116 | EFI_PEI_LOAD_FILE_PPI *PiLoadFile;\r | |
117 | UINT32 AuthenticationState;\r | |
118 | \r | |
119 | Status = PeiServicesLocatePpi (\r | |
120 | &gEfiPeiLoadFilePpiGuid,\r | |
121 | 0,\r | |
122 | NULL,\r | |
123 | (VOID **) &PiLoadFile\r | |
124 | );\r | |
125 | ASSERT_EFI_ERROR (Status);\r | |
126 | \r | |
127 | return PiLoadFile->LoadFile (\r | |
128 | PiLoadFile,\r | |
129 | (EFI_PEI_FILE_HANDLE) FfsHeader,\r | |
130 | ImageAddress,\r | |
131 | ImageSize,\r | |
132 | EntryPoint,\r | |
133 | &AuthenticationState\r | |
134 | );\r | |
135 | \r | |
136 | }\r | |
137 | \r |