]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/ReadOnlyVariable2ToReadOnlyVariableThunk/ReadOnlyVariable2ToReadOnlyVariableThunk.c
Add .S (for GCC) file for Pei/PeiLib/PeiLib_Edk2.inf.
[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
4259256b 78EFI_STATUS\r
79EFIAPI\r
80PeimInitializeReadOnlyVariable2 (\r
81 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
82 IN EFI_PEI_SERVICES **PeiServices\r
83 )\r
84/*++\r
85\r
86Routine Description:\r
87\r
88 Provide the functionality of the variable services.\r
89\r
90Arguments:\r
91\r
92 FfsHeadher - The FFS file header\r
93 PeiServices - General purpose services available to every PEIM.\r
94\r
95Returns:\r
96\r
97 Status - EFI_SUCCESS if the interface could be successfully\r
98 installed\r
99\r
100--*/\r
101{\r
6c45955b 102 VOID *Interface;\r
103 EFI_STATUS Status;\r
104\r
105 //\r
106 // Make sure ReadOnlyVariable2ToReadOnlyVariable module is not present. If so, the call chain will form a\r
107 // infinite loop: ReadOnlyVariable2 -> ReadOnlyVariable -> ReadOnlyVariable2 -> ....\r
108 //\r
109 Status = PeiServicesLocatePpi (&gPeiReadonlyVariableThunkPresentPpiGuid, 0, NULL, &Interface);\r
110 ASSERT (Status == EFI_NOT_FOUND);\r
111 \r
f21c3770 112 Status = PeiServicesInstallPpi (&mReadOnlyVariableThunkPresent);\r
113 ASSERT_EFI_ERROR (Status);\r
114 \r
4259256b 115 //\r
116 // Publish the variable capability to other modules\r
117 //\r
118 return PeiServicesInstallPpi (&mPpiListVariable);\r
119}\r
120\r
2be3c946 121/**\r
122 Provide the read variable functionality of the variable services.\r
123\r
124 @param PeiServices General purpose services available to every PEIM.\r
125 @param VariableName The variable name\r
126 @param VendorGuid The vendor's GUID\r
127 @param Attributes Pointer to the attribute\r
128 @param DataSize Size of data\r
129 @param Data Pointer to data\r
130\r
131 @retval EFI_SUCCESS The interface could be successfully installed\r
132 @retval EFI_NOT_FOUND The variable could not be discovered\r
133 @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough\r
134\r
135**/\r
4259256b 136EFI_STATUS\r
137EFIAPI\r
138PeiGetVariable (\r
139 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
140 IN CONST CHAR16 *VariableName,\r
141 IN CONST EFI_GUID *VariableGuid,\r
142 OUT UINT32 *Attributes,\r
143 IN OUT UINTN *DataSize,\r
144 OUT VOID *Data\r
145 )\r
4259256b 146{\r
147 EFI_STATUS Status;\r
148 EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;\r
149\r
150 Status = PeiServicesLocatePpi (\r
151 &gEfiPeiReadOnlyVariablePpiGuid,\r
152 0,\r
153 NULL,\r
154 (VOID **)&ReadOnlyVariable\r
155 );\r
156 ASSERT_EFI_ERROR (Status);\r
157\r
158 return ReadOnlyVariable->PeiGetVariable (\r
159 GetPeiServicesTablePointer (),\r
160 (CHAR16 *)VariableName,\r
161 (EFI_GUID *)VariableGuid,\r
162 Attributes,\r
163 DataSize,\r
164 Data\r
165 );\r
166}\r
167\r
2be3c946 168/**\r
169 Provide the get next variable functionality of the variable services.\r
170\r
171 @param PeiServices General purpose services available to every PEIM.\r
172 @param VariabvleNameSize The variable name's size.\r
173 @param VariableName A pointer to the variable's name.\r
174 @param VariableGuid A pointer to the EFI_GUID structure.\r
175 @param VariableNameSize Size of the variable name\r
176 @param VariableName The variable name\r
177 @param VendorGuid The vendor's GUID\r
178\r
179 @retval EFI_SUCCESS The interface could be successfully installed\r
180 @retval EFI_NOT_FOUND The variable could not be discovered\r
181\r
182**/\r
4259256b 183EFI_STATUS\r
184EFIAPI\r
185PeiGetNextVariableName (\r
186 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
187 IN OUT UINTN *VariableNameSize,\r
188 IN OUT CHAR16 *VariableName,\r
189 IN OUT EFI_GUID *VariableGuid\r
190 )\r
4259256b 191{\r
192 EFI_STATUS Status;\r
193 EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;\r
194\r
195 Status = PeiServicesLocatePpi (\r
196 &gEfiPeiReadOnlyVariablePpiGuid,\r
197 0,\r
198 NULL,\r
199 (VOID **)&ReadOnlyVariable\r
200 );\r
201 ASSERT_EFI_ERROR (Status);\r
202\r
203 return ReadOnlyVariable->PeiGetNextVariableName (\r
204 GetPeiServicesTablePointer (),\r
205 VariableNameSize,\r
206 VariableName,\r
207 VariableGuid\r
208 );\r
209}\r