]>
Commit | Line | Data |
---|---|---|
c8eb679c | 1 | /** @file\r |
ec3d17dc | 2 | Module produce EFI_PEI_READ_ONLY_VARIABLE_PPI on top of EFI_PEI_READ_ONLY_VARIABLE2_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_VARIABLE_PPI on top of EFI_PEI_READ_ONLY_VARIABLE2_PPI. \r | |
7 | # This module is used on platform when both of these two conditions are true:\r | |
8 | # 1) Framework module consumes EFI_PEI_READ_ONLY_VARIABLE_PPI is present.\r | |
9 | # 2) The platform has a PI module that only produces EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r | |
4259256b | 10 | \r |
c8eb679c | 11 | This module can't be used together with ReadOnlyVariable2ToReadOnlyVariableThunk module.\r |
12 | \r | |
584d5652 HT |
13 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r |
14 | This program and the accompanying materials\r | |
4259256b | 15 | are licensed and made available under the terms and conditions of the BSD License\r |
16 | which accompanies this distribution. The full text of the license may be found at\r | |
17 | http://opensource.org/licenses/bsd-license.php\r | |
18 | \r | |
19 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
20 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
21 | Module Name:\r | |
22 | \r | |
ec3d17dc | 23 | **/\r |
4259256b | 24 | \r |
25 | #include <PiPei.h>\r | |
26 | #include <Ppi/ReadOnlyVariable.h>\r | |
27 | #include <Ppi/ReadOnlyVariable2.h>\r | |
28 | #include <Library/DebugLib.h>\r | |
c8eb679c | 29 | #include <Library/PeiServicesLib.h>\r |
4259256b | 30 | \r |
2be3c946 | 31 | /**\r |
32 | Provide the read variable functionality of the variable services.\r | |
33 | \r | |
26a76fbc LG |
34 | @param[in] PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r |
35 | @param[in] VariableName A NULL-terminated Unicode string that is the name of the vendor's variable.\r | |
36 | @param[in] VendorGuid A unique identifier for the vendor.\r | |
37 | @param[out] Attributes This OPTIONAL parameter may be either NULL or\r | |
38 | a pointer to the location in which to return\r | |
39 | the attributes bitmask for the variable.\r | |
40 | @param[in, out] DataSize On input, the size in bytes of the return Data buffer.\r | |
41 | On output, the size of data returned in Data.\r | |
42 | @param[out] Data The buffer to return the contents of the variable.\r | |
2be3c946 | 43 | \r |
44 | @retval EFI_SUCCESS The interface could be successfully installed\r | |
45 | @retval EFI_NOT_FOUND The variable could not be discovered\r | |
46 | @retval EFI_BUFFER_TOO_SMALL The caller buffer is not large enough\r | |
47 | \r | |
48 | **/\r | |
4259256b | 49 | EFI_STATUS\r |
50 | EFIAPI\r | |
51 | PeiGetVariable (\r | |
52 | IN EFI_PEI_SERVICES **PeiServices,\r | |
53 | IN CHAR16 *VariableName,\r | |
54 | IN EFI_GUID *VendorGuid,\r | |
55 | OUT UINT32 *Attributes OPTIONAL,\r | |
56 | IN OUT UINTN *DataSize,\r | |
57 | OUT VOID *Data\r | |
58 | )\r | |
4259256b | 59 | {\r |
60 | EFI_STATUS Status;\r | |
61 | EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r | |
62 | \r | |
63 | Status = (*PeiServices)->LocatePpi (\r | |
64 | (CONST EFI_PEI_SERVICES **)PeiServices, \r | |
65 | &gEfiPeiReadOnlyVariable2PpiGuid, \r | |
66 | 0, \r | |
67 | NULL, \r | |
68 | (VOID **)&ReadOnlyVariable2\r | |
69 | );\r | |
70 | ASSERT_EFI_ERROR (Status);\r | |
71 | \r | |
72 | return ReadOnlyVariable2->GetVariable (\r | |
73 | ReadOnlyVariable2,\r | |
74 | VariableName,\r | |
75 | VendorGuid,\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 LG |
85 | @param[in] PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r |
86 | @param[in, out] VariableNameSize The size of the VariableName buffer.\r | |
87 | @param[in, out] VariableName On input, supplies the last VariableName that was\r | |
88 | returned by GetNextVariableName(). On output, returns the Null-terminated\r | |
89 | Unicode string of the current variable.\r | |
90 | @param[in, out] VendorGuid On input, supplies the last VendorGuid that was\r | |
91 | returned by GetNextVariableName(). On output, returns the VendorGuid\r | |
92 | of the current variable.\r | |
2be3c946 | 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 | |
4259256b | 98 | EFI_STATUS\r |
99 | EFIAPI\r | |
100 | PeiGetNextVariableName (\r | |
101 | IN EFI_PEI_SERVICES **PeiServices,\r | |
102 | IN OUT UINTN *VariableNameSize,\r | |
103 | IN OUT CHAR16 *VariableName,\r | |
104 | IN OUT EFI_GUID *VendorGuid\r | |
105 | )\r | |
4259256b | 106 | {\r |
107 | EFI_STATUS Status;\r | |
108 | EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r | |
109 | \r | |
110 | Status = (*PeiServices)->LocatePpi (\r | |
111 | (CONST EFI_PEI_SERVICES **)PeiServices, \r | |
112 | &gEfiPeiReadOnlyVariable2PpiGuid, \r | |
113 | 0, \r | |
114 | NULL, \r | |
115 | (VOID **)&ReadOnlyVariable2\r | |
116 | );\r | |
117 | ASSERT_EFI_ERROR (Status);\r | |
118 | \r | |
119 | return ReadOnlyVariable2->NextVariableName (\r | |
120 | ReadOnlyVariable2,\r | |
121 | VariableNameSize,\r | |
122 | VariableName,\r | |
123 | VendorGuid\r | |
124 | );\r | |
125 | }\r | |
26a76fbc LG |
126 | \r |
127 | //\r | |
128 | // Module globals\r | |
129 | //\r | |
130 | EFI_PEI_READ_ONLY_VARIABLE_PPI mVariablePpi = {\r | |
131 | PeiGetVariable,\r | |
132 | PeiGetNextVariableName\r | |
133 | };\r | |
134 | \r | |
135 | EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {\r | |
136 | (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r | |
137 | &gEfiPeiReadOnlyVariablePpiGuid,\r | |
138 | &mVariablePpi\r | |
139 | };\r | |
140 | \r | |
141 | /**\r | |
142 | Standard entry point of a PEIM.\r | |
143 | \r | |
144 | @param FileHandle Handle of the file being invoked.\r | |
145 | @param PeiServices General purpose services available to every PEIM.\r | |
146 | \r | |
147 | @retval EFI_SUCCESS If the gEfiPeiReadOnlyVariablePpiGuid interface could be successfully installed.\r | |
148 | \r | |
149 | **/\r | |
150 | EFI_STATUS\r | |
151 | EFIAPI\r | |
152 | PeimInitializeReadOnlyVariable (\r | |
153 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
154 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
155 | )\r | |
156 | {\r | |
157 | //\r | |
158 | //Developer should make sure ReadOnlyVariableToReadOnlyVariable2 module is not present. If so, the call chain will form a\r | |
159 | // infinite loop: ReadOnlyVariable -> ReadOnlyVariable2 -> ReadOnlyVariable -> ....\r | |
160 | //\r | |
161 | //\r | |
162 | // Publish the variable capability to other modules\r | |
163 | //\r | |
164 | return (*PeiServices)->InstallPpi (PeiServices, &mPpiListVariable);\r | |
165 | }\r |