Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 6 | |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
| 9 | #include <drivers/generic_delay_timer.h> |
| 10 | #include <plat/common/platform.h> |
Antonio Nino Diaz | a320ecd | 2019-01-15 14:19:50 +0000 | [diff] [blame] | 11 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | |
Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 13 | #include <plat_arm.h> |
Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 14 | |
| 15 | #pragma weak bl2_el3_early_platform_setup |
| 16 | #pragma weak bl2_el3_plat_arch_setup |
| 17 | #pragma weak bl2_el3_plat_prepare_exit |
| 18 | |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 19 | #define MAP_BL2_EL3_TOTAL MAP_REGION_FLAT( \ |
| 20 | bl2_el3_tzram_layout.total_base, \ |
| 21 | bl2_el3_tzram_layout.total_size, \ |
| 22 | MT_MEMORY | MT_RW | MT_SECURE) |
| 23 | |
Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 24 | static meminfo_t bl2_el3_tzram_layout; |
| 25 | |
| 26 | /* |
| 27 | * Perform arm specific early platform setup. At this moment we only initialize |
| 28 | * the console and the memory layout. |
| 29 | */ |
| 30 | void arm_bl2_el3_early_platform_setup(void) |
| 31 | { |
| 32 | /* Initialize the console to provide early debug support */ |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 33 | arm_console_boot_init(); |
Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 34 | |
| 35 | /* |
| 36 | * Allow BL2 to see the whole Trusted RAM. This is determined |
| 37 | * statically since we cannot rely on BL1 passing this information |
| 38 | * in the BL2_AT_EL3 case. |
| 39 | */ |
| 40 | bl2_el3_tzram_layout.total_base = ARM_BL_RAM_BASE; |
| 41 | bl2_el3_tzram_layout.total_size = ARM_BL_RAM_SIZE; |
| 42 | |
| 43 | /* Initialise the IO layer and register platform IO devices */ |
| 44 | plat_arm_io_setup(); |
| 45 | } |
| 46 | |
| 47 | void bl2_el3_early_platform_setup(u_register_t arg0 __unused, |
| 48 | u_register_t arg1 __unused, |
| 49 | u_register_t arg2 __unused, |
| 50 | u_register_t arg3 __unused) |
| 51 | { |
| 52 | arm_bl2_el3_early_platform_setup(); |
| 53 | |
| 54 | /* |
| 55 | * Initialize Interconnect for this cluster during cold boot. |
| 56 | * No need for locks as no other CPU is active. |
| 57 | */ |
| 58 | plat_arm_interconnect_init(); |
| 59 | /* |
| 60 | * Enable Interconnect coherency for the primary CPU's cluster. |
| 61 | */ |
| 62 | plat_arm_interconnect_enter_coherency(); |
| 63 | |
| 64 | generic_delay_timer_init(); |
| 65 | } |
| 66 | |
| 67 | /******************************************************************************* |
| 68 | * Perform the very early platform specific architectural setup here. At the |
| 69 | * moment this is only initializes the mmu in a quick and dirty way. |
| 70 | ******************************************************************************/ |
| 71 | void arm_bl2_el3_plat_arch_setup(void) |
| 72 | { |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 73 | |
Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 74 | #if USE_COHERENT_MEM |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 75 | /* Ensure ARM platforms dont use coherent memory in BL2_AT_EL3 */ |
| 76 | assert(BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE == 0U); |
Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 77 | #endif |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 78 | |
| 79 | const mmap_region_t bl_regions[] = { |
| 80 | MAP_BL2_EL3_TOTAL, |
Daniel Boulby | 4e97abd | 2018-07-16 14:09:15 +0100 | [diff] [blame] | 81 | ARM_MAP_BL_RO, |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 82 | {0} |
| 83 | }; |
| 84 | |
Roberto Vargas | 344ff02 | 2018-10-19 16:44:18 +0100 | [diff] [blame] | 85 | setup_page_tables(bl_regions, plat_arm_get_mmap()); |
Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 86 | |
| 87 | #ifdef AARCH32 |
Antonio Nino Diaz | 533d3a8 | 2018-08-07 16:35:19 +0100 | [diff] [blame] | 88 | enable_mmu_svc_mon(0); |
Roberto Vargas | 5220780 | 2017-11-17 13:22:18 +0000 | [diff] [blame] | 89 | #else |
| 90 | enable_mmu_el3(0); |
| 91 | #endif |
| 92 | } |
| 93 | |
| 94 | void bl2_el3_plat_arch_setup(void) |
| 95 | { |
| 96 | arm_bl2_el3_plat_arch_setup(); |
| 97 | } |
| 98 | |
| 99 | void bl2_el3_plat_prepare_exit(void) |
| 100 | { |
| 101 | } |