arm_tsp_setup.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <platform_def.h>
  8. #include <bl32/tsp/platform_tsp.h>
  9. #include <common/bl_common.h>
  10. #include <common/debug.h>
  11. #include <drivers/arm/pl011.h>
  12. #include <drivers/console.h>
  13. #include <plat/arm/common/plat_arm.h>
  14. /* Weak definitions may be overridden in specific ARM standard platform */
  15. #pragma weak tsp_early_platform_setup
  16. #pragma weak tsp_platform_setup
  17. #pragma weak tsp_plat_arch_setup
  18. #define MAP_BL_TSP_TOTAL MAP_REGION_FLAT( \
  19. BL32_BASE, \
  20. BL32_END - BL32_BASE, \
  21. MT_MEMORY | MT_RW | MT_SECURE)
  22. /*******************************************************************************
  23. * Initialize the UART
  24. ******************************************************************************/
  25. static console_t arm_tsp_runtime_console;
  26. void arm_tsp_early_platform_setup(void)
  27. {
  28. /*
  29. * Initialize a different console than already in use to display
  30. * messages from TSP
  31. */
  32. int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE,
  33. PLAT_ARM_TSP_UART_CLK_IN_HZ,
  34. ARM_CONSOLE_BAUDRATE,
  35. &arm_tsp_runtime_console);
  36. if (rc == 0)
  37. panic();
  38. console_set_scope(&arm_tsp_runtime_console,
  39. CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
  40. }
  41. void tsp_early_platform_setup(void)
  42. {
  43. arm_tsp_early_platform_setup();
  44. }
  45. /*******************************************************************************
  46. * Perform platform specific setup placeholder
  47. ******************************************************************************/
  48. void tsp_platform_setup(void)
  49. {
  50. plat_arm_gic_driver_init();
  51. }
  52. /*******************************************************************************
  53. * Perform the very early platform specific architectural setup here. At the
  54. * moment this is only initializes the MMU
  55. ******************************************************************************/
  56. void tsp_plat_arch_setup(void)
  57. {
  58. #if USE_COHERENT_MEM
  59. /* Ensure ARM platforms don't use coherent memory in TSP */
  60. assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
  61. #endif
  62. const mmap_region_t bl_regions[] = {
  63. MAP_BL_TSP_TOTAL,
  64. ARM_MAP_BL_RO,
  65. {0}
  66. };
  67. setup_page_tables(bl_regions, plat_arm_get_mmap());
  68. enable_mmu_el1(0);
  69. #if PLAT_RO_XLAT_TABLES
  70. arm_xlat_make_tables_readonly();
  71. #endif
  72. }