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
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.
11 This module can't be used together with ReadOnlyVariable2ToReadOnlyVariableThunk module.
13 Copyright (c) 2006 - 2008 Intel Corporation. <BR>
14 All rights reserved. This program and the accompanying materials
15 are licensed and made available under the terms and conditions of the BSD License
16 which accompanies this distribution. The full text of the license may be found at
17 http://opensource.org/licenses/bsd-license.php
19 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
20 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
26 #include <Ppi/ReadOnlyVariable.h>
27 #include <Ppi/ReadOnlyVariable2.h>
28 #include <Ppi/ReadOnlyVariableThunkPresent.h>
29 #include <Library/DebugLib.h>
30 #include <Library/PeiServicesLib.h>
33 // Function Prototypes
38 IN EFI_PEI_SERVICES
**PeiServices
,
39 IN CHAR16
*VariableName
,
40 IN EFI_GUID
*VendorGuid
,
41 OUT UINT32
*Attributes OPTIONAL
,
42 IN OUT UINTN
*DataSize
,
48 PeiGetNextVariableName (
49 IN EFI_PEI_SERVICES
**PeiServices
,
50 IN OUT UINTN
*VariableNameSize
,
51 IN OUT CHAR16
*VariableName
,
52 IN OUT EFI_GUID
*VendorGuid
58 EFI_PEI_READ_ONLY_VARIABLE_PPI mVariablePpi
= {
60 PeiGetNextVariableName
63 EFI_PEI_PPI_DESCRIPTOR mPpiListVariable
= {
64 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
65 &gEfiPeiReadOnlyVariablePpiGuid
,
69 EFI_PEI_PPI_DESCRIPTOR mReadOnlyVariableThunkPresent
= {
70 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
71 &gPeiReadonlyVariableThunkPresentPpiGuid
,
77 Standard entry point of a PEIM.
79 @param FfsHeadher The FFS file header
80 @param PeiServices General purpose services available to every PEIM.
82 @retval EFI_SUCCESS If the gEfiPeiReadOnlyVariablePpiGuid interface could be successfully installed.
87 PeimInitializeReadOnlyVariable (
88 IN EFI_PEI_FILE_HANDLE FfsHeader
,
89 IN CONST EFI_PEI_SERVICES
**PeiServices
96 // Make sure ReadOnlyVariableToReadOnlyVariable2 module is not present. If so, the call chain will form a
97 // infinite loop: ReadOnlyVariable -> ReadOnlyVariable2 -> ReadOnlyVariable -> ....
99 Status
= PeiServicesLocatePpi (&gPeiReadonlyVariableThunkPresentPpiGuid
, 0, NULL
, &Interface
);
100 ASSERT (Status
== EFI_NOT_FOUND
);
102 Status
= PeiServicesInstallPpi (&mReadOnlyVariableThunkPresent
);
103 ASSERT_EFI_ERROR (Status
);
106 // Publish the variable capability to other modules
108 return (*PeiServices
)->InstallPpi (PeiServices
, &mPpiListVariable
);
112 Provide the read variable functionality of the variable services.
114 @param PeiServices General purpose services available to every PEIM.
115 @param VariableName The variable name
116 @param VendorGuid The vendor's GUID
117 @param Attributes Pointer to the attribute
118 @param DataSize Size of data
119 @param Data Pointer to data
121 @retval EFI_SUCCESS The interface could be successfully installed
122 @retval EFI_NOT_FOUND The variable could not be discovered
123 @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough
129 IN EFI_PEI_SERVICES
**PeiServices
,
130 IN CHAR16
*VariableName
,
131 IN EFI_GUID
*VendorGuid
,
132 OUT UINT32
*Attributes OPTIONAL
,
133 IN OUT UINTN
*DataSize
,
138 EFI_PEI_READ_ONLY_VARIABLE2_PPI
*ReadOnlyVariable2
;
140 Status
= (*PeiServices
)->LocatePpi (
141 (CONST EFI_PEI_SERVICES
**)PeiServices
,
142 &gEfiPeiReadOnlyVariable2PpiGuid
,
145 (VOID
**)&ReadOnlyVariable2
147 ASSERT_EFI_ERROR (Status
);
149 return ReadOnlyVariable2
->GetVariable (
160 Provide the get next variable functionality of the variable services.
162 @param PeiServices General purpose services available to every PEIM.
163 @param VariabvleNameSize The variable name's size.
164 @param VariableName A pointer to the variable's name.
165 @param VariableGuid A pointer to the EFI_GUID structure.
166 @param VariableNameSize Size of the variable name
167 @param VariableName The variable name
168 @param VendorGuid The vendor's GUID
170 @retval EFI_SUCCESS The interface could be successfully installed
171 @retval EFI_NOT_FOUND The variable could not be discovered
176 PeiGetNextVariableName (
177 IN EFI_PEI_SERVICES
**PeiServices
,
178 IN OUT UINTN
*VariableNameSize
,
179 IN OUT CHAR16
*VariableName
,
180 IN OUT EFI_GUID
*VendorGuid
184 EFI_PEI_READ_ONLY_VARIABLE2_PPI
*ReadOnlyVariable2
;
186 Status
= (*PeiServices
)->LocatePpi (
187 (CONST EFI_PEI_SERVICES
**)PeiServices
,
188 &gEfiPeiReadOnlyVariable2PpiGuid
,
191 (VOID
**)&ReadOnlyVariable2
193 ASSERT_EFI_ERROR (Status
);
195 return ReadOnlyVariable2
->NextVariableName (