| 1 |
/* |
| 2 |
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <assert.h> |
| 8 |
#include <string.h> |
| 9 |
|
| 10 |
#include <platform_def.h> |
| 11 |
|
| 12 |
#include <arch_helpers.h> |
| 13 |
#include <common/bl_common.h> |
| 14 |
#include <drivers/generic_delay_timer.h> |
| 15 |
#include <plat/arm/common/plat_arm.h> |
| 16 |
#include <plat/common/platform.h> |
| 17 |
|
| 18 |
/* Weak definitions may be overridden in specific ARM standard platform */ |
| 19 |
#pragma weak bl2u_platform_setup |
| 20 |
#pragma weak bl2u_early_platform_setup |
| 21 |
#pragma weak bl2u_plat_arch_setup |
| 22 |
|
| 23 |
#define MAP_BL2U_TOTAL MAP_REGION_FLAT( \ |
| 24 |
BL2U_BASE, \ |
| 25 |
BL2U_LIMIT - BL2U_BASE, \ |
| 26 |
MT_MEMORY | MT_RW | MT_SECURE) |
| 27 |
|
| 28 |
/* |
| 29 |
* Perform ARM standard platform setup for BL2U |
| 30 |
*/ |
| 31 |
void arm_bl2u_platform_setup(void) |
| 32 |
{ |
| 33 |
/* Initialize the secure environment */ |
| 34 |
plat_arm_security_setup(); |
| 35 |
} |
| 36 |
|
| 37 |
void bl2u_platform_setup(void) |
| 38 |
{ |
| 39 |
arm_bl2u_platform_setup(); |
| 40 |
} |
| 41 |
|
| 42 |
void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info) |
| 43 |
{ |
| 44 |
/* Initialize the console to provide early debug support */ |
| 45 |
arm_console_boot_init(); |
| 46 |
|
| 47 |
generic_delay_timer_init(); |
| 48 |
} |
| 49 |
|
| 50 |
/******************************************************************************* |
| 51 |
* BL1 can pass platform dependent information to BL2U in x1. |
| 52 |
* In case of ARM CSS platforms x1 contains SCP_BL2U image info. |
| 53 |
* In case of ARM FVP platforms x1 is not used. |
| 54 |
* In both cases, x0 contains the extents of the memory available to BL2U |
| 55 |
******************************************************************************/ |
| 56 |
void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info) |
| 57 |
{ |
| 58 |
arm_bl2u_early_platform_setup(mem_layout, plat_info); |
| 59 |
} |
| 60 |
|
| 61 |
/******************************************************************************* |
| 62 |
* Perform the very early platform specific architectural setup here. At the |
| 63 |
* moment this is only initializes the mmu in a quick and dirty way. |
| 64 |
* The memory that is used by BL2U is only mapped. |
| 65 |
******************************************************************************/ |
| 66 |
void arm_bl2u_plat_arch_setup(void) |
| 67 |
{ |
| 68 |
|
| 69 |
#if USE_COHERENT_MEM |
| 70 |
/* Ensure ARM platforms dont use coherent memory in BL2U */ |
| 71 |
assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U); |
| 72 |
#endif |
| 73 |
|
| 74 |
const mmap_region_t bl_regions[] = { |
| 75 |
MAP_BL2U_TOTAL, |
| 76 |
ARM_MAP_BL_RO, |
| 77 |
#if USE_ROMLIB |
| 78 |
ARM_MAP_ROMLIB_CODE, |
| 79 |
ARM_MAP_ROMLIB_DATA, |
| 80 |
#endif |
| 81 |
{0} |
| 82 |
}; |
| 83 |
|
| 84 |
setup_page_tables(bl_regions, plat_arm_get_mmap()); |
| 85 |
|
| 86 |
#ifdef __aarch64__ |
| 87 |
enable_mmu_el1(0); |
| 88 |
#else |
| 89 |
enable_mmu_svc_mon(0); |
| 90 |
#endif |
| 91 |
arm_setup_romlib(); |
| 92 |
} |
| 93 |
|
| 94 |
void bl2u_plat_arch_setup(void) |
| 95 |
{ |
| 96 |
arm_bl2u_plat_arch_setup(); |
| 97 |
} |