]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/VariableFormat.h
40bd4612866164ea958db2d71e022fe65211ede0
[mirror_edk2.git] / MdeModulePkg / Include / VariableFormat.h
1 /** @file
2 The variable data structures are related to EDK II specific UEFI variable implementation.
3 Variable data header and Variable storage region header are defined here.
4
5 Copyright (c) 2006 - 2008 Intel Corporation. <BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __VARIABLE_FORMAT_H__
17 #define __VARIABLE_FORMAT_H__
18
19 ///
20 /// Alignment of variable name and data.
21 /// For IA32/X64 architecture, the alignment is set to 1, and 8 is for IPF archtecture.
22 ///
23 #if defined (MDE_CPU_IPF)
24 #define ALIGNMENT 8
25 #else
26 #define ALIGNMENT 1
27 #endif
28
29 //
30 // GET_PAD_SIZE to calculate miminal pad bytes to make current size satisfy the alignment requirement
31 //
32 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
33 #define GET_PAD_SIZE(a) (0)
34 #else
35 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
36 #endif
37
38 ///
39 /// Alignment of Variable Data Header in Variable Store region
40 ///
41 #define HEADER_ALIGNMENT 4
42 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
43
44 ///
45 /// Status of Variable Store Region
46 ///
47 typedef enum {
48 EfiRaw,
49 EfiValid,
50 EfiInvalid,
51 EfiUnknown
52 } VARIABLE_STORE_STATUS;
53
54 #pragma pack(1)
55
56 #define VARIABLE_STORE_SIGNATURE SIGNATURE_32 ('$', 'V', 'S', 'S')
57
58 ///
59 /// Variable Store Header Format and State
60 ///
61 #define VARIABLE_STORE_FORMATTED 0x5a
62 #define VARIABLE_STORE_HEALTHY 0xfe
63
64 ///
65 /// Variable Store region header
66 ///
67 typedef struct {
68 ///
69 /// Variable store region signature.
70 ///
71 UINT32 Signature;
72 ///
73 /// Size of variable store region including this header
74 ///
75 UINT32 Size;
76 ///
77 /// variable region format state
78 ///
79 UINT8 Format;
80 ///
81 /// variable region healthy state
82 ///
83 UINT8 State;
84 UINT16 Reserved;
85 UINT32 Reserved1;
86 } VARIABLE_STORE_HEADER;
87
88 ///
89 /// Variable data start flag
90 ///
91 #define VARIABLE_DATA 0x55AA
92
93 ///
94 /// Variable State flags
95 ///
96 #define VAR_IN_DELETED_TRANSITION 0xfe ///< Variable is in obsolete transistion
97 #define VAR_DELETED 0xfd ///< Variable is obsolete
98 #define VAR_HEADER_VALID_ONLY 0x7f ///< Variable header has been valid
99 #define VAR_ADDED 0x3f ///< Variable has been completely added
100
101 ///
102 /// Single Variable Data Header Structure
103 ///
104 typedef struct {
105 ///
106 /// Variable Data Start Flag
107 ///
108 UINT16 StartId;
109 ///
110 /// Variable State defined above
111 ///
112 UINT8 State;
113 UINT8 Reserved;
114 ///
115 /// Attributes of variable defined in UEFI spec
116 ///
117 UINT32 Attributes;
118 ///
119 /// Size of variable Null-terminated Unicode string name
120 ///
121 UINT32 NameSize;
122 ///
123 /// Size of the variable data without this header
124 ///
125 UINT32 DataSize;
126 ///
127 /// A unique identifier for the vendor that produce and consume this varaible.
128 ///
129 EFI_GUID VendorGuid;
130 } VARIABLE_HEADER;
131
132 #pragma pack()
133
134 #endif // _EFI_VARIABLE_H_