sgi_plat.c 4.2 KB

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