]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/ReadOnlyVariableToReadOnlyVariable2Thunk/ReadOnlyVariableToReadOnlyVariable2Thunk.c
1) Add in FvFileLoaderToLoadFileThunk.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / ReadOnlyVariableToReadOnlyVariable2Thunk / ReadOnlyVariableToReadOnlyVariable2Thunk.c
CommitLineData
c8eb679c 1/** @file\r
ec3d17dc 2Module produce EFI_PEI_READ_ONLY_VARIABLE_PPI on top of EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
3UEFI PI Spec supersedes Intel's Framework Specs. \r
4# EFI_PEI_READ_ONLY_VARIABLE_PPI defined in Intel Framework Pkg is replaced by EFI_PEI_READ_ONLY_VARIABLE2_PPI\r
5# in MdePkg.\r
6# This module produces EFI_PEI_READ_ONLY_VARIABLE_PPI on top of EFI_PEI_READ_ONLY_VARIABLE2_PPI. \r
7# This module is used on platform when both of these two conditions are true:\r
8# 1) Framework module consumes EFI_PEI_READ_ONLY_VARIABLE_PPI is present.\r
9# 2) The platform has a PI module that only produces EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
4259256b 10\r
c8eb679c 11This module can't be used together with ReadOnlyVariable2ToReadOnlyVariableThunk module.\r
12\r
4259256b 13Copyright (c) 2006 - 2008 Intel Corporation. <BR>\r
14All rights reserved. This program and the accompanying materials\r
15are licensed and made available under the terms and conditions of the BSD License\r
16which accompanies this distribution. The full text of the license may be found at\r
17http://opensource.org/licenses/bsd-license.php\r
18\r
19THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
20WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
21Module Name:\r
22\r
ec3d17dc 23**/\r
4259256b 24\r
25#include <PiPei.h>\r
26#include <Ppi/ReadOnlyVariable.h>\r
27#include <Ppi/ReadOnlyVariable2.h>\r
c8eb679c 28#include <Ppi/ReadOnlyVariableThunkPresent.h>\r
4259256b 29#include <Library/DebugLib.h>\r
c8eb679c 30#include <Library/PeiServicesLib.h>\r
4259256b 31\r
32//\r
33// Function Prototypes\r
34//\r
35EFI_STATUS\r
36EFIAPI\r
37PeiGetVariable (\r
38 IN EFI_PEI_SERVICES **PeiServices,\r
39 IN CHAR16 *VariableName,\r
40 IN EFI_GUID *VendorGuid,\r
41 OUT UINT32 *Attributes OPTIONAL,\r
42 IN OUT UINTN *DataSize,\r
43 OUT VOID *Data\r
44 );\r
45\r
46EFI_STATUS\r
47EFIAPI\r
48PeiGetNextVariableName (\r
49 IN EFI_PEI_SERVICES **PeiServices,\r
50 IN OUT UINTN *VariableNameSize,\r
51 IN OUT CHAR16 *VariableName,\r
52 IN OUT EFI_GUID *VendorGuid\r
53 );\r
54\r
55//\r
56// Module globals\r
57//\r
58EFI_PEI_READ_ONLY_VARIABLE_PPI mVariablePpi = {\r
59 PeiGetVariable,\r
60 PeiGetNextVariableName\r
61};\r
62\r
63EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {\r
64 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
65 &gEfiPeiReadOnlyVariablePpiGuid,\r
66 &mVariablePpi\r
67};\r
68\r
001d920c 69/**\r
70 Standard entry point of a PEIM.\r
71\r
72 @param FfsHeadher The FFS file header\r
73 @param PeiServices General purpose services available to every PEIM.\r
74\r
75 @retval EFI_SUCCESS If the gEfiPeiReadOnlyVariablePpiGuid interface could be successfully installed.\r
76\r
77--*/\r
4259256b 78EFI_STATUS\r
79EFIAPI\r
80PeimInitializeReadOnlyVariable (\r
001d920c 81 IN EFI_PEI_FILE_HANDLE FfsHeader,\r
4259256b 82 IN CONST EFI_PEI_SERVICES **PeiServices\r
83 )\r
4259256b 84{\r
c8eb679c 85 VOID *Interface;\r
86 EFI_STATUS Status;\r
87\r
88 //\r
89 // Make sure ReadOnlyVariableToReadOnlyVariable2 module is not present. If so, the call chain will form a\r
90 // infinite loop: ReadOnlyVariable -> ReadOnlyVariable2 -> ReadOnlyVariable -> ....\r
91 //\r
92 Status = PeiServicesLocatePpi (&gPeiReadonlyVariableThunkPresentPpiGuid, 0, NULL, &Interface);\r
93 ASSERT (Status == EFI_NOT_FOUND);\r
94\r
4259256b 95 //\r
96 // Publish the variable capability to other modules\r
97 //\r
98 return (*PeiServices)->InstallPpi (PeiServices, &mPpiListVariable);\r
99}\r
100\r
101EFI_STATUS\r
102EFIAPI\r
103PeiGetVariable (\r
104 IN EFI_PEI_SERVICES **PeiServices,\r
105 IN CHAR16 *VariableName,\r
106 IN EFI_GUID *VendorGuid,\r
107 OUT UINT32 *Attributes OPTIONAL,\r
108 IN OUT UINTN *DataSize,\r
109 OUT VOID *Data\r
110 )\r
111/*++\r
112\r
113Routine Description:\r
114\r
115 Provide the read variable functionality of the variable services.\r
116\r
117Arguments:\r
118\r
119 PeiServices - General purpose services available to every PEIM.\r
120\r
121 VariableName - The variable name\r
122\r
123 VendorGuid - The vendor's GUID\r
124\r
125 Attributes - Pointer to the attribute\r
126\r
127 DataSize - Size of data\r
128\r
129 Data - Pointer to data\r
130\r
131Returns:\r
132\r
133 EFI_SUCCESS - The interface could be successfully installed\r
134\r
135 EFI_NOT_FOUND - The variable could not be discovered\r
136\r
137 EFI_BUFFER_TOO_SMALL - The caller buffer is not large enough\r
138\r
139--*/\r
140{\r
141 EFI_STATUS Status;\r
142 EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r
143\r
144 Status = (*PeiServices)->LocatePpi (\r
145 (CONST EFI_PEI_SERVICES **)PeiServices, \r
146 &gEfiPeiReadOnlyVariable2PpiGuid, \r
147 0, \r
148 NULL, \r
149 (VOID **)&ReadOnlyVariable2\r
150 );\r
151 ASSERT_EFI_ERROR (Status);\r
152\r
153 return ReadOnlyVariable2->GetVariable (\r
154 ReadOnlyVariable2,\r
155 VariableName,\r
156 VendorGuid,\r
157 Attributes,\r
158 DataSize,\r
159 Data\r
160 );\r
161}\r
162\r
163EFI_STATUS\r
164EFIAPI\r
165PeiGetNextVariableName (\r
166 IN EFI_PEI_SERVICES **PeiServices,\r
167 IN OUT UINTN *VariableNameSize,\r
168 IN OUT CHAR16 *VariableName,\r
169 IN OUT EFI_GUID *VendorGuid\r
170 )\r
171/*++\r
172\r
173Routine Description:\r
174\r
175 Provide the get next variable functionality of the variable services.\r
176\r
177Arguments:\r
178\r
179 PeiServices - General purpose services available to every PEIM.\r
180 VariabvleNameSize - The variable name's size.\r
181 VariableName - A pointer to the variable's name.\r
182 VariableGuid - A pointer to the EFI_GUID structure.\r
183\r
184 VariableNameSize - Size of the variable name\r
185\r
186 VariableName - The variable name\r
187\r
188 VendorGuid - The vendor's GUID\r
189\r
190Returns:\r
191\r
192 EFI_SUCCESS - The interface could be successfully installed\r
193\r
194 EFI_NOT_FOUND - The variable could not be discovered\r
195\r
196--*/\r
197{\r
198 EFI_STATUS Status;\r
199 EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r
200\r
201 Status = (*PeiServices)->LocatePpi (\r
202 (CONST EFI_PEI_SERVICES **)PeiServices, \r
203 &gEfiPeiReadOnlyVariable2PpiGuid, \r
204 0, \r
205 NULL, \r
206 (VOID **)&ReadOnlyVariable2\r
207 );\r
208 ASSERT_EFI_ERROR (Status);\r
209\r
210 return ReadOnlyVariable2->NextVariableName (\r
211 ReadOnlyVariable2,\r
212 VariableNameSize,\r
213 VariableName,\r
214 VendorGuid\r
215 );\r
216}\r