]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/Pei/Variable.h
Retire the "Include/Common" of MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / Pei / Variable.h
1 /*++
2
3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 Variable.h
15
16 Abstract:
17
18 Tiano PEIM to provide the variable functionality
19
20 --*/
21
22 #ifndef _PEI_VARIABLE_H
23 #define _PEI_VARIABLE_H
24
25 #include <PiPei.h>
26 #include <Ppi/ReadOnlyVariable2.h>
27 #include <Library/DebugLib.h>
28 #include <Library/PeimEntryPoint.h>
29 #include <Library/HobLib.h>
30 #include <Library/PcdLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/PeiServicesTablePointerLib.h>
33 #include <VariableFormat.h>
34
35 //
36 // Define GET_PAD_SIZE to optimize compiler
37 //
38 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
39 #define GET_PAD_SIZE(a) (0)
40 #else
41 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
42 #endif
43
44 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
45
46 #define GET_VARIABLE_DATA_PTR(a) \
47 (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (a) + (a)->NameSize + GET_PAD_SIZE ((a)->NameSize))
48
49 typedef struct {
50 VARIABLE_HEADER *CurrPtr;
51 VARIABLE_HEADER *EndPtr;
52 VARIABLE_HEADER *StartPtr;
53 } VARIABLE_POINTER_TRACK;
54
55 #define VARIABLE_INDEX_TABLE_VOLUME 122
56
57 #define EFI_VARIABLE_INDEX_TABLE_GUID \
58 { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }
59
60 typedef struct {
61 UINT16 Length;
62 UINT16 GoneThrough;
63 VARIABLE_HEADER *EndPtr;
64 VARIABLE_HEADER *StartPtr;
65 UINT16 Index[VARIABLE_INDEX_TABLE_VOLUME];
66 } VARIABLE_INDEX_TABLE;
67
68
69 //
70 // Functions
71 //
72 EFI_STATUS
73 EFIAPI
74 PeimInitializeVariableServices (
75 IN EFI_FFS_FILE_HEADER *FfsHeader,
76 IN EFI_PEI_SERVICES **PeiServices
77 )
78 /*++
79
80 Routine Description:
81
82 TODO: Add function description
83
84 Arguments:
85
86 FfsHeader - TODO: add argument description
87 PeiServices - TODO: add argument description
88
89 Returns:
90
91 TODO: add return values
92
93 --*/
94 ;
95
96 EFI_STATUS
97 EFIAPI
98 PeiGetVariable (
99 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
100 IN CONST CHAR16 *VariableName,
101 IN CONST EFI_GUID *VariableGuid,
102 OUT UINT32 *Attributes,
103 IN OUT UINTN *DataSize,
104 OUT VOID *Data
105 )
106 /*++
107
108 Routine Description:
109
110 TODO: Add function description
111
112 Arguments:
113
114 PeiServices - TODO: add argument description
115 VariableName - TODO: add argument description
116 VendorGuid - TODO: add argument description
117 Attributes - TODO: add argument description
118 DataSize - TODO: add argument description
119 Data - TODO: add argument description
120
121 Returns:
122
123 TODO: add return values
124
125 --*/
126 ;
127
128 EFI_STATUS
129 EFIAPI
130 PeiGetNextVariableName (
131 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
132 IN OUT UINTN *VariableNameSize,
133 IN OUT CHAR16 *VariableName,
134 IN OUT EFI_GUID *VariableGuid
135 )
136 /*++
137
138 Routine Description:
139
140 TODO: Add function description
141
142 Arguments:
143
144 PeiServices - TODO: add argument description
145 VariableNameSize - TODO: add argument description
146 VariableName - TODO: add argument description
147 VendorGuid - TODO: add argument description
148
149 Returns:
150
151 TODO: add return values
152
153 --*/
154 ;
155
156 /**
157 Get one variable by the index count.
158
159 @param IndexTable The pointer to variable index table.
160 @param Count The index count of variable in index table.
161
162 @return The pointer to variable header indexed by count.
163
164 **/
165 VARIABLE_HEADER *
166 GetVariableByIndex (
167 IN VARIABLE_INDEX_TABLE *IndexTable,
168 IN UINT32 Count
169 );
170
171 /**
172 Record Variable in VariableIndex HOB.
173
174 Record Variable in VariableIndex HOB and update the length of variable index table.
175
176 @param IndexTable The pointer to variable index table.
177 @param Variable The pointer to the variable that will be recorded.
178
179 @retval VOID
180
181 **/
182 VOID
183 VariableIndexTableUpdate (
184 IN OUT VARIABLE_INDEX_TABLE *IndexTable,
185 IN VARIABLE_HEADER *Variable
186 );
187
188 #endif // _PEI_VARIABLE_H