]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
7ff469779c05a070ad84b779e1a9e6ecb3891f55
[mirror_edk2.git] / SecurityPkg / Include / Guid / AuthenticatedVariableFormat.h
1 /** @file
2 The variable data structures are related to EDKII-specific
3 implementation of UEFI authenticated variables.
4 AuthenticatedVariableFormat.h defines variable data headers
5 and variable storage region headers.
6
7 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __AUTHENTICATED_VARIABLE_FORMAT_H__
19 #define __AUTHENTICATED_VARIABLE_FORMAT_H__
20
21 #define EFI_AUTHENTICATED_VARIABLE_GUID \
22 { 0xaaf32c78, 0x947b, 0x439a, { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 } }
23
24 #define EFI_SECURE_BOOT_ENABLE_DISABLE \
25 { 0xf0a30bc7, 0xaf08, 0x4556, { 0x99, 0xc4, 0x0, 0x10, 0x9, 0xc9, 0x3a, 0x44 } }
26
27
28 extern EFI_GUID gEfiAuthenticatedVariableGuid;
29 extern EFI_GUID gEfiSecureBootEnableDisableGuid;
30
31 ///
32 /// "SecureBootEnable" variable for the Secure boot feature enable/disable.
33 ///
34 #define EFI_SECURE_BOOT_ENABLE_NAME L"SecureBootEnable"
35 #define SECURE_BOOT_ENABLE 1
36 #define SECURE_BOOT_DISABLE 0
37
38 ///
39 /// Alignment of variable name and data, according to the architecture:
40 /// * For IA-32 and Intel(R) 64 architectures: 1.
41 /// * For IA-64 architecture: 8.
42 ///
43 #if defined (MDE_CPU_IPF)
44 #define ALIGNMENT 8
45 #else
46 #define ALIGNMENT 1
47 #endif
48
49 //
50 // GET_PAD_SIZE calculates the miminal pad bytes needed to make the current pad size satisfy the alignment requirement.
51 //
52 #if (ALIGNMENT == 1)
53 #define GET_PAD_SIZE(a) (0)
54 #else
55 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
56 #endif
57
58 ///
59 /// Alignment of Variable Data Header in Variable Store region.
60 ///
61 #define HEADER_ALIGNMENT 4
62 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
63
64 ///
65 /// Status of Variable Store Region.
66 ///
67 typedef enum {
68 EfiRaw,
69 EfiValid,
70 EfiInvalid,
71 EfiUnknown
72 } VARIABLE_STORE_STATUS;
73
74 #pragma pack(1)
75
76 #define VARIABLE_STORE_SIGNATURE EFI_AUTHENTICATED_VARIABLE_GUID
77
78 ///
79 /// Variable Store Header Format and State.
80 ///
81 #define VARIABLE_STORE_FORMATTED 0x5a
82 #define VARIABLE_STORE_HEALTHY 0xfe
83
84 ///
85 /// Variable Store region header.
86 ///
87 typedef struct {
88 ///
89 /// Variable store region signature.
90 ///
91 EFI_GUID Signature;
92 ///
93 /// Size of entire variable store,
94 /// including size of variable store header but not including the size of FvHeader.
95 ///
96 UINT32 Size;
97 ///
98 /// Variable region format state.
99 ///
100 UINT8 Format;
101 ///
102 /// Variable region healthy state.
103 ///
104 UINT8 State;
105 UINT16 Reserved;
106 UINT32 Reserved1;
107 } VARIABLE_STORE_HEADER;
108
109 ///
110 /// Variable data start flag.
111 ///
112 #define VARIABLE_DATA 0x55AA
113
114 ///
115 /// Variable State flags.
116 ///
117 #define VAR_IN_DELETED_TRANSITION 0xfe ///< Variable is in obsolete transition.
118 #define VAR_DELETED 0xfd ///< Variable is obsolete.
119 #define VAR_HEADER_VALID_ONLY 0x7f ///< Variable header has been valid.
120 #define VAR_ADDED 0x3f ///< Variable has been completely added.
121
122 ///
123 /// Single Variable Data Header Structure.
124 ///
125 typedef struct {
126 ///
127 /// Variable Data Start Flag.
128 ///
129 UINT16 StartId;
130 ///
131 /// Variable State defined above.
132 ///
133 UINT8 State;
134 UINT8 Reserved;
135 ///
136 /// Attributes of variable defined in UEFI specification.
137 ///
138 UINT32 Attributes;
139 ///
140 /// Associated monotonic count value against replay attack.
141 ///
142 UINT64 MonotonicCount;
143 ///
144 /// Associated TimeStamp value against replay attack.
145 ///
146 EFI_TIME TimeStamp;
147 ///
148 /// Index of associated public key in database.
149 ///
150 UINT32 PubKeyIndex;
151 ///
152 /// Size of variable null-terminated Unicode string name.
153 ///
154 UINT32 NameSize;
155 ///
156 /// Size of the variable data without this header.
157 ///
158 UINT32 DataSize;
159 ///
160 /// A unique identifier for the vendor that produces and consumes this varaible.
161 ///
162 EFI_GUID VendorGuid;
163 } VARIABLE_HEADER;
164
165 #pragma pack()
166
167 typedef struct _VARIABLE_INFO_ENTRY VARIABLE_INFO_ENTRY;
168
169 ///
170 /// This structure contains the variable list that is put in EFI system table.
171 /// The variable driver collects all variables that were used at boot service time and produces this list.
172 /// This is an optional feature to dump all used variables in shell environment.
173 ///
174 struct _VARIABLE_INFO_ENTRY {
175 VARIABLE_INFO_ENTRY *Next; ///< Pointer to next entry.
176 EFI_GUID VendorGuid; ///< Guid of Variable.
177 CHAR16 *Name; ///< Name of Variable.
178 UINT32 Attributes; ///< Attributes of variable defined in UEFI spec.
179 UINT32 ReadCount; ///< Number of times to read this variable.
180 UINT32 WriteCount; ///< Number of times to write this variable.
181 UINT32 DeleteCount; ///< Number of times to delete this variable.
182 UINT32 CacheCount; ///< Number of times that cache hits this variable.
183 BOOLEAN Volatile; ///< TRUE if volatile, FALSE if non-volatile.
184 };
185
186 #endif // __AUTHENTICATED_VARIABLE_FORMAT_H__