]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
Add security package to repository.
[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 extern EFI_GUID gEfiAuthenticatedVariableGuid;
25
26 ///
27 /// Alignment of variable name and data, according to the architecture:
28 /// * For IA-32 and Intel(R) 64 architectures: 1.
29 /// * For IA-64 architecture: 8.
30 ///
31 #if defined (MDE_CPU_IPF)
32 #define ALIGNMENT 8
33 #else
34 #define ALIGNMENT 1
35 #endif
36
37 //
38 // GET_PAD_SIZE calculates the miminal pad bytes needed to make the current pad size satisfy the alignment requirement.
39 //
40 #if (ALIGNMENT == 1)
41 #define GET_PAD_SIZE(a) (0)
42 #else
43 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
44 #endif
45
46 ///
47 /// Alignment of Variable Data Header in Variable Store region.
48 ///
49 #define HEADER_ALIGNMENT 4
50 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
51
52 ///
53 /// Status of Variable Store Region.
54 ///
55 typedef enum {
56 EfiRaw,
57 EfiValid,
58 EfiInvalid,
59 EfiUnknown
60 } VARIABLE_STORE_STATUS;
61
62 #pragma pack(1)
63
64 #define VARIABLE_STORE_SIGNATURE EFI_AUTHENTICATED_VARIABLE_GUID
65
66 ///
67 /// Variable Store Header Format and State.
68 ///
69 #define VARIABLE_STORE_FORMATTED 0x5a
70 #define VARIABLE_STORE_HEALTHY 0xfe
71
72 ///
73 /// Variable Store region header.
74 ///
75 typedef struct {
76 ///
77 /// Variable store region signature.
78 ///
79 EFI_GUID Signature;
80 ///
81 /// Size of entire variable store,
82 /// including size of variable store header but not including the size of FvHeader.
83 ///
84 UINT32 Size;
85 ///
86 /// Variable region format state.
87 ///
88 UINT8 Format;
89 ///
90 /// Variable region healthy state.
91 ///
92 UINT8 State;
93 UINT16 Reserved;
94 UINT32 Reserved1;
95 } VARIABLE_STORE_HEADER;
96
97 ///
98 /// Variable data start flag.
99 ///
100 #define VARIABLE_DATA 0x55AA
101
102 ///
103 /// Variable State flags.
104 ///
105 #define VAR_IN_DELETED_TRANSITION 0xfe ///< Variable is in obsolete transition.
106 #define VAR_DELETED 0xfd ///< Variable is obsolete.
107 #define VAR_HEADER_VALID_ONLY 0x7f ///< Variable header has been valid.
108 #define VAR_ADDED 0x3f ///< Variable has been completely added.
109
110 ///
111 /// Single Variable Data Header Structure.
112 ///
113 typedef struct {
114 ///
115 /// Variable Data Start Flag.
116 ///
117 UINT16 StartId;
118 ///
119 /// Variable State defined above.
120 ///
121 UINT8 State;
122 UINT8 Reserved;
123 ///
124 /// Attributes of variable defined in UEFI specification.
125 ///
126 UINT32 Attributes;
127 ///
128 /// Associated monotonic count value against replay attack.
129 ///
130 UINT64 MonotonicCount;
131 ///
132 /// Associated TimeStamp value against replay attack.
133 ///
134 EFI_TIME TimeStamp;
135 ///
136 /// Index of associated public key in database.
137 ///
138 UINT32 PubKeyIndex;
139 ///
140 /// Size of variable null-terminated Unicode string name.
141 ///
142 UINT32 NameSize;
143 ///
144 /// Size of the variable data without this header.
145 ///
146 UINT32 DataSize;
147 ///
148 /// A unique identifier for the vendor that produces and consumes this varaible.
149 ///
150 EFI_GUID VendorGuid;
151 } VARIABLE_HEADER;
152
153 #pragma pack()
154
155 typedef struct _VARIABLE_INFO_ENTRY VARIABLE_INFO_ENTRY;
156
157 ///
158 /// This structure contains the variable list that is put in EFI system table.
159 /// The variable driver collects all variables that were used at boot service time and produces this list.
160 /// This is an optional feature to dump all used variables in shell environment.
161 ///
162 struct _VARIABLE_INFO_ENTRY {
163 VARIABLE_INFO_ENTRY *Next; ///< Pointer to next entry.
164 EFI_GUID VendorGuid; ///< Guid of Variable.
165 CHAR16 *Name; ///< Name of Variable.
166 UINT32 Attributes; ///< Attributes of variable defined in UEFI spec.
167 UINT32 ReadCount; ///< Number of times to read this variable.
168 UINT32 WriteCount; ///< Number of times to write this variable.
169 UINT32 DeleteCount; ///< Number of times to delete this variable.
170 UINT32 CacheCount; ///< Number of times that cache hits this variable.
171 BOOLEAN Volatile; ///< TRUE if volatile, FALSE if non-volatile.
172 };
173
174 #endif // __AUTHENTICATED_VARIABLE_FORMAT_H__