]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Guid/VariableFormat.h
MdeModulePkg: Add match2 opcode support in SetupBrowserDxe and sample code in DriverS...
[mirror_edk2.git] / MdeModulePkg / Include / Guid / VariableFormat.h
1 /** @file
2 The variable data structures are related to EDK II-specific implementation of UEFI variables.
3 VariableFormat.h defines variable data headers and variable storage region headers.
4
5 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 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 #define EFI_VARIABLE_GUID \
20 { 0xddcf3616, 0x3275, 0x4164, { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d } }
21
22 extern EFI_GUID gEfiVariableGuid;
23
24 ///
25 /// Alignment of variable name and data, according to the architecture:
26 /// * For IA-32 and Intel(R) 64 architectures: 1.
27 /// * For IA-64 architecture: 8.
28 ///
29 #if defined (MDE_CPU_IPF)
30 #define ALIGNMENT 8
31 #else
32 #define ALIGNMENT 1
33 #endif
34
35 //
36 // GET_PAD_SIZE calculates the miminal pad bytes needed to make the current pad size satisfy the alignment requirement.
37 //
38 #if (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 ///
45 /// Alignment of Variable Data Header in Variable Store region.
46 ///
47 #define HEADER_ALIGNMENT 4
48 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
49
50 ///
51 /// Status of Variable Store Region.
52 ///
53 typedef enum {
54 EfiRaw,
55 EfiValid,
56 EfiInvalid,
57 EfiUnknown
58 } VARIABLE_STORE_STATUS;
59
60 #pragma pack(1)
61
62 #define VARIABLE_STORE_SIGNATURE EFI_VARIABLE_GUID
63
64 ///
65 /// Variable Store Header Format and State.
66 ///
67 #define VARIABLE_STORE_FORMATTED 0x5a
68 #define VARIABLE_STORE_HEALTHY 0xfe
69
70 ///
71 /// Variable Store region header.
72 ///
73 typedef struct {
74 ///
75 /// Variable store region signature.
76 ///
77 EFI_GUID Signature;
78 ///
79 /// Size of entire variable store,
80 /// including size of variable store header but not including the size of FvHeader.
81 ///
82 UINT32 Size;
83 ///
84 /// Variable region format state.
85 ///
86 UINT8 Format;
87 ///
88 /// Variable region healthy state.
89 ///
90 UINT8 State;
91 UINT16 Reserved;
92 UINT32 Reserved1;
93 } VARIABLE_STORE_HEADER;
94
95 ///
96 /// Variable data start flag.
97 ///
98 #define VARIABLE_DATA 0x55AA
99
100 ///
101 /// Variable State flags.
102 ///
103 #define VAR_IN_DELETED_TRANSITION 0xfe ///< Variable is in obsolete transition.
104 #define VAR_DELETED 0xfd ///< Variable is obsolete.
105 #define VAR_HEADER_VALID_ONLY 0x7f ///< Variable header has been valid.
106 #define VAR_ADDED 0x3f ///< Variable has been completely added.
107
108 ///
109 /// Single Variable Data Header Structure.
110 ///
111 typedef struct {
112 ///
113 /// Variable Data Start Flag.
114 ///
115 UINT16 StartId;
116 ///
117 /// Variable State defined above.
118 ///
119 UINT8 State;
120 UINT8 Reserved;
121 ///
122 /// Attributes of variable defined in UEFI specification.
123 ///
124 UINT32 Attributes;
125 ///
126 /// Size of variable null-terminated Unicode string name.
127 ///
128 UINT32 NameSize;
129 ///
130 /// Size of the variable data without this header.
131 ///
132 UINT32 DataSize;
133 ///
134 /// A unique identifier for the vendor that produces and consumes this varaible.
135 ///
136 EFI_GUID VendorGuid;
137 } VARIABLE_HEADER;
138
139 #pragma pack()
140
141 typedef struct _VARIABLE_INFO_ENTRY VARIABLE_INFO_ENTRY;
142
143 ///
144 /// This structure contains the variable list that is put in EFI system table.
145 /// The variable driver collects all variables that were used at boot service time and produces this list.
146 /// This is an optional feature to dump all used variables in shell environment.
147 ///
148 struct _VARIABLE_INFO_ENTRY {
149 VARIABLE_INFO_ENTRY *Next; ///< Pointer to next entry.
150 EFI_GUID VendorGuid; ///< Guid of Variable.
151 CHAR16 *Name; ///< Name of Variable.
152 UINT32 Attributes; ///< Attributes of variable defined in UEFI specification.
153 UINT32 ReadCount; ///< Number of times to read this variable.
154 UINT32 WriteCount; ///< Number of times to write this variable.
155 UINT32 DeleteCount; ///< Number of times to delete this variable.
156 UINT32 CacheCount; ///< Number of times that cache hits this variable.
157 BOOLEAN Volatile; ///< TRUE if volatile, FALSE if non-volatile.
158 };
159
160 #endif // _EFI_VARIABLE_H_