]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/ReadOnlyVariable2OnReadOnlyVariableThunk/ReadOnlyVariable2OnReadOnlyVariableThunk.c
Fix build break.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / ReadOnlyVariable2OnReadOnlyVariableThunk / ReadOnlyVariable2OnReadOnlyVariableThunk.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
29#include <Library/DebugLib.h>\r
30#include <Library/PeiServicesTablePointerLib.h>\r
31#include <Library/PeiServicesLib.h>\r
32\r
33//\r
34// Function Prototypes\r
35//\r
36EFI_STATUS\r
37EFIAPI\r
38PeiGetVariable (\r
39 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
40 IN CONST CHAR16 *VariableName,\r
41 IN CONST EFI_GUID *VariableGuid,\r
42 OUT UINT32 *Attributes,\r
43 IN OUT UINTN *DataSize,\r
44 OUT VOID *Data\r
45 );\r
46\r
47EFI_STATUS\r
48EFIAPI\r
49PeiGetNextVariableName (\r
50 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
51 IN OUT UINTN *VariableNameSize,\r
52 IN OUT CHAR16 *VariableName,\r
53 IN OUT EFI_GUID *VariableGuid\r
54 );\r
55\r
56//\r
57// Module globals\r
58//\r
59EFI_PEI_READ_ONLY_VARIABLE2_PPI mVariablePpi = {\r
60 PeiGetVariable,\r
61 PeiGetNextVariableName\r
62};\r
63\r
64EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {\r
65 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
66 &gEfiPeiReadOnlyVariable2PpiGuid,\r
67 &mVariablePpi\r
68};\r
69\r
6c45955b 70\r
48a59ce0 71/**\r
72 User entry for this PEIM driver.\r
73 \r
74 @param FileHandle Handle of the file being invoked.\r
75 @param PeiServices Describes the list of possible PEI Services.\r
76\r
77 @retval EFI_SUCCESS ReadOnlyVariable2 PPI is successfully installed.\r
78 @return Others ReadOnlyVariable2 PPI is not successfully installed.\r
79\r
80**/\r
4259256b 81EFI_STATUS\r
82EFIAPI\r
83PeimInitializeReadOnlyVariable2 (\r
48a59ce0 84 IN EFI_PEI_FILE_HANDLE FfsHeader,\r
85 IN CONST EFI_PEI_SERVICES **PeiServices\r
4259256b 86 )\r
4259256b 87{\r
9d5eaca4 88 //\r
89 // This thunk module can only be used together with a PI PEI core, as we \r
90 // assume PeiServices Pointer Table can be located in a standard way defined\r
91 // in PI spec.\r
92 //\r
93 ASSERT ((*PeiServices)->Hdr.Revision >= 0x00010000);\r
6c45955b 94\r
95 //\r
a45d1619 96 // Developer should make sure ReadOnlyVariable2ToReadOnlyVariable module is not present. or else, the call chain will form a\r
97 // infinite loop: ReadOnlyVariable2 -> ReadOnlyVariable -> ReadOnlyVariable2 -> .....\r
6c45955b 98 //\r
4259256b 99 //\r
100 // Publish the variable capability to other modules\r
101 //\r
102 return PeiServicesInstallPpi (&mPpiListVariable);\r
103}\r
104\r
2be3c946 105/**\r
106 Provide the read variable functionality of the variable services.\r
107\r
108 @param PeiServices General purpose services available to every PEIM.\r
109 @param VariableName The variable name\r
110 @param VendorGuid The vendor's GUID\r
111 @param Attributes Pointer to the attribute\r
112 @param DataSize Size of data\r
113 @param Data Pointer to data\r
114\r
115 @retval EFI_SUCCESS The interface could be successfully installed\r
116 @retval EFI_NOT_FOUND The variable could not be discovered\r
117 @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough\r
118\r
119**/\r
4259256b 120EFI_STATUS\r
121EFIAPI\r
122PeiGetVariable (\r
123 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
124 IN CONST CHAR16 *VariableName,\r
125 IN CONST EFI_GUID *VariableGuid,\r
126 OUT UINT32 *Attributes,\r
127 IN OUT UINTN *DataSize,\r
128 OUT VOID *Data\r
129 )\r
4259256b 130{\r
131 EFI_STATUS Status;\r
132 EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;\r
133\r
134 Status = PeiServicesLocatePpi (\r
135 &gEfiPeiReadOnlyVariablePpiGuid,\r
136 0,\r
137 NULL,\r
138 (VOID **)&ReadOnlyVariable\r
139 );\r
140 ASSERT_EFI_ERROR (Status);\r
141\r
b3d8b21f 142 return ReadOnlyVariable->GetVariable (\r
79ec0fac 143 (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),\r
4259256b 144 (CHAR16 *)VariableName,\r
145 (EFI_GUID *)VariableGuid,\r
146 Attributes,\r
147 DataSize,\r
148 Data\r
149 );\r
150}\r
151\r
2be3c946 152/**\r
153 Provide the get next variable functionality of the variable services.\r
154\r
155 @param PeiServices General purpose services available to every PEIM.\r
156 @param VariabvleNameSize The variable name's size.\r
157 @param VariableName A pointer to the variable's name.\r
158 @param VariableGuid A pointer to the EFI_GUID structure.\r
159 @param VariableNameSize Size of the variable name\r
160 @param VariableName The variable name\r
161 @param VendorGuid The vendor's GUID\r
162\r
163 @retval EFI_SUCCESS The interface could be successfully installed\r
164 @retval EFI_NOT_FOUND The variable could not be discovered\r
165\r
166**/\r
4259256b 167EFI_STATUS\r
168EFIAPI\r
169PeiGetNextVariableName (\r
170 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
171 IN OUT UINTN *VariableNameSize,\r
172 IN OUT CHAR16 *VariableName,\r
173 IN OUT EFI_GUID *VariableGuid\r
174 )\r
4259256b 175{\r
176 EFI_STATUS Status;\r
177 EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;\r
178\r
179 Status = PeiServicesLocatePpi (\r
180 &gEfiPeiReadOnlyVariablePpiGuid,\r
181 0,\r
182 NULL,\r
183 (VOID **)&ReadOnlyVariable\r
184 );\r
185 ASSERT_EFI_ERROR (Status);\r
186\r
b3d8b21f 187 return ReadOnlyVariable->GetNextVariableName (\r
79ec0fac 188 (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),\r
4259256b 189 VariableNameSize,\r
190 VariableName,\r
191 VariableGuid\r
192 );\r
193}\r