]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/FCE/Fce.h
Revert "BaseTools/FMMT: Add a tool FMMT"
[mirror_edk2.git] / BaseTools / Source / C / FCE / Fce.h
1 /** @file
2
3 FCE is a tool which enables developers to retrieve and change HII configuration ("Setup")
4 data in Firmware Device files (".fd" files).
5
6 Copyright (c) 2011-2019, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #ifndef _FCE_H_
12 #define _FCE_H_ 1
13
14 //#define NDEBUG
15
16 #include "Common.h"
17 #include "IfrParse.h"
18 #include "VariableCommon.h"
19 #include "BinaryParse.h"
20 #include "BinaryCreate.h"
21 ///
22 /// Utility global variables
23 ///
24 #define UTILITY_MAJOR_VERSION 0
25 #define UTILITY_MINOR_VERSION 34
26
27 #define UTILITY_NAME "FCE"
28
29 #define SUCCESS 0
30 #define FAIL 1
31 #define VR_FAIL 2
32 #define MAX_INPUT_ALLOCATE_SIZE 256
33
34 ///
35 /// The type of file input and operations
36 ///
37 typedef enum {
38 INFD,
39 OUTFD,
40 OUTTXT,
41 SETUPTXT
42 } FILETYPE;
43
44 typedef enum {
45 NONE,
46 READ,
47 UPDATE,
48 UPDATE_REMOVE,
49 UPDATE_IGNORE,
50 VERIFY,
51 UPDATEQ
52 } OPERATION_TYPE;
53
54 typedef struct _GUID_SEC_TOOL_ENTRY {
55 EFI_GUID Guid;
56 CHAR8* Name;
57 CHAR8* Path;
58 struct _GUID_SEC_TOOL_ENTRY *Next;
59 } GUID_SEC_TOOL_ENTRY;
60
61 ///
62 /// The tag for use in identifying UNICODE files.
63 /// If the file is UNICODE, the first 16 bits of the file will equal this value.
64 ///
65 enum {
66 BigUnicodeFileTag = 0xFEFF,
67 LittleUnicodeFileTag = 0xFFFE
68 };
69
70 typedef enum {
71 ASCII,
72 BIG_UCS2,
73 LITTLE_UCS2
74 } FILE_TYPE;
75
76 /**
77 Exchange the data between Efi variable and the data of VarList when the
78 variable use the authenticated variable header
79
80 If VarToList is TRUE, copy the efi variable data to the VarList; Otherwise,
81 update the data from varlist to efi variable.
82
83 @param VarToList The flag to control the direction of exchange.
84 @param StorageListHead Decide which variale list be updated
85
86 @retval EFI_SUCCESS Get the address successfully.
87 @retval EFI_OUT_OF_RESOURCES No available in the EFI variable zone.
88 @retval EFI_INVALID_PARAMETER Invalid variable name.
89 **/
90 EFI_STATUS
91 SynAuthEfiVariable (
92 IN BOOLEAN VarToList,
93 IN LIST_ENTRY *StorageListHead
94 );
95
96 /**
97 Remove the variable from Efi variable
98
99 Found the variable with the same name in StorageListHead and remove it.
100
101 @param StorageListHead Decide which variale list be removed.
102
103 @retval EFI_SUCCESS Remove the variables successfully.
104 **/
105 EFI_STATUS
106 RemoveAuthEfiVariable (
107 IN LIST_ENTRY *StorageListHead
108 );
109
110 /**
111 Exchange the data between Efi variable and the data of VarList when the
112 variable use the time stamp authenticated variable header
113
114 If VarToList is TRUE, copy the efi variable data to the VarList; Otherwise,
115 update the data from varlist to efi variable.
116
117 @param VarToList The flag to control the direction of exchange.
118 @param StorageListHead Decide which variale list be updated
119
120 @retval EFI_SUCCESS Get the address successfully.
121 @retval EFI_OUT_OF_RESOURCES No available in the EFI variable zone.
122 @retval EFI_INVALID_PARAMETER Invalid variable name.
123 **/
124
125 EFI_STATUS
126 SynAuthEfiVariableBasedTime (
127 IN BOOLEAN VarToList,
128 IN LIST_ENTRY *StorageListHead
129 );
130
131 /**
132 Remove the variable from Efi variable
133
134 Found the variable with the same name in StorageListHead and remove it.
135
136 @param StorageListHead Decide which variale list be removed.
137
138 @retval EFI_SUCCESS Remove the variables successfully.
139 **/
140 EFI_STATUS
141 RemoveAuthEfiVariableBasedTime (
142 IN LIST_ENTRY *StorageListHead
143 );
144
145 /**
146 Exchange the data between Efi variable and the data of VarList when the
147 variable use the authenticated variable header
148
149 If VarToList is TRUE, copy the efi variable data to the VarList; Otherwise,
150 update the data from varlist to efi variable.
151
152 @param VarToList The flag to control the direction of exchange.
153 @param StorageListHead Decide which variale list be updated
154
155 @retval EFI_SUCCESS Get the address successfully.
156 @retval EFI_OUT_OF_RESOURCES No available in the EFI variable zone.
157 **/
158
159 EFI_STATUS
160 SynEfiVariable (
161 IN BOOLEAN VarToList,
162 IN LIST_ENTRY *StorageListHead
163 );
164
165 /**
166 Remove the variable from Efi variable
167
168 Found the variable with the same name in StorageListHead and remove it.
169
170 @param StorageListHead Decide which variale list be removed.
171
172 @retval EFI_SUCCESS Remove the variables successfully.
173 **/
174 EFI_STATUS
175 RemoveNormalEfiVariable (
176 IN LIST_ENTRY *StorageListHead
177 );
178
179 /**
180 Read all defaultId and platformId from binary.
181
182 @param Binary The pointer to the bianry
183 @param Storage The pointer to the Storage
184 **/
185 VOID
186 ReadDefaultAndPlatformIdFromBfv (
187 IN UINT8 *Binary,
188 IN FORMSET_STORAGE *Storage
189 );
190
191 /**
192 Store all defaultId and platformId to binary.
193
194 @param Binary The pointer to the bianry
195 @param Storage The pointer to the Storage
196
197 @retval Length Return the length of the header
198 **/
199
200 UINT32
201 WriteDefaultAndPlatformId (
202 IN UINT8 *Binary,
203 IN FORMSET_STORAGE *Storage
204 );
205
206 /**
207 Store all defaultId and platformId to binary.
208
209 @param Binary The pointer to the bianry
210 @param Storage The pointer to the Storage
211
212 @retval Length Return the length of the header
213 **/
214 UINT32
215 WriteNvStoreDefaultAndPlatformId (
216 IN UINT8 *Binary,
217 IN FORMSET_STORAGE *Storage
218 );
219
220 /**
221 Copy variable to binary in multi-platform mode
222
223 @param Storage The pointer to a storage in storage list.
224 @param StorageBeginning The pointer to the beginning of storage under specifed platformId and defaultId
225 @param Index The number of the storage. If the Index is 0, record the variable header to
226 the binary. Or else, only record the storage.
227
228 @return length The length of storage
229 **/
230 UINT32
231 CopyVariableToBinary (
232 IN FORMSET_STORAGE *Storage,
233 IN OUT UINT8 *StorageBeginning,
234 IN UINT32 Index
235 );
236
237 /**
238 Copy variable to binary in multi-platform mode
239
240 @param Storage The pointer to a storage in storage list.
241 @param StorageBeginning The pointer to the beginning of storage under specifed platformId and defaultId
242 @param Index The number of the storage. If the Index is 0, record the variable header to
243 the binary. Or else, only record the storage.
244
245 @return length The length of storage
246 **/
247 UINT32
248 CopyVariableToNvStoreBinary (
249 IN FORMSET_STORAGE *Storage,
250 IN OUT UINT8 *StorageBeginning,
251 IN UINT32 Index
252 );
253
254
255 /**
256 Read variable to storage list in multi-platform mode
257
258 @param Binary The pointer to the header of storage under specifed platformId and defaultId
259 @param StorageListEntry The pointer to the storage list.
260
261 @return length The length of storage
262 **/
263
264 UINT32
265 ReadNvStoreVariableToList (
266 IN UINT8 *Binary,
267 IN LIST_ENTRY *StorageListEntry
268 );
269
270 /**
271 Read variable to storage list in multi-platform mode
272
273 @param Binary The pointer to the header of storage under specifed platformId and defaultId
274 @param StorageListEntry The pointer to the storage list.
275
276 @return length The length of storage
277 **/
278 UINT32
279 ReadVariableToList (
280 IN UINT8 *Binary,
281 IN LIST_ENTRY *StorageListEntry
282 );
283
284 /**
285 Check whether exists the valid normal variables in NvStorage or not.
286
287 @retval TRUE If existed, return TRUE.
288 @retval FALSE Others
289 **/
290 BOOLEAN
291 ExistNormalEfiVarOrNot (
292 IN LIST_ENTRY *StorageListHead
293 );
294
295 /**
296 Fix the size of variable header.
297
298 @param Binary The pointer to the header of storage under specifed platformId and defaultId
299 @param Length The length of binary.
300
301 **/
302 VOID
303 FixVariableHeaderSize (
304 IN UINT8 *BinaryBeginning,
305 IN UINT32 Length
306 );
307
308 /**
309 Fix the size of variable header.
310
311 @param Binary The pointer to the header of storage under specifed platformId and defaultId
312 @param Length The length of binary.
313
314 **/
315
316 VOID
317 FixNvStoreVariableHeaderSize (
318 IN UINT8 *BinaryBeginning,
319 IN UINT32 Length
320 );
321 /**
322 Copy time-based authenticated variable to binary in multi-platform mode
323
324 @param Storage The pointer to a storage in storage list.
325 @param StorageBeginning The pointer to the beginning of storage under specifed platformId and defaultId
326 @param Index The number of the storage. If the Index is 0, record the variable header to
327 the binary. Or else, only record the storage.
328 @return length The length of storage
329 **/
330 UINT32
331 CopyTimeBasedVariableToBinary (
332 IN FORMSET_STORAGE *Storage,
333 IN OUT UINT8 *StorageBeginning,
334 IN UINT32 Index
335 );
336
337 /**
338 Read time-based authenticated variable to storage list in multi-platform mode
339
340 @param Binary The pointer to the header of storage under specifed platformId and defaultId
341 @param StorageListEntry The pointer to the storage list.
342
343 @return length The length of storage
344 **/
345 UINT32
346 ReadTimeBasedVariableToList (
347 IN UINT8 *Binary,
348 IN LIST_ENTRY *StorageListEntry
349 );
350
351 /**
352 Check whether exists the valid time-based variables in NvStorage or not.
353
354 @retval TRUE If existed, return TRUE.
355 @retval FALSE Others
356 **/
357 BOOLEAN
358 ExistTimeBasedEfiVarOrNot (
359 IN LIST_ENTRY *StorageListHead
360 );
361
362 /**
363 Fix the size of time-based variable header.
364
365 @param Binary The pointer to the header of storage under specifed platformId and defaultId
366 @param Length The length of binary.
367
368 **/
369 VOID
370 FixBasedTimeVariableHeaderSize (
371 IN UINT8 *BinaryBeginning,
372 IN UINT32 Length
373 );
374
375 /**
376 Copy Monotonic-Based authenticated variable to binary in multi-platform mode
377
378 @param Storage The pointer to a storage in storage list.
379 @param StorageBeginning The pointer to the beginning of storage under specifed platformId and defaultId
380 @param Index The number of the storage. If the Index is 0, record the variable header to
381 the binary. Or else, only record the storage.
382
383 @return length The length of storage
384 **/
385 UINT32
386 CopyMonotonicBasedVariableToBinary (
387 IN FORMSET_STORAGE *Storage,
388 IN OUT UINT8 *StorageBeginning,
389 IN UINT32 Index
390 );
391
392 /**
393 Read Monotonic-based authenticated variable to storage list in multi-platform mode
394
395 @param Binary The pointer to the header of storage under specifed platformId and defaultId
396 @param StorageListEntry The pointer to the storage list.
397
398 @return length The length of storage
399 **/
400 UINT32
401 ReadMonotonicBasedVariableToList (
402 IN UINT8 *Binary,
403 IN LIST_ENTRY *StorageListEntry
404 );
405
406 /**
407 Check whether exists the valid MonotonicBased variables in NvStorage or not.
408
409 @retval TRUE If existed, return TRUE.
410 @retval FALSE Others
411 **/
412 BOOLEAN
413 ExistMonotonicBasedEfiVarOrNot (
414 IN LIST_ENTRY *StorageListHead
415 );
416
417 /**
418 Fix the size of montonic variable header.
419
420 @param Binary The pointer to the header of storage under specifed platformId and defaultId
421 @param Length The length of binary.
422
423 **/
424 VOID
425 FixMontonicVariableHeaderSize (
426 IN UINT8 *BinaryBeginning,
427 IN UINT32 Length
428 );
429
430 /**
431 FCE application entry point
432
433 @param argc The number of input parameters.
434 @param *argv[] The array pointer to the parameters.
435
436 @retval 0 The application exited normally.
437 @retval 1 An error occurred.
438 @retval 2 An error about check occurred.
439
440 **/
441 int
442 main (
443 int argc,
444 char *argv[]
445 );
446
447 #endif