1 /* 2 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 #include <errno.h> 9 10 #include <arch_helpers.h> 11 #include <common/bl_common.h> 12 #include <common/debug.h> 13 #include <lib/xlat_tables/xlat_tables_compat.h> 14 #include <plat/common/platform.h> 15 16 /* 17 * The following platform functions are weakly defined. The Platforms 18 * may redefine with strong definition. 19 */ 20 #pragma weak bl2_el3_plat_prepare_exit 21 #pragma weak plat_error_handler 22 #pragma weak bl2_plat_preload_setup 23 #pragma weak bl2_plat_handle_pre_image_load 24 #pragma weak bl2_plat_handle_post_image_load 25 #pragma weak plat_try_next_boot_source 26 bl2_el3_plat_prepare_exit(void)27 void bl2_el3_plat_prepare_exit(void) 28 { 29 } 30 plat_error_handler(int err)31 void __dead2 plat_error_handler(int err) 32 { 33 while (1) 34 wfi(); 35 } 36 bl2_plat_preload_setup(void)37 void bl2_plat_preload_setup(void) 38 { 39 } 40 bl2_plat_handle_pre_image_load(unsigned int image_id)41 int bl2_plat_handle_pre_image_load(unsigned int image_id) 42 { 43 return 0; 44 } 45 bl2_plat_handle_post_image_load(unsigned int image_id)46 int bl2_plat_handle_post_image_load(unsigned int image_id) 47 { 48 return 0; 49 } 50 plat_try_next_boot_source(void)51 int plat_try_next_boot_source(void) 52 { 53 return 0; 54 } 55 56 /* 57 * Set up the page tables for the generic and platform-specific memory regions. 58 * The size of the Trusted SRAM seen by the BL image must be specified as well 59 * as an array specifying the generic memory regions which can be; 60 * - Code section; 61 * - Read-only data section; 62 * - Init code section, if applicable 63 * - Coherent memory region, if applicable. 64 */ 65 setup_page_tables(const mmap_region_t * bl_regions,const mmap_region_t * plat_regions)66 void __init setup_page_tables(const mmap_region_t *bl_regions, 67 const mmap_region_t *plat_regions) 68 { 69 #if LOG_LEVEL >= LOG_LEVEL_VERBOSE 70 const mmap_region_t *regions = bl_regions; 71 72 while (regions->size != 0U) { 73 VERBOSE("Region: 0x%lx - 0x%lx has attributes 0x%x\n", 74 regions->base_va, 75 regions->base_va + regions->size, 76 regions->attr); 77 regions++; 78 } 79 #endif 80 /* 81 * Map the Trusted SRAM with appropriate memory attributes. 82 * Subsequent mappings will adjust the attributes for specific regions. 83 */ 84 mmap_add(bl_regions); 85 86 /* Now (re-)map the platform-specific memory regions */ 87 mmap_add(plat_regions); 88 89 /* Create the page tables to reflect the above mappings */ 90 init_xlat_tables(); 91 } 92