blob: 07f6a8272140667426194a3e0520691a4a40aa46 [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,
Govindraj Raja232a11f2023-10-03 16:39:32 -050048 * length = PLAT_PARTITION_BLOCK_SIZE * (128/4 + 2)
Manish V Badarkhedd6f2522021-02-22 17:30:17 +000049 */
Govindraj Raja232a11f2023-10-03 16:39:32 -050050 .length = LBA(PLAT_PARTITION_MAX_ENTRIES / 4 + 2),
Manish V Badarkhedd6f2522021-02-22 17:30:17 +000051};
Govindraj Rajad2706562023-10-16 09:30:16 -050052
53/*
54 * length will be assigned at runtime based on MBR header data.
55 * Backup GPT Header is present in Last LBA-1 and its entries
56 * are last 32 blocks starts at LBA-33, On runtime update these
57 * before device usage. Update offset to beginning LBA-33 and
58 * length to LBA-33.
59 */
60static io_block_spec_t bkup_gpt_spec = {
61 .offset = PLAT_ARM_FLASH_IMAGE_BASE,
62 .length = 0,
63};
Manish V Badarkhedd6f2522021-02-22 17:30:17 +000064#endif /* ARM_GPT_SUPPORT */
Louis Mayencourtbadcac82019-10-24 15:18:46 +010065
66const io_uuid_spec_t arm_uuid_spec[MAX_NUMBER_IDS] = {
67 [BL2_IMAGE_ID] = {UUID_TRUSTED_BOOT_FIRMWARE_BL2},
68 [TB_FW_CONFIG_ID] = {UUID_TB_FW_CONFIG},
Louis Mayencourt244027d2020-06-11 21:15:15 +010069 [FW_CONFIG_ID] = {UUID_FW_CONFIG},
Louis Mayencourt6b232d92020-02-28 16:57:30 +000070#if !ARM_IO_IN_DTB
71 [SCP_BL2_IMAGE_ID] = {UUID_SCP_FIRMWARE_SCP_BL2},
72 [BL31_IMAGE_ID] = {UUID_EL3_RUNTIME_FIRMWARE_BL31},
73 [BL32_IMAGE_ID] = {UUID_SECURE_PAYLOAD_BL32},
74 [BL32_EXTRA1_IMAGE_ID] = {UUID_SECURE_PAYLOAD_BL32_EXTRA1},
75 [BL32_EXTRA2_IMAGE_ID] = {UUID_SECURE_PAYLOAD_BL32_EXTRA2},
76 [BL33_IMAGE_ID] = {UUID_NON_TRUSTED_FIRMWARE_BL33},
77 [HW_CONFIG_ID] = {UUID_HW_CONFIG},
78 [SOC_FW_CONFIG_ID] = {UUID_SOC_FW_CONFIG},
79 [TOS_FW_CONFIG_ID] = {UUID_TOS_FW_CONFIG},
80 [NT_FW_CONFIG_ID] = {UUID_NT_FW_CONFIG},
Zelalem Aweke96c0bab2021-07-11 18:39:39 -050081 [RMM_IMAGE_ID] = {UUID_REALM_MONITOR_MGMT_FIRMWARE},
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +020082#if ETHOSN_NPU_TZMP1
83 [ETHOSN_NPU_FW_IMAGE_ID] = {UUID_ETHOSN_FW},
84#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourt6b232d92020-02-28 16:57:30 +000085#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +010086#if TRUSTED_BOARD_BOOT
87 [TRUSTED_BOOT_FW_CERT_ID] = {UUID_TRUSTED_BOOT_FW_CERT},
Louis Mayencourt6b232d92020-02-28 16:57:30 +000088#if !ARM_IO_IN_DTB
laurenw-arm23075462022-04-21 17:03:30 -050089 [CCA_CONTENT_CERT_ID] = {UUID_CCA_CONTENT_CERT},
90 [CORE_SWD_KEY_CERT_ID] = {UUID_CORE_SWD_KEY_CERT},
91 [PLAT_KEY_CERT_ID] = {UUID_PLAT_KEY_CERT},
Louis Mayencourt6b232d92020-02-28 16:57:30 +000092 [TRUSTED_KEY_CERT_ID] = {UUID_TRUSTED_KEY_CERT},
93 [SCP_FW_KEY_CERT_ID] = {UUID_SCP_FW_KEY_CERT},
94 [SOC_FW_KEY_CERT_ID] = {UUID_SOC_FW_KEY_CERT},
95 [TRUSTED_OS_FW_KEY_CERT_ID] = {UUID_TRUSTED_OS_FW_KEY_CERT},
96 [NON_TRUSTED_FW_KEY_CERT_ID] = {UUID_NON_TRUSTED_FW_KEY_CERT},
97 [SCP_FW_CONTENT_CERT_ID] = {UUID_SCP_FW_CONTENT_CERT},
98 [SOC_FW_CONTENT_CERT_ID] = {UUID_SOC_FW_CONTENT_CERT},
99 [TRUSTED_OS_FW_CONTENT_CERT_ID] = {UUID_TRUSTED_OS_FW_CONTENT_CERT},
100 [NON_TRUSTED_FW_CONTENT_CERT_ID] = {UUID_NON_TRUSTED_FW_CONTENT_CERT},
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100101#if defined(SPD_spmd)
Manish Pandeyd07d0172020-07-23 16:54:30 +0100102 [SIP_SP_CONTENT_CERT_ID] = {UUID_SIP_SECURE_PARTITION_CONTENT_CERT},
Manish Pandeyaff80752020-07-31 16:15:16 +0100103 [PLAT_SP_CONTENT_CERT_ID] = {UUID_PLAT_SECURE_PARTITION_CONTENT_CERT},
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100104#endif
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200105#if ETHOSN_NPU_TZMP1
106 [ETHOSN_NPU_FW_KEY_CERT_ID] = {UUID_ETHOSN_FW_KEY_CERTIFICATE},
107 [ETHOSN_NPU_FW_CONTENT_CERT_ID] = {UUID_ETHOSN_FW_CONTENT_CERTIFICATE},
108#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000109#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100110#endif /* TRUSTED_BOARD_BOOT */
111};
112
113/* By default, ARM platforms load images from the FIP */
114struct plat_io_policy policies[MAX_NUMBER_IDS] = {
Manish V Badarkhedd6f2522021-02-22 17:30:17 +0000115#if ARM_GPT_SUPPORT
116 [GPT_IMAGE_ID] = {
117 &memmap_dev_handle,
118 (uintptr_t)&gpt_spec,
119 open_memmap
120 },
Govindraj Rajad2706562023-10-16 09:30:16 -0500121 [BKUP_GPT_IMAGE_ID] = {
122 &memmap_dev_handle,
123 (uintptr_t)&bkup_gpt_spec,
124 open_memmap
125 },
Manish V Badarkhedd6f2522021-02-22 17:30:17 +0000126#endif /* ARM_GPT_SUPPORT */
Manish V Badarkhed2f0a7a2021-06-25 23:43:33 +0100127#if PSA_FWU_SUPPORT
128 [FWU_METADATA_IMAGE_ID] = {
129 &memmap_dev_handle,
130 /* filled runtime from partition information */
131 (uintptr_t)&fwu_metadata_spec,
132 open_memmap
133 },
134 [BKUP_FWU_METADATA_IMAGE_ID] = {
135 &memmap_dev_handle,
136 /* filled runtime from partition information */
137 (uintptr_t)&fwu_metadata_spec,
138 open_memmap
139 },
140#endif /* PSA_FWU_SUPPORT */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100141 [FIP_IMAGE_ID] = {
142 &memmap_dev_handle,
143 (uintptr_t)&fip_block_spec,
144 open_memmap
145 },
146 [BL2_IMAGE_ID] = {
147 &fip_dev_handle,
148 (uintptr_t)&arm_uuid_spec[BL2_IMAGE_ID],
149 open_fip
150 },
151 [TB_FW_CONFIG_ID] = {
152 &fip_dev_handle,
153 (uintptr_t)&arm_uuid_spec[TB_FW_CONFIG_ID],
154 open_fip
155 },
Louis Mayencourt244027d2020-06-11 21:15:15 +0100156 [FW_CONFIG_ID] = {
157 &fip_dev_handle,
158 (uintptr_t)&arm_uuid_spec[FW_CONFIG_ID],
159 open_fip
160 },
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000161#if !ARM_IO_IN_DTB
162 [SCP_BL2_IMAGE_ID] = {
163 &fip_dev_handle,
164 (uintptr_t)&arm_uuid_spec[SCP_BL2_IMAGE_ID],
165 open_fip
166 },
167 [BL31_IMAGE_ID] = {
168 &fip_dev_handle,
169 (uintptr_t)&arm_uuid_spec[BL31_IMAGE_ID],
170 open_fip
171 },
172 [BL32_IMAGE_ID] = {
173 &fip_dev_handle,
174 (uintptr_t)&arm_uuid_spec[BL32_IMAGE_ID],
175 open_fip
176 },
177 [BL32_EXTRA1_IMAGE_ID] = {
178 &fip_dev_handle,
179 (uintptr_t)&arm_uuid_spec[BL32_EXTRA1_IMAGE_ID],
180 open_fip
181 },
182 [BL32_EXTRA2_IMAGE_ID] = {
183 &fip_dev_handle,
184 (uintptr_t)&arm_uuid_spec[BL32_EXTRA2_IMAGE_ID],
185 open_fip
186 },
187 [BL33_IMAGE_ID] = {
188 &fip_dev_handle,
189 (uintptr_t)&arm_uuid_spec[BL33_IMAGE_ID],
190 open_fip
191 },
Zelalem Aweke96c0bab2021-07-11 18:39:39 -0500192 [RMM_IMAGE_ID] = {
193 &fip_dev_handle,
194 (uintptr_t)&arm_uuid_spec[RMM_IMAGE_ID],
195 open_fip
196 },
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000197 [HW_CONFIG_ID] = {
198 &fip_dev_handle,
199 (uintptr_t)&arm_uuid_spec[HW_CONFIG_ID],
200 open_fip
201 },
202 [SOC_FW_CONFIG_ID] = {
203 &fip_dev_handle,
204 (uintptr_t)&arm_uuid_spec[SOC_FW_CONFIG_ID],
205 open_fip
206 },
207 [TOS_FW_CONFIG_ID] = {
208 &fip_dev_handle,
209 (uintptr_t)&arm_uuid_spec[TOS_FW_CONFIG_ID],
210 open_fip
211 },
212 [NT_FW_CONFIG_ID] = {
213 &fip_dev_handle,
214 (uintptr_t)&arm_uuid_spec[NT_FW_CONFIG_ID],
215 open_fip
216 },
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200217#if ETHOSN_NPU_TZMP1
218 [ETHOSN_NPU_FW_IMAGE_ID] = {
Rob Hughes9a2177a2023-01-17 16:10:26 +0000219 &fip_dev_handle,
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200220 (uintptr_t)&arm_uuid_spec[ETHOSN_NPU_FW_IMAGE_ID],
Rob Hughes9a2177a2023-01-17 16:10:26 +0000221 open_fip
222 },
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200223#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000224#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100225#if TRUSTED_BOARD_BOOT
226 [TRUSTED_BOOT_FW_CERT_ID] = {
227 &fip_dev_handle,
228 (uintptr_t)&arm_uuid_spec[TRUSTED_BOOT_FW_CERT_ID],
229 open_fip
230 },
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000231#if !ARM_IO_IN_DTB
laurenw-arm23075462022-04-21 17:03:30 -0500232 [CCA_CONTENT_CERT_ID] = {
233 &fip_dev_handle,
234 (uintptr_t)&arm_uuid_spec[CCA_CONTENT_CERT_ID],
235 open_fip
236 },
237 [CORE_SWD_KEY_CERT_ID] = {
238 &fip_dev_handle,
239 (uintptr_t)&arm_uuid_spec[CORE_SWD_KEY_CERT_ID],
240 open_fip
241 },
242 [PLAT_KEY_CERT_ID] = {
243 &fip_dev_handle,
244 (uintptr_t)&arm_uuid_spec[PLAT_KEY_CERT_ID],
245 open_fip
246 },
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000247 [TRUSTED_KEY_CERT_ID] = {
248 &fip_dev_handle,
249 (uintptr_t)&arm_uuid_spec[TRUSTED_KEY_CERT_ID],
250 open_fip
251 },
252 [SCP_FW_KEY_CERT_ID] = {
253 &fip_dev_handle,
254 (uintptr_t)&arm_uuid_spec[SCP_FW_KEY_CERT_ID],
255 open_fip
256 },
257 [SOC_FW_KEY_CERT_ID] = {
258 &fip_dev_handle,
259 (uintptr_t)&arm_uuid_spec[SOC_FW_KEY_CERT_ID],
260 open_fip
261 },
262 [TRUSTED_OS_FW_KEY_CERT_ID] = {
263 &fip_dev_handle,
264 (uintptr_t)&arm_uuid_spec[TRUSTED_OS_FW_KEY_CERT_ID],
265 open_fip
266 },
267 [NON_TRUSTED_FW_KEY_CERT_ID] = {
268 &fip_dev_handle,
269 (uintptr_t)&arm_uuid_spec[NON_TRUSTED_FW_KEY_CERT_ID],
270 open_fip
271 },
272 [SCP_FW_CONTENT_CERT_ID] = {
273 &fip_dev_handle,
274 (uintptr_t)&arm_uuid_spec[SCP_FW_CONTENT_CERT_ID],
275 open_fip
276 },
277 [SOC_FW_CONTENT_CERT_ID] = {
278 &fip_dev_handle,
279 (uintptr_t)&arm_uuid_spec[SOC_FW_CONTENT_CERT_ID],
280 open_fip
281 },
282 [TRUSTED_OS_FW_CONTENT_CERT_ID] = {
283 &fip_dev_handle,
284 (uintptr_t)&arm_uuid_spec[TRUSTED_OS_FW_CONTENT_CERT_ID],
285 open_fip
286 },
287 [NON_TRUSTED_FW_CONTENT_CERT_ID] = {
288 &fip_dev_handle,
289 (uintptr_t)&arm_uuid_spec[NON_TRUSTED_FW_CONTENT_CERT_ID],
290 open_fip
291 },
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100292#if defined(SPD_spmd)
Manish Pandeyd07d0172020-07-23 16:54:30 +0100293 [SIP_SP_CONTENT_CERT_ID] = {
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100294 &fip_dev_handle,
Manish Pandeyd07d0172020-07-23 16:54:30 +0100295 (uintptr_t)&arm_uuid_spec[SIP_SP_CONTENT_CERT_ID],
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100296 open_fip
297 },
Manish Pandeyaff80752020-07-31 16:15:16 +0100298 [PLAT_SP_CONTENT_CERT_ID] = {
299 &fip_dev_handle,
300 (uintptr_t)&arm_uuid_spec[PLAT_SP_CONTENT_CERT_ID],
301 open_fip
302 },
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100303#endif
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200304#if ETHOSN_NPU_TZMP1
305 [ETHOSN_NPU_FW_KEY_CERT_ID] = {
Rob Hughes9a2177a2023-01-17 16:10:26 +0000306 &fip_dev_handle,
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200307 (uintptr_t)&arm_uuid_spec[ETHOSN_NPU_FW_KEY_CERT_ID],
Rob Hughes9a2177a2023-01-17 16:10:26 +0000308 open_fip
309 },
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200310 [ETHOSN_NPU_FW_CONTENT_CERT_ID] = {
Rob Hughes9a2177a2023-01-17 16:10:26 +0000311 &fip_dev_handle,
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200312 (uintptr_t)&arm_uuid_spec[ETHOSN_NPU_FW_CONTENT_CERT_ID],
Rob Hughes9a2177a2023-01-17 16:10:26 +0000313 open_fip
314 },
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200315#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000316#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100317#endif /* TRUSTED_BOARD_BOOT */
318};
319
320#ifdef IMAGE_BL2
321
Rob Hughesa45a2dd2023-01-20 10:43:41 +0000322#define FCONF_ARM_IO_UUID_NUM_BASE U(10)
323
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200324#if ETHOSN_NPU_TZMP1
Rob Hughes9a2177a2023-01-17 16:10:26 +0000325#define FCONF_ARM_IO_UUID_NUM_NPU U(1)
326#else
327#define FCONF_ARM_IO_UUID_NUM_NPU U(0)
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200328#endif /* ETHOSN_NPU_TZMP1 */
Rob Hughes9a2177a2023-01-17 16:10:26 +0000329
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100330#if TRUSTED_BOARD_BOOT
Rob Hughesa45a2dd2023-01-20 10:43:41 +0000331#define FCONF_ARM_IO_UUID_NUM_TBB U(12)
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100332#else
Rob Hughesa45a2dd2023-01-20 10:43:41 +0000333#define FCONF_ARM_IO_UUID_NUM_TBB U(0)
334#endif /* TRUSTED_BOARD_BOOT */
335
336#if TRUSTED_BOARD_BOOT && defined(SPD_spmd)
337#define FCONF_ARM_IO_UUID_NUM_SPD U(2)
338#else
339#define FCONF_ARM_IO_UUID_NUM_SPD U(0)
340#endif /* TRUSTED_BOARD_BOOT && defined(SPD_spmd) */
341
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200342#if TRUSTED_BOARD_BOOT && ETHOSN_NPU_TZMP1
Rob Hughes9a2177a2023-01-17 16:10:26 +0000343#define FCONF_ARM_IO_UUID_NUM_NPU_TBB U(2)
344#else
345#define FCONF_ARM_IO_UUID_NUM_NPU_TBB U(0)
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200346#endif /* TRUSTED_BOARD_BOOT && ETHOSN_NPU_TZMP1 */
Rob Hughes9a2177a2023-01-17 16:10:26 +0000347
Rob Hughesa45a2dd2023-01-20 10:43:41 +0000348#define FCONF_ARM_IO_UUID_NUMBER FCONF_ARM_IO_UUID_NUM_BASE + \
Rob Hughes9a2177a2023-01-17 16:10:26 +0000349 FCONF_ARM_IO_UUID_NUM_NPU + \
350 FCONF_ARM_IO_UUID_NUM_TBB + \
351 FCONF_ARM_IO_UUID_NUM_SPD + \
352 FCONF_ARM_IO_UUID_NUM_NPU_TBB
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100353
354static io_uuid_spec_t fconf_arm_uuids[FCONF_ARM_IO_UUID_NUMBER];
355static OBJECT_POOL_ARRAY(fconf_arm_uuids_pool, fconf_arm_uuids);
356
357struct policies_load_info {
358 unsigned int image_id;
359 const char *name;
360};
361
362/* image id to property name table */
363static const struct policies_load_info load_info[FCONF_ARM_IO_UUID_NUMBER] = {
364 {SCP_BL2_IMAGE_ID, "scp_bl2_uuid"},
365 {BL31_IMAGE_ID, "bl31_uuid"},
366 {BL32_IMAGE_ID, "bl32_uuid"},
367 {BL32_EXTRA1_IMAGE_ID, "bl32_extra1_uuid"},
368 {BL32_EXTRA2_IMAGE_ID, "bl32_extra2_uuid"},
369 {BL33_IMAGE_ID, "bl33_uuid"},
370 {HW_CONFIG_ID, "hw_cfg_uuid"},
371 {SOC_FW_CONFIG_ID, "soc_fw_cfg_uuid"},
372 {TOS_FW_CONFIG_ID, "tos_fw_cfg_uuid"},
373 {NT_FW_CONFIG_ID, "nt_fw_cfg_uuid"},
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200374#if ETHOSN_NPU_TZMP1
375 {ETHOSN_NPU_FW_IMAGE_ID, "ethosn_npu_fw_uuid"},
376#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100377#if TRUSTED_BOARD_BOOT
laurenw-arm23075462022-04-21 17:03:30 -0500378 {CCA_CONTENT_CERT_ID, "cca_cert_uuid"},
379 {CORE_SWD_KEY_CERT_ID, "core_swd_cert_uuid"},
380 {PLAT_KEY_CERT_ID, "plat_cert_uuid"},
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100381 {TRUSTED_KEY_CERT_ID, "t_key_cert_uuid"},
382 {SCP_FW_KEY_CERT_ID, "scp_fw_key_uuid"},
383 {SOC_FW_KEY_CERT_ID, "soc_fw_key_uuid"},
384 {TRUSTED_OS_FW_KEY_CERT_ID, "tos_fw_key_cert_uuid"},
385 {NON_TRUSTED_FW_KEY_CERT_ID, "nt_fw_key_cert_uuid"},
386 {SCP_FW_CONTENT_CERT_ID, "scp_fw_content_cert_uuid"},
387 {SOC_FW_CONTENT_CERT_ID, "soc_fw_content_cert_uuid"},
388 {TRUSTED_OS_FW_CONTENT_CERT_ID, "tos_fw_content_cert_uuid"},
389 {NON_TRUSTED_FW_CONTENT_CERT_ID, "nt_fw_content_cert_uuid"},
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100390#if defined(SPD_spmd)
Manish Pandeyd07d0172020-07-23 16:54:30 +0100391 {SIP_SP_CONTENT_CERT_ID, "sip_sp_content_cert_uuid"},
Manish Pandeyaff80752020-07-31 16:15:16 +0100392 {PLAT_SP_CONTENT_CERT_ID, "plat_sp_content_cert_uuid"},
Manish Pandey5f8e1a02020-05-27 22:40:10 +0100393#endif
Rajasekaran Kalidoss85999a82023-05-08 14:55:13 +0200394#if ETHOSN_NPU_TZMP1
395 {ETHOSN_NPU_FW_KEY_CERT_ID, "ethosn_npu_fw_key_cert_uuid"},
396 {ETHOSN_NPU_FW_CONTENT_CERT_ID, "ethosn_npu_fw_content_cert_uuid"},
397#endif /* ETHOSN_NPU_TZMP1 */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100398#endif /* TRUSTED_BOARD_BOOT */
399};
400
401int fconf_populate_arm_io_policies(uintptr_t config)
402{
403 int err, node;
404 unsigned int i;
405
406 union uuid_helper_t uuid_helper;
407 io_uuid_spec_t *uuid_ptr;
408
409 /* As libfdt uses void *, we can't avoid this cast */
410 const void *dtb = (void *)config;
411
412 /* Assert the node offset point to "arm,io-fip-handle" compatible property */
413 const char *compatible_str = "arm,io-fip-handle";
414 node = fdt_node_offset_by_compatible(dtb, -1, compatible_str);
415 if (node < 0) {
416 ERROR("FCONF: Can't find %s compatible in dtb\n", compatible_str);
417 return node;
418 }
419
420 /* Locate the uuid cells and read the value for all the load info uuid */
421 for (i = 0; i < FCONF_ARM_IO_UUID_NUMBER; i++) {
422 uuid_ptr = pool_alloc(&fconf_arm_uuids_pool);
David Horstmannb2df4c12021-04-08 14:50:21 +0100423 err = fdtw_read_uuid(dtb, node, load_info[i].name, 16,
424 (uint8_t *)&uuid_helper);
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100425 if (err < 0) {
426 WARN("FCONF: Read cell failed for %s\n", load_info[i].name);
427 return err;
428 }
429
David Horstmannb2df4c12021-04-08 14:50:21 +0100430 VERBOSE("FCONF: arm-io_policies.%s cell found with value = "
431 "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100432 load_info[i].name,
David Horstmannb2df4c12021-04-08 14:50:21 +0100433 uuid_helper.uuid_struct.time_low[0], uuid_helper.uuid_struct.time_low[1],
434 uuid_helper.uuid_struct.time_low[2], uuid_helper.uuid_struct.time_low[3],
435 uuid_helper.uuid_struct.time_mid[0], uuid_helper.uuid_struct.time_mid[1],
436 uuid_helper.uuid_struct.time_hi_and_version[0],
437 uuid_helper.uuid_struct.time_hi_and_version[1],
438 uuid_helper.uuid_struct.clock_seq_hi_and_reserved,
439 uuid_helper.uuid_struct.clock_seq_low,
440 uuid_helper.uuid_struct.node[0], uuid_helper.uuid_struct.node[1],
441 uuid_helper.uuid_struct.node[2], uuid_helper.uuid_struct.node[3],
442 uuid_helper.uuid_struct.node[4], uuid_helper.uuid_struct.node[5]);
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100443
444 uuid_ptr->uuid = uuid_helper.uuid_struct;
445 policies[load_info[i].image_id].image_spec = (uintptr_t)uuid_ptr;
446 policies[load_info[i].image_id].dev_handle = &fip_dev_handle;
447 policies[load_info[i].image_id].check = open_fip;
448 }
449 return 0;
450}
451
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000452#if ARM_IO_IN_DTB
Madhukar Pappireddy81519692019-12-06 15:46:42 -0600453FCONF_REGISTER_POPULATOR(TB_FW, arm_io, fconf_populate_arm_io_policies);
Louis Mayencourt6b232d92020-02-28 16:57:30 +0000454#endif /* ARM_IO_IN_DTB */
Louis Mayencourtbadcac82019-10-24 15:18:46 +0100455
456#endif /* IMAGE_BL2 */