]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/ReadOnlyVariableToReadOnlyVariable2Thunk/ReadOnlyVariableToReadOnlyVariable2Thunk.c
Update to doxygen comments.
[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
2be3c946 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
2be3c946 101/**\r
102 Provide the read variable functionality of the variable services.\r
103\r
104 @param PeiServices General purpose services available to every PEIM.\r
105 @param VariableName The variable name\r
106 @param VendorGuid The vendor's GUID\r
107 @param Attributes Pointer to the attribute\r
108 @param DataSize Size of data\r
109 @param Data Pointer to data\r
110\r
111 @retval EFI_SUCCESS The interface could be successfully installed\r
112 @retval EFI_NOT_FOUND The variable could not be discovered\r
113 @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough\r
114\r
115**/\r
4259256b 116EFI_STATUS\r
117EFIAPI\r
118PeiGetVariable (\r
119 IN EFI_PEI_SERVICES **PeiServices,\r
120 IN CHAR16 *VariableName,\r
121 IN EFI_GUID *VendorGuid,\r
122 OUT UINT32 *Attributes OPTIONAL,\r
123 IN OUT UINTN *DataSize,\r
124 OUT VOID *Data\r
125 )\r
4259256b 126{\r
127 EFI_STATUS Status;\r
128 EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r
129\r
130 Status = (*PeiServices)->LocatePpi (\r
131 (CONST EFI_PEI_SERVICES **)PeiServices, \r
132 &gEfiPeiReadOnlyVariable2PpiGuid, \r
133 0, \r
134 NULL, \r
135 (VOID **)&ReadOnlyVariable2\r
136 );\r
137 ASSERT_EFI_ERROR (Status);\r
138\r
139 return ReadOnlyVariable2->GetVariable (\r
140 ReadOnlyVariable2,\r
141 VariableName,\r
142 VendorGuid,\r
143 Attributes,\r
144 DataSize,\r
145 Data\r
146 );\r
147}\r
148\r
2be3c946 149/**\r
150 Provide the get next variable functionality of the variable services.\r
151\r
152 @param PeiServices General purpose services available to every PEIM.\r
153 @param VariabvleNameSize The variable name's size.\r
154 @param VariableName A pointer to the variable's name.\r
155 @param VariableGuid A pointer to the EFI_GUID structure.\r
156 @param VariableNameSize Size of the variable name\r
157 @param VariableName The variable name\r
158 @param VendorGuid The vendor's GUID\r
159\r
160 @retval EFI_SUCCESS The interface could be successfully installed\r
161 @retval EFI_NOT_FOUND The variable could not be discovered\r
162\r
163**/\r
4259256b 164EFI_STATUS\r
165EFIAPI\r
166PeiGetNextVariableName (\r
167 IN EFI_PEI_SERVICES **PeiServices,\r
168 IN OUT UINTN *VariableNameSize,\r
169 IN OUT CHAR16 *VariableName,\r
170 IN OUT EFI_GUID *VendorGuid\r
171 )\r
4259256b 172{\r
173 EFI_STATUS Status;\r
174 EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r
175\r
176 Status = (*PeiServices)->LocatePpi (\r
177 (CONST EFI_PEI_SERVICES **)PeiServices, \r
178 &gEfiPeiReadOnlyVariable2PpiGuid, \r
179 0, \r
180 NULL, \r
181 (VOID **)&ReadOnlyVariable2\r
182 );\r
183 ASSERT_EFI_ERROR (Status);\r
184\r
185 return ReadOnlyVariable2->NextVariableName (\r
186 ReadOnlyVariable2,\r
187 VariableNameSize,\r
188 VariableName,\r
189 VendorGuid\r
190 );\r
191}\r