xref: /rk3399_ARM-atf/plat/arm/board/tc/tc_bl2_dpe.c (revision 1f47a7133f7fe7fb038aca97fc93533964b2b429)
1 /*
2  * Copyright (c) 2024, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <stdint.h>
8 
9 #include <drivers/arm/rss_comms.h>
10 #include <drivers/measured_boot/metadata.h>
11 #include <drivers/measured_boot/rss/dice_prot_env.h>
12 #include <plat/arm/common/plat_arm.h>
13 #include <plat/common/platform.h>
14 #include <platform_def.h>
15 #include <tools_share/zero_oid.h>
16 
17 /*
18  * The content and the values of this array depends on:
19  * - build config: Which components are loaded: SPMD, TOS, SPx, etc ?
20  * - boot order: the last element in a layer should be treated differently.
21  */
22 
23 /*
24  * TODO:
25  *     - The content of the array must be tailored according to the build
26  *       config (TOS, SPMD, etc). All loaded components (executables and
27  *       config blobs) must be present in this array.
28  *     - Current content is according to the Trusty build config.
29  */
30 struct dpe_metadata tc_dpe_metadata[] = {
31 	{
32 		.id = BL31_IMAGE_ID,
33 		.signer_id_size = SIGNER_ID_MIN_SIZE,
34 		.sw_type = MBOOT_BL31_IMAGE_STRING,
35 		.allow_new_context_to_derive = false,
36 		.retain_parent_context = true,
37 		.create_certificate = false,
38 		.pk_oid = BL31_IMAGE_KEY_OID },
39 	{
40 		.id = BL32_IMAGE_ID,
41 		.signer_id_size = SIGNER_ID_MIN_SIZE,
42 		.sw_type = MBOOT_BL32_IMAGE_STRING,
43 		.allow_new_context_to_derive = false,
44 		.retain_parent_context = true,
45 		.create_certificate = false,
46 		.pk_oid = BL32_IMAGE_KEY_OID },
47 	{
48 		.id = BL33_IMAGE_ID,
49 		.signer_id_size = SIGNER_ID_MIN_SIZE,
50 		.sw_type = MBOOT_BL33_IMAGE_STRING,
51 		.allow_new_context_to_derive = true,
52 		.retain_parent_context = true,
53 		.create_certificate = false,
54 		.pk_oid = BL33_IMAGE_KEY_OID },
55 
56 	{
57 		.id = HW_CONFIG_ID,
58 		.signer_id_size = SIGNER_ID_MIN_SIZE,
59 		.sw_type = MBOOT_HW_CONFIG_STRING,
60 		.allow_new_context_to_derive = false,
61 		.retain_parent_context = true,
62 		.create_certificate = false,
63 		.pk_oid = HW_CONFIG_KEY_OID },
64 	{
65 		.id = NT_FW_CONFIG_ID,
66 		.signer_id_size = SIGNER_ID_MIN_SIZE,
67 		.sw_type = MBOOT_NT_FW_CONFIG_STRING,
68 		.allow_new_context_to_derive = false,
69 		.retain_parent_context = true,
70 		.create_certificate = false,
71 		.pk_oid = NT_FW_CONFIG_KEY_OID },
72 	{
73 		.id = SCP_BL2_IMAGE_ID,
74 		.signer_id_size = SIGNER_ID_MIN_SIZE,
75 		.sw_type = MBOOT_SCP_BL2_IMAGE_STRING,
76 		.allow_new_context_to_derive = false,
77 		.retain_parent_context = true,
78 		.create_certificate = false,
79 		.pk_oid = SCP_BL2_IMAGE_KEY_OID },
80 	{
81 		.id = SOC_FW_CONFIG_ID,
82 		.signer_id_size = SIGNER_ID_MIN_SIZE,
83 		.sw_type = MBOOT_SOC_FW_CONFIG_STRING,
84 		.allow_new_context_to_derive = false,
85 		.retain_parent_context = true,
86 		.create_certificate = false,
87 		.pk_oid = SOC_FW_CONFIG_KEY_OID },
88 	{
89 		.id = TOS_FW_CONFIG_ID,
90 		.signer_id_size = SIGNER_ID_MIN_SIZE,
91 		.sw_type = MBOOT_TOS_FW_CONFIG_STRING,
92 		.allow_new_context_to_derive = false,
93 		.retain_parent_context = true,
94 		.create_certificate = false,
95 		.pk_oid = TOS_FW_CONFIG_KEY_OID },
96 #if defined(SPD_spmd)
97 	{
98 		.id = SP_PKG1_ID,
99 		.signer_id_size = SIGNER_ID_MIN_SIZE,
100 		.sw_type = MBOOT_SP1_STRING,
101 		.allow_new_context_to_derive = false,
102 		.retain_parent_context = true,
103 		.create_certificate = true, /* With Trusty only one SP is loaded */
104 		.pk_oid = NULL },
105 	{
106 		.id = SP_PKG2_ID,
107 		.signer_id_size = SIGNER_ID_MIN_SIZE,
108 		.sw_type = MBOOT_SP2_STRING,
109 		.allow_new_context_to_derive = false,
110 		.retain_parent_context = true,
111 		.create_certificate = false,
112 		.pk_oid = NULL },
113 	{
114 		.id = SP_PKG3_ID,
115 		.signer_id_size = SIGNER_ID_MIN_SIZE,
116 		.sw_type = MBOOT_SP3_STRING,
117 		.allow_new_context_to_derive = false,
118 		.retain_parent_context = true,
119 		.create_certificate = false,
120 		.pk_oid = NULL },
121 	{
122 		.id = SP_PKG4_ID,
123 		.signer_id_size = SIGNER_ID_MIN_SIZE,
124 		.sw_type = MBOOT_SP4_STRING,
125 		.allow_new_context_to_derive = false,
126 		.retain_parent_context = true,
127 		.create_certificate = false,
128 		.pk_oid = NULL },
129 	{
130 		.id = SP_PKG5_ID,
131 		.signer_id_size = SIGNER_ID_MIN_SIZE,
132 		.sw_type = MBOOT_SP5_STRING,
133 		.allow_new_context_to_derive = false,
134 		.retain_parent_context = true,
135 		.create_certificate = false,
136 		.pk_oid = NULL },
137 	{
138 		.id = SP_PKG6_ID,
139 		.signer_id_size = SIGNER_ID_MIN_SIZE,
140 		.sw_type = MBOOT_SP6_STRING,
141 		.allow_new_context_to_derive = false,
142 		.retain_parent_context = true,
143 		.create_certificate = false,
144 		.pk_oid = NULL },
145 	{
146 		.id = SP_PKG7_ID,
147 		.signer_id_size = SIGNER_ID_MIN_SIZE,
148 		.sw_type = MBOOT_SP7_STRING,
149 		.allow_new_context_to_derive = false,
150 		.retain_parent_context = true,
151 		.create_certificate = false,
152 		.pk_oid = NULL },
153 	{
154 		.id = SP_PKG8_ID,
155 		.signer_id_size = SIGNER_ID_MIN_SIZE,
156 		.sw_type = MBOOT_SP8_STRING,
157 		.allow_new_context_to_derive = false,
158 		.retain_parent_context = true,
159 		.create_certificate = false,
160 		.pk_oid = NULL },
161 
162 #endif
163 	{
164 		.id = DPE_INVALID_ID }
165 };
166 
167 void bl2_plat_mboot_init(void)
168 {
169 	/* Initialize the communication channel between AP and RSS */
170 	(void)rss_comms_init(PLAT_RSS_AP_SND_MHU_BASE,
171 			     PLAT_RSS_AP_RCV_MHU_BASE);
172 
173 	dpe_init(tc_dpe_metadata);
174 }
175 
176 void bl2_plat_mboot_finish(void)
177 {
178 	/* Nothing to do. */
179 }
180