1 /* 2 * Copyright (c) 2025, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <stdint.h> 8 9 #include <drivers/measured_boot/event_log/event_log.h> 10 #include <drivers/measured_boot/metadata.h> 11 #include <plat/arm/common/plat_arm.h> 12 #include <tools_share/zero_oid.h> 13 14 /* Event Log data */ 15 static uint8_t *event_log; 16 17 /* Juno table with platform specific image IDs, names and PCRs */ 18 const event_log_metadata_t juno_event_log_metadata[] = { 19 { FW_CONFIG_ID, MBOOT_FW_CONFIG_STRING, PCR_0 }, 20 { TB_FW_CONFIG_ID, MBOOT_TB_FW_CONFIG_STRING, PCR_0 }, 21 { BL2_IMAGE_ID, MBOOT_BL2_IMAGE_STRING, PCR_0 }, 22 { EVLOG_INVALID_ID, NULL, (unsigned int)(-1) } /* Terminator */ 23 }; 24 25 void bl1_plat_mboot_init(void) 26 { 27 #if TRANSFER_LIST 28 size_t event_log_max_size; 29 int rc; 30 31 event_log = transfer_list_event_log_extend( 32 secure_tl, PLAT_ARM_EVENT_LOG_MAX_SIZE, 33 &event_log_max_size); 34 assert(event_log != NULL); 35 36 rc = event_log_init(event_log, event_log + event_log_max_size); 37 if (rc < 0) { 38 ERROR("Failed to initialize event log (%d).\n", rc); 39 panic(); 40 } 41 42 rc = event_log_write_header(); 43 if (rc < 0) { 44 ERROR("Failed to write event log header (%d).\n", rc); 45 panic(); 46 } 47 #endif 48 } 49 50 void bl1_plat_mboot_finish(void) 51 { 52 #if TRANSFER_LIST 53 uint8_t *rc __unused; 54 size_t event_log_cur_size = event_log_get_cur_size(event_log); 55 56 rc = transfer_list_event_log_finish( 57 secure_tl, (uintptr_t)event_log + event_log_cur_size); 58 59 if (rc != NULL) 60 return; 61 62 /* 63 * Panic if we fail to set up the event log for the next stage. 64 * This is a fatal error because, on the Juno platform, 65 * BL2 software assumes that a valid event Log buffer exists and 66 * will use the same event Log buffer to append image 67 * measurements. 68 */ 69 panic(); 70 #endif 71 } 72