]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/ReadOnlyVariableOnReadOnlyVariable2Thunk/ReadOnlyVariableOnReadOnlyVariable2Thunk.c
Remove dependency on include file in package outside of EKD2.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / ReadOnlyVariableOnReadOnlyVariable2Thunk / ReadOnlyVariableOnReadOnlyVariable2Thunk.c
1 /** @file
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 This module can't be used together with ReadOnlyVariable2ToReadOnlyVariableThunk module.
12
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
18
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.
21 Module Name:
22
23 **/
24
25 #include <PiPei.h>
26 #include <Ppi/ReadOnlyVariable.h>
27 #include <Ppi/ReadOnlyVariable2.h>
28 #include <Library/DebugLib.h>
29 #include <Library/PeiServicesLib.h>
30
31 //
32 // Function Prototypes
33 //
34 EFI_STATUS
35 EFIAPI
36 PeiGetVariable (
37 IN EFI_PEI_SERVICES **PeiServices,
38 IN CHAR16 *VariableName,
39 IN EFI_GUID *VendorGuid,
40 OUT UINT32 *Attributes OPTIONAL,
41 IN OUT UINTN *DataSize,
42 OUT VOID *Data
43 );
44
45 EFI_STATUS
46 EFIAPI
47 PeiGetNextVariableName (
48 IN EFI_PEI_SERVICES **PeiServices,
49 IN OUT UINTN *VariableNameSize,
50 IN OUT CHAR16 *VariableName,
51 IN OUT EFI_GUID *VendorGuid
52 );
53
54 //
55 // Module globals
56 //
57 EFI_PEI_READ_ONLY_VARIABLE_PPI mVariablePpi = {
58 PeiGetVariable,
59 PeiGetNextVariableName
60 };
61
62 EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {
63 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
64 &gEfiPeiReadOnlyVariablePpiGuid,
65 &mVariablePpi
66 };
67
68
69
70 /**
71 Standard entry point of a PEIM.
72
73 @param FfsHeadher The FFS file header
74 @param PeiServices General purpose services available to every PEIM.
75
76 @retval EFI_SUCCESS If the gEfiPeiReadOnlyVariablePpiGuid interface could be successfully installed.
77
78 **/
79 EFI_STATUS
80 EFIAPI
81 PeimInitializeReadOnlyVariable (
82 IN EFI_PEI_FILE_HANDLE FfsHeader,
83 IN CONST EFI_PEI_SERVICES **PeiServices
84 )
85 {
86 //
87 //Developer should make sure ReadOnlyVariableToReadOnlyVariable2 module is not present. If so, the call chain will form a
88 // infinite loop: ReadOnlyVariable -> ReadOnlyVariable2 -> ReadOnlyVariable -> ....
89 //
90 //
91 // Publish the variable capability to other modules
92 //
93 return (*PeiServices)->InstallPpi (PeiServices, &mPpiListVariable);
94 }
95
96 /**
97 Provide the read variable functionality of the variable services.
98
99 @param PeiServices General purpose services available to every PEIM.
100 @param VariableName The variable name
101 @param VendorGuid The vendor's GUID
102 @param Attributes Pointer to the attribute
103 @param DataSize Size of data
104 @param Data Pointer to data
105
106 @retval EFI_SUCCESS The interface could be successfully installed
107 @retval EFI_NOT_FOUND The variable could not be discovered
108 @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough
109
110 **/
111 EFI_STATUS
112 EFIAPI
113 PeiGetVariable (
114 IN EFI_PEI_SERVICES **PeiServices,
115 IN CHAR16 *VariableName,
116 IN EFI_GUID *VendorGuid,
117 OUT UINT32 *Attributes OPTIONAL,
118 IN OUT UINTN *DataSize,
119 OUT VOID *Data
120 )
121 {
122 EFI_STATUS Status;
123 EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;
124
125 Status = (*PeiServices)->LocatePpi (
126 (CONST EFI_PEI_SERVICES **)PeiServices,
127 &gEfiPeiReadOnlyVariable2PpiGuid,
128 0,
129 NULL,
130 (VOID **)&ReadOnlyVariable2
131 );
132 ASSERT_EFI_ERROR (Status);
133
134 return ReadOnlyVariable2->GetVariable (
135 ReadOnlyVariable2,
136 VariableName,
137 VendorGuid,
138 Attributes,
139 DataSize,
140 Data
141 );
142 }
143
144 /**
145 Provide the get next variable functionality of the variable services.
146
147 @param PeiServices General purpose services available to every PEIM.
148 @param VariabvleNameSize The variable name's size.
149 @param VariableName A pointer to the variable's name.
150 @param VariableGuid A pointer to the EFI_GUID structure.
151 @param VariableNameSize Size of the variable name
152 @param VariableName The variable name
153 @param VendorGuid The vendor's GUID
154
155 @retval EFI_SUCCESS The interface could be successfully installed
156 @retval EFI_NOT_FOUND The variable could not be discovered
157
158 **/
159 EFI_STATUS
160 EFIAPI
161 PeiGetNextVariableName (
162 IN EFI_PEI_SERVICES **PeiServices,
163 IN OUT UINTN *VariableNameSize,
164 IN OUT CHAR16 *VariableName,
165 IN OUT EFI_GUID *VendorGuid
166 )
167 {
168 EFI_STATUS Status;
169 EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;
170
171 Status = (*PeiServices)->LocatePpi (
172 (CONST EFI_PEI_SERVICES **)PeiServices,
173 &gEfiPeiReadOnlyVariable2PpiGuid,
174 0,
175 NULL,
176 (VOID **)&ReadOnlyVariable2
177 );
178 ASSERT_EFI_ERROR (Status);
179
180 return ReadOnlyVariable2->NextVariableName (
181 ReadOnlyVariable2,
182 VariableNameSize,
183 VariableName,
184 VendorGuid
185 );
186 }