1 /* 2 * Copyright (c) 2024, Pengutronix, Inc. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 #include <errno.h> 7 #include <stdint.h> 8 9 #include <common/bl_common.h> 10 #include <common/desc_image_load.h> 11 12 #include <plat_common.h> 13 14 /* 15 * This function checks if @arg0 can safely be accessed as a pointer 16 * and if it does, it fills in @bl32_info and @bl33_info with data 17 * found in @arg0. 18 * 19 * Returns 0 when @arg0 can be used as entry point info and a negative 20 * error code otherwise. 21 */ 22 int imx_bl31_params_parse(uintptr_t arg0, uintptr_t ocram_base, 23 uintptr_t ocram_size, 24 entry_point_info_t *bl32_info, 25 entry_point_info_t *bl33_info) 26 { 27 bl_params_t *v2 = (void *)(uintptr_t)arg0; 28 29 if (arg0 & 0x3) { 30 return -EINVAL; 31 } 32 33 if (arg0 < ocram_base || arg0 >= ocram_base + ocram_size) { 34 return -EINVAL; 35 } 36 37 if (v2->h.version != PARAM_VERSION_2) { 38 return -EINVAL; 39 } 40 41 if (v2->h.type != PARAM_BL_PARAMS) { 42 return -EINVAL; 43 } 44 45 bl31_params_parse_helper(arg0, bl32_info, bl33_info); 46 47 return 0; 48 } 49