blob: 27acc3a648c87a8de2c5ffa8ae04436e8e498127 [file] [log] [blame]
Louis Mayencourtbadcac82019-10-24 15:18:46 +01001/*
Rob Hughesa45a2dd2023-01-20 10:43:41 +00002 * Copyright (c) 2019-2023, ARM Limited. All rights reserved.
Louis Mayencourtbadcac82019-10-24 15:18:46 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <assert.h>
8
9#include <common/debug.h>
10#include <common/fdt_wrappers.h>
11#include <drivers/io/io_storage.h>
Manish V Badarkhedd6f2522021-02-22 17:30:17 +000012#include <drivers/partition/partition.h>
Louis Mayencourtbadcac82019-10-24 15:18:46 +010013#include <lib/object_pool.h>
14#include <libfdt.h>
15#include <tools_share/firmware_image_package.h>
16
17#include <plat/arm/common/arm_fconf_getter.h>
18#include <plat/arm/common/arm_fconf_io_storage.h>
19#include <platform_def.h>
20
Manish V Badarkhed2f0a7a2021-06-25 23:43:33 +010021#if PSA_FWU_SUPPORT
22/* metadata entry details */
23static io_block_spec_t fwu_metadata_spec;
24#endif /* PSA_FWU_SUPPORT */
25
Manish V Badarkhedd6f2522021-02-22 17:30:17 +000026io_block_spec_t fip_block_spec = {
27/*
28 * This is fixed FIP address used by BL1, BL2 loads partition table
29 * to get FIP address.
30 */
31#if ARM_GPT_SUPPORT
32 .offset = PLAT_ARM_FLASH_IMAGE_BASE + PLAT_ARM_FIP_OFFSET_IN_GPT,
33#else
Manish V Badarkhe443ccbc2021-04-22 11:13:21 +010034 .offset = PLAT_ARM_FLASH_IMAGE_BASE,
Manish V Badarkhedd6f2522021-02-22 17:30:17 +000035#endif /* ARM_GPT_SUPPORT */
Manish V Badarkhe443ccbc2021-04-22 11:13:21 +010036 .length = PLAT_ARM_FLASH_IMAGE_MAX_SIZE
Louis Mayencourtbadcac82019-10-24 15:18:46 +010037};
38
Manish V Badarkhedd6f2522021-02-22 17:30:17 +000039#if ARM_GPT_SUPPORT
40static const io_block_spec_t gpt_spec = {
41 .offset = PLAT_ARM_FLASH_IMAGE_BASE,
42 /*
43 * PLAT_PARTITION_BLOCK_SIZE = 512
44 * PLAT_PARTITION_MAX_ENTRIES = 128
45 * each sector has 4 partition entries, and there are
46 * 2 reserved sectors i.e. protective MBR and primary
47 * GPT header hence length gets calculated as,
48 * length = 512 * (128/4 + 2)
49 */
50 .length = PLAT_PARTITION_BLOCK_SIZE *
51 (PLAT_PARTITION_MAX_ENTRIES / 4 + 2),
52};
53#endif /* ARM_GPT_SUPPORT */
Louis Mayencourtbadcac82019-10-24 15:18:46 +010054
55const io_uuid_spec_t arm_uuid_spec[MAX_NUMBER_IDS] = {
56 [BL2_IMAGE_ID] = {UUID_TRUSTED_BOOT_FIRMWARE_BL2},
57 [TB_FW_CONFIG_ID] = {UUID_TB_FW_CONFIG},
Louis Mayencourt244027d2020-06-11 21:15:15 +010058 [FW_CONFIG_ID] = {UUID_FW_CONFIG},
Louis Mayencourt6b232d92020-02-28 16:57:30 +000059#if !ARM_IO_IN_DTB
60 [SCP_BL2_IMAGE_ID] = {UUID_SCP_FIRMWARE_SCP_BL2},
61 [BL31_IMAGE_ID] = {UUID_EL3_RUNTIME_FIRMWARE_BL31},
62 [BL32_IMAGE_ID] = {UUID_SECURE_PAYLOAD_BL32},
63 [BL32_EXTRA1_IMAGE_ID] = {UUID_SECURE_PAYLOAD_BL32_EXTRA1},
64 [BL32_EXTRA2_IMAGE_ID] = {UUID_SECURE_PAYLOAD_BL32_EXTRA2},
65 [BL33_IMAGE_ID] = {UUID_NON_TRUSTED_FIRMWARE_BL33},
66 [HW_CONFIG_ID] = {UUID_HW_CONFIG},
67 [SOC_FW_CONFIG_ID] = {UUID_SOC_FW_CONFIG},
68 [TOS_FW_CONFIG_ID] = {UUID_TOS_FW_CONFIG},
69 [NT_FW_CONFIG_ID] = {UUID_NT_FW_CONFIG},
Zelalem Aweke96c0bab2021-07-11 18:39:39 -050070 [RMM_IMAGE_ID] = {UUID_REALM_MONITOR_MGMT_FIRMWARE},
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +020071#if ETHOSN_NPU_TZMP1
72 [ETHOSN_NPU_FW_IMAGE_ID] = {UUID_ETHOSN_FW},
73#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourt6b232d92020-02-28 16:57:30 +000074#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +010075#if TRUSTED_BOARD_BOOT
76 [TRUSTED_BOOT_FW_CERT_ID] = {UUID_TRUSTED_BOOT_FW_CERT},
Louis Mayencourt6b232d92020-02-28 16:57:30 +000077#if !ARM_IO_IN_DTB
laurenw-arm23075462022-04-21 17:03:30 -050078 [CCA_CONTENT_CERT_ID] = {UUID_CCA_CONTENT_CERT},
79 [CORE_SWD_KEY_CERT_ID] = {UUID_CORE_SWD_KEY_CERT},
80 [PLAT_KEY_CERT_ID] = {UUID_PLAT_KEY_CERT},
Louis Mayencourt6b232d92020-02-28 16:57:30 +000081 [TRUSTED_KEY_CERT_ID] = {UUID_TRUSTED_KEY_CERT},
82 [SCP_FW_KEY_CERT_ID] = {UUID_SCP_FW_KEY_CERT},
83 [SOC_FW_KEY_CERT_ID] = {UUID_SOC_FW_KEY_CERT},
84 [TRUSTED_OS_FW_KEY_CERT_ID] = {UUID_TRUSTED_OS_FW_KEY_CERT},
85 [NON_TRUSTED_FW_KEY_CERT_ID] = {UUID_NON_TRUSTED_FW_KEY_CERT},
86 [SCP_FW_CONTENT_CERT_ID] = {UUID_SCP_FW_CONTENT_CERT},
87 [SOC_FW_CONTENT_CERT_ID] = {UUID_SOC_FW_CONTENT_CERT},
88 [TRUSTED_OS_FW_CONTENT_CERT_ID] = {UUID_TRUSTED_OS_FW_CONTENT_CERT},
89 [NON_TRUSTED_FW_CONTENT_CERT_ID] = {UUID_NON_TRUSTED_FW_CONTENT_CERT},
Manish Pandey5f8e1a02020-05-27 22:40:10 +010090#if defined(SPD_spmd)
Manish Pandeyd07d0172020-07-23 16:54:30 +010091 [SIP_SP_CONTENT_CERT_ID] = {UUID_SIP_SECURE_PARTITION_CONTENT_CERT},
Manish Pandeyaff80752020-07-31 16:15:16 +010092 [PLAT_SP_CONTENT_CERT_ID] = {UUID_PLAT_SECURE_PARTITION_CONTENT_CERT},
Manish Pandey5f8e1a02020-05-27 22:40:10 +010093#endif
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +020094#if ETHOSN_NPU_TZMP1
95 [ETHOSN_NPU_FW_KEY_CERT_ID] = {UUID_ETHOSN_FW_KEY_CERTIFICATE},
96 [ETHOSN_NPU_FW_CONTENT_CERT_ID] = {UUID_ETHOSN_FW_CONTENT_CERTIFICATE},
97#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourt6b232d92020-02-28 16:57:30 +000098#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +010099#endif /* TRUSTED_BOARD_BOOT */
100};
101
102/* By default, ARM platforms load images from the FIP */
103struct plat_io_policy policies[MAX_NUMBER_IDS] = {
Manish V Badarkhedd6f2522021-02-22 17:30:17 +0000104#if ARM_GPT_SUPPORT
105 [GPT_IMAGE_ID] = {
106 &memmap_dev_handle,
107 (uintptr_t)&gpt_spec,
108 open_memmap
109 },
110#endif /* ARM_GPT_SUPPORT */
Manish V Badarkhed2f0a7a2021-06-25 23:43:33 +0100111#if PSA_FWU_SUPPORT
112 [FWU_METADATA_IMAGE_ID] = {
113 &memmap_dev_handle,
114 /* filled runtime from partition information */
115 (uintptr_t)&fwu_metadata_spec,
116 open_memmap
117 },
118 [BKUP_FWU_METADATA_IMAGE_ID] = {
119 &memmap_dev_handle,
120 /* filled runtime from partition information */
121 (uintptr_t)&fwu_metadata_spec,
122 open_memmap
123 },
124#endif /* PSA_FWU_SUPPORT */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100125 [FIP_IMAGE_ID] = {
126 &memmap_dev_handle,
127 (uintptr_t)&fip_block_spec,
128 open_memmap
129 },
130 [BL2_IMAGE_ID] = {
131 &fip_dev_handle,
132 (uintptr_t)&arm_uuid_spec[BL2_IMAGE_ID],
133 open_fip
134 },
135 [TB_FW_CONFIG_ID] = {
136 &fip_dev_handle,
137 (uintptr_t)&arm_uuid_spec[TB_FW_CONFIG_ID],
138 open_fip
139 },
Louis Mayencourt244027d2020-06-11 21:15:15 +0100140 [FW_CONFIG_ID] = {
141 &fip_dev_handle,
142 (uintptr_t)&arm_uuid_spec[FW_CONFIG_ID],
143 open_fip
144 },
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000145#if !ARM_IO_IN_DTB
146 [SCP_BL2_IMAGE_ID] = {
147 &fip_dev_handle,
148 (uintptr_t)&arm_uuid_spec[SCP_BL2_IMAGE_ID],
149 open_fip
150 },
151 [BL31_IMAGE_ID] = {
152 &fip_dev_handle,
153 (uintptr_t)&arm_uuid_spec[BL31_IMAGE_ID],
154 open_fip
155 },
156 [BL32_IMAGE_ID] = {
157 &fip_dev_handle,
158 (uintptr_t)&arm_uuid_spec[BL32_IMAGE_ID],
159 open_fip
160 },
161 [BL32_EXTRA1_IMAGE_ID] = {
162 &fip_dev_handle,
163 (uintptr_t)&arm_uuid_spec[BL32_EXTRA1_IMAGE_ID],
164 open_fip
165 },
166 [BL32_EXTRA2_IMAGE_ID] = {
167 &fip_dev_handle,
168 (uintptr_t)&arm_uuid_spec[BL32_EXTRA2_IMAGE_ID],
169 open_fip
170 },
171 [BL33_IMAGE_ID] = {
172 &fip_dev_handle,
173 (uintptr_t)&arm_uuid_spec[BL33_IMAGE_ID],
174 open_fip
175 },
Zelalem Aweke96c0bab2021-07-11 18:39:39 -0500176 [RMM_IMAGE_ID] = {
177 &fip_dev_handle,
178 (uintptr_t)&arm_uuid_spec[RMM_IMAGE_ID],
179 open_fip
180 },
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000181 [HW_CONFIG_ID] = {
182 &fip_dev_handle,
183 (uintptr_t)&arm_uuid_spec[HW_CONFIG_ID],
184 open_fip
185 },
186 [SOC_FW_CONFIG_ID] = {
187 &fip_dev_handle,
188 (uintptr_t)&arm_uuid_spec[SOC_FW_CONFIG_ID],
189 open_fip
190 },
191 [TOS_FW_CONFIG_ID] = {
192 &fip_dev_handle,
193 (uintptr_t)&arm_uuid_spec[TOS_FW_CONFIG_ID],
194 open_fip
195 },
196 [NT_FW_CONFIG_ID] = {
197 &fip_dev_handle,
198 (uintptr_t)&arm_uuid_spec[NT_FW_CONFIG_ID],
199 open_fip
200 },
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200201#if ETHOSN_NPU_TZMP1
202 [ETHOSN_NPU_FW_IMAGE_ID] = {
Rob Hughes9a2177a2023-01-17 16:10:26 +0000203 &fip_dev_handle,
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200204 (uintptr_t)&arm_uuid_spec[ETHOSN_NPU_FW_IMAGE_ID],
Rob Hughes9a2177a2023-01-17 16:10:26 +0000205 open_fip
206 },
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200207#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000208#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100209#if TRUSTED_BOARD_BOOT
210 [TRUSTED_BOOT_FW_CERT_ID] = {
211 &fip_dev_handle,
212 (uintptr_t)&arm_uuid_spec[TRUSTED_BOOT_FW_CERT_ID],
213 open_fip
214 },
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000215#if !ARM_IO_IN_DTB
laurenw-arm23075462022-04-21 17:03:30 -0500216 [CCA_CONTENT_CERT_ID] = {
217 &fip_dev_handle,
218 (uintptr_t)&arm_uuid_spec[CCA_CONTENT_CERT_ID],
219 open_fip
220 },
221 [CORE_SWD_KEY_CERT_ID] = {
222 &fip_dev_handle,
223 (uintptr_t)&arm_uuid_spec[CORE_SWD_KEY_CERT_ID],
224 open_fip
225 },
226 [PLAT_KEY_CERT_ID] = {
227 &fip_dev_handle,
228 (uintptr_t)&arm_uuid_spec[PLAT_KEY_CERT_ID],
229 open_fip
230 },
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000231 [TRUSTED_KEY_CERT_ID] = {
232 &fip_dev_handle,
233 (uintptr_t)&arm_uuid_spec[TRUSTED_KEY_CERT_ID],
234 open_fip
235 },
236 [SCP_FW_KEY_CERT_ID] = {
237 &fip_dev_handle,
238 (uintptr_t)&arm_uuid_spec[SCP_FW_KEY_CERT_ID],
239 open_fip
240 },
241 [SOC_FW_KEY_CERT_ID] = {
242 &fip_dev_handle,
243 (uintptr_t)&arm_uuid_spec[SOC_FW_KEY_CERT_ID],
244 open_fip
245 },
246 [TRUSTED_OS_FW_KEY_CERT_ID] = {
247 &fip_dev_handle,
248 (uintptr_t)&arm_uuid_spec[TRUSTED_OS_FW_KEY_CERT_ID],
249 open_fip
250 },
251 [NON_TRUSTED_FW_KEY_CERT_ID] = {
252 &fip_dev_handle,
253 (uintptr_t)&arm_uuid_spec[NON_TRUSTED_FW_KEY_CERT_ID],
254 open_fip
255 },
256 [SCP_FW_CONTENT_CERT_ID] = {
257 &fip_dev_handle,
258 (uintptr_t)&arm_uuid_spec[SCP_FW_CONTENT_CERT_ID],
259 open_fip
260 },
261 [SOC_FW_CONTENT_CERT_ID] = {
262 &fip_dev_handle,
263 (uintptr_t)&arm_uuid_spec[SOC_FW_CONTENT_CERT_ID],
264 open_fip
265 },
266 [TRUSTED_OS_FW_CONTENT_CERT_ID] = {
267 &fip_dev_handle,
268 (uintptr_t)&arm_uuid_spec[TRUSTED_OS_FW_CONTENT_CERT_ID],
269 open_fip
270 },
271 [NON_TRUSTED_FW_CONTENT_CERT_ID] = {
272 &fip_dev_handle,
273 (uintptr_t)&arm_uuid_spec[NON_TRUSTED_FW_CONTENT_CERT_ID],
274 open_fip
275 },
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100276#if defined(SPD_spmd)
Manish Pandeyd07d0172020-07-23 16:54:30 +0100277 [SIP_SP_CONTENT_CERT_ID] = {
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100278 &fip_dev_handle,
Manish Pandeyd07d0172020-07-23 16:54:30 +0100279 (uintptr_t)&arm_uuid_spec[SIP_SP_CONTENT_CERT_ID],
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100280 open_fip
281 },
Manish Pandeyaff80752020-07-31 16:15:16 +0100282 [PLAT_SP_CONTENT_CERT_ID] = {
283 &fip_dev_handle,
284 (uintptr_t)&arm_uuid_spec[PLAT_SP_CONTENT_CERT_ID],
285 open_fip
286 },
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100287#endif
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200288#if ETHOSN_NPU_TZMP1
289 [ETHOSN_NPU_FW_KEY_CERT_ID] = {
Rob Hughes9a2177a2023-01-17 16:10:26 +0000290 &fip_dev_handle,
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200291 (uintptr_t)&arm_uuid_spec[ETHOSN_NPU_FW_KEY_CERT_ID],
Rob Hughes9a2177a2023-01-17 16:10:26 +0000292 open_fip
293 },
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200294 [ETHOSN_NPU_FW_CONTENT_CERT_ID] = {
Rob Hughes9a2177a2023-01-17 16:10:26 +0000295 &fip_dev_handle,
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200296 (uintptr_t)&arm_uuid_spec[ETHOSN_NPU_FW_CONTENT_CERT_ID],
Rob Hughes9a2177a2023-01-17 16:10:26 +0000297 open_fip
298 },
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200299#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000300#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100301#endif /* TRUSTED_BOARD_BOOT */
302};
303
304#ifdef IMAGE_BL2
305
Rob Hughesa45a2dd2023-01-20 10:43:41 +0000306#define FCONF_ARM_IO_UUID_NUM_BASE U(10)
307
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200308#if ETHOSN_NPU_TZMP1
Rob Hughes9a2177a2023-01-17 16:10:26 +0000309#define FCONF_ARM_IO_UUID_NUM_NPU U(1)
310#else
311#define FCONF_ARM_IO_UUID_NUM_NPU U(0)
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200312#endif /* ETHOSN_NPU_TZMP1 */
Rob Hughes9a2177a2023-01-17 16:10:26 +0000313
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100314#if TRUSTED_BOARD_BOOT
Rob Hughesa45a2dd2023-01-20 10:43:41 +0000315#define FCONF_ARM_IO_UUID_NUM_TBB U(12)
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100316#else
Rob Hughesa45a2dd2023-01-20 10:43:41 +0000317#define FCONF_ARM_IO_UUID_NUM_TBB U(0)
318#endif /* TRUSTED_BOARD_BOOT */
319
320#if TRUSTED_BOARD_BOOT && defined(SPD_spmd)
321#define FCONF_ARM_IO_UUID_NUM_SPD U(2)
322#else
323#define FCONF_ARM_IO_UUID_NUM_SPD U(0)
324#endif /* TRUSTED_BOARD_BOOT && defined(SPD_spmd) */
325
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200326#if TRUSTED_BOARD_BOOT && ETHOSN_NPU_TZMP1
Rob Hughes9a2177a2023-01-17 16:10:26 +0000327#define FCONF_ARM_IO_UUID_NUM_NPU_TBB U(2)
328#else
329#define FCONF_ARM_IO_UUID_NUM_NPU_TBB U(0)
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200330#endif /* TRUSTED_BOARD_BOOT && ETHOSN_NPU_TZMP1 */
Rob Hughes9a2177a2023-01-17 16:10:26 +0000331
Rob Hughesa45a2dd2023-01-20 10:43:41 +0000332#define FCONF_ARM_IO_UUID_NUMBER FCONF_ARM_IO_UUID_NUM_BASE + \
Rob Hughes9a2177a2023-01-17 16:10:26 +0000333 FCONF_ARM_IO_UUID_NUM_NPU + \
334 FCONF_ARM_IO_UUID_NUM_TBB + \
335 FCONF_ARM_IO_UUID_NUM_SPD + \
336 FCONF_ARM_IO_UUID_NUM_NPU_TBB
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100337
338static io_uuid_spec_t fconf_arm_uuids[FCONF_ARM_IO_UUID_NUMBER];
339static OBJECT_POOL_ARRAY(fconf_arm_uuids_pool, fconf_arm_uuids);
340
341struct policies_load_info {
342 unsigned int image_id;
343 const char *name;
344};
345
346/* image id to property name table */
347static const struct policies_load_info load_info[FCONF_ARM_IO_UUID_NUMBER] = {
348 {SCP_BL2_IMAGE_ID, "scp_bl2_uuid"},
349 {BL31_IMAGE_ID, "bl31_uuid"},
350 {BL32_IMAGE_ID, "bl32_uuid"},
351 {BL32_EXTRA1_IMAGE_ID, "bl32_extra1_uuid"},
352 {BL32_EXTRA2_IMAGE_ID, "bl32_extra2_uuid"},
353 {BL33_IMAGE_ID, "bl33_uuid"},
354 {HW_CONFIG_ID, "hw_cfg_uuid"},
355 {SOC_FW_CONFIG_ID, "soc_fw_cfg_uuid"},
356 {TOS_FW_CONFIG_ID, "tos_fw_cfg_uuid"},
357 {NT_FW_CONFIG_ID, "nt_fw_cfg_uuid"},
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200358#if ETHOSN_NPU_TZMP1
359 {ETHOSN_NPU_FW_IMAGE_ID, "ethosn_npu_fw_uuid"},
360#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100361#if TRUSTED_BOARD_BOOT
laurenw-arm23075462022-04-21 17:03:30 -0500362 {CCA_CONTENT_CERT_ID, "cca_cert_uuid"},
363 {CORE_SWD_KEY_CERT_ID, "core_swd_cert_uuid"},
364 {PLAT_KEY_CERT_ID, "plat_cert_uuid"},
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100365 {TRUSTED_KEY_CERT_ID, "t_key_cert_uuid"},
366 {SCP_FW_KEY_CERT_ID, "scp_fw_key_uuid"},
367 {SOC_FW_KEY_CERT_ID, "soc_fw_key_uuid"},
368 {TRUSTED_OS_FW_KEY_CERT_ID, "tos_fw_key_cert_uuid"},
369 {NON_TRUSTED_FW_KEY_CERT_ID, "nt_fw_key_cert_uuid"},
370 {SCP_FW_CONTENT_CERT_ID, "scp_fw_content_cert_uuid"},
371 {SOC_FW_CONTENT_CERT_ID, "soc_fw_content_cert_uuid"},
372 {TRUSTED_OS_FW_CONTENT_CERT_ID, "tos_fw_content_cert_uuid"},
373 {NON_TRUSTED_FW_CONTENT_CERT_ID, "nt_fw_content_cert_uuid"},
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100374#if defined(SPD_spmd)
Manish Pandeyd07d0172020-07-23 16:54:30 +0100375 {SIP_SP_CONTENT_CERT_ID, "sip_sp_content_cert_uuid"},
Manish Pandeyaff80752020-07-31 16:15:16 +0100376 {PLAT_SP_CONTENT_CERT_ID, "plat_sp_content_cert_uuid"},
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100377#endif
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200378#if ETHOSN_NPU_TZMP1
379 {ETHOSN_NPU_FW_KEY_CERT_ID, "ethosn_npu_fw_key_cert_uuid"},
380 {ETHOSN_NPU_FW_CONTENT_CERT_ID, "ethosn_npu_fw_content_cert_uuid"},
381#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100382#endif /* TRUSTED_BOARD_BOOT */
383};
384
385int fconf_populate_arm_io_policies(uintptr_t config)
386{
387 int err, node;
388 unsigned int i;
389
390 union uuid_helper_t uuid_helper;
391 io_uuid_spec_t *uuid_ptr;
392
393 /* As libfdt uses void *, we can't avoid this cast */
394 const void *dtb = (void *)config;
395
396 /* Assert the node offset point to "arm,io-fip-handle" compatible property */
397 const char *compatible_str = "arm,io-fip-handle";
398 node = fdt_node_offset_by_compatible(dtb, -1, compatible_str);
399 if (node < 0) {
400 ERROR("FCONF: Can't find %s compatible in dtb\n", compatible_str);
401 return node;
402 }
403
404 /* Locate the uuid cells and read the value for all the load info uuid */
405 for (i = 0; i < FCONF_ARM_IO_UUID_NUMBER; i++) {
406 uuid_ptr = pool_alloc(&fconf_arm_uuids_pool);
David Horstmannb2df4c12021-04-08 14:50:21 +0100407 err = fdtw_read_uuid(dtb, node, load_info[i].name, 16,
408 (uint8_t *)&uuid_helper);
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100409 if (err < 0) {
410 WARN("FCONF: Read cell failed for %s\n", load_info[i].name);
411 return err;
412 }
413
David Horstmannb2df4c12021-04-08 14:50:21 +0100414 VERBOSE("FCONF: arm-io_policies.%s cell found with value = "
415 "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100416 load_info[i].name,
David Horstmannb2df4c12021-04-08 14:50:21 +0100417 uuid_helper.uuid_struct.time_low[0], uuid_helper.uuid_struct.time_low[1],
418 uuid_helper.uuid_struct.time_low[2], uuid_helper.uuid_struct.time_low[3],
419 uuid_helper.uuid_struct.time_mid[0], uuid_helper.uuid_struct.time_mid[1],
420 uuid_helper.uuid_struct.time_hi_and_version[0],
421 uuid_helper.uuid_struct.time_hi_and_version[1],
422 uuid_helper.uuid_struct.clock_seq_hi_and_reserved,
423 uuid_helper.uuid_struct.clock_seq_low,
424 uuid_helper.uuid_struct.node[0], uuid_helper.uuid_struct.node[1],
425 uuid_helper.uuid_struct.node[2], uuid_helper.uuid_struct.node[3],
426 uuid_helper.uuid_struct.node[4], uuid_helper.uuid_struct.node[5]);
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100427
428 uuid_ptr->uuid = uuid_helper.uuid_struct;
429 policies[load_info[i].image_id].image_spec = (uintptr_t)uuid_ptr;
430 policies[load_info[i].image_id].dev_handle = &fip_dev_handle;
431 policies[load_info[i].image_id].check = open_fip;
432 }
433 return 0;
434}
435
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000436#if ARM_IO_IN_DTB
Madhukar Pappireddy81519692019-12-06 15:46:42 -0600437FCONF_REGISTER_POPULATOR(TB_FW, arm_io, fconf_populate_arm_io_policies);
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000438#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100439
440#endif /* IMAGE_BL2 */