]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | The internal header file includes the common header files, defines\r | |
4 | internal structure and functions used by PeiVariable module.\r | |
5 | \r | |
6 | Copyright (c) 2006 - 2008, Intel Corporation\r | |
7 | All rights reserved. This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef _PEI_VARIABLE_H_\r | |
18 | #define _PEI_VARIABLE_H_\r | |
19 | \r | |
20 | #include <PiPei.h>\r | |
21 | #include <Ppi/ReadOnlyVariable2.h>\r | |
22 | \r | |
23 | #include <Library/DebugLib.h>\r | |
24 | #include <Library/PeimEntryPoint.h>\r | |
25 | #include <Library/HobLib.h>\r | |
26 | #include <Library/PcdLib.h>\r | |
27 | #include <Library/BaseMemoryLib.h>\r | |
28 | #include <Library/PeiServicesTablePointerLib.h>\r | |
29 | #include <Library/PeiServicesLib.h>\r | |
30 | \r | |
31 | #include <VariableFormat.h>\r | |
32 | \r | |
33 | //\r | |
34 | // Define GET_PAD_SIZE to optimize compiler\r | |
35 | //\r | |
36 | #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))\r | |
37 | #define GET_PAD_SIZE(a) (0)\r | |
38 | #else\r | |
39 | #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))\r | |
40 | #endif\r | |
41 | \r | |
42 | #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))\r | |
43 | \r | |
44 | typedef struct {\r | |
45 | VARIABLE_HEADER *CurrPtr;\r | |
46 | VARIABLE_HEADER *EndPtr;\r | |
47 | VARIABLE_HEADER *StartPtr;\r | |
48 | } VARIABLE_POINTER_TRACK;\r | |
49 | \r | |
50 | #define VARIABLE_INDEX_TABLE_VOLUME 122\r | |
51 | \r | |
52 | #define EFI_VARIABLE_INDEX_TABLE_GUID \\r | |
53 | { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }\r | |
54 | \r | |
55 | typedef struct {\r | |
56 | UINT16 Length;\r | |
57 | UINT16 GoneThrough;\r | |
58 | VARIABLE_HEADER *EndPtr;\r | |
59 | VARIABLE_HEADER *StartPtr;\r | |
60 | UINT16 Index[VARIABLE_INDEX_TABLE_VOLUME];\r | |
61 | } VARIABLE_INDEX_TABLE;\r | |
62 | \r | |
63 | \r | |
64 | //\r | |
65 | // Functions\r | |
66 | //\r | |
67 | /**\r | |
68 | Provide the functionality of the variable services.\r | |
69 | \r | |
70 | @param FileHandle Handle of the file being invoked. \r | |
71 | Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().\r | |
72 | @param PeiServices General purpose services available to every PEIM.\r | |
73 | \r | |
74 | @retval EFI_SUCCESS If the interface could be successfully installed\r | |
75 | @retval Others Returned from PeiServicesInstallPpi()\r | |
76 | \r | |
77 | **/\r | |
78 | EFI_STATUS\r | |
79 | EFIAPI\r | |
80 | PeimInitializeVariableServices (\r | |
81 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
82 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
83 | );\r | |
84 | \r | |
85 | /**\r | |
86 | This service retrieves a variable's value using its name and GUID.\r | |
87 | \r | |
88 | Read the specified variable from the UEFI variable store. If the Data \r | |
89 | buffer is too small to hold the contents of the variable, the error\r | |
90 | EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer\r | |
91 | size to obtain the data.\r | |
92 | \r | |
93 | @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r | |
94 | @param VariableName A pointer to a null-terminated string that is the variable's name.\r | |
95 | @param VariableGuid A pointer to an EFI_GUID that is the variable's GUID. The combination of\r | |
96 | VariableGuid and VariableName must be unique.\r | |
97 | @param Attributes If non-NULL, on return, points to the variable's attributes.\r | |
98 | @param DataSize On entry, points to the size in bytes of the Data buffer.\r | |
99 | On return, points to the size of the data returned in Data.\r | |
100 | @param Data Points to the buffer which will hold the returned variable value.\r | |
101 | \r | |
102 | @retval EFI_SUCCESS The variable was read successfully.\r | |
103 | @retval EFI_NOT_FOUND The variable could not be found.\r | |
104 | @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the resulting data. \r | |
105 | DataSize is updated with the size required for \r | |
106 | the specified variable.\r | |
107 | @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.\r | |
108 | @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.\r | |
109 | \r | |
110 | **/\r | |
111 | EFI_STATUS\r | |
112 | EFIAPI\r | |
113 | PeiGetVariable (\r | |
114 | IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r | |
115 | IN CONST CHAR16 *VariableName,\r | |
116 | IN CONST EFI_GUID *VariableGuid,\r | |
117 | OUT UINT32 *Attributes,\r | |
118 | IN OUT UINTN *DataSize,\r | |
119 | OUT VOID *Data\r | |
120 | );\r | |
121 | \r | |
122 | /**\r | |
123 | Return the next variable name and GUID.\r | |
124 | \r | |
125 | This function is called multiple times to retrieve the VariableName \r | |
126 | and VariableGuid of all variables currently available in the system. \r | |
127 | On each call, the previous results are passed into the interface, \r | |
128 | and, on return, the interface returns the data for the next \r | |
129 | interface. When the entire variable list has been returned, \r | |
130 | EFI_NOT_FOUND is returned.\r | |
131 | \r | |
132 | @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r | |
133 | \r | |
134 | @param VariableNameSize On entry, points to the size of the buffer pointed to by VariableName.\r | |
135 | @param VariableName On entry, a pointer to a null-terminated string that is the variable's name.\r | |
136 | On return, points to the next variable's null-terminated name string.\r | |
137 | \r | |
138 | @param VariableGuid On entry, a pointer to an UEFI _GUID that is the variable's GUID. \r | |
139 | On return, a pointer to the next variable's GUID.\r | |
140 | \r | |
141 | @retval EFI_SUCCESS The variable was read successfully.\r | |
142 | @retval EFI_NOT_FOUND The variable could not be found.\r | |
143 | @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the resulting\r | |
144 | data. VariableNameSize is updated with the size\r | |
145 | required for the specified variable.\r | |
146 | @retval EFI_INVALID_PARAMETER VariableName, VariableGuid or\r | |
147 | VariableNameSize is NULL.\r | |
148 | @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.\r | |
149 | \r | |
150 | **/\r | |
151 | EFI_STATUS\r | |
152 | EFIAPI\r | |
153 | PeiGetNextVariableName (\r | |
154 | IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r | |
155 | IN OUT UINTN *VariableNameSize,\r | |
156 | IN OUT CHAR16 *VariableName,\r | |
157 | IN OUT EFI_GUID *VariableGuid\r | |
158 | );\r | |
159 | \r | |
160 | /**\r | |
161 | Get one variable by the index count.\r | |
162 | \r | |
163 | @param IndexTable The pointer to variable index table.\r | |
164 | @param Count The index count of variable in index table.\r | |
165 | \r | |
166 | @return The pointer to variable header indexed by count.\r | |
167 | \r | |
168 | **/\r | |
169 | VARIABLE_HEADER *\r | |
170 | GetVariableByIndex (\r | |
171 | IN VARIABLE_INDEX_TABLE *IndexTable,\r | |
172 | IN UINT32 Count\r | |
173 | );\r | |
174 | \r | |
175 | /**\r | |
176 | Record Variable in VariableIndex HOB.\r | |
177 | \r | |
178 | Record Variable in VariableIndex HOB and update the length of variable index table.\r | |
179 | \r | |
180 | @param IndexTable The pointer to variable index table.\r | |
181 | @param Variable The pointer to the variable that will be recorded.\r | |
182 | \r | |
183 | **/\r | |
184 | VOID\r | |
185 | VariableIndexTableUpdate (\r | |
186 | IN OUT VARIABLE_INDEX_TABLE *IndexTable,\r | |
187 | IN VARIABLE_HEADER *Variable\r | |
188 | );\r | |
189 | \r | |
190 | #endif\r |