nrd_plat2.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright (c) 2021-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 <lib/utils_def.h>
  9. #include <drivers/arm/css/sds.h>
  10. #include <drivers/arm/sbsa.h>
  11. #include <plat/arm/common/plat_arm.h>
  12. #include <plat/common/platform.h>
  13. #if SPM_MM
  14. #include <services/spm_mm_partition.h>
  15. #endif
  16. /*
  17. * Table of regions for different BL stages to map using the MMU.
  18. */
  19. #if IMAGE_BL1
  20. const mmap_region_t plat_arm_mmap[] = {
  21. NRD_CSS_SHARED_RAM_MMAP(0),
  22. NRD_ROS_FLASH0_RO_MMAP,
  23. NRD_CSS_PERIPH_MMAP(0),
  24. NRD_ROS_PLATFORM_PERIPH_MMAP,
  25. NRD_ROS_SYSTEM_PERIPH_MMAP,
  26. {0}
  27. };
  28. #endif
  29. #if IMAGE_BL2
  30. const mmap_region_t plat_arm_mmap[] = {
  31. NRD_CSS_SHARED_RAM_MMAP(0),
  32. NRD_ROS_FLASH0_RO_MMAP,
  33. #ifdef PLAT_ARM_MEM_PROT_ADDR
  34. ARM_V2M_MAP_MEM_PROTECT,
  35. #endif
  36. NRD_CSS_PERIPH_MMAP(0),
  37. NRD_ROS_MEMCNTRL_MMAP(0),
  38. NRD_ROS_PLATFORM_PERIPH_MMAP,
  39. NRD_ROS_SYSTEM_PERIPH_MMAP,
  40. ARM_MAP_NS_DRAM1,
  41. #if NRD_CHIP_COUNT > 1
  42. NRD_ROS_MEMCNTRL_MMAP(1),
  43. #endif
  44. #if NRD_CHIP_COUNT > 2
  45. NRD_ROS_MEMCNTRL_MMAP(2),
  46. #endif
  47. #if NRD_CHIP_COUNT > 3
  48. NRD_ROS_MEMCNTRL_MMAP(3),
  49. #endif
  50. #if ARM_BL31_IN_DRAM
  51. ARM_MAP_BL31_SEC_DRAM,
  52. #endif
  53. #if SPM_MM || (SPMC_AT_EL3 && SPMC_AT_EL3_SEL0_SP)
  54. ARM_SP_IMAGE_MMAP,
  55. #endif
  56. #if TRUSTED_BOARD_BOOT && !RESET_TO_BL2
  57. ARM_MAP_BL1_RW,
  58. #endif
  59. {0}
  60. };
  61. #endif
  62. #if IMAGE_BL31
  63. const mmap_region_t plat_arm_mmap[] = {
  64. NRD_CSS_SHARED_RAM_MMAP(0),
  65. #ifdef PLAT_ARM_MEM_PROT_ADDR
  66. ARM_V2M_MAP_MEM_PROTECT,
  67. #endif
  68. NRD_CSS_PERIPH_MMAP(0),
  69. NRD_ROS_PLATFORM_PERIPH_MMAP,
  70. NRD_ROS_SYSTEM_PERIPH_MMAP,
  71. #if SPM_MM || (SPMC_AT_EL3 && SPMC_AT_EL3_SEL0_SP)
  72. ARM_SPM_BUF_EL3_MMAP,
  73. #endif
  74. {0}
  75. };
  76. #if SPM_MM && defined(IMAGE_BL31)
  77. const mmap_region_t plat_arm_secure_partition_mmap[] = {
  78. NRD_ROS_SECURE_SYSTEMREG_USER_MMAP,
  79. NRD_ROS_SECURE_NOR2_USER_MMAP,
  80. NRD_CSS_SECURE_UART_USER_MMAP,
  81. NRD_ROS_PLATFORM_PERIPH_USER_MMAP,
  82. ARM_SP_IMAGE_MMAP,
  83. ARM_SP_IMAGE_NS_BUF_MMAP,
  84. #if ENABLE_FEAT_RAS && FFH_SUPPORT
  85. NRD_CSS_SP_CPER_BUF_MMAP,
  86. #endif
  87. ARM_SP_IMAGE_RW_MMAP,
  88. ARM_SPM_BUF_EL0_MMAP,
  89. {0}
  90. };
  91. #endif /* SPM_MM && defined(IMAGE_BL31) */
  92. #endif
  93. ARM_CASSERT_MMAP
  94. #if SPM_MM && defined(IMAGE_BL31)
  95. /*
  96. * Boot information passed to a secure partition during initialisation. Linear
  97. * indices in MP information will be filled at runtime.
  98. */
  99. static spm_mm_mp_info_t sp_mp_info[] = {
  100. [0] = {0x81000000, 0},
  101. [1] = {0x81010000, 0},
  102. [2] = {0x81020000, 0},
  103. [3] = {0x81030000, 0},
  104. [4] = {0x81040000, 0},
  105. [5] = {0x81050000, 0},
  106. [6] = {0x81060000, 0},
  107. [7] = {0x81070000, 0},
  108. [8] = {0x81080000, 0},
  109. [9] = {0x81090000, 0},
  110. [10] = {0x810a0000, 0},
  111. [11] = {0x810b0000, 0},
  112. [12] = {0x810c0000, 0},
  113. [13] = {0x810d0000, 0},
  114. [14] = {0x810e0000, 0},
  115. [15] = {0x810f0000, 0},
  116. };
  117. const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = {
  118. .h.type = PARAM_SP_IMAGE_BOOT_INFO,
  119. .h.version = VERSION_1,
  120. .h.size = sizeof(spm_mm_boot_info_t),
  121. .h.attr = 0,
  122. .sp_mem_base = ARM_SP_IMAGE_BASE,
  123. .sp_mem_limit = ARM_SP_IMAGE_LIMIT,
  124. .sp_image_base = ARM_SP_IMAGE_BASE,
  125. .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE,
  126. .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE,
  127. .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE,
  128. .sp_shared_buf_base = PLAT_SPM_BUF_BASE,
  129. .sp_image_size = ARM_SP_IMAGE_SIZE,
  130. .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
  131. .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE,
  132. .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE,
  133. .sp_shared_buf_size = PLAT_SPM_BUF_SIZE,
  134. .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS,
  135. .num_cpus = PLATFORM_CORE_COUNT,
  136. .mp_info = &sp_mp_info[0],
  137. };
  138. const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
  139. {
  140. return plat_arm_secure_partition_mmap;
  141. }
  142. const struct spm_mm_boot_info *plat_get_secure_partition_boot_info(
  143. void *cookie)
  144. {
  145. return &plat_arm_secure_partition_boot_info;
  146. }
  147. #endif /* SPM_MM && defined(IMAGE_BL31) */
  148. #if TRUSTED_BOARD_BOOT
  149. int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
  150. {
  151. assert(heap_addr != NULL);
  152. assert(heap_size != NULL);
  153. return arm_get_mbedtls_heap(heap_addr, heap_size);
  154. }
  155. #endif
  156. void plat_arm_secure_wdt_start(void)
  157. {
  158. sbsa_wdog_start(NRD_CSS_SECURE_WDOG_BASE, NRD_CSS_SECURE_WDOG_TIMEOUT);
  159. }
  160. void plat_arm_secure_wdt_stop(void)
  161. {
  162. sbsa_wdog_stop(NRD_CSS_SECURE_WDOG_BASE);
  163. }
  164. static sds_region_desc_t nrd_sds_regions[] = {
  165. { .base = PLAT_ARM_SDS_MEM_BASE },
  166. };
  167. sds_region_desc_t *plat_sds_get_regions(unsigned int *region_count)
  168. {
  169. *region_count = ARRAY_SIZE(nrd_sds_regions);
  170. return nrd_sds_regions;
  171. }