xref: /freebsd/sys/contrib/edk2/Include/Uefi/UefiMultiPhase.h (revision 580fcf642ea2d5a1e60f24947d1c2e97007e44e9)
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   ///
107   /// A memory region that describes system memory that has not been accepted
108   /// by a corresponding call to the underlying isolation architecture.
109   ///
110   EfiUnacceptedMemoryType,
111   EfiMaxMemoryType,
112   //
113   // +---------------------------------------------------+
114   // | 0..(EfiMaxMemoryType - 1)    - Normal memory type |
115   // +---------------------------------------------------+
116   // | EfiMaxMemoryType..0x6FFFFFFF - Invalid            |
117   // +---------------------------------------------------+
118   // | 0x70000000..0x7FFFFFFF       - OEM reserved       |
119   // +---------------------------------------------------+
120   // | 0x80000000..0xFFFFFFFF       - OS reserved        |
121   // +---------------------------------------------------+
122   //
123   MEMORY_TYPE_OEM_RESERVED_MIN = 0x70000000,
124   MEMORY_TYPE_OEM_RESERVED_MAX = 0x7FFFFFFF,
125   MEMORY_TYPE_OS_RESERVED_MIN  = 0x80000000,
126   MEMORY_TYPE_OS_RESERVED_MAX  = 0xFFFFFFFF
127 } EFI_MEMORY_TYPE;
128 
129 ///
130 /// Enumeration of reset types.
131 ///
132 typedef enum {
133   ///
134   /// Used to induce a system-wide reset. This sets all circuitry within the
135   /// system to its initial state.  This type of reset is asynchronous to system
136   /// operation and operates withgout regard to cycle boundaries.  EfiColdReset
137   /// is tantamount to a system power cycle.
138   ///
139   EfiResetCold,
140   ///
141   /// Used to induce a system-wide initialization. The processors are set to their
142   /// initial state, and pending cycles are not corrupted.  If the system does
143   /// not support this reset type, then an EfiResetCold must be performed.
144   ///
145   EfiResetWarm,
146   ///
147   /// Used to induce an entry into a power state equivalent to the ACPI G2/S5 or G3
148   /// state.  If the system does not support this reset type, then when the system
149   /// is rebooted, it should exhibit the EfiResetCold attributes.
150   ///
151   EfiResetShutdown,
152   ///
153   /// Used to induce a system-wide reset. The exact type of the reset is defined by
154   /// the EFI_GUID that follows the Null-terminated Unicode string passed into
155   /// ResetData. If the platform does not recognize the EFI_GUID in ResetData the
156   /// platform must pick a supported reset type to perform. The platform may
157   /// optionally log the parameters from any non-normal reset that occurs.
158   ///
159   EfiResetPlatformSpecific
160 } EFI_RESET_TYPE;
161 
162 ///
163 /// Data structure that precedes all of the standard EFI table types.
164 ///
165 typedef struct {
166   ///
167   /// A 64-bit signature that identifies the type of table that follows.
168   /// Unique signatures have been generated for the EFI System Table,
169   /// the EFI Boot Services Table, and the EFI Runtime Services Table.
170   ///
171   UINT64    Signature;
172   ///
173   /// The revision of the EFI Specification to which this table
174   /// conforms. The upper 16 bits of this field contain the major
175   /// revision value, and the lower 16 bits contain the minor revision
176   /// value. The minor revision values are limited to the range of 00..99.
177   ///
178   UINT32    Revision;
179   ///
180   /// The size, in bytes, of the entire table including the EFI_TABLE_HEADER.
181   ///
182   UINT32    HeaderSize;
183   ///
184   /// The 32-bit CRC for the entire table. This value is computed by
185   /// setting this field to 0, and computing the 32-bit CRC for HeaderSize bytes.
186   ///
187   UINT32    CRC32;
188   ///
189   /// Reserved field that must be set to 0.
190   ///
191   UINT32    Reserved;
192 } EFI_TABLE_HEADER;
193 
194 ///
195 /// AuthInfo is a WIN_CERTIFICATE using the wCertificateType
196 /// WIN_CERTIFICATE_UEFI_GUID and the CertType
197 /// EFI_CERT_TYPE_RSA2048_SHA256_GUID. If the attribute specifies
198 /// authenticated access, then the Data buffer should begin with an
199 /// authentication descriptor prior to the data payload and DataSize
200 /// should reflect the the data.and descriptor size. The caller
201 /// shall digest the Monotonic Count value and the associated data
202 /// for the variable update using the SHA-256 1-way hash algorithm.
203 /// The ensuing the 32-byte digest will be signed using the private
204 /// key associated w/ the public/private 2048-bit RSA key-pair. The
205 /// WIN_CERTIFICATE shall be used to describe the signature of the
206 /// Variable data *Data. In addition, the signature will also
207 /// include the MonotonicCount value to guard against replay attacks.
208 ///
209 typedef struct {
210   ///
211   /// Included in the signature of
212   /// AuthInfo.Used to ensure freshness/no
213   /// replay. Incremented during each
214   /// "Write" access.
215   ///
216   UINT64    MonotonicCount;
217   ///
218   /// Provides the authorization for the variable
219   /// access. It is a signature across the
220   /// variable data and the  Monotonic Count
221   /// value. Caller uses Private key that is
222   /// associated with a public key that has been
223   /// provisioned via the key exchange.
224   ///
225   WIN_CERTIFICATE_UEFI_GUID    AuthInfo;
226 } EFI_VARIABLE_AUTHENTICATION;
227 
228 ///
229 /// When the attribute EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS is
230 /// set, then the Data buffer shall begin with an instance of a complete (and serialized)
231 /// EFI_VARIABLE_AUTHENTICATION_2 descriptor. The descriptor shall be followed by the new
232 /// variable value and DataSize shall reflect the combined size of the descriptor and the new
233 /// variable value. The authentication descriptor is not part of the variable data and is not
234 /// returned by subsequent calls to GetVariable().
235 ///
236 typedef struct {
237   ///
238   /// For the TimeStamp value, components Pad1, Nanosecond, TimeZone, Daylight and
239   /// Pad2 shall be set to 0. This means that the time shall always be expressed in GMT.
240   ///
241   EFI_TIME                     TimeStamp;
242   ///
243   /// Only a CertType of  EFI_CERT_TYPE_PKCS7_GUID is accepted.
244   ///
245   WIN_CERTIFICATE_UEFI_GUID    AuthInfo;
246 } EFI_VARIABLE_AUTHENTICATION_2;
247 #endif // VFRCOMPILE
248 
249 #endif
250