]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/ReadOnlyVariable2OnReadOnlyVariableThunk/ReadOnlyVariable2OnReadOnlyVariableThunk.c
Update code to match EDKII coding style.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / ReadOnlyVariable2OnReadOnlyVariableThunk / ReadOnlyVariable2OnReadOnlyVariableThunk.c
CommitLineData
6c45955b 1/** @file\r
2Module produce EFI_PEI_READ_ONLY_VARIABLE2_PPI on top of EFI_PEI_READ_ONLY_VARIABLE_PPI.\r
3UEFI PI Spec supersedes Intel's Framework Specs. \r
4EFI_PEI_READ_ONLY_VARIABLE_PPI defined in Intel Framework Pkg is replaced by EFI_PEI_READ_ONLY_VARIABLE2_PPI\r
5in MdePkg.\r
6This module produces EFI_PEI_READ_ONLY_VARIABLE2_PPI on top of EFI_PEI_READ_ONLY_VARIABLE_PPI. \r
7This module is used on platform when both of these two conditions are true:\r
81) Framework module produces EFI_PEI_READ_ONLY_VARIABLE_PPI is present.\r
92) The platform has PI modules that only consumes EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
10\r
11This module can't be used together with ReadOnlyVariableToReadOnlyVariable2Thunk module.\r
12\r
4259256b 13\r
26a76fbc 14Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
4259256b 15All rights reserved. This program and the accompanying materials\r
16are licensed and made available under the terms and conditions of the BSD License\r
17which accompanies this distribution. The full text of the license may be found at\r
18http://opensource.org/licenses/bsd-license.php\r
19\r
20THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
21WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
22Module Name:\r
23\r
6c45955b 24**/\r
4259256b 25\r
26#include <PiPei.h>\r
27#include <Ppi/ReadOnlyVariable2.h>\r
28#include <Ppi/ReadOnlyVariable.h>\r
29#include <Library/DebugLib.h>\r
30#include <Library/PeiServicesTablePointerLib.h>\r
31#include <Library/PeiServicesLib.h>\r
32\r
2be3c946 33/**\r
34 Provide the read variable functionality of the variable services.\r
35\r
26a76fbc
LG
36 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
37 @param VariableName A pointer to a null-terminated string that is the variable's name.\r
38 @param VariableGuid A pointer to an EFI_GUID that is the variable's GUID. The combination of\r
39 VariableGuid and VariableName must be unique.\r
40 @param Attributes If non-NULL, on return, points to the variable's attributes.\r
41 @param DataSize On entry, points to the size in bytes of the Data buffer.\r
42 On return, points to the size of the data returned in Data.\r
43 @param Data Points to the buffer which will hold the returned variable value.\r
2be3c946 44\r
45 @retval EFI_SUCCESS The interface could be successfully installed\r
46 @retval EFI_NOT_FOUND The variable could not be discovered\r
47 @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough\r
48\r
49**/\r
4259256b 50EFI_STATUS\r
51EFIAPI\r
52PeiGetVariable (\r
53 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
54 IN CONST CHAR16 *VariableName,\r
55 IN CONST EFI_GUID *VariableGuid,\r
56 OUT UINT32 *Attributes,\r
57 IN OUT UINTN *DataSize,\r
58 OUT VOID *Data\r
59 )\r
4259256b 60{\r
61 EFI_STATUS Status;\r
62 EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;\r
63\r
64 Status = PeiServicesLocatePpi (\r
65 &gEfiPeiReadOnlyVariablePpiGuid,\r
66 0,\r
67 NULL,\r
68 (VOID **)&ReadOnlyVariable\r
69 );\r
70 ASSERT_EFI_ERROR (Status);\r
71\r
b4b9fbc4 72 return ReadOnlyVariable->PeiGetVariable (\r
79ec0fac 73 (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),\r
4259256b 74 (CHAR16 *)VariableName,\r
75 (EFI_GUID *)VariableGuid,\r
76 Attributes,\r
77 DataSize,\r
78 Data\r
79 );\r
80}\r
81\r
2be3c946 82/**\r
83 Provide the get next variable functionality of the variable services.\r
84\r
26a76fbc 85 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
2be3c946 86\r
26a76fbc
LG
87 @param VariableNameSize On entry, points to the size of the buffer pointed to by VariableName.\r
88 @param VariableName On entry, a pointer to a null-terminated string that is the variable's name.\r
89 On return, points to the next variable's null-terminated name string.\r
90\r
91 @param VariableGuid On entry, a pointer to an EFI_GUID that is the variable's GUID. \r
92 On return, a pointer to the next variable's GUID.\r
93\r
94 @retval EFI_SUCCESS The interface could be successfully installed\r
95 @retval EFI_NOT_FOUND The variable could not be discovered\r
2be3c946 96\r
97**/\r
4259256b 98EFI_STATUS\r
99EFIAPI\r
100PeiGetNextVariableName (\r
101 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
102 IN OUT UINTN *VariableNameSize,\r
103 IN OUT CHAR16 *VariableName,\r
104 IN OUT EFI_GUID *VariableGuid\r
105 )\r
4259256b 106{\r
107 EFI_STATUS Status;\r
108 EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;\r
109\r
110 Status = PeiServicesLocatePpi (\r
111 &gEfiPeiReadOnlyVariablePpiGuid,\r
112 0,\r
113 NULL,\r
114 (VOID **)&ReadOnlyVariable\r
115 );\r
116 ASSERT_EFI_ERROR (Status);\r
117\r
b4b9fbc4 118 return ReadOnlyVariable->PeiGetNextVariableName (\r
79ec0fac 119 (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),\r
4259256b 120 VariableNameSize,\r
121 VariableName,\r
122 VariableGuid\r
123 );\r
124}\r
26a76fbc
LG
125\r
126//\r
127// Module globals\r
128//\r
129EFI_PEI_READ_ONLY_VARIABLE2_PPI mVariablePpi = {\r
130 PeiGetVariable,\r
131 PeiGetNextVariableName\r
132};\r
133\r
134EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {\r
135 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
136 &gEfiPeiReadOnlyVariable2PpiGuid,\r
137 &mVariablePpi\r
138};\r
139\r
140/**\r
141 User entry for this PEIM driver.\r
142 \r
143 @param FileHandle Handle of the file being invoked.\r
144 @param PeiServices Describes the list of possible PEI Services.\r
145\r
146 @retval EFI_SUCCESS ReadOnlyVariable2 PPI is successfully installed.\r
147 @return Others ReadOnlyVariable2 PPI is not successfully installed.\r
148\r
149**/\r
150EFI_STATUS\r
151EFIAPI\r
152PeimInitializeReadOnlyVariable2 (\r
153 IN EFI_PEI_FILE_HANDLE FileHandle,\r
154 IN CONST EFI_PEI_SERVICES **PeiServices\r
155 )\r
156{\r
157 //\r
158 // This thunk module can only be used together with a PI PEI core, as we \r
159 // assume PeiServices Pointer Table can be located in a standard way defined\r
160 // in PI spec.\r
161 //\r
162 ASSERT ((*PeiServices)->Hdr.Revision >= 0x00010000);\r
163\r
164 //\r
165 // Developer should make sure ReadOnlyVariable2ToReadOnlyVariable module is not present. or else, the call chain will form a\r
166 // infinite loop: ReadOnlyVariable2 -> ReadOnlyVariable -> ReadOnlyVariable2 -> .....\r
167 //\r
168 //\r
169 // Publish the variable capability to other modules\r
170 //\r
171 return PeiServicesInstallPpi (&mPpiListVariable);\r
172}\r