juno_private.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice, this
  8. * list of conditions and the following disclaimer.
  9. *
  10. * Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. *
  14. * Neither the name of ARM nor the names of its contributors may be used
  15. * to endorse or promote products derived from this software without specific
  16. * prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  22. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. * POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef __JUNO_PRIVATE_H__
  31. #define __JUNO_PRIVATE_H__
  32. #include <bakery_lock.h>
  33. #include <bl_common.h>
  34. #include <cpu_data.h>
  35. #include <platform_def.h>
  36. #include <stdint.h>
  37. /*******************************************************************************
  38. * Forward declarations
  39. ******************************************************************************/
  40. struct plat_pm_ops;
  41. struct meminfo;
  42. struct bl31_params;
  43. struct image_info;
  44. struct entry_point_info;
  45. /*******************************************************************************
  46. * This structure represents the superset of information that is passed to
  47. * BL3-1 e.g. while passing control to it from BL2 which is bl31_params
  48. * and other platform specific params
  49. ******************************************************************************/
  50. typedef struct bl2_to_bl31_params_mem {
  51. struct bl31_params bl31_params;
  52. struct image_info bl31_image_info;
  53. struct image_info bl32_image_info;
  54. struct image_info bl33_image_info;
  55. struct entry_point_info bl33_ep_info;
  56. struct entry_point_info bl32_ep_info;
  57. struct entry_point_info bl31_ep_info;
  58. } bl2_to_bl31_params_mem_t;
  59. #if IMAGE_BL31
  60. #if USE_COHERENT_MEM
  61. /*
  62. * These are wrapper macros to the Coherent Memory Bakery Lock API.
  63. */
  64. #define juno_lock_init(_lock_arg) bakery_lock_init(_lock_arg)
  65. #define juno_lock_get(_lock_arg) bakery_lock_get(_lock_arg)
  66. #define juno_lock_release(_lock_arg) bakery_lock_release(_lock_arg)
  67. #else
  68. /*******************************************************************************
  69. * Constants that specify how many bakeries this platform implements and bakery
  70. * ids.
  71. ******************************************************************************/
  72. #define JUNO_MAX_BAKERIES 1
  73. #define JUNO_MHU_BAKERY_ID 0
  74. /*******************************************************************************
  75. * Definition of structure which holds platform specific per-cpu data. Currently
  76. * it holds only the bakery lock information for each cpu. Constants to specify
  77. * how many bakeries this platform implements and bakery ids are specified in
  78. * juno_def.h
  79. ******************************************************************************/
  80. typedef struct juno_cpu_data {
  81. bakery_info_t pcpu_bakery_info[JUNO_MAX_BAKERIES];
  82. } juno_cpu_data_t;
  83. /* Macro to define the offset of bakery_info_t in juno_cpu_data_t */
  84. #define JUNO_CPU_DATA_LOCK_OFFSET __builtin_offsetof\
  85. (juno_cpu_data_t, pcpu_bakery_info)
  86. /*******************************************************************************
  87. * Helper macros for bakery lock api when using the above juno_cpu_data_t for
  88. * bakery lock data structures. It assumes that the bakery_info is at the
  89. * beginning of the platform specific per-cpu data.
  90. ******************************************************************************/
  91. #define juno_lock_init(_lock_arg) /* No init required */
  92. #define juno_lock_get(_lock_arg) bakery_lock_get(_lock_arg, \
  93. CPU_DATA_PLAT_PCPU_OFFSET + \
  94. JUNO_CPU_DATA_LOCK_OFFSET)
  95. #define juno_lock_release(_lock_arg) bakery_lock_release(_lock_arg, \
  96. CPU_DATA_PLAT_PCPU_OFFSET + \
  97. JUNO_CPU_DATA_LOCK_OFFSET)
  98. /*
  99. * Ensure that the size of the Juno specific per-cpu data structure and the size
  100. * of the memory allocated in generic per-cpu data for the platform are the same.
  101. */
  102. CASSERT(PLAT_PCPU_DATA_SIZE == sizeof(juno_cpu_data_t), \
  103. juno_pcpu_data_size_mismatch);
  104. #endif /* __USE_COHERENT_MEM__ */
  105. #else
  106. /*
  107. * Dummy wrapper macros for all other BL stages other than BL3-1
  108. */
  109. #define juno_lock_init(_lock_arg)
  110. #define juno_lock_get(_lock_arg)
  111. #define juno_lock_release(_lock_arg)
  112. #endif /* __IMAGE_BL31__ */
  113. /*******************************************************************************
  114. * Function and variable prototypes
  115. ******************************************************************************/
  116. void bl1_plat_arch_setup(void);
  117. void bl2_plat_arch_setup(void);
  118. void bl31_plat_arch_setup(void);
  119. int platform_setup_pm(const struct plat_pm_ops **plat_ops);
  120. unsigned int platform_get_core_pos(unsigned long mpidr);
  121. void configure_mmu_el1(unsigned long total_base,
  122. unsigned long total_size,
  123. unsigned long ro_start,
  124. unsigned long ro_limit,
  125. unsigned long coh_start,
  126. unsigned long coh_limit);
  127. void configure_mmu_el3(unsigned long total_base,
  128. unsigned long total_size,
  129. unsigned long ro_start,
  130. unsigned long ro_limit,
  131. unsigned long coh_start,
  132. unsigned long coh_limit);
  133. void plat_report_exception(unsigned long type);
  134. unsigned long plat_get_ns_image_entrypoint(void);
  135. unsigned long platform_get_stack(unsigned long mpidr);
  136. uint64_t plat_get_syscnt_freq(void);
  137. void plat_gic_init(void);
  138. /* Declarations for plat_topology.c */
  139. int plat_setup_topology(void);
  140. int plat_get_max_afflvl(void);
  141. unsigned int plat_get_aff_count(unsigned int aff_lvl, unsigned long mpidr);
  142. unsigned int plat_get_aff_state(unsigned int aff_lvl, unsigned long mpidr);
  143. /* Declarations for plat_io_storage.c */
  144. void io_setup(void);
  145. int plat_get_image_source(const char *image_name,
  146. uintptr_t *dev_handle,
  147. uintptr_t *image_spec);
  148. /* Declarations for security.c */
  149. void plat_security_setup(void);
  150. /*
  151. * Before calling this function BL2 is loaded in memory and its entrypoint
  152. * is set by load_image. This is a placeholder for the platform to change
  153. * the entrypoint of BL2 and set SPSR and security state.
  154. * On Juno we are only setting the security state, entrypoint
  155. */
  156. void bl1_plat_set_bl2_ep_info(struct image_info *image,
  157. struct entry_point_info *ep);
  158. /*
  159. * Before calling this function BL3-1 is loaded in memory and its entrypoint
  160. * is set by load_image. This is a placeholder for the platform to change
  161. * the entrypoint of BL3-1 and set SPSR and security state.
  162. * On Juno we are only setting the security state, entrypoint
  163. */
  164. void bl2_plat_set_bl31_ep_info(struct image_info *image,
  165. struct entry_point_info *ep);
  166. /*
  167. * Before calling this function BL3-2 is loaded in memory and its entrypoint
  168. * is set by load_image. This is a placeholder for the platform to change
  169. * the entrypoint of BL3-2 and set SPSR and security state.
  170. * On Juno we are only setting the security state, entrypoint
  171. */
  172. void bl2_plat_set_bl32_ep_info(struct image_info *image,
  173. struct entry_point_info *ep);
  174. /*
  175. * Before calling this function BL3-3 is loaded in memory and its entrypoint
  176. * is set by load_image. This is a placeholder for the platform to change
  177. * the entrypoint of BL3-3 and set SPSR and security state.
  178. * On Juno we are only setting the security state, entrypoint
  179. */
  180. void bl2_plat_set_bl33_ep_info(struct image_info *image,
  181. struct entry_point_info *ep);
  182. /* Gets the memory layout for BL3-2 */
  183. void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info);
  184. /* Gets the memory layout for BL3-3 */
  185. void bl2_plat_get_bl33_meminfo(struct meminfo *mem_info);
  186. #endif /* __JUNO_PRIVATE_H__ */