Alexei Fedorov | 71d81dc | 2020-07-13 13:58:06 +0100 | [diff] [blame] | 1 | /* |
Sandrine Bailleux | 4e9af17 | 2021-07-01 14:13:09 +0200 | [diff] [blame] | 2 | * Copyright (c) 2020-2021, Arm Limited. All rights reserved. |
Alexei Fedorov | 71d81dc | 2020-07-13 13:58:06 +0100 | [diff] [blame] | 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> |
Manish V Badarkhe | 7ca9d65 | 2021-09-14 22:41:46 +0100 | [diff] [blame^] | 13 | #include <common/tbbr/tbbr_img_def.h> |
Sandrine Bailleux | 3c2db6f | 2021-07-07 14:47:08 +0200 | [diff] [blame] | 14 | #include <drivers/measured_boot/event_log/tcg.h> |
Alexei Fedorov | 71d81dc | 2020-07-13 13:58:06 +0100 | [diff] [blame] | 15 | |
| 16 | /* |
| 17 | * Set Event Log debug level to one of: |
| 18 | * |
| 19 | * LOG_LEVEL_ERROR |
| 20 | * LOG_LEVEL_INFO |
| 21 | * LOG_LEVEL_WARNING |
| 22 | * LOG_LEVEL_VERBOSE |
| 23 | */ |
Alexei Fedorov | 71d81dc | 2020-07-13 13:58:06 +0100 | [diff] [blame] | 24 | #if EVENT_LOG_LEVEL == LOG_LEVEL_ERROR |
| 25 | #define LOG_EVENT ERROR |
| 26 | #elif EVENT_LOG_LEVEL == LOG_LEVEL_NOTICE |
| 27 | #define LOG_EVENT NOTICE |
| 28 | #elif EVENT_LOG_LEVEL == LOG_LEVEL_WARNING |
| 29 | #define LOG_EVENT WARN |
| 30 | #elif EVENT_LOG_LEVEL == LOG_LEVEL_INFO |
| 31 | #define LOG_EVENT INFO |
| 32 | #elif EVENT_LOG_LEVEL == LOG_LEVEL_VERBOSE |
| 33 | #define LOG_EVENT VERBOSE |
| 34 | #else |
| 35 | #error "Not supported EVENT_LOG_LEVEL" |
| 36 | #endif |
| 37 | |
| 38 | /* Number of hashing algorithms supported */ |
| 39 | #define HASH_ALG_COUNT 1U |
| 40 | |
| 41 | #define INVALID_ID MAX_NUMBER_IDS |
| 42 | |
| 43 | #define MEMBER_SIZE(type, member) sizeof(((type *)0)->member) |
| 44 | |
| 45 | #define BL2_STRING "BL_2" |
| 46 | #define BL31_STRING "BL_31" |
| 47 | #define BL32_STRING "BL_32" |
| 48 | #define BL32_EXTRA1_IMAGE_STRING "BL32_EXTRA1_IMAGE" |
| 49 | #define BL32_EXTRA2_IMAGE_STRING "BL32_EXTRA2_IMAGE" |
| 50 | #define BL33_STRING "BL_33" |
| 51 | #define GPT_IMAGE_STRING "GPT" |
| 52 | #define HW_CONFIG_STRING "HW_CONFIG" |
| 53 | #define NT_FW_CONFIG_STRING "NT_FW_CONFIG" |
| 54 | #define SCP_BL2_IMAGE_STRING "SCP_BL2_IMAGE" |
| 55 | #define SOC_FW_CONFIG_STRING "SOC_FW_CONFIG" |
| 56 | #define STM32_IMAGE_STRING "STM32" |
| 57 | #define TOS_FW_CONFIG_STRING "TOS_FW_CONFIG" |
| 58 | |
| 59 | typedef struct { |
| 60 | unsigned int id; |
| 61 | const char *name; |
| 62 | unsigned int pcr; |
Manish V Badarkhe | 7ca9d65 | 2021-09-14 22:41:46 +0100 | [diff] [blame^] | 63 | } event_log_metadata_t; |
Alexei Fedorov | 71d81dc | 2020-07-13 13:58:06 +0100 | [diff] [blame] | 64 | |
| 65 | #define ID_EVENT_SIZE (sizeof(id_event_headers_t) + \ |
| 66 | (sizeof(id_event_algorithm_size_t) * HASH_ALG_COUNT) + \ |
| 67 | sizeof(id_event_struct_data_t)) |
| 68 | |
| 69 | #define LOC_EVENT_SIZE (sizeof(event2_header_t) + \ |
| 70 | sizeof(tpmt_ha) + TCG_DIGEST_SIZE + \ |
| 71 | sizeof(event2_data_t) + \ |
| 72 | sizeof(startup_locality_event_t)) |
| 73 | |
| 74 | #define LOG_MIN_SIZE (ID_EVENT_SIZE + LOC_EVENT_SIZE) |
| 75 | |
| 76 | #define EVENT2_HDR_SIZE (sizeof(event2_header_t) + \ |
| 77 | sizeof(tpmt_ha) + TCG_DIGEST_SIZE + \ |
| 78 | sizeof(event2_data_t)) |
| 79 | |
| 80 | /* Functions' declarations */ |
Manish V Badarkhe | 7ca9d65 | 2021-09-14 22:41:46 +0100 | [diff] [blame^] | 81 | void event_log_init(uint8_t *event_log_start, uint8_t *event_log_finish); |
| 82 | void event_log_write_header(void); |
Alexei Fedorov | 71d81dc | 2020-07-13 13:58:06 +0100 | [diff] [blame] | 83 | void dump_event_log(uint8_t *log_addr, size_t log_size); |
Manish V Badarkhe | 7ca9d65 | 2021-09-14 22:41:46 +0100 | [diff] [blame^] | 84 | const event_log_metadata_t *plat_event_log_get_metadata(void); |
Sandrine Bailleux | 4e9af17 | 2021-07-01 14:13:09 +0200 | [diff] [blame] | 85 | int event_log_measure_and_record(uintptr_t data_base, uint32_t data_size, |
| 86 | uint32_t data_id); |
Manish V Badarkhe | 7ca9d65 | 2021-09-14 22:41:46 +0100 | [diff] [blame^] | 87 | size_t event_log_get_cur_size(uint8_t *event_log_start); |
Sandrine Bailleux | 898c099 | 2021-06-17 16:10:40 +0200 | [diff] [blame] | 88 | |
Alexei Fedorov | 71d81dc | 2020-07-13 13:58:06 +0100 | [diff] [blame] | 89 | #endif /* EVENT_LOG_H */ |