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