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 - 2010, 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 <Library/DebugLib.h>
29 #include <Library/PeiServicesLib.h>
32 Provide the read variable functionality of the variable services.
34 @param[in] PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
35 @param[in] VariableName A NULL-terminated Unicode string that is the name of the vendor's variable.
36 @param[in] VendorGuid A unique identifier for the vendor.
37 @param[out] Attributes This OPTIONAL parameter may be either NULL or
38 a pointer to the location in which to return
39 the attributes bitmask for the variable.
40 @param[in, out] DataSize On input, the size in bytes of the return Data buffer.
41 On output, the size of data returned in Data.
42 @param[out] Data The buffer to return the contents of the variable.
44 @retval EFI_SUCCESS The interface could be successfully installed
45 @retval EFI_NOT_FOUND The variable could not be discovered
46 @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough
52 IN EFI_PEI_SERVICES
**PeiServices
,
53 IN CHAR16
*VariableName
,
54 IN EFI_GUID
*VendorGuid
,
55 OUT UINT32
*Attributes OPTIONAL
,
56 IN OUT UINTN
*DataSize
,
61 EFI_PEI_READ_ONLY_VARIABLE2_PPI
*ReadOnlyVariable2
;
63 Status
= (*PeiServices
)->LocatePpi (
64 (CONST EFI_PEI_SERVICES
**)PeiServices
,
65 &gEfiPeiReadOnlyVariable2PpiGuid
,
68 (VOID
**)&ReadOnlyVariable2
70 ASSERT_EFI_ERROR (Status
);
72 return ReadOnlyVariable2
->GetVariable (
83 Provide the get next variable functionality of the variable services.
85 @param[in] PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
86 @param[in, out] VariableNameSize The size of the VariableName buffer.
87 @param[in, out] VariableName On input, supplies the last VariableName that was
88 returned by GetNextVariableName(). On output, returns the Null-terminated
89 Unicode string of the current variable.
90 @param[in, out] VendorGuid On input, supplies the last VendorGuid that was
91 returned by GetNextVariableName(). On output, returns the VendorGuid
92 of the current variable.
94 @retval EFI_SUCCESS The interface could be successfully installed
95 @retval EFI_NOT_FOUND The variable could not be discovered
100 PeiGetNextVariableName (
101 IN EFI_PEI_SERVICES
**PeiServices
,
102 IN OUT UINTN
*VariableNameSize
,
103 IN OUT CHAR16
*VariableName
,
104 IN OUT EFI_GUID
*VendorGuid
108 EFI_PEI_READ_ONLY_VARIABLE2_PPI
*ReadOnlyVariable2
;
110 Status
= (*PeiServices
)->LocatePpi (
111 (CONST EFI_PEI_SERVICES
**)PeiServices
,
112 &gEfiPeiReadOnlyVariable2PpiGuid
,
115 (VOID
**)&ReadOnlyVariable2
117 ASSERT_EFI_ERROR (Status
);
119 return ReadOnlyVariable2
->NextVariableName (
130 EFI_PEI_READ_ONLY_VARIABLE_PPI mVariablePpi
= {
132 PeiGetNextVariableName
135 EFI_PEI_PPI_DESCRIPTOR mPpiListVariable
= {
136 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
137 &gEfiPeiReadOnlyVariablePpiGuid
,
142 Standard entry point of a PEIM.
144 @param FileHandle Handle of the file being invoked.
145 @param PeiServices General purpose services available to every PEIM.
147 @retval EFI_SUCCESS If the gEfiPeiReadOnlyVariablePpiGuid interface could be successfully installed.
152 PeimInitializeReadOnlyVariable (
153 IN EFI_PEI_FILE_HANDLE FileHandle
,
154 IN CONST EFI_PEI_SERVICES
**PeiServices
158 //Developer should make sure ReadOnlyVariableToReadOnlyVariable2 module is not present. If so, the call chain will form a
159 // infinite loop: ReadOnlyVariable -> ReadOnlyVariable2 -> ReadOnlyVariable -> ....
162 // Publish the variable capability to other modules
164 return (*PeiServices
)->InstallPpi (PeiServices
, &mPpiListVariable
);