1 /* 2 * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * Redistributions of source code must retain the above copyright notice, this 8 * list of conditions and the following disclaimer. 9 * 10 * Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 14 * Neither the name of ARM nor the names of its contributors may be used 15 * to endorse or promote products derived from this software without specific 16 * prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #include <arch_helpers.h> 32 #include <arm_def.h> 33 #include <bl_common.h> 34 #include <console.h> 35 #include <platform_def.h> 36 #include <plat_arm.h> 37 #include <string.h> 38 39 #if USE_COHERENT_MEM 40 /* 41 * The next 2 constants identify the extents of the coherent memory region. 42 * These addresses are used by the MMU setup code and therefore they must be 43 * page-aligned. It is the responsibility of the linker script to ensure that 44 * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols refer to 45 * page-aligned addresses. 46 */ 47 #define BL2U_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__) 48 #define BL2U_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__) 49 #endif 50 51 /* Weak definitions may be overridden in specific ARM standard platform */ 52 #pragma weak bl2u_platform_setup 53 #pragma weak bl2u_early_platform_setup 54 #pragma weak bl2u_plat_arch_setup 55 56 /* 57 * Perform ARM standard platform setup for BL2U 58 */ 59 void arm_bl2u_platform_setup(void) 60 { 61 /* Initialize the secure environment */ 62 plat_arm_security_setup(); 63 } 64 65 void bl2u_platform_setup(void) 66 { 67 arm_bl2u_platform_setup(); 68 } 69 70 void arm_bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info) 71 { 72 /* Initialize the console to provide early debug support */ 73 console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ, 74 ARM_CONSOLE_BAUDRATE); 75 } 76 77 /******************************************************************************* 78 * BL1 can pass platform dependent information to BL2U in x1. 79 * In case of ARM CSS platforms x1 contains SCP_BL2U image info. 80 * In case of ARM FVP platforms x1 is not used. 81 * In both cases, x0 contains the extents of the memory available to BL2U 82 ******************************************************************************/ 83 void bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info) 84 { 85 arm_bl2u_early_platform_setup(mem_layout, plat_info); 86 } 87 88 /******************************************************************************* 89 * Perform the very early platform specific architectural setup here. At the 90 * moment this is only initializes the mmu in a quick and dirty way. 91 * The memory that is used by BL2U is only mapped. 92 ******************************************************************************/ 93 void arm_bl2u_plat_arch_setup(void) 94 { 95 arm_setup_page_tables(BL2U_BASE, 96 BL31_LIMIT, 97 BL_CODE_BASE, 98 BL_CODE_LIMIT, 99 BL_RO_DATA_BASE, 100 BL_RO_DATA_LIMIT 101 #if USE_COHERENT_MEM 102 , 103 BL2U_COHERENT_RAM_BASE, 104 BL2U_COHERENT_RAM_LIMIT 105 #endif 106 ); 107 enable_mmu_el1(0); 108 } 109 110 void bl2u_plat_arch_setup(void) 111 { 112 arm_bl2u_plat_arch_setup(); 113 } 114