]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/ReadOnlyVariableOnReadOnlyVariable2Thunk/ReadOnlyVariableOnReadOnlyVariable2Thunk.c
Fix ICC build break properly
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / ReadOnlyVariableOnReadOnlyVariable2Thunk / ReadOnlyVariableOnReadOnlyVariable2Thunk.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
28#include <Library/DebugLib.h>\r
c8eb679c 29#include <Library/PeiServicesLib.h>\r
4259256b 30\r
31//\r
32// Function Prototypes\r
33//\r
34EFI_STATUS\r
35EFIAPI\r
36PeiGetVariable (\r
37 IN EFI_PEI_SERVICES **PeiServices,\r
38 IN CHAR16 *VariableName,\r
39 IN EFI_GUID *VendorGuid,\r
40 OUT UINT32 *Attributes OPTIONAL,\r
41 IN OUT UINTN *DataSize,\r
42 OUT VOID *Data\r
43 );\r
44\r
45EFI_STATUS\r
46EFIAPI\r
47PeiGetNextVariableName (\r
48 IN EFI_PEI_SERVICES **PeiServices,\r
49 IN OUT UINTN *VariableNameSize,\r
50 IN OUT CHAR16 *VariableName,\r
51 IN OUT EFI_GUID *VendorGuid\r
52 );\r
53\r
54//\r
55// Module globals\r
56//\r
57EFI_PEI_READ_ONLY_VARIABLE_PPI mVariablePpi = {\r
58 PeiGetVariable,\r
59 PeiGetNextVariableName\r
60};\r
61\r
62EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {\r
63 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
64 &gEfiPeiReadOnlyVariablePpiGuid,\r
65 &mVariablePpi\r
66};\r
67\r
f21c3770 68\r
69\r
001d920c 70/**\r
71 Standard entry point of a PEIM.\r
72\r
73 @param FfsHeadher The FFS file header\r
74 @param PeiServices General purpose services available to every PEIM.\r
75\r
76 @retval EFI_SUCCESS If the gEfiPeiReadOnlyVariablePpiGuid interface could be successfully installed.\r
77\r
2be3c946 78**/\r
4259256b 79EFI_STATUS\r
80EFIAPI\r
81PeimInitializeReadOnlyVariable (\r
001d920c 82 IN EFI_PEI_FILE_HANDLE FfsHeader,\r
4259256b 83 IN CONST EFI_PEI_SERVICES **PeiServices\r
84 )\r
4259256b 85{\r
c8eb679c 86 //\r
a45d1619 87 //Developer should make sure ReadOnlyVariableToReadOnlyVariable2 module is not present. If so, the call chain will form a\r
c8eb679c 88 // infinite loop: ReadOnlyVariable -> ReadOnlyVariable2 -> ReadOnlyVariable -> ....\r
89 //\r
4259256b 90 //\r
91 // Publish the variable capability to other modules\r
92 //\r
93 return (*PeiServices)->InstallPpi (PeiServices, &mPpiListVariable);\r
94}\r
95\r
2be3c946 96/**\r
97 Provide the read variable functionality of the variable services.\r
98\r
99 @param PeiServices General purpose services available to every PEIM.\r
100 @param VariableName The variable name\r
101 @param VendorGuid The vendor's GUID\r
102 @param Attributes Pointer to the attribute\r
103 @param DataSize Size of data\r
104 @param Data Pointer to data\r
105\r
106 @retval EFI_SUCCESS The interface could be successfully installed\r
107 @retval EFI_NOT_FOUND The variable could not be discovered\r
108 @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough\r
109\r
110**/\r
4259256b 111EFI_STATUS\r
112EFIAPI\r
113PeiGetVariable (\r
114 IN EFI_PEI_SERVICES **PeiServices,\r
115 IN CHAR16 *VariableName,\r
116 IN EFI_GUID *VendorGuid,\r
117 OUT UINT32 *Attributes OPTIONAL,\r
118 IN OUT UINTN *DataSize,\r
119 OUT VOID *Data\r
120 )\r
4259256b 121{\r
122 EFI_STATUS Status;\r
123 EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r
124\r
125 Status = (*PeiServices)->LocatePpi (\r
126 (CONST EFI_PEI_SERVICES **)PeiServices, \r
127 &gEfiPeiReadOnlyVariable2PpiGuid, \r
128 0, \r
129 NULL, \r
130 (VOID **)&ReadOnlyVariable2\r
131 );\r
132 ASSERT_EFI_ERROR (Status);\r
133\r
134 return ReadOnlyVariable2->GetVariable (\r
135 ReadOnlyVariable2,\r
136 VariableName,\r
137 VendorGuid,\r
138 Attributes,\r
139 DataSize,\r
140 Data\r
141 );\r
142}\r
143\r
2be3c946 144/**\r
145 Provide the get next variable functionality of the variable services.\r
146\r
147 @param PeiServices General purpose services available to every PEIM.\r
148 @param VariabvleNameSize The variable name's size.\r
149 @param VariableName A pointer to the variable's name.\r
150 @param VariableGuid A pointer to the EFI_GUID structure.\r
151 @param VariableNameSize Size of the variable name\r
152 @param VariableName The variable name\r
153 @param VendorGuid The vendor's GUID\r
154\r
155 @retval EFI_SUCCESS The interface could be successfully installed\r
156 @retval EFI_NOT_FOUND The variable could not be discovered\r
157\r
158**/\r
4259256b 159EFI_STATUS\r
160EFIAPI\r
161PeiGetNextVariableName (\r
162 IN EFI_PEI_SERVICES **PeiServices,\r
163 IN OUT UINTN *VariableNameSize,\r
164 IN OUT CHAR16 *VariableName,\r
165 IN OUT EFI_GUID *VendorGuid\r
166 )\r
4259256b 167{\r
168 EFI_STATUS Status;\r
169 EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r
170\r
171 Status = (*PeiServices)->LocatePpi (\r
172 (CONST EFI_PEI_SERVICES **)PeiServices, \r
173 &gEfiPeiReadOnlyVariable2PpiGuid, \r
174 0, \r
175 NULL, \r
176 (VOID **)&ReadOnlyVariable2\r
177 );\r
178 ASSERT_EFI_ERROR (Status);\r
179\r
180 return ReadOnlyVariable2->NextVariableName (\r
181 ReadOnlyVariable2,\r
182 VariableNameSize,\r
183 VariableName,\r
184 VendorGuid\r
185 );\r
186}\r