blob: aea418c143c75dce2493d7dcbd5cb56f12494c14 [file] [log] [blame]
Alexei Fedorovd686fa32020-07-13 13:58:06 +01001/*
2 * Copyright (c) 2020, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef EVENT_LOG_H
8#define EVENT_LOG_H
9
10#include <stdint.h>
11
12#include <common/debug.h>
Alexei Fedorovd686fa32020-07-13 13:58:06 +010013
14/*
15 * Set Event Log debug level to one of:
16 *
17 * LOG_LEVEL_ERROR
18 * LOG_LEVEL_INFO
19 * LOG_LEVEL_WARNING
20 * LOG_LEVEL_VERBOSE
21 */
Alexei Fedorovd686fa32020-07-13 13:58:06 +010022#if EVENT_LOG_LEVEL == LOG_LEVEL_ERROR
23#define LOG_EVENT ERROR
24#elif EVENT_LOG_LEVEL == LOG_LEVEL_NOTICE
25#define LOG_EVENT NOTICE
26#elif EVENT_LOG_LEVEL == LOG_LEVEL_WARNING
27#define LOG_EVENT WARN
28#elif EVENT_LOG_LEVEL == LOG_LEVEL_INFO
29#define LOG_EVENT INFO
30#elif EVENT_LOG_LEVEL == LOG_LEVEL_VERBOSE
31#define LOG_EVENT VERBOSE
32#else
33#error "Not supported EVENT_LOG_LEVEL"
34#endif
35
36/* Number of hashing algorithms supported */
37#define HASH_ALG_COUNT 1U
38
39#define INVALID_ID MAX_NUMBER_IDS
40
41#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
42
43#define BL2_STRING "BL_2"
44#define BL31_STRING "BL_31"
45#define BL32_STRING "BL_32"
46#define BL32_EXTRA1_IMAGE_STRING "BL32_EXTRA1_IMAGE"
47#define BL32_EXTRA2_IMAGE_STRING "BL32_EXTRA2_IMAGE"
48#define BL33_STRING "BL_33"
49#define GPT_IMAGE_STRING "GPT"
50#define HW_CONFIG_STRING "HW_CONFIG"
51#define NT_FW_CONFIG_STRING "NT_FW_CONFIG"
52#define SCP_BL2_IMAGE_STRING "SCP_BL2_IMAGE"
53#define SOC_FW_CONFIG_STRING "SOC_FW_CONFIG"
54#define STM32_IMAGE_STRING "STM32"
55#define TOS_FW_CONFIG_STRING "TOS_FW_CONFIG"
56
57typedef struct {
58 unsigned int id;
59 const char *name;
60 unsigned int pcr;
61} image_data_t;
62
63typedef struct {
64 const image_data_t *images_data;
65 int (*set_nt_fw_info)(uintptr_t config_base,
66#ifdef SPD_opteed
67 uintptr_t log_addr,
68#endif
69 size_t log_size, uintptr_t *ns_log_addr);
70 int (*set_tos_fw_info)(uintptr_t config_base, uintptr_t log_addr,
71 size_t log_size);
72} measured_boot_data_t;
73
Lucian Paul-Trifu3519afe2022-03-08 15:02:31 +000074#define ID_EVENT_SIZE (sizeof(id_event_container_t) + \
75 (sizeof(id_event_alg_info_t) * HASH_ALG_COUNT) + \
76 sizeof(id_event_vendor_data_t))
Alexei Fedorovd686fa32020-07-13 13:58:06 +010077
78#define LOC_EVENT_SIZE (sizeof(event2_header_t) + \
Lucian Paul-Trifu3519afe2022-03-08 15:02:31 +000079 sizeof(tpmt_ha_t) + TCG_DIGEST_SIZE + \
Alexei Fedorovd686fa32020-07-13 13:58:06 +010080 sizeof(event2_data_t) + \
Lucian Paul-Trifu3519afe2022-03-08 15:02:31 +000081 sizeof(startup_locality_event_data_t))
Alexei Fedorovd686fa32020-07-13 13:58:06 +010082
83#define LOG_MIN_SIZE (ID_EVENT_SIZE + LOC_EVENT_SIZE)
84
85#define EVENT2_HDR_SIZE (sizeof(event2_header_t) + \
Lucian Paul-Trifu3519afe2022-03-08 15:02:31 +000086 sizeof(tpmt_ha_t) + TCG_DIGEST_SIZE + \
Alexei Fedorovd686fa32020-07-13 13:58:06 +010087 sizeof(event2_data_t))
88
89/* Functions' declarations */
90void event_log_init(void);
91int event_log_finalise(uint8_t **log_addr, size_t *log_size);
92void dump_event_log(uint8_t *log_addr, size_t log_size);
93const measured_boot_data_t *plat_get_measured_boot_data(void);
94int tpm_record_measurement(uintptr_t data_base, uint32_t data_size,
95 uint32_t data_id);
96#endif /* EVENT_LOG_H */