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