Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 1 | /* |
Petre-Ionut Tudor | e5a6fef | 2019-11-07 15:18:03 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 5 | */ |
| 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 | |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 9 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | |
| 11 | #include <bl32/tsp/platform_tsp.h> |
| 12 | #include <common/bl_common.h> |
| 13 | #include <common/debug.h> |
| 14 | #include <drivers/arm/pl011.h> |
| 15 | #include <drivers/console.h> |
Antonio Nino Diaz | bd7b740 | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 16 | #include <plat/arm/common/plat_arm.h> |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 17 | |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 18 | /* Weak definitions may be overridden in specific ARM standard platform */ |
| 19 | #pragma weak tsp_early_platform_setup |
| 20 | #pragma weak tsp_platform_setup |
| 21 | #pragma weak tsp_plat_arch_setup |
| 22 | |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 23 | #define MAP_BL_TSP_TOTAL MAP_REGION_FLAT( \ |
| 24 | BL32_BASE, \ |
| 25 | BL32_END - BL32_BASE, \ |
| 26 | MT_MEMORY | MT_RW | MT_SECURE) |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 27 | |
| 28 | /******************************************************************************* |
| 29 | * Initialize the UART |
| 30 | ******************************************************************************/ |
Andre Przywara | 2b1b1a5 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 31 | static console_t arm_tsp_runtime_console; |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 32 | |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 33 | void arm_tsp_early_platform_setup(void) |
| 34 | { |
| 35 | /* |
| 36 | * Initialize a different console than already in use to display |
| 37 | * messages from TSP |
| 38 | */ |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 39 | int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE, |
| 40 | PLAT_ARM_TSP_UART_CLK_IN_HZ, |
| 41 | ARM_CONSOLE_BAUDRATE, |
| 42 | &arm_tsp_runtime_console); |
| 43 | if (rc == 0) |
| 44 | panic(); |
| 45 | |
Andre Przywara | 2b1b1a5 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 46 | console_set_scope(&arm_tsp_runtime_console, |
Antonio Nino Diaz | 23ede6a | 2018-06-19 09:29:36 +0100 | [diff] [blame] | 47 | CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | void tsp_early_platform_setup(void) |
| 51 | { |
| 52 | arm_tsp_early_platform_setup(); |
| 53 | } |
| 54 | |
| 55 | /******************************************************************************* |
| 56 | * Perform platform specific setup placeholder |
| 57 | ******************************************************************************/ |
| 58 | void tsp_platform_setup(void) |
| 59 | { |
Achin Gupta | 1fa7eb6 | 2015-11-03 14:18:34 +0000 | [diff] [blame] | 60 | plat_arm_gic_driver_init(); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | /******************************************************************************* |
| 64 | * Perform the very early platform specific architectural setup here. At the |
Elyes Haouas | 2be03c0 | 2023-02-13 09:14:48 +0100 | [diff] [blame] | 65 | * moment this is only initializes the MMU |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 66 | ******************************************************************************/ |
| 67 | void tsp_plat_arch_setup(void) |
| 68 | { |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 69 | #if USE_COHERENT_MEM |
Paul Beesley | 1fbc97b | 2019-01-11 18:26:51 +0000 | [diff] [blame] | 70 | /* Ensure ARM platforms don't use coherent memory in TSP */ |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 71 | assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 72 | #endif |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 73 | |
| 74 | const mmap_region_t bl_regions[] = { |
| 75 | MAP_BL_TSP_TOTAL, |
Daniel Boulby | 4e97abd | 2018-07-16 14:09:15 +0100 | [diff] [blame] | 76 | ARM_MAP_BL_RO, |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 77 | {0} |
| 78 | }; |
| 79 | |
Roberto Vargas | 344ff02 | 2018-10-19 16:44:18 +0100 | [diff] [blame] | 80 | setup_page_tables(bl_regions, plat_arm_get_mmap()); |
Sandrine Bailleux | 4a1267a | 2016-05-18 16:11:47 +0100 | [diff] [blame] | 81 | enable_mmu_el1(0); |
Petre-Ionut Tudor | e5a6fef | 2019-11-07 15:18:03 +0000 | [diff] [blame] | 82 | |
| 83 | #if PLAT_RO_XLAT_TABLES |
| 84 | arm_xlat_make_tables_readonly(); |
| 85 | #endif |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 86 | } |