Home | History | Annotate | Download | only in juno
      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 
     31 #ifndef __JUNO_PRIVATE_H__
     32 #define __JUNO_PRIVATE_H__
     33 
     34 #include <bakery_lock.h>
     35 #include <bl_common.h>
     36 #include <cpu_data.h>
     37 #include <platform_def.h>
     38 #include <stdint.h>
     39 
     40 /*******************************************************************************
     41  * Forward declarations
     42  ******************************************************************************/
     43 struct plat_pm_ops;
     44 struct meminfo;
     45 struct bl31_params;
     46 struct image_info;
     47 struct entry_point_info;
     48 
     49 /*******************************************************************************
     50  * This structure represents the superset of information that is passed to
     51  * BL3-1 e.g. while passing control to it from BL2 which is bl31_params
     52  * and other platform specific params
     53  ******************************************************************************/
     54 typedef struct bl2_to_bl31_params_mem {
     55 	struct bl31_params bl31_params;
     56 	struct image_info bl31_image_info;
     57 	struct image_info bl32_image_info;
     58 	struct image_info bl33_image_info;
     59 	struct entry_point_info bl33_ep_info;
     60 	struct entry_point_info bl32_ep_info;
     61 	struct entry_point_info bl31_ep_info;
     62 } bl2_to_bl31_params_mem_t;
     63 
     64 #if IMAGE_BL31
     65 #if USE_COHERENT_MEM
     66 /*
     67  * These are wrapper macros to the Coherent Memory Bakery Lock API.
     68  */
     69 #define juno_lock_init(_lock_arg)		bakery_lock_init(_lock_arg)
     70 #define juno_lock_get(_lock_arg)		bakery_lock_get(_lock_arg)
     71 #define juno_lock_release(_lock_arg)		bakery_lock_release(_lock_arg)
     72 
     73 #else
     74 
     75 /*******************************************************************************
     76  * Constants that specify how many bakeries this platform implements and bakery
     77  * ids.
     78  ******************************************************************************/
     79 #define JUNO_MAX_BAKERIES	1
     80 #define JUNO_MHU_BAKERY_ID	0
     81 
     82 /*******************************************************************************
     83  * Definition of structure which holds platform specific per-cpu data. Currently
     84  * it holds only the bakery lock information for each cpu. Constants to specify
     85  * how many bakeries this platform implements and bakery ids are specified in
     86  * juno_def.h
     87  ******************************************************************************/
     88 typedef struct juno_cpu_data {
     89 	bakery_info_t pcpu_bakery_info[JUNO_MAX_BAKERIES];
     90 } juno_cpu_data_t;
     91 
     92 /* Macro to define the offset of bakery_info_t in juno_cpu_data_t */
     93 #define JUNO_CPU_DATA_LOCK_OFFSET	__builtin_offsetof\
     94 					    (juno_cpu_data_t, pcpu_bakery_info)
     95 
     96 /*******************************************************************************
     97  * Helper macros for bakery lock api when using the above juno_cpu_data_t for
     98  * bakery lock data structures. It assumes that the bakery_info is at the
     99  * beginning of the platform specific per-cpu data.
    100  ******************************************************************************/
    101 #define juno_lock_init(_lock_arg)		/* No init required */
    102 #define juno_lock_get(_lock_arg)		bakery_lock_get(_lock_arg,	\
    103 						    CPU_DATA_PLAT_PCPU_OFFSET + \
    104 						    JUNO_CPU_DATA_LOCK_OFFSET)
    105 #define juno_lock_release(_lock_arg)		bakery_lock_release(_lock_arg,	\
    106 						    CPU_DATA_PLAT_PCPU_OFFSET + \
    107 						    JUNO_CPU_DATA_LOCK_OFFSET)
    108 
    109 /*
    110  * Ensure that the size of the Juno specific per-cpu data structure and the size
    111  * of the memory allocated in generic per-cpu data for the platform are the same.
    112  */
    113 CASSERT(PLAT_PCPU_DATA_SIZE == sizeof(juno_cpu_data_t),	\
    114 	juno_pcpu_data_size_mismatch);
    115 #endif /* __USE_COHERENT_MEM__ */
    116 #else
    117 /*
    118  * Dummy wrapper macros for all other BL stages other than BL3-1
    119  */
    120 #define juno_lock_init(_lock_arg)
    121 #define juno_lock_get(_lock_arg)
    122 #define juno_lock_release(_lock_arg)
    123 
    124 #endif /* __IMAGE_BL31__ */
    125 
    126 /*******************************************************************************
    127  * Function and variable prototypes
    128  ******************************************************************************/
    129 void bl1_plat_arch_setup(void);
    130 void bl2_plat_arch_setup(void);
    131 void bl31_plat_arch_setup(void);
    132 int platform_setup_pm(const struct plat_pm_ops **plat_ops);
    133 unsigned int platform_get_core_pos(unsigned long mpidr);
    134 void configure_mmu_el1(unsigned long total_base,
    135 		       unsigned long total_size,
    136 		       unsigned long ro_start,
    137 		       unsigned long ro_limit
    138 #if USE_COHERENT_MEM
    139 		       , unsigned long coh_start,
    140 		       unsigned long coh_limit
    141 #endif
    142 		       );
    143 void configure_mmu_el3(unsigned long total_base,
    144 		       unsigned long total_size,
    145 		       unsigned long ro_start,
    146 		       unsigned long ro_limit
    147 #if USE_COHERENT_MEM
    148 		       , unsigned long coh_start,
    149 		       unsigned long coh_limit
    150 #endif
    151 		       );
    152 void plat_report_exception(unsigned long type);
    153 unsigned long plat_get_ns_image_entrypoint(void);
    154 unsigned long platform_get_stack(unsigned long mpidr);
    155 uint64_t plat_get_syscnt_freq(void);
    156 void plat_gic_init(void);
    157 
    158 /* Declarations for plat_topology.c */
    159 int plat_setup_topology(void);
    160 int plat_get_max_afflvl(void);
    161 unsigned int plat_get_aff_count(unsigned int aff_lvl, unsigned long mpidr);
    162 unsigned int plat_get_aff_state(unsigned int aff_lvl, unsigned long mpidr);
    163 
    164 /* Declarations for plat_io_storage.c */
    165 void io_setup(void);
    166 int plat_get_image_source(const char *image_name,
    167 			  uintptr_t *dev_handle,
    168 			  uintptr_t *image_spec);
    169 
    170 /* Declarations for security.c */
    171 void plat_security_setup(void);
    172 
    173 /*
    174  * Before calling this function BL2 is loaded in memory and its entrypoint
    175  * is set by load_image. This is a placeholder for the platform to change
    176  * the entrypoint of BL2 and set SPSR and security state.
    177  * On Juno we are only setting the security state, entrypoint
    178  */
    179 void bl1_plat_set_bl2_ep_info(struct image_info *image,
    180 			      struct entry_point_info *ep);
    181 
    182 /*
    183  * Before calling this function BL3-1 is loaded in memory and its entrypoint
    184  * is set by load_image. This is a placeholder for the platform to change
    185  * the entrypoint of BL3-1 and set SPSR and security state.
    186  * On Juno we are only setting the security state, entrypoint
    187  */
    188 void bl2_plat_set_bl31_ep_info(struct image_info *image,
    189 			       struct entry_point_info *ep);
    190 
    191 /*
    192  * Before calling this function BL3-2 is loaded in memory and its entrypoint
    193  * is set by load_image. This is a placeholder for the platform to change
    194  * the entrypoint of BL3-2 and set SPSR and security state.
    195  * On Juno we are only setting the security state, entrypoint
    196  */
    197 void bl2_plat_set_bl32_ep_info(struct image_info *image,
    198 			       struct entry_point_info *ep);
    199 
    200 /*
    201  * Before calling this function BL3-3 is loaded in memory and its entrypoint
    202  * is set by load_image. This is a placeholder for the platform to change
    203  * the entrypoint of BL3-3 and set SPSR and security state.
    204  * On Juno we are only setting the security state, entrypoint
    205  */
    206 void bl2_plat_set_bl33_ep_info(struct image_info *image,
    207 			       struct entry_point_info *ep);
    208 
    209 /* Gets the memory layout for BL3-2 */
    210 void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info);
    211 
    212 /* Gets the memory layout for BL3-3 */
    213 void bl2_plat_get_bl33_meminfo(struct meminfo *mem_info);
    214 
    215 #endif /* __JUNO_PRIVATE_H__ */
    216