1dcda29f6SYatharth Kochar /* 21af540efSRoberto Vargas * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. 3dcda29f6SYatharth Kochar * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 5dcda29f6SYatharth Kochar */ 6dcda29f6SYatharth Kochar 7dcda29f6SYatharth Kochar #include <arch_helpers.h> 8dcda29f6SYatharth Kochar #include <arm_def.h> 9d323af9eSDaniel Boulby #include <assert.h> 10dcda29f6SYatharth Kochar #include <bl_common.h> 1174847ab2SSoby Mathew #include <generic_delay_timer.h> 12dcda29f6SYatharth Kochar #include <plat_arm.h> 134adb10c1SIsla Mitchell #include <platform_def.h> 141af540efSRoberto Vargas #include <platform.h> 15dcda29f6SYatharth Kochar #include <string.h> 16dcda29f6SYatharth Kochar 17dcda29f6SYatharth Kochar /* Weak definitions may be overridden in specific ARM standard platform */ 18dcda29f6SYatharth Kochar #pragma weak bl2u_platform_setup 19dcda29f6SYatharth Kochar #pragma weak bl2u_early_platform_setup 20dcda29f6SYatharth Kochar #pragma weak bl2u_plat_arch_setup 21dcda29f6SYatharth Kochar 22d323af9eSDaniel Boulby #define MAP_BL2U_TOTAL MAP_REGION_FLAT( \ 23d323af9eSDaniel Boulby BL2U_BASE, \ 24d323af9eSDaniel Boulby BL2U_LIMIT - BL2U_BASE, \ 25d323af9eSDaniel Boulby MT_MEMORY | MT_RW | MT_SECURE) 26d323af9eSDaniel Boulby 27dcda29f6SYatharth Kochar /* 28dcda29f6SYatharth Kochar * Perform ARM standard platform setup for BL2U 29dcda29f6SYatharth Kochar */ 30dcda29f6SYatharth Kochar void arm_bl2u_platform_setup(void) 31dcda29f6SYatharth Kochar { 32dcda29f6SYatharth Kochar /* Initialize the secure environment */ 33dcda29f6SYatharth Kochar plat_arm_security_setup(); 34dcda29f6SYatharth Kochar } 35dcda29f6SYatharth Kochar 36dcda29f6SYatharth Kochar void bl2u_platform_setup(void) 37dcda29f6SYatharth Kochar { 38dcda29f6SYatharth Kochar arm_bl2u_platform_setup(); 39dcda29f6SYatharth Kochar } 40dcda29f6SYatharth Kochar 416c77e749SSandrine Bailleux void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info) 42dcda29f6SYatharth Kochar { 43dcda29f6SYatharth Kochar /* Initialize the console to provide early debug support */ 4488a0523eSAntonio Nino Diaz arm_console_boot_init(); 4588a0523eSAntonio Nino Diaz 4674847ab2SSoby Mathew generic_delay_timer_init(); 47dcda29f6SYatharth Kochar } 48dcda29f6SYatharth Kochar 49dcda29f6SYatharth Kochar /******************************************************************************* 50dcda29f6SYatharth Kochar * BL1 can pass platform dependent information to BL2U in x1. 51dcda29f6SYatharth Kochar * In case of ARM CSS platforms x1 contains SCP_BL2U image info. 52dcda29f6SYatharth Kochar * In case of ARM FVP platforms x1 is not used. 53dcda29f6SYatharth Kochar * In both cases, x0 contains the extents of the memory available to BL2U 54dcda29f6SYatharth Kochar ******************************************************************************/ 556c77e749SSandrine Bailleux void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info) 56dcda29f6SYatharth Kochar { 57dcda29f6SYatharth Kochar arm_bl2u_early_platform_setup(mem_layout, plat_info); 58dcda29f6SYatharth Kochar } 59dcda29f6SYatharth Kochar 60dcda29f6SYatharth Kochar /******************************************************************************* 61dcda29f6SYatharth Kochar * Perform the very early platform specific architectural setup here. At the 62dcda29f6SYatharth Kochar * moment this is only initializes the mmu in a quick and dirty way. 63dcda29f6SYatharth Kochar * The memory that is used by BL2U is only mapped. 64dcda29f6SYatharth Kochar ******************************************************************************/ 65dcda29f6SYatharth Kochar void arm_bl2u_plat_arch_setup(void) 66dcda29f6SYatharth Kochar { 67d323af9eSDaniel Boulby 68dcda29f6SYatharth Kochar #if USE_COHERENT_MEM 69d323af9eSDaniel Boulby /* Ensure ARM platforms dont use coherent memory in BL2U */ 70d323af9eSDaniel Boulby assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U); 71dcda29f6SYatharth Kochar #endif 72d323af9eSDaniel Boulby 73d323af9eSDaniel Boulby const mmap_region_t bl_regions[] = { 74d323af9eSDaniel Boulby MAP_BL2U_TOTAL, 752ecaafd2SDaniel Boulby ARM_MAP_BL_RO, 76d323af9eSDaniel Boulby {0} 77d323af9eSDaniel Boulby }; 78d323af9eSDaniel Boulby 79d323af9eSDaniel Boulby arm_setup_page_tables(bl_regions, plat_arm_get_mmap()); 80d323af9eSDaniel Boulby 811bd61d0aSYatharth Kochar #ifdef AARCH32 82*1e54cbb8SAntonio Nino Diaz enable_mmu_svc_mon(0); 831bd61d0aSYatharth Kochar #else 84b5fa6563SSandrine Bailleux enable_mmu_el1(0); 851bd61d0aSYatharth Kochar #endif 86dcda29f6SYatharth Kochar } 87dcda29f6SYatharth Kochar 88dcda29f6SYatharth Kochar void bl2u_plat_arch_setup(void) 89dcda29f6SYatharth Kochar { 90dcda29f6SYatharth Kochar arm_bl2u_plat_arch_setup(); 91dcda29f6SYatharth Kochar } 92