xref: /rk3399_ARM-atf/plat/arm/board/fvp/fvp_bl1_measured_boot.c (revision 025b1b816b607c7ac43a77172040c44b7750a622)
1 /*
2  * Copyright (c) 2021-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[PLAT_ARM_EVENT_LOG_MAX_SIZE];
16 
17 /* FVP table with platform specific image IDs, names and PCRs */
18 const event_log_metadata_t fvp_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 
23 	{ EVLOG_INVALID_ID, NULL, (unsigned int)(-1) }	/* Terminator */
24 };
25 
26 void bl1_plat_mboot_init(void)
27 {
28 	size_t event_log_max_size = PLAT_ARM_EVENT_LOG_MAX_SIZE;
29 	int rc;
30 
31 	rc = event_log_init(event_log, event_log + event_log_max_size);
32 	if (rc < 0) {
33 		ERROR("Failed to initialize event log (%d).\n", rc);
34 		panic();
35 	}
36 
37 	rc = event_log_write_header();
38 	if (rc < 0) {
39 		ERROR("Failed to write event log header (%d).\n", rc);
40 		panic();
41 	}
42 }
43 
44 void bl1_plat_mboot_finish(void)
45 {
46 	size_t event_log_cur_size;
47 
48 	event_log_cur_size = event_log_get_cur_size(event_log);
49 	int rc = arm_set_tb_fw_info((uintptr_t)event_log,
50 				    event_log_cur_size,
51 				    PLAT_ARM_EVENT_LOG_MAX_SIZE);
52 	if (rc != 0) {
53 		/*
54 		 * It is a fatal error because on FVP platform, BL2 software
55 		 * assumes that a valid Event Log buffer exist and it will use
56 		 * same Event Log buffer to append image measurements.
57 		 */
58 		panic();
59 	}
60 }
61