nrd_plat1.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Copyright (c) 2018-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 <common/bl_common.h>
  9. #include <common/debug.h>
  10. #include <drivers/arm/ccn.h>
  11. #include <drivers/arm/css/sds.h>
  12. #include <lib/utils_def.h>
  13. #include <plat/arm/common/plat_arm.h>
  14. #include <plat/common/platform.h>
  15. #include <drivers/arm/sbsa.h>
  16. #if SPM_MM
  17. #include <services/spm_mm_partition.h>
  18. #endif
  19. /*
  20. * Table of regions for different BL stages to map using the MMU.
  21. * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
  22. * arm_configure_mmu_elx() will give the available subset of that.
  23. *
  24. * Replace or extend the below regions as required
  25. */
  26. #if IMAGE_BL1
  27. const mmap_region_t plat_arm_mmap[] = {
  28. ARM_MAP_SHARED_RAM,
  29. NRD_MAP_FLASH0_RO,
  30. NRD_CSS_PERIPH_MMAP(0),
  31. NRD_ROS_PERIPH_MMAP(0),
  32. {0}
  33. };
  34. #endif
  35. #if IMAGE_BL2
  36. const mmap_region_t plat_arm_mmap[] = {
  37. ARM_MAP_SHARED_RAM,
  38. NRD_MAP_FLASH0_RO,
  39. #ifdef PLAT_ARM_MEM_PROT_ADDR
  40. ARM_V2M_MAP_MEM_PROTECT,
  41. #endif
  42. NRD_CSS_PERIPH_MMAP(0),
  43. NRD_ROS_PERIPH_MMAP(0),
  44. ARM_MAP_NS_DRAM1,
  45. #if NRD_CHIP_COUNT > 1
  46. NRD_CSS_PERIPH_MMAP(1),
  47. #endif
  48. #if NRD_CHIP_COUNT > 2
  49. NRD_CSS_PERIPH_MMAP(2),
  50. #endif
  51. #if NRD_CHIP_COUNT > 3
  52. NRD_CSS_PERIPH_MMAP(3),
  53. #endif
  54. #if ARM_BL31_IN_DRAM
  55. ARM_MAP_BL31_SEC_DRAM,
  56. #endif
  57. #if SPM_MM
  58. ARM_SP_IMAGE_MMAP,
  59. #endif
  60. #if TRUSTED_BOARD_BOOT && !RESET_TO_BL2
  61. ARM_MAP_BL1_RW,
  62. #endif
  63. {0}
  64. };
  65. #endif
  66. #if IMAGE_BL31
  67. const mmap_region_t plat_arm_mmap[] = {
  68. ARM_MAP_SHARED_RAM,
  69. V2M_MAP_IOFPGA,
  70. NRD_CSS_PERIPH_MMAP(0),
  71. #ifdef PLAT_ARM_MEM_PROT_ADDR
  72. ARM_V2M_MAP_MEM_PROTECT,
  73. #endif
  74. NRD_ROS_PERIPH_MMAP(0),
  75. #if SPM_MM
  76. ARM_SPM_BUF_EL3_MMAP,
  77. #endif
  78. {0}
  79. };
  80. #if SPM_MM && defined(IMAGE_BL31)
  81. const mmap_region_t plat_arm_secure_partition_mmap[] = {
  82. NRD_ROS_SECURE_SYSTEMREG_USER_MMAP,
  83. NRD_ROS_SECURE_NOR2_USER_MMAP,
  84. NRD_CSS_SECURE_UART_MMAP,
  85. ARM_SP_IMAGE_MMAP,
  86. ARM_SP_IMAGE_NS_BUF_MMAP,
  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] = {0x81000100, 0},
  102. [2] = {0x81000200, 0},
  103. [3] = {0x81000300, 0},
  104. [4] = {0x81010000, 0},
  105. [5] = {0x81010100, 0},
  106. [6] = {0x81010200, 0},
  107. [7] = {0x81010300, 0},
  108. };
  109. const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = {
  110. .h.type = PARAM_SP_IMAGE_BOOT_INFO,
  111. .h.version = VERSION_1,
  112. .h.size = sizeof(spm_mm_boot_info_t),
  113. .h.attr = 0,
  114. .sp_mem_base = ARM_SP_IMAGE_BASE,
  115. .sp_mem_limit = ARM_SP_IMAGE_LIMIT,
  116. .sp_image_base = ARM_SP_IMAGE_BASE,
  117. .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE,
  118. .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE,
  119. .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE,
  120. .sp_shared_buf_base = PLAT_SPM_BUF_BASE,
  121. .sp_image_size = ARM_SP_IMAGE_SIZE,
  122. .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE,
  123. .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE,
  124. .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE,
  125. .sp_shared_buf_size = PLAT_SPM_BUF_SIZE,
  126. .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS,
  127. .num_cpus = PLATFORM_CORE_COUNT,
  128. .mp_info = &sp_mp_info[0],
  129. };
  130. const struct mmap_region *plat_get_secure_partition_mmap(void *cookie)
  131. {
  132. return plat_arm_secure_partition_mmap;
  133. }
  134. const struct spm_mm_boot_info *plat_get_secure_partition_boot_info(
  135. void *cookie)
  136. {
  137. return &plat_arm_secure_partition_boot_info;
  138. }
  139. #endif /* SPM_MM && defined(IMAGE_BL31) */
  140. #if TRUSTED_BOARD_BOOT
  141. int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
  142. {
  143. assert(heap_addr != NULL);
  144. assert(heap_size != NULL);
  145. return arm_get_mbedtls_heap(heap_addr, heap_size);
  146. }
  147. #endif
  148. void plat_arm_secure_wdt_start(void)
  149. {
  150. sbsa_wdog_start(NRD_CSS_WDOG_BASE, NRD_CSS_WDOG_TIMEOUT);
  151. }
  152. void plat_arm_secure_wdt_stop(void)
  153. {
  154. sbsa_wdog_stop(NRD_CSS_WDOG_BASE);
  155. }
  156. static sds_region_desc_t nrd_sds_regions[] = {
  157. { .base = PLAT_ARM_SDS_MEM_BASE },
  158. };
  159. sds_region_desc_t *plat_sds_get_regions(unsigned int *region_count)
  160. {
  161. *region_count = ARRAY_SIZE(nrd_sds_regions);
  162. return nrd_sds_regions;
  163. }