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