1 /*
2  * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "image.h"
9 
10 #include "region_defs.h"
11 #include "tfm_plat_otp.h"
12 
bl1_read_bl1_2_image(uint8_t * image)13 fih_int bl1_read_bl1_2_image(uint8_t *image)
14 {
15     fih_int fih_rc;
16     enum tfm_plat_err_t plat_err;
17     uint32_t bl1_2_len;
18 
19     plat_err = tfm_plat_otp_read(PLAT_OTP_ID_BL1_2_IMAGE_LEN, sizeof(bl1_2_len),
20                                  (uint8_t *)&bl1_2_len);
21     fih_rc = fih_int_encode_zero_equality(plat_err);
22     if (fih_not_eq(fih_rc, FIH_SUCCESS)) {
23         FIH_RET(fih_rc);
24     }
25 
26     plat_err = tfm_plat_otp_read(PLAT_OTP_ID_BL1_2_IMAGE, bl1_2_len, image);
27     fih_rc = fih_int_encode_zero_equality(plat_err);
28 
29     FIH_RET(fih_rc);
30 }
31