Home | History | Annotate | Download | only in fvp
      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 __FVP_PRIVATE_H__
     32 #define __FVP_PRIVATE_H__
     33 
     34 #include <bakery_lock.h>
     35 #include <bl_common.h>
     36 #include <cpu_data.h>
     37 #include <platform_def.h>
     38 
     39 
     40 typedef volatile struct mailbox {
     41 	unsigned long value
     42 	__attribute__((__aligned__(CACHE_WRITEBACK_GRANULE)));
     43 } mailbox_t;
     44 
     45 /*******************************************************************************
     46  * This structure represents the superset of information that is passed to
     47  * BL31 e.g. while passing control to it from BL2 which is bl31_params
     48  * and bl31_plat_params and its elements
     49  ******************************************************************************/
     50 typedef struct bl2_to_bl31_params_mem {
     51 	bl31_params_t bl31_params;
     52 	image_info_t bl31_image_info;
     53 	image_info_t bl32_image_info;
     54 	image_info_t bl33_image_info;
     55 	entry_point_info_t bl33_ep_info;
     56 	entry_point_info_t bl32_ep_info;
     57 	entry_point_info_t bl31_ep_info;
     58 } bl2_to_bl31_params_mem_t;
     59 
     60 #if USE_COHERENT_MEM
     61 /*
     62  * These are wrapper macros to the Coherent Memory Bakery Lock API.
     63  */
     64 #define fvp_lock_init(_lock_arg)	bakery_lock_init(_lock_arg)
     65 #define fvp_lock_get(_lock_arg)		bakery_lock_get(_lock_arg)
     66 #define fvp_lock_release(_lock_arg)	bakery_lock_release(_lock_arg)
     67 
     68 #else
     69 
     70 /*******************************************************************************
     71  * Constants to specify how many bakery locks this platform implements. These
     72  * are used if the platform chooses not to use coherent memory for bakery lock
     73  * data structures.
     74  ******************************************************************************/
     75 #define FVP_MAX_BAKERIES	1
     76 #define FVP_PWRC_BAKERY_ID	0
     77 
     78 /*******************************************************************************
     79  * Definition of structure which holds platform specific per-cpu data. Currently
     80  * it holds only the bakery lock information for each cpu. Constants to
     81  * specify how many bakeries this platform implements and bakery ids are
     82  * specified in fvp_def.h
     83  ******************************************************************************/
     84 typedef struct fvp_cpu_data {
     85 	bakery_info_t pcpu_bakery_info[FVP_MAX_BAKERIES];
     86 } fvp_cpu_data_t;
     87 
     88 /* Macro to define the offset of bakery_info_t in fvp_cpu_data_t */
     89 #define FVP_CPU_DATA_LOCK_OFFSET	__builtin_offsetof\
     90 					    (fvp_cpu_data_t, pcpu_bakery_info)
     91 
     92 
     93 /*******************************************************************************
     94  * Helper macros for bakery lock api when using the above fvp_cpu_data_t for
     95  * bakery lock data structures. It assumes that the bakery_info is at the
     96  * beginning of the platform specific per-cpu data.
     97  ******************************************************************************/
     98 #define fvp_lock_init(_lock_arg)	/* No init required */
     99 #define fvp_lock_get(_lock_arg)		bakery_lock_get(_lock_arg,  	    \
    100 						CPU_DATA_PLAT_PCPU_OFFSET + \
    101 						FVP_CPU_DATA_LOCK_OFFSET)
    102 #define fvp_lock_release(_lock_arg)	bakery_lock_release(_lock_arg,	    \
    103 						CPU_DATA_PLAT_PCPU_OFFSET + \
    104 						FVP_CPU_DATA_LOCK_OFFSET)
    105 
    106 /*
    107  * Ensure that the size of the FVP specific per-cpu data structure and the size
    108  * of the memory allocated in generic per-cpu data for the platform are the same.
    109  */
    110 CASSERT(PLAT_PCPU_DATA_SIZE == sizeof(fvp_cpu_data_t),	\
    111 	fvp_pcpu_data_size_mismatch);
    112 
    113 #endif /* __USE_COHERENT_MEM__ */
    114 
    115 /*******************************************************************************
    116  * Function and variable prototypes
    117  ******************************************************************************/
    118 void fvp_configure_mmu_el1(unsigned long total_base,
    119 			   unsigned long total_size,
    120 			   unsigned long,
    121 			   unsigned long
    122 #if USE_COHERENT_MEM
    123 			   , unsigned long,
    124 			   unsigned long
    125 #endif
    126 			   );
    127 void fvp_configure_mmu_el3(unsigned long total_base,
    128 			   unsigned long total_size,
    129 			   unsigned long,
    130 			   unsigned long
    131 #if USE_COHERENT_MEM
    132 			   , unsigned long,
    133 			   unsigned long
    134 #endif
    135 			   );
    136 
    137 int fvp_config_setup(void);
    138 
    139 void fvp_cci_init(void);
    140 void fvp_cci_enable(void);
    141 
    142 void fvp_gic_init(void);
    143 
    144 /* Declarations for fvp_topology.c */
    145 int fvp_setup_topology(void);
    146 
    147 /* Declarations for fvp_io_storage.c */
    148 void fvp_io_setup(void);
    149 
    150 /* Declarations for fvp_security.c */
    151 void fvp_security_setup(void);
    152 
    153 /* Gets the SPR for BL32 entry */
    154 uint32_t fvp_get_spsr_for_bl32_entry(void);
    155 
    156 /* Gets the SPSR for BL33 entry */
    157 uint32_t fvp_get_spsr_for_bl33_entry(void);
    158 
    159 
    160 #endif /* __FVP_PRIVATE_H__ */
    161