arm_spm_def.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef ARM_SPM_DEF_H
  7. #define ARM_SPM_DEF_H
  8. #include <lib/utils_def.h>
  9. #include <lib/xlat_tables/xlat_tables_defs.h>
  10. /*
  11. * If BL31 is placed in DRAM, place the Secure Partition in DRAM right after the
  12. * region used by BL31. If BL31 it is placed in SRAM, put the Secure Partition
  13. * at the base of DRAM.
  14. */
  15. #define ARM_SP_IMAGE_BASE BL32_BASE
  16. #define ARM_SP_IMAGE_LIMIT BL32_LIMIT
  17. /* The maximum size of the S-EL0 payload can be 3MB */
  18. #define ARM_SP_IMAGE_SIZE ULL(0x300000)
  19. #ifdef IMAGE_BL2
  20. /* SPM Payload memory. Mapped as RW in BL2. */
  21. #define ARM_SP_IMAGE_MMAP MAP_REGION_FLAT( \
  22. ARM_SP_IMAGE_BASE, \
  23. ARM_SP_IMAGE_SIZE, \
  24. MT_MEMORY | MT_RW | MT_SECURE)
  25. #endif
  26. #ifdef IMAGE_BL31
  27. /* SPM Payload memory. Mapped as code in S-EL1 */
  28. #define ARM_SP_IMAGE_MMAP MAP_REGION2( \
  29. ARM_SP_IMAGE_BASE, \
  30. ARM_SP_IMAGE_BASE, \
  31. ARM_SP_IMAGE_SIZE, \
  32. MT_CODE | MT_SECURE | MT_USER, \
  33. PAGE_SIZE)
  34. #endif
  35. /*
  36. * Memory shared between EL3 and S-EL0. It is used by EL3 to push data into
  37. * S-EL0, so it is mapped with RW permission from EL3 and with RO permission
  38. * from S-EL0. Placed after SPM Payload memory.
  39. */
  40. #define PLAT_SPM_BUF_BASE (ARM_SP_IMAGE_BASE + ARM_SP_IMAGE_SIZE)
  41. #define PLAT_SPM_BUF_SIZE ULL(0x100000)
  42. #define ARM_SPM_BUF_EL3_MMAP MAP_REGION_FLAT( \
  43. PLAT_SPM_BUF_BASE, \
  44. PLAT_SPM_BUF_SIZE, \
  45. MT_RW_DATA | MT_SECURE)
  46. #define ARM_SPM_BUF_EL0_MMAP MAP_REGION2( \
  47. PLAT_SPM_BUF_BASE, \
  48. PLAT_SPM_BUF_BASE, \
  49. PLAT_SPM_BUF_SIZE, \
  50. MT_RO_DATA | MT_SECURE | MT_USER,\
  51. PAGE_SIZE)
  52. /*
  53. * Memory shared between Normal world and S-EL0 for passing data during service
  54. * requests. Mapped as RW and NS. Placed after the shared memory between EL3 and
  55. * S-EL0.
  56. */
  57. #define PLAT_SP_IMAGE_NS_BUF_BASE (PLAT_SPM_BUF_BASE + PLAT_SPM_BUF_SIZE)
  58. #define PLAT_SP_IMAGE_NS_BUF_SIZE ULL(0x10000)
  59. #define ARM_SP_IMAGE_NS_BUF_MMAP MAP_REGION2( \
  60. PLAT_SP_IMAGE_NS_BUF_BASE, \
  61. PLAT_SP_IMAGE_NS_BUF_BASE, \
  62. PLAT_SP_IMAGE_NS_BUF_SIZE, \
  63. MT_RW_DATA | MT_NS | MT_USER, \
  64. PAGE_SIZE)
  65. /*
  66. * RW memory, which uses the remaining Trusted DRAM. Placed after the memory
  67. * shared between Secure and Non-secure worlds, or after the platform specific
  68. * buffers, if defined. First there is the stack memory for all CPUs and then
  69. * there is the common heap memory. Both are mapped with RW permissions.
  70. */
  71. #define PLAT_SP_IMAGE_STACK_BASE PLAT_ARM_SP_IMAGE_STACK_BASE
  72. #define PLAT_SP_IMAGE_STACK_PCPU_SIZE ULL(0x2000)
  73. #define ARM_SP_IMAGE_STACK_TOTAL_SIZE (PLATFORM_CORE_COUNT * \
  74. PLAT_SP_IMAGE_STACK_PCPU_SIZE)
  75. #define ARM_SP_IMAGE_HEAP_BASE (PLAT_SP_IMAGE_STACK_BASE + \
  76. ARM_SP_IMAGE_STACK_TOTAL_SIZE)
  77. #define ARM_SP_IMAGE_HEAP_SIZE (ARM_SP_IMAGE_LIMIT - ARM_SP_IMAGE_HEAP_BASE)
  78. #define ARM_SP_IMAGE_RW_MMAP MAP_REGION2( \
  79. PLAT_SP_IMAGE_STACK_BASE, \
  80. PLAT_SP_IMAGE_STACK_BASE, \
  81. (ARM_SP_IMAGE_LIMIT - \
  82. PLAT_SP_IMAGE_STACK_BASE), \
  83. MT_RW_DATA | MT_SECURE | MT_USER,\
  84. PAGE_SIZE)
  85. /* Total number of memory regions with distinct properties */
  86. #define ARM_SP_IMAGE_NUM_MEM_REGIONS 6
  87. /* Cookies passed to the Secure Partition at boot. Not used by ARM platforms. */
  88. #define PLAT_SPM_COOKIE_0 ULL(0)
  89. #define PLAT_SPM_COOKIE_1 ULL(0)
  90. #endif /* ARM_SPM_DEF_H */