1 /* 2 * Copyright 2024 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 #include <errno.h> 7 8 #include <common/bl_common.h> 9 #include <lib/xlat_tables/xlat_tables_v2.h> 10 11 #include <s32cc-bl-common.h> 12 13 int s32cc_bl_mmu_setup(void) 14 { 15 const unsigned long code_start = BL_CODE_BASE; 16 const unsigned long rw_start = BL_CODE_END; 17 unsigned long code_size; 18 unsigned long rw_size; 19 20 if (code_start > BL_CODE_END) { 21 return -EINVAL; 22 } 23 24 if (rw_start > BL_END) { 25 return -EINVAL; 26 } 27 28 code_size = BL_CODE_END - code_start; 29 rw_size = BL_END - rw_start; 30 31 mmap_add_region(code_start, code_start, code_size, 32 MT_RO | MT_MEMORY | MT_SECURE); 33 mmap_add_region(rw_start, rw_start, rw_size, 34 MT_RW | MT_MEMORY | MT_SECURE); 35 36 init_xlat_tables(); 37 enable_mmu_el3(0); 38 39 return 0; 40 } 41