1 /* 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> 13 #include <drivers/measured_boot/tcg.h> 14 15 /* 16 * Set Event Log debug level to one of: 17 * 18 * LOG_LEVEL_ERROR 19 * LOG_LEVEL_INFO 20 * LOG_LEVEL_WARNING 21 * LOG_LEVEL_VERBOSE 22 */ 23 #if EVENT_LOG_LEVEL == LOG_LEVEL_ERROR 24 #define LOG_EVENT ERROR 25 #elif EVENT_LOG_LEVEL == LOG_LEVEL_NOTICE 26 #define LOG_EVENT NOTICE 27 #elif EVENT_LOG_LEVEL == LOG_LEVEL_WARNING 28 #define LOG_EVENT WARN 29 #elif EVENT_LOG_LEVEL == LOG_LEVEL_INFO 30 #define LOG_EVENT INFO 31 #elif EVENT_LOG_LEVEL == LOG_LEVEL_VERBOSE 32 #define LOG_EVENT VERBOSE 33 #else 34 #error "Not supported EVENT_LOG_LEVEL" 35 #endif 36 37 /* Number of hashing algorithms supported */ 38 #define HASH_ALG_COUNT 1U 39 40 #define INVALID_ID MAX_NUMBER_IDS 41 42 #define MEMBER_SIZE(type, member) sizeof(((type *)0)->member) 43 44 #define BL2_STRING "BL_2" 45 #define BL31_STRING "BL_31" 46 #define BL32_STRING "BL_32" 47 #define BL32_EXTRA1_IMAGE_STRING "BL32_EXTRA1_IMAGE" 48 #define BL32_EXTRA2_IMAGE_STRING "BL32_EXTRA2_IMAGE" 49 #define BL33_STRING "BL_33" 50 #define GPT_IMAGE_STRING "GPT" 51 #define HW_CONFIG_STRING "HW_CONFIG" 52 #define NT_FW_CONFIG_STRING "NT_FW_CONFIG" 53 #define SCP_BL2_IMAGE_STRING "SCP_BL2_IMAGE" 54 #define SOC_FW_CONFIG_STRING "SOC_FW_CONFIG" 55 #define STM32_IMAGE_STRING "STM32" 56 #define TOS_FW_CONFIG_STRING "TOS_FW_CONFIG" 57 58 typedef struct { 59 unsigned int id; 60 const char *name; 61 unsigned int pcr; 62 } image_data_t; 63 64 typedef struct { 65 const image_data_t *images_data; 66 int (*set_nt_fw_info)(uintptr_t config_base, 67 #ifdef SPD_opteed 68 uintptr_t log_addr, 69 #endif 70 size_t log_size, uintptr_t *ns_log_addr); 71 int (*set_tos_fw_info)(uintptr_t config_base, uintptr_t log_addr, 72 size_t log_size); 73 } measured_boot_data_t; 74 75 #define ID_EVENT_SIZE (sizeof(id_event_headers_t) + \ 76 (sizeof(id_event_algorithm_size_t) * HASH_ALG_COUNT) + \ 77 sizeof(id_event_struct_data_t)) 78 79 #define LOC_EVENT_SIZE (sizeof(event2_header_t) + \ 80 sizeof(tpmt_ha) + TCG_DIGEST_SIZE + \ 81 sizeof(event2_data_t) + \ 82 sizeof(startup_locality_event_t)) 83 84 #define LOG_MIN_SIZE (ID_EVENT_SIZE + LOC_EVENT_SIZE) 85 86 #define EVENT2_HDR_SIZE (sizeof(event2_header_t) + \ 87 sizeof(tpmt_ha) + TCG_DIGEST_SIZE + \ 88 sizeof(event2_data_t)) 89 90 /* Functions' declarations */ 91 void event_log_init(void); 92 int event_log_finalise(uint8_t **log_addr, size_t *log_size); 93 void dump_event_log(uint8_t *log_addr, size_t log_size); 94 const measured_boot_data_t *plat_get_measured_boot_data(void); 95 int tpm_record_measurement(uintptr_t data_base, uint32_t data_size, 96 uint32_t data_id); 97 #endif /* EVENT_LOG_H */ 98