aboutsummaryrefslogtreecommitdiff
path: root/include/drivers/measured_boot/event_log.h
blob: aea418c143c75dce2493d7dcbd5cb56f12494c14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Copyright (c) 2020, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef EVENT_LOG_H
#define EVENT_LOG_H

#include <stdint.h>

#include <common/debug.h>

/*
 * Set Event Log debug level to one of:
 *
 * LOG_LEVEL_ERROR
 * LOG_LEVEL_INFO
 * LOG_LEVEL_WARNING
 * LOG_LEVEL_VERBOSE
 */
#if EVENT_LOG_LEVEL   == LOG_LEVEL_ERROR
#define	LOG_EVENT	ERROR
#elif EVENT_LOG_LEVEL == LOG_LEVEL_NOTICE
#define	LOG_EVENT	NOTICE
#elif EVENT_LOG_LEVEL == LOG_LEVEL_WARNING
#define	LOG_EVENT	WARN
#elif EVENT_LOG_LEVEL == LOG_LEVEL_INFO
#define	LOG_EVENT	INFO
#elif EVENT_LOG_LEVEL == LOG_LEVEL_VERBOSE
#define	LOG_EVENT	VERBOSE
#else
#error "Not supported EVENT_LOG_LEVEL"
#endif

/* Number of hashing algorithms supported */
#define HASH_ALG_COUNT	1U

#define	INVALID_ID	MAX_NUMBER_IDS

#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member)

#define BL2_STRING			"BL_2"
#define BL31_STRING			"BL_31"
#define BL32_STRING			"BL_32"
#define	BL32_EXTRA1_IMAGE_STRING	"BL32_EXTRA1_IMAGE"
#define	BL32_EXTRA2_IMAGE_STRING	"BL32_EXTRA2_IMAGE"
#define BL33_STRING			"BL_33"
#define GPT_IMAGE_STRING		"GPT"
#define HW_CONFIG_STRING		"HW_CONFIG"
#define NT_FW_CONFIG_STRING		"NT_FW_CONFIG"
#define SCP_BL2_IMAGE_STRING		"SCP_BL2_IMAGE"
#define SOC_FW_CONFIG_STRING		"SOC_FW_CONFIG"
#define STM32_IMAGE_STRING		"STM32"
#define	TOS_FW_CONFIG_STRING		"TOS_FW_CONFIG"

typedef struct {
	unsigned int id;
	const char *name;
	unsigned int pcr;
} image_data_t;

typedef struct {
	const image_data_t *images_data;
	int (*set_nt_fw_info)(uintptr_t config_base,
#ifdef SPD_opteed
				uintptr_t log_addr,
#endif
				size_t log_size, uintptr_t *ns_log_addr);
	int (*set_tos_fw_info)(uintptr_t config_base, uintptr_t log_addr,
				size_t log_size);
} measured_boot_data_t;

#define	ID_EVENT_SIZE	(sizeof(id_event_container_t) + \
			(sizeof(id_event_alg_info_t) * HASH_ALG_COUNT) + \
			sizeof(id_event_vendor_data_t))

#define	LOC_EVENT_SIZE	(sizeof(event2_header_t) + \
			sizeof(tpmt_ha_t) + TCG_DIGEST_SIZE + \
			sizeof(event2_data_t) + \
			sizeof(startup_locality_event_data_t))

#define	LOG_MIN_SIZE	(ID_EVENT_SIZE + LOC_EVENT_SIZE)

#define EVENT2_HDR_SIZE	(sizeof(event2_header_t) + \
			sizeof(tpmt_ha_t) + TCG_DIGEST_SIZE + \
			sizeof(event2_data_t))

/* Functions' declarations */
void event_log_init(void);
int event_log_finalise(uint8_t **log_addr, size_t *log_size);
void dump_event_log(uint8_t *log_addr, size_t log_size);
const measured_boot_data_t *plat_get_measured_boot_data(void);
int tpm_record_measurement(uintptr_t data_base, uint32_t data_size,
			   uint32_t data_id);
#endif /* EVENT_LOG_H */