2 This includes some definitions introduced in UEFI that will be used in both PEI and DXE phases.
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
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.
15 #ifndef __UEFI_MULTIPHASE_H__
16 #define __UEFI_MULTIPHASE_H__
18 #include <ProcessorBind.h>
21 /// Enumeration of memory types introduced in UEFI.
27 EfiReservedMemoryType
,
29 /// The code portions of a loaded application.
30 /// (Note that UEFI OS loaders are UEFI applications.)
34 /// The data portions of a loaded application and the default data allocation
35 /// type used by an application to allocate pool memory.
39 /// The code portions of a loaded Boot Services Driver
43 /// The data portions of a loaded Boot Serves Driver, and the default data
44 /// allocation type used by a Boot Services Driver to allocate pool memory.
48 /// The code portions of a loaded Runtime Services Driver.
50 EfiRuntimeServicesCode
,
52 /// The data portions of a loaded Runtime Services Driver and the default
53 /// data allocation type used by a Runtime Services Driver to allocate pool memory.
55 EfiRuntimeServicesData
,
57 /// Free (unallocated) memory.
59 EfiConventionalMemory
,
61 /// Memory in which errors have been detected.
65 /// Memory that holds the ACPI tables.
69 /// Address space reserved for use by the firmware.
73 /// Used by system firmware to request that a memory-mapped IO region
74 /// be mapped by the OS to a virtual address so it can be accessed by EFI runtime services.
78 /// System memory-mapped IO region that is used to translate memory
79 /// cycles to IO cycles by the processor.
81 EfiMemoryMappedIOPortSpace
,
83 /// Address space reserved by the firmware for code that is part of the processor.
90 /// Data structure that precedes all of the standard EFI table types.
94 /// A 64-bit signature that identifies the type of table that follows.
95 /// Unique signatures have been generated for the EFI System Table,
96 /// the EFI Boot Services Table, and the EFI Runtime Services Table.
100 /// The revision of the EFI Specification to which this table
101 /// conforms. The upper 16 bits of this field contain the major
102 /// revision value, and the lower 16 bits contain the minor revision
103 /// value. The minor revision values are limited to the range of 00..99.
107 /// The size, in bytes, of the entire table including the EFI_TABLE_HEADER.
111 /// The 32-bit CRC for the entire table. This value is computed by
112 /// setting this field to 0, and computing the 32-bit CRC for HeaderSize bytes.
116 /// Reserved field that must be set to 0.
122 /// Attributes of variable.
124 #define EFI_VARIABLE_NON_VOLATILE 0x00000001
125 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
126 #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
127 #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008
130 /// This attribute is identified by the mnemonic 'HR'
131 /// elsewhere in this specification.
133 #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010
136 // _WIN_CERTIFICATE.wCertificateType
138 #define WIN_CERT_TYPE_EFI_PKCS115 0x0EF0
139 #define WIN_CERT_TYPE_EFI_GUID 0x0EF1
142 /// The WIN_CERTIFICATE structure is part of the PE/COFF specification.
144 typedef struct _WIN_CERTIFICATE
{
146 /// The length of the entire certificate,
147 /// including the length of the header, in bytes.
151 /// The revision level of the WIN_CERTIFICATE
152 /// structure. The current revision level is 0x0200.
156 /// The certificate type. See WIN_CERT_TYPE_xxx for the UEFI
157 /// certificate types. The UEFI specification reserves the range of
158 /// certificate type values from 0x0EF0 to 0x0EFF.
160 UINT16 wCertificateType
;
162 /// The following is the actual certificate. The format of
163 /// the certificate depends on wCertificateType.
165 /// UINT8 bCertificate[ANYSIZE_ARRAY];
170 /// WIN_CERTIFICATE_UEFI_GUID.CertType
172 #define EFI_CERT_TYPE_RSA2048_SHA256_GUID \
173 {0xa7717414, 0xc616, 0x4977, {0x94, 0x20, 0x84, 0x47, 0x12, 0xa7, 0x35, 0xbf } }
176 /// WIN_CERTIFICATE_UEFI_GUID.CertData
178 typedef struct _EFI_CERT_BLOCK_RSA_2048_SHA256
{
180 UINT8 PublicKey
[256];
181 UINT8 Signature
[256];
182 } EFI_CERT_BLOCK_RSA_2048_SHA256
;
186 /// Certificate which encapsulates a GUID-specific digital signature
188 typedef struct _WIN_CERTIFICATE_UEFI_GUID
{
190 /// This is the standard WIN_CERTIFICATE header, where
191 /// wCertificateType is set to WIN_CERT_TYPE_UEFI_GUID.
195 /// This is the unique id which determines the
196 /// format of the CertData. In this case, the
197 /// value is EFI_CERT_TYPE_RSA2048_SHA256_GUID.
201 /// The following is the certificate data. The format of
202 /// the data is determined by the CertType. In this case the value is
203 /// EFI_CERT_BLOCK_RSA_2048_SHA256.
205 /// UINT8 CertData[ANYSIZE_ARRAY];
207 } WIN_CERTIFICATE_UEFI_GUID
;
211 /// Certificate which encapsulates the RSASSA_PKCS1-v1_5 digital signature.
213 /// The WIN_CERTIFICATE_UEFI_PKCS1_15 structure is derived from
214 /// WIN_CERTIFICATE and encapsulate the information needed to
215 /// implement the RSASSA-PKCS1-v1_5 digital signature algorithm as
216 /// specified in RFC2437.
218 typedef struct _WIN_CERTIFICATE_EFI_PKCS1_15
{
220 /// This is the standard WIN_CERTIFICATE header, where
221 /// wCertificateType is set to WIN_CERT_TYPE_UEFI_PKCS1_15.
225 /// This is the hashing algorithm which was performed on the
226 /// UEFI executable when creating the digital signature.
228 EFI_GUID HashAlgorithm
;
230 /// The following is the actual digital signature. The
231 /// size of the signature is the same size as the key
232 /// (1024-bit key is 128 bytes) and can be determined by
233 /// subtracting the length of the other parts of this header
234 /// from the total length of the certificate as found in
237 /// UINT8 Signature[ANYSIZE_ARRAY];
239 } WIN_CERTIFICATE_EFI_PKCS1_15
;
244 /// AuthInfo is a WIN_CERTIFICATE using the wCertificateType
245 /// WIN_CERTIFICATE_UEFI_GUID and the CertType
246 /// EFI_CERT_TYPE_RSA2048_SHA256. If the attribute specifies
247 /// authenticated access, then the Data buffer should begin with an
248 /// authentication descriptor prior to the data payload and DataSize
249 /// should reflect the the data.and descriptor size. The caller
250 /// shall digest the Monotonic Count value and the associated data
251 /// for the variable update using the SHA-256 1-way hash algorithm.
252 /// The ensuing the 32-byte digest will be signed using the private
253 /// key associated w/ the public/private 2048-bit RSA key-pair. The
254 /// WIN_CERTIFICATE shall be used to describe the signature of the
255 /// Variable data *Data. In addition, the signature will also
256 /// include the MonotonicCount value to guard against replay attacks
260 /// Included in the signature of
261 /// AuthInfo.Used to ensure freshness/no
262 /// replay. Incremented during each
265 UINT64 MonotonicCount
;
267 /// Provides the authorization for the variable
268 /// access. It is a signature across the
269 /// variable data and the Monotonic Count
270 /// value. Caller uses Private key that is
271 /// associated with a public key that has been
272 /// provisioned via the key exchange.
274 WIN_CERTIFICATE_UEFI_GUID AuthInfo
;
275 } EFI_VARIABLE_AUTHENTICATION
;