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 7d323af9eSDaniel Boulby #include <assert.h> 8dcda29f6SYatharth Kochar #include <string.h> 9dcda29f6SYatharth Kochar 1009d40e0eSAntonio Nino Diaz #include <platform_def.h> 1109d40e0eSAntonio Nino Diaz 1209d40e0eSAntonio Nino Diaz #include <arch_helpers.h> 1309d40e0eSAntonio Nino Diaz #include <common/bl_common.h> 1409d40e0eSAntonio Nino Diaz #include <drivers/generic_delay_timer.h> 15bd9344f6SAntonio Nino Diaz #include <plat/arm/common/plat_arm.h> 1609d40e0eSAntonio Nino Diaz #include <plat/common/platform.h> 1709d40e0eSAntonio Nino Diaz 18dcda29f6SYatharth Kochar /* Weak definitions may be overridden in specific ARM standard platform */ 19dcda29f6SYatharth Kochar #pragma weak bl2u_platform_setup 20dcda29f6SYatharth Kochar #pragma weak bl2u_early_platform_setup 21dcda29f6SYatharth Kochar #pragma weak bl2u_plat_arch_setup 22dcda29f6SYatharth Kochar 23d323af9eSDaniel Boulby #define MAP_BL2U_TOTAL MAP_REGION_FLAT( \ 24d323af9eSDaniel Boulby BL2U_BASE, \ 25d323af9eSDaniel Boulby BL2U_LIMIT - BL2U_BASE, \ 26d323af9eSDaniel Boulby MT_MEMORY | MT_RW | MT_SECURE) 27d323af9eSDaniel Boulby 28dcda29f6SYatharth Kochar /* 29dcda29f6SYatharth Kochar * Perform ARM standard platform setup for BL2U 30dcda29f6SYatharth Kochar */ 31dcda29f6SYatharth Kochar void arm_bl2u_platform_setup(void) 32dcda29f6SYatharth Kochar { 33dcda29f6SYatharth Kochar /* Initialize the secure environment */ 34dcda29f6SYatharth Kochar plat_arm_security_setup(); 35dcda29f6SYatharth Kochar } 36dcda29f6SYatharth Kochar 37dcda29f6SYatharth Kochar void bl2u_platform_setup(void) 38dcda29f6SYatharth Kochar { 39dcda29f6SYatharth Kochar arm_bl2u_platform_setup(); 40dcda29f6SYatharth Kochar } 41dcda29f6SYatharth Kochar 426c77e749SSandrine Bailleux void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info) 43dcda29f6SYatharth Kochar { 44dcda29f6SYatharth Kochar /* Initialize the console to provide early debug support */ 4588a0523eSAntonio Nino Diaz arm_console_boot_init(); 4688a0523eSAntonio Nino Diaz 4774847ab2SSoby Mathew generic_delay_timer_init(); 48dcda29f6SYatharth Kochar } 49dcda29f6SYatharth Kochar 50dcda29f6SYatharth Kochar /******************************************************************************* 51dcda29f6SYatharth Kochar * BL1 can pass platform dependent information to BL2U in x1. 52dcda29f6SYatharth Kochar * In case of ARM CSS platforms x1 contains SCP_BL2U image info. 53dcda29f6SYatharth Kochar * In case of ARM FVP platforms x1 is not used. 54dcda29f6SYatharth Kochar * In both cases, x0 contains the extents of the memory available to BL2U 55dcda29f6SYatharth Kochar ******************************************************************************/ 566c77e749SSandrine Bailleux void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info) 57dcda29f6SYatharth Kochar { 58dcda29f6SYatharth Kochar arm_bl2u_early_platform_setup(mem_layout, plat_info); 59dcda29f6SYatharth Kochar } 60dcda29f6SYatharth Kochar 61dcda29f6SYatharth Kochar /******************************************************************************* 62dcda29f6SYatharth Kochar * Perform the very early platform specific architectural setup here. At the 63dcda29f6SYatharth Kochar * moment this is only initializes the mmu in a quick and dirty way. 64dcda29f6SYatharth Kochar * The memory that is used by BL2U is only mapped. 65dcda29f6SYatharth Kochar ******************************************************************************/ 66dcda29f6SYatharth Kochar void arm_bl2u_plat_arch_setup(void) 67dcda29f6SYatharth Kochar { 68d323af9eSDaniel Boulby 69dcda29f6SYatharth Kochar #if USE_COHERENT_MEM 70d323af9eSDaniel Boulby /* Ensure ARM platforms dont use coherent memory in BL2U */ 71d323af9eSDaniel Boulby assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U); 72dcda29f6SYatharth Kochar #endif 73d323af9eSDaniel Boulby 74d323af9eSDaniel Boulby const mmap_region_t bl_regions[] = { 75d323af9eSDaniel Boulby MAP_BL2U_TOTAL, 762ecaafd2SDaniel Boulby ARM_MAP_BL_RO, 771eb735d7SRoberto Vargas #if USE_ROMLIB 781eb735d7SRoberto Vargas ARM_MAP_ROMLIB_CODE, 791eb735d7SRoberto Vargas ARM_MAP_ROMLIB_DATA, 801eb735d7SRoberto Vargas #endif 81d323af9eSDaniel Boulby {0} 82d323af9eSDaniel Boulby }; 83d323af9eSDaniel Boulby 840916c38dSRoberto Vargas setup_page_tables(bl_regions, plat_arm_get_mmap()); 85d323af9eSDaniel Boulby 86*402b3cf8SJulius Werner #ifdef __aarch64__ 87b5fa6563SSandrine Bailleux enable_mmu_el1(0); 88*402b3cf8SJulius Werner #else 89*402b3cf8SJulius Werner enable_mmu_svc_mon(0); 901bd61d0aSYatharth Kochar #endif 911eb735d7SRoberto Vargas arm_setup_romlib(); 92dcda29f6SYatharth Kochar } 93dcda29f6SYatharth Kochar 94dcda29f6SYatharth Kochar void bl2u_plat_arch_setup(void) 95dcda29f6SYatharth Kochar { 96dcda29f6SYatharth Kochar arm_bl2u_plat_arch_setup(); 97dcda29f6SYatharth Kochar } 98