]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
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 | |
5 | in MdePkg.\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 | |
10 | \r | |
11 | This module can't be used together with ReadOnlyVariableToReadOnlyVariable2Thunk module.\r | |
12 | \r | |
13 | \r | |
14 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
15 | 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 | |
19 | \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 | |
22 | Module Name:\r | |
23 | \r | |
24 | **/\r | |
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 | |
33 | /**\r | |
34 | Provide the read variable functionality of the variable services.\r | |
35 | \r | |
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 | |
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 | |
50 | EFI_STATUS\r | |
51 | EFIAPI\r | |
52 | PeiGetVariable (\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 | |
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 | |
72 | return ReadOnlyVariable->PeiGetVariable (\r | |
73 | (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),\r | |
74 | (CHAR16 *)VariableName,\r | |
75 | (EFI_GUID *)VariableGuid,\r | |
76 | Attributes,\r | |
77 | DataSize,\r | |
78 | Data\r | |
79 | );\r | |
80 | }\r | |
81 | \r | |
82 | /**\r | |
83 | Provide the get next variable functionality of the variable services.\r | |
84 | \r | |
85 | @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r | |
86 | \r | |
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 | |
96 | \r | |
97 | **/\r | |
98 | EFI_STATUS\r | |
99 | EFIAPI\r | |
100 | PeiGetNextVariableName (\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 | |
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 | |
118 | return ReadOnlyVariable->PeiGetNextVariableName (\r | |
119 | (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),\r | |
120 | VariableNameSize,\r | |
121 | VariableName,\r | |
122 | VariableGuid\r | |
123 | );\r | |
124 | }\r | |
125 | \r | |
126 | //\r | |
127 | // Module globals\r | |
128 | //\r | |
129 | EFI_PEI_READ_ONLY_VARIABLE2_PPI mVariablePpi = {\r | |
130 | PeiGetVariable,\r | |
131 | PeiGetNextVariableName\r | |
132 | };\r | |
133 | \r | |
134 | EFI_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 | |
150 | EFI_STATUS\r | |
151 | EFIAPI\r | |
152 | PeimInitializeReadOnlyVariable2 (\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 |