xref: /rk3399_ARM-atf/plat/arm/board/juno/juno_bl2_measured_boot.c (revision 04cf04c72d403e0c057505882fac9002d39d4102)
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 <common/tbbr/tbbr_img_def.h>
10 #include <drivers/measured_boot/event_log/event_log.h>
11 #include <drivers/measured_boot/metadata.h>
12 #include <plat/arm/common/plat_arm.h>
13 #include <plat/common/common_def.h>
14 #if defined(ARM_COT_cca)
15 #include <tools_share/cca_oid.h>
16 #else
17 #include <tools_share/tbbr_oid.h>
18 #endif /* ARM_COT_cca */
19 
20 /* Event Log data */
21 static uint8_t *event_log_base;
22 
23 /* table with platform specific image IDs, names and PCRs */
24 const event_log_metadata_t juno_event_log_metadata[] = {
25 	{ BL31_IMAGE_ID, MBOOT_BL31_IMAGE_STRING, PCR_0 },
26 	{ BL32_IMAGE_ID, MBOOT_BL32_IMAGE_STRING, PCR_0 },
27 	{ BL32_EXTRA1_IMAGE_ID, MBOOT_BL32_EXTRA1_IMAGE_STRING, PCR_0 },
28 	{ BL32_EXTRA2_IMAGE_ID, MBOOT_BL32_EXTRA2_IMAGE_STRING, PCR_0 },
29 	{ BL33_IMAGE_ID, MBOOT_BL33_IMAGE_STRING, PCR_0 },
30 	{ HW_CONFIG_ID, MBOOT_HW_CONFIG_STRING, PCR_0 },
31 	{ NT_FW_CONFIG_ID, MBOOT_NT_FW_CONFIG_STRING, PCR_0 },
32 	{ SCP_BL2_IMAGE_ID, MBOOT_SCP_BL2_IMAGE_STRING, PCR_0 },
33 	{ SOC_FW_CONFIG_ID, MBOOT_SOC_FW_CONFIG_STRING, PCR_0 },
34 	{ TOS_FW_CONFIG_ID, MBOOT_TOS_FW_CONFIG_STRING, PCR_0 },
35 	{ EVLOG_INVALID_ID, NULL, (unsigned int)(-1) }	/* Terminator */
36 };
37 
38 void bl2_plat_mboot_init(void)
39 {
40 #if TRANSFER_LIST
41 	uint8_t *event_log_start;
42 	uint8_t *event_log_finish;
43 	size_t event_log_max_size;
44 
45 	event_log_start = transfer_list_event_log_extend(
46 		secure_tl, PLAT_ARM_EVENT_LOG_MAX_SIZE, &event_log_max_size);
47 	if (event_log_start == NULL) {
48 		panic();
49 	}
50 
51 	event_log_finish = event_log_start + event_log_max_size;
52 
53 	event_log_base = event_log_start;
54 
55 	event_log_init(event_log_start, event_log_finish);
56 #endif
57 }
58 
59 int plat_mboot_measure_critical_data(unsigned int critical_data_id,
60 				     const void *base, size_t size)
61 {
62 	/* Nothing */
63 	return 0;
64 }
65 
66 void bl2_plat_mboot_finish(void)
67 {
68 #if TRANSFER_LIST
69 	/* Event Log filled size */
70 	size_t event_log_cur_size;
71 
72 	event_log_cur_size = event_log_get_cur_size((uint8_t *)event_log_base);
73 
74 	/*
75 	 * Re-size the event log for the next stage and update the size to include
76 	 * the entire event log (i.e., not just what this stage has added.)
77 	 */
78 	event_log_base = transfer_list_event_log_finish(
79 		secure_tl, (uintptr_t)event_log_base + event_log_cur_size);
80 	if (event_log_base == NULL) {
81 		panic();
82 	}
83 
84 	event_log_cur_size = event_log_get_cur_size((uint8_t *)event_log_base);
85 	event_log_dump(event_log_base, event_log_cur_size);
86 #endif /* TRANSFER_LIST */
87 }
88