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