tc_plat.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (c) 2020-2024, 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 <plat/common/platform.h>
  9. #include <common/bl_common.h>
  10. #include <common/debug.h>
  11. #include <drivers/arm/ccn.h>
  12. #include <drivers/arm/css/sds.h>
  13. #include <lib/utils_def.h>
  14. #include <plat/arm/common/plat_arm.h>
  15. #include <plat/common/platform.h>
  16. #include <drivers/arm/sbsa.h>
  17. #if SPM_MM
  18. #include <services/spm_mm_partition.h>
  19. #endif
  20. /*
  21. * Table of regions for different BL stages to map using the MMU.
  22. * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
  23. * arm_configure_mmu_elx() will give the available subset of that.
  24. */
  25. #if IMAGE_BL1
  26. const mmap_region_t plat_arm_mmap[] = {
  27. ARM_MAP_SHARED_RAM,
  28. TC_MAP_NS_DRAM1,
  29. TC_FLASH0_RO,
  30. TC_MAP_DEVICE,
  31. {0}
  32. };
  33. #endif
  34. #if IMAGE_BL2
  35. const mmap_region_t plat_arm_mmap[] = {
  36. ARM_MAP_SHARED_RAM,
  37. TC_FLASH0_RO,
  38. TC_MAP_DEVICE,
  39. TC_MAP_NS_DRAM1,
  40. #if defined(SPD_spmd)
  41. TC_MAP_TZC_DRAM1,
  42. #endif
  43. #if ARM_BL31_IN_DRAM
  44. ARM_MAP_BL31_SEC_DRAM,
  45. #endif
  46. #if SPM_MM
  47. ARM_SP_IMAGE_MMAP,
  48. #endif
  49. #if TRUSTED_BOARD_BOOT && !RESET_TO_BL2
  50. ARM_MAP_BL1_RW,
  51. #endif
  52. #ifdef SPD_opteed
  53. ARM_MAP_OPTEE_CORE_MEM,
  54. ARM_OPTEE_PAGEABLE_LOAD_MEM,
  55. #endif
  56. {0}
  57. };
  58. #endif
  59. #if IMAGE_BL31
  60. const mmap_region_t plat_arm_mmap[] = {
  61. ARM_MAP_SHARED_RAM,
  62. V2M_MAP_IOFPGA,
  63. TC_MAP_DEVICE,
  64. PLAT_DTB_DRAM_NS,
  65. #if SPM_MM
  66. ARM_SPM_BUF_EL3_MMAP,
  67. #endif
  68. {0}
  69. };
  70. #if SPM_MM && defined(IMAGE_BL31)
  71. const mmap_region_t plat_arm_secure_partition_mmap[] = {
  72. PLAT_ARM_SECURE_MAP_DEVICE,
  73. ARM_SP_IMAGE_MMAP,
  74. ARM_SP_IMAGE_NS_BUF_MMAP,
  75. ARM_SP_CPER_BUF_MMAP,
  76. ARM_SP_IMAGE_RW_MMAP,
  77. ARM_SPM_BUF_EL0_MMAP,
  78. {0}
  79. };
  80. #endif /* SPM_MM && defined(IMAGE_BL31) */
  81. #endif
  82. ARM_CASSERT_MMAP
  83. #if SPM_MM && defined(IMAGE_BL31)
  84. /*
  85. * Boot information passed to a secure partition during initialisation. Linear
  86. * indices in MP information will be filled at runtime.
  87. */
  88. static spm_mm_mp_info_t sp_mp_info[] = {
  89. [0] = {0x81000000, 0},
  90. [1] = {0x81000100, 0},
  91. [2] = {0x81000200, 0},
  92. [3] = {0x81000300, 0},
  93. [4] = {0x81010000, 0},
  94. [5] = {0x81010100, 0},
  95. [6] = {0x81010200, 0},
  96. [7] = {0x81010300, 0},
  97. };
  98. const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = {
  99. .h.type = PARAM_SP_IMAGE_BOOT_INFO,
  100. .h.version = VERSION_1,
  101. .h.size = sizeof(spm_mm_boot_info_t),
  102. .h.attr = 0,
  103. .sp_mem_base = ARM_SP_IMAGE_BASE,
  104. .sp_mem_limit = ARM_SP_IMAGE_LIMIT,
  105. .sp_image_base = ARM_SP_IMAGE_BASE,
  106. .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE,
  107. .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE,
  108. .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE,
  109. .sp_shared_buf_base = PLAT_SPM_BUF_BASE,
  110. .sp_image_size = ARM_SP_IMAGE_SIZE,
  111. .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
  112. .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE,
  113. .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE,
  114. .sp_shared_buf_size = PLAT_SPM_BUF_SIZE,
  115. .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS,
  116. .num_cpus = PLATFORM_CORE_COUNT,
  117. .mp_info = &sp_mp_info[0],
  118. };
  119. const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
  120. {
  121. return plat_arm_secure_partition_mmap;
  122. }
  123. const struct spm_mm_boot_info *plat_get_secure_partition_boot_info(
  124. void *cookie)
  125. {
  126. return &plat_arm_secure_partition_boot_info;
  127. }
  128. #endif /* SPM_MM && defined(IMAGE_BL31) */
  129. #if TRUSTED_BOARD_BOOT || MEASURED_BOOT
  130. int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
  131. {
  132. assert(heap_addr != NULL);
  133. assert(heap_size != NULL);
  134. return arm_get_mbedtls_heap(heap_addr, heap_size);
  135. }
  136. #endif
  137. void plat_arm_secure_wdt_start(void)
  138. {
  139. sbsa_wdog_start(SBSA_SECURE_WDOG_CONTROL_BASE, SBSA_SECURE_WDOG_TIMEOUT);
  140. }
  141. void plat_arm_secure_wdt_stop(void)
  142. {
  143. sbsa_wdog_stop(SBSA_SECURE_WDOG_CONTROL_BASE);
  144. }
  145. void plat_arm_secure_wdt_refresh(void)
  146. {
  147. sbsa_wdog_refresh(SBSA_SECURE_WDOG_REFRESH_BASE);
  148. }
  149. static sds_region_desc_t tc_sds_regions[] = {
  150. { .base = PLAT_ARM_SDS_MEM_BASE },
  151. { .base = PLAT_ARM_RSE_AP_SDS_MEM_BASE },
  152. };
  153. sds_region_desc_t *plat_sds_get_regions(unsigned int *region_count)
  154. {
  155. *region_count = ARRAY_SIZE(tc_sds_regions);
  156. return tc_sds_regions;
  157. }