xref: /freebsd/sys/contrib/edk2/Include/Uefi/UefiMultiPhase.h (revision a90b9d0159070121c221b966469c3e36d912bf82)
1 /** @file
2   This includes some definitions introduced in UEFI that will be used in both PEI and DXE phases.
3 
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7 **/
8 
9 #ifndef __UEFI_MULTIPHASE_H__
10 #define __UEFI_MULTIPHASE_H__
11 
12 ///
13 /// Attributes of variable.
14 ///
15 #define EFI_VARIABLE_NON_VOLATILE                            0x00000001
16 #define EFI_VARIABLE_BOOTSERVICE_ACCESS                      0x00000002
17 #define EFI_VARIABLE_RUNTIME_ACCESS                          0x00000004
18 ///
19 /// This attribute is identified by the mnemonic 'HR'
20 /// elsewhere in this specification.
21 ///
22 #define EFI_VARIABLE_HARDWARE_ERROR_RECORD                   0x00000008
23 ///
24 /// Attributes of Authenticated Variable
25 ///
26 #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS   0x00000020
27 #define EFI_VARIABLE_APPEND_WRITE                            0x00000040
28 ///
29 /// NOTE: EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated and should be considered reserved.
30 ///
31 #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS              0x00000010
32 
33 #ifndef VFRCOMPILE
34 #include <Guid/WinCertificate.h>
35 ///
36 /// Enumeration of memory types introduced in UEFI.
37 ///
38 typedef enum {
39   ///
40   /// Not used.
41   ///
42   EfiReservedMemoryType,
43   ///
44   /// The code portions of a loaded application.
45   /// (Note that UEFI OS loaders are UEFI applications.)
46   ///
47   EfiLoaderCode,
48   ///
49   /// The data portions of a loaded application and the default data allocation
50   /// type used by an application to allocate pool memory.
51   ///
52   EfiLoaderData,
53   ///
54   /// The code portions of a loaded Boot Services Driver.
55   ///
56   EfiBootServicesCode,
57   ///
58   /// The data portions of a loaded Boot Serves Driver, and the default data
59   /// allocation type used by a Boot Services Driver to allocate pool memory.
60   ///
61   EfiBootServicesData,
62   ///
63   /// The code portions of a loaded Runtime Services Driver.
64   ///
65   EfiRuntimeServicesCode,
66   ///
67   /// The data portions of a loaded Runtime Services Driver and the default
68   /// data allocation type used by a Runtime Services Driver to allocate pool memory.
69   ///
70   EfiRuntimeServicesData,
71   ///
72   /// Free (unallocated) memory.
73   ///
74   EfiConventionalMemory,
75   ///
76   /// Memory in which errors have been detected.
77   ///
78   EfiUnusableMemory,
79   ///
80   /// Memory that holds the ACPI tables.
81   ///
82   EfiACPIReclaimMemory,
83   ///
84   /// Address space reserved for use by the firmware.
85   ///
86   EfiACPIMemoryNVS,
87   ///
88   /// Used by system firmware to request that a memory-mapped IO region
89   /// be mapped by the OS to a virtual address so it can be accessed by EFI runtime services.
90   ///
91   EfiMemoryMappedIO,
92   ///
93   /// System memory-mapped IO region that is used to translate memory
94   /// cycles to IO cycles by the processor.
95   ///
96   EfiMemoryMappedIOPortSpace,
97   ///
98   /// Address space reserved by the firmware for code that is part of the processor.
99   ///
100   EfiPalCode,
101   ///
102   /// A memory region that operates as EfiConventionalMemory,
103   /// however it happens to also support byte-addressable non-volatility.
104   ///
105   EfiPersistentMemory,
106   EfiMaxMemoryType
107 } EFI_MEMORY_TYPE;
108 
109 ///
110 /// Enumeration of reset types.
111 ///
112 typedef enum {
113   ///
114   /// Used to induce a system-wide reset. This sets all circuitry within the
115   /// system to its initial state.  This type of reset is asynchronous to system
116   /// operation and operates withgout regard to cycle boundaries.  EfiColdReset
117   /// is tantamount to a system power cycle.
118   ///
119   EfiResetCold,
120   ///
121   /// Used to induce a system-wide initialization. The processors are set to their
122   /// initial state, and pending cycles are not corrupted.  If the system does
123   /// not support this reset type, then an EfiResetCold must be performed.
124   ///
125   EfiResetWarm,
126   ///
127   /// Used to induce an entry into a power state equivalent to the ACPI G2/S5 or G3
128   /// state.  If the system does not support this reset type, then when the system
129   /// is rebooted, it should exhibit the EfiResetCold attributes.
130   ///
131   EfiResetShutdown,
132   ///
133   /// Used to induce a system-wide reset. The exact type of the reset is defined by
134   /// the EFI_GUID that follows the Null-terminated Unicode string passed into
135   /// ResetData. If the platform does not recognize the EFI_GUID in ResetData the
136   /// platform must pick a supported reset type to perform. The platform may
137   /// optionally log the parameters from any non-normal reset that occurs.
138   ///
139   EfiResetPlatformSpecific
140 } EFI_RESET_TYPE;
141 
142 ///
143 /// Data structure that precedes all of the standard EFI table types.
144 ///
145 typedef struct {
146   ///
147   /// A 64-bit signature that identifies the type of table that follows.
148   /// Unique signatures have been generated for the EFI System Table,
149   /// the EFI Boot Services Table, and the EFI Runtime Services Table.
150   ///
151   UINT64  Signature;
152   ///
153   /// The revision of the EFI Specification to which this table
154   /// conforms. The upper 16 bits of this field contain the major
155   /// revision value, and the lower 16 bits contain the minor revision
156   /// value. The minor revision values are limited to the range of 00..99.
157   ///
158   UINT32  Revision;
159   ///
160   /// The size, in bytes, of the entire table including the EFI_TABLE_HEADER.
161   ///
162   UINT32  HeaderSize;
163   ///
164   /// The 32-bit CRC for the entire table. This value is computed by
165   /// setting this field to 0, and computing the 32-bit CRC for HeaderSize bytes.
166   ///
167   UINT32  CRC32;
168   ///
169   /// Reserved field that must be set to 0.
170   ///
171   UINT32  Reserved;
172 } EFI_TABLE_HEADER;
173 
174 ///
175 /// AuthInfo is a WIN_CERTIFICATE using the wCertificateType
176 /// WIN_CERTIFICATE_UEFI_GUID and the CertType
177 /// EFI_CERT_TYPE_RSA2048_SHA256_GUID. If the attribute specifies
178 /// authenticated access, then the Data buffer should begin with an
179 /// authentication descriptor prior to the data payload and DataSize
180 /// should reflect the the data.and descriptor size. The caller
181 /// shall digest the Monotonic Count value and the associated data
182 /// for the variable update using the SHA-256 1-way hash algorithm.
183 /// The ensuing the 32-byte digest will be signed using the private
184 /// key associated w/ the public/private 2048-bit RSA key-pair. The
185 /// WIN_CERTIFICATE shall be used to describe the signature of the
186 /// Variable data *Data. In addition, the signature will also
187 /// include the MonotonicCount value to guard against replay attacks.
188 ///
189 typedef struct {
190   ///
191   /// Included in the signature of
192   /// AuthInfo.Used to ensure freshness/no
193   /// replay. Incremented during each
194   /// "Write" access.
195   ///
196   UINT64                      MonotonicCount;
197   ///
198   /// Provides the authorization for the variable
199   /// access. It is a signature across the
200   /// variable data and the  Monotonic Count
201   /// value. Caller uses Private key that is
202   /// associated with a public key that has been
203   /// provisioned via the key exchange.
204   ///
205   WIN_CERTIFICATE_UEFI_GUID   AuthInfo;
206 } EFI_VARIABLE_AUTHENTICATION;
207 
208 ///
209 /// When the attribute EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS is
210 /// set, then the Data buffer shall begin with an instance of a complete (and serialized)
211 /// EFI_VARIABLE_AUTHENTICATION_2 descriptor. The descriptor shall be followed by the new
212 /// variable value and DataSize shall reflect the combined size of the descriptor and the new
213 /// variable value. The authentication descriptor is not part of the variable data and is not
214 /// returned by subsequent calls to GetVariable().
215 ///
216 typedef struct {
217   ///
218   /// For the TimeStamp value, components Pad1, Nanosecond, TimeZone, Daylight and
219   /// Pad2 shall be set to 0. This means that the time shall always be expressed in GMT.
220   ///
221   EFI_TIME                    TimeStamp;
222   ///
223   /// Only a CertType of  EFI_CERT_TYPE_PKCS7_GUID is accepted.
224   ///
225   WIN_CERTIFICATE_UEFI_GUID   AuthInfo;
226  } EFI_VARIABLE_AUTHENTICATION_2;
227 #endif // VFRCOMPILE
228 
229 #endif
230