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