187edbaf7d755e1b7f5ce40288455866afb1b7a8
[mirror_edk2.git] / MdeModulePkg / Universal / VariablePei / 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 //
26 // BugBug: We need relcate the head file.
27 //
28 #include <Common/Variable.h>
29
30 //
31 // Define GET_PAD_SIZE to optimize compiler
32 //
33 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
34 #define GET_PAD_SIZE(a) (0)
35 #else
36 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
37 #endif
38
39 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
40
41 #define GET_VARIABLE_DATA_PTR(a) \
42 (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (a) + (a)->NameSize + GET_PAD_SIZE ((a)->NameSize))
43
44 typedef struct {
45 VARIABLE_HEADER *CurrPtr;
46 VARIABLE_HEADER *EndPtr;
47 VARIABLE_HEADER *StartPtr;
48 } VARIABLE_POINTER_TRACK;
49
50 #define VARIABLE_INDEX_TABLE_VOLUME 122
51
52 #define EFI_VARIABLE_INDEX_TABLE_GUID \
53 { 0x8cfdb8c8, 0xd6b2, 0x40f3, { 0x8e, 0x97, 0x02, 0x30, 0x7c, 0xc9, 0x8b, 0x7c } }
54
55 typedef struct {
56 UINT16 Length;
57 UINT16 GoneThrough;
58 VARIABLE_HEADER *EndPtr;
59 VARIABLE_HEADER *StartPtr;
60 UINT16 Index[VARIABLE_INDEX_TABLE_VOLUME];
61 } VARIABLE_INDEX_TABLE;
62
63
64 //
65 // Functions
66 //
67 EFI_STATUS
68 EFIAPI
69 PeimInitializeVariableServices (
70 IN EFI_FFS_FILE_HEADER *FfsHeader,
71 IN EFI_PEI_SERVICES **PeiServices
72 )
73 /*++
74
75 Routine Description:
76
77 TODO: Add function description
78
79 Arguments:
80
81 FfsHeader - TODO: add argument description
82 PeiServices - TODO: add argument description
83
84 Returns:
85
86 TODO: add return values
87
88 --*/
89 ;
90
91 EFI_STATUS
92 EFIAPI
93 PeiGetVariable (
94 IN EFI_PEI_SERVICES **PeiServices,
95 IN CHAR16 *VariableName,
96 IN EFI_GUID * VendorGuid,
97 OUT UINT32 *Attributes OPTIONAL,
98 IN OUT UINTN *DataSize,
99 OUT VOID *Data
100 )
101 /*++
102
103 Routine Description:
104
105 TODO: Add function description
106
107 Arguments:
108
109 PeiServices - TODO: add argument description
110 VariableName - TODO: add argument description
111 VendorGuid - TODO: add argument description
112 Attributes - TODO: add argument description
113 DataSize - TODO: add argument description
114 Data - TODO: add argument description
115
116 Returns:
117
118 TODO: add return values
119
120 --*/
121 ;
122
123 EFI_STATUS
124 EFIAPI
125 PeiGetNextVariableName (
126 IN EFI_PEI_SERVICES **PeiServices,
127 IN OUT UINTN *VariableNameSize,
128 IN OUT CHAR16 *VariableName,
129 IN OUT EFI_GUID *VendorGuid
130 )
131 /*++
132
133 Routine Description:
134
135 TODO: Add function description
136
137 Arguments:
138
139 PeiServices - TODO: add argument description
140 VariableNameSize - TODO: add argument description
141 VariableName - TODO: add argument description
142 VendorGuid - TODO: add argument description
143
144 Returns:
145
146 TODO: add return values
147
148 --*/
149 ;
150
151 /**
152 Get one variable by the index count.
153
154 @param IndexTable The pointer to variable index table.
155 @param Count The index count of variable in index table.
156
157 @return The pointer to variable header indexed by count.
158
159 **/
160 VARIABLE_HEADER *
161 GetVariableByIndex (
162 IN VARIABLE_INDEX_TABLE *IndexTable,
163 IN UINT32 Count
164 );
165
166 /**
167 Record Variable in VariableIndex HOB.
168
169 Record Variable in VariableIndex HOB and update the length of variable index table.
170
171 @param IndexTable The pointer to variable index table.
172 @param Variable The pointer to the variable that will be recorded.
173
174 @retval VOID
175
176 **/
177 VOID
178 VariableIndexTableUpdate (
179 IN OUT VARIABLE_INDEX_TABLE *IndexTable,
180 IN VARIABLE_HEADER *Variable
181 );
182
183 #endif // _PEI_VARIABLE_H