2 Module produce EFI_PEI_READ_ONLY_VARIABLE2_PPI on top of EFI_PEI_READ_ONLY_VARIABLE_PPI.
\r
3 UEFI 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
6 This module produces EFI_PEI_READ_ONLY_VARIABLE2_PPI on top of EFI_PEI_READ_ONLY_VARIABLE_PPI.
\r
7 This module is used on platform when both of these two conditions are true:
\r
8 1) Framework module produces EFI_PEI_READ_ONLY_VARIABLE_PPI is present.
\r
9 2) The platform has PI modules that only consumes EFI_PEI_READ_ONLY_VARIABLE2_PPI.
\r
11 This module can't be used together with ReadOnlyVariableToReadOnlyVariable2Thunk module.
\r
14 Copyright (c) 2006 - 2008 Intel Corporation. <BR>
\r
15 All rights reserved. This program and the accompanying materials
\r
16 are licensed and made available under the terms and conditions of the BSD License
\r
17 which accompanies this distribution. The full text of the license may be found at
\r
18 http://opensource.org/licenses/bsd-license.php
\r
20 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
\r
21 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
\r
27 #include <Ppi/ReadOnlyVariable2.h>
\r
28 #include <Ppi/ReadOnlyVariable.h>
\r
29 #include <Ppi/ReadOnlyVariableThunkPresent.h>
\r
30 #include <Library/DebugLib.h>
\r
31 #include <Library/PeiServicesTablePointerLib.h>
\r
32 #include <Library/PeiServicesLib.h>
\r
35 // Function Prototypes
\r
40 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
\r
41 IN CONST CHAR16 *VariableName,
\r
42 IN CONST EFI_GUID *VariableGuid,
\r
43 OUT UINT32 *Attributes,
\r
44 IN OUT UINTN *DataSize,
\r
50 PeiGetNextVariableName (
\r
51 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
\r
52 IN OUT UINTN *VariableNameSize,
\r
53 IN OUT CHAR16 *VariableName,
\r
54 IN OUT EFI_GUID *VariableGuid
\r
60 EFI_PEI_READ_ONLY_VARIABLE2_PPI mVariablePpi = {
\r
62 PeiGetNextVariableName
\r
65 EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {
\r
66 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
\r
67 &gEfiPeiReadOnlyVariable2PpiGuid,
\r
72 EFI_PEI_PPI_DESCRIPTOR mReadOnlyVariableThunkPresent = {
\r
73 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
\r
74 &gPeiReadonlyVariableThunkPresentPpiGuid,
\r
80 PeimInitializeReadOnlyVariable2 (
\r
81 IN EFI_FFS_FILE_HEADER *FfsHeader,
\r
82 IN EFI_PEI_SERVICES **PeiServices
\r
86 Routine Description:
\r
88 Provide the functionality of the variable services.
\r
92 FfsHeadher - The FFS file header
\r
93 PeiServices - General purpose services available to every PEIM.
\r
97 Status - EFI_SUCCESS if the interface could be successfully
\r
106 // Make sure ReadOnlyVariable2ToReadOnlyVariable module is not present. If so, the call chain will form a
\r
107 // infinite loop: ReadOnlyVariable2 -> ReadOnlyVariable -> ReadOnlyVariable2 -> ....
\r
109 Status = PeiServicesLocatePpi (&gPeiReadonlyVariableThunkPresentPpiGuid, 0, NULL, &Interface);
\r
110 ASSERT (Status == EFI_NOT_FOUND);
\r
112 PeiServicesInstallPpi (&mReadOnlyVariableThunkPresent);
\r
114 // Publish the variable capability to other modules
\r
116 return PeiServicesInstallPpi (&mPpiListVariable);
\r
120 Provide the read variable functionality of the variable services.
\r
122 @param PeiServices General purpose services available to every PEIM.
\r
123 @param VariableName The variable name
\r
124 @param VendorGuid The vendor's GUID
\r
125 @param Attributes Pointer to the attribute
\r
126 @param DataSize Size of data
\r
127 @param Data Pointer to data
\r
129 @retval EFI_SUCCESS The interface could be successfully installed
\r
130 @retval EFI_NOT_FOUND The variable could not be discovered
\r
131 @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough
\r
137 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
\r
138 IN CONST CHAR16 *VariableName,
\r
139 IN CONST EFI_GUID *VariableGuid,
\r
140 OUT UINT32 *Attributes,
\r
141 IN OUT UINTN *DataSize,
\r
146 EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;
\r
148 Status = PeiServicesLocatePpi (
\r
149 &gEfiPeiReadOnlyVariablePpiGuid,
\r
152 (VOID **)&ReadOnlyVariable
\r
154 ASSERT_EFI_ERROR (Status);
\r
156 return ReadOnlyVariable->PeiGetVariable (
\r
157 GetPeiServicesTablePointer (),
\r
158 (CHAR16 *)VariableName,
\r
159 (EFI_GUID *)VariableGuid,
\r
167 Provide the get next variable functionality of the variable services.
\r
169 @param PeiServices General purpose services available to every PEIM.
\r
170 @param VariabvleNameSize The variable name's size.
\r
171 @param VariableName A pointer to the variable's name.
\r
172 @param VariableGuid A pointer to the EFI_GUID structure.
\r
173 @param VariableNameSize Size of the variable name
\r
174 @param VariableName The variable name
\r
175 @param VendorGuid The vendor's GUID
\r
177 @retval EFI_SUCCESS The interface could be successfully installed
\r
178 @retval EFI_NOT_FOUND The variable could not be discovered
\r
183 PeiGetNextVariableName (
\r
184 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
\r
185 IN OUT UINTN *VariableNameSize,
\r
186 IN OUT CHAR16 *VariableName,
\r
187 IN OUT EFI_GUID *VariableGuid
\r
191 EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;
\r
193 Status = PeiServicesLocatePpi (
\r
194 &gEfiPeiReadOnlyVariablePpiGuid,
\r
197 (VOID **)&ReadOnlyVariable
\r
199 ASSERT_EFI_ERROR (Status);
\r
201 return ReadOnlyVariable->PeiGetNextVariableName (
\r
202 GetPeiServicesTablePointer (),
\r