tpm2-tss  3.2.1
TPM Software stack 2.0 TCG spec compliant implementation
efi_event.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 #ifndef TCG_EFI_EVENT_H
3 #define TCG_EFI_EVENT_H 1
4 
5 #include <uuid/uuid.h>
6 #include <uchar.h>
7 
8 #include "tss2_tpm2_types.h"
9 
10 /*
11  * Log event types. These are spread out over 2 specs:
12  * "TCG EFI Protocol Specification For TPM Family 1.1 or 1.2" and
13  * "TCG PC Client Specific Implementation Specification for Conventional BIOS"
14  */
15 #define EV_PREBOOT_CERT 0x0
16 #define EV_POST_CODE 0x1
17 #define EV_UNUSED 0x2
18 #define EV_NO_ACTION 0x3
19 #define EV_SEPARATOR 0x4
20 #define EV_ACTION 0x5
21 #define EV_EVENT_TAG 0x6
22 #define EV_S_CRTM_CONTENTS 0x7
23 #define EV_S_CRTM_VERSION 0x8
24 #define EV_CPU_MICROCODE 0x9
25 #define EV_PLATFORM_CONFIG_FLAGS 0xa
26 #define EV_TABLE_OF_DEVICES 0xb
27 #define EV_COMPACT_HASH 0xc
28 #define EV_IPL 0xd
29 #define EV_IPL_PARTITION_DATA 0xe
30 #define EV_NONHOST_CODE 0xf
31 #define EV_NONHOST_CONFIG 0x10
32 #define EV_NONHOST_INFO 0x11
33 #define EV_OMIT_BOOT_DEVICE_EVENTS 0x12
34 
35 /* TCG EFI Platform Specification For TPM Family 1.1 or 1.2 */
36 #define EV_EFI_EVENT_BASE 0x80000000
37 #define EV_EFI_VARIABLE_DRIVER_CONFIG EV_EFI_EVENT_BASE + 0x1
38 #define EV_EFI_VARIABLE_BOOT EV_EFI_EVENT_BASE + 0x2
39 #define EV_EFI_BOOT_SERVICES_APPLICATION EV_EFI_EVENT_BASE + 0x3
40 #define EV_EFI_BOOT_SERVICES_DRIVER EV_EFI_EVENT_BASE + 0x4
41 #define EV_EFI_RUNTIME_SERVICES_DRIVER EV_EFI_EVENT_BASE + 0x5
42 #define EV_EFI_GPT_EVENT EV_EFI_EVENT_BASE + 0x6
43 #define EV_EFI_ACTION EV_EFI_EVENT_BASE + 0x7
44 #define EV_EFI_PLATFORM_FIRMWARE_BLOB EV_EFI_EVENT_BASE + 0x8
45 #define EV_EFI_HANDOFF_TABLES EV_EFI_EVENT_BASE + 0x9
46 #define EV_EFI_HCRTM_EVENT EV_EFI_EVENT_BASE + 0x10
47 #define EV_EFI_VARIABLE_AUTHORITY EV_EFI_EVENT_BASE + 0xe0
48 
49 #ifndef PACKED
50 #define PACKED __attribute__((__packed__))
51 #endif
52 
53 typedef struct {
54  UINT16 AlgorithmId;
55  UINT8 Digest[];
56 } PACKED TCG_DIGEST2;
57 
58 typedef struct {
59  UINT32 EventSize;
60  UINT8 Event [];
61 } PACKED TCG_EVENT2;
62 
63 typedef struct {
64  UINT32 PCRIndex;
65  UINT32 EventType;
66  UINT32 DigestCount;
67  TCG_DIGEST2 Digests [];
68  /* TCG_EVENT2 comes next */
69 } PACKED TCG_EVENT_HEADER2;
70 
71 /* Helper structure for dealing with unaligned char16_t */
72 typedef struct {
73  char16_t c;
74 } PACKED UTF16_CHAR;
75 
76 typedef struct {
77  uuid_t VariableName;
78  UINT64 UnicodeNameLength;
79  UINT64 VariableDataLength;
80  char16_t UnicodeName[];
81  /* INT8 VariableData[] comes next */
82 } PACKED UEFI_VARIABLE_DATA;
83 
84 typedef UINT64 UEFI_PHYSICAL_ADDRESS;
85 typedef struct {
86  UEFI_PHYSICAL_ADDRESS BlobBase;
87  UINT64 BlobLength;
88 } PACKED UEFI_PLATFORM_FIRMWARE_BLOB;
89 
90 typedef struct {
91  UINT32 pcrIndex;
92  UINT32 eventType;
93  BYTE digest[20];
94  UINT32 eventDataSize;
95  BYTE event[];
96 } PACKED TCG_EVENT;
97 
98 typedef struct {
99  UINT16 algorithmId;
100  UINT16 digestSize;
101 } PACKED TCG_SPECID_ALG;
102 
103 typedef struct {
104  UINT8 vendorInfoSize;
105  BYTE vendorInfo[];
106 } PACKED TCG_VENDOR_INFO;
107 
108 typedef struct {
109  BYTE Signature[16];
110  UINT32 platformClass;
111  UINT8 specVersionMinor;
112  UINT8 specVersionMajor;
113  UINT8 specErrata;
114  UINT8 uintnSize;
115  UINT32 numberOfAlgorithms;
116  TCG_SPECID_ALG digestSizes[];
117  /* then TCG_VendorStuff */
118 } PACKED TCG_SPECID_EVENT;
119 
120 typedef struct {
121  UEFI_PHYSICAL_ADDRESS ImageLocationInMemory;
122  UINT64 ImageLengthInMemory;
123  UINT64 ImageLinkTimeAddress;
124  UINT64 LengthOfDevicePath;
125  BYTE DevicePath[];
126 } PACKED UEFI_IMAGE_LOAD_EVENT;
127 
128 #endif
Definition: efi_event.h:53