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