blob: b7ef4488a5edc20e798c163489ffe9578c3caae8 [file] [log] [blame]
Sandrine Bailleux01b916b2014-07-17 16:06:39 +01001/*
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
Soby Mathew8c5fe0b2015-01-08 18:02:19 +000034#include <bakery_lock.h>
Sandrine Bailleux01b916b2014-07-17 16:06:39 +010035#include <bl_common.h>
Soby Mathew8c5fe0b2015-01-08 18:02:19 +000036#include <cpu_data.h>
Sandrine Bailleux01b916b2014-07-17 16:06:39 +010037#include <platform_def.h>
38#include <stdint.h>
39
40/*******************************************************************************
41 * Forward declarations
42 ******************************************************************************/
43struct plat_pm_ops;
44struct meminfo;
45struct bl31_params;
46struct image_info;
47struct 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 ******************************************************************************/
54typedef 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
Soby Mathew8c5fe0b2015-01-08 18:02:19 +000064#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 ******************************************************************************/
88typedef 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 */
113CASSERT(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
Sandrine Bailleux01b916b2014-07-17 16:06:39 +0100126/*******************************************************************************
127 * Function and variable prototypes
128 ******************************************************************************/
129void bl1_plat_arch_setup(void);
130void bl2_plat_arch_setup(void);
131void bl31_plat_arch_setup(void);
132int platform_setup_pm(const struct plat_pm_ops **plat_ops);
133unsigned int platform_get_core_pos(unsigned long mpidr);
134void configure_mmu_el1(unsigned long total_base,
135 unsigned long total_size,
136 unsigned long ro_start,
137 unsigned long ro_limit,
138 unsigned long coh_start,
139 unsigned long coh_limit);
140void configure_mmu_el3(unsigned long total_base,
141 unsigned long total_size,
142 unsigned long ro_start,
143 unsigned long ro_limit,
144 unsigned long coh_start,
145 unsigned long coh_limit);
146void plat_report_exception(unsigned long type);
147unsigned long plat_get_ns_image_entrypoint(void);
148unsigned long platform_get_stack(unsigned long mpidr);
149uint64_t plat_get_syscnt_freq(void);
Juan Castillo33132e62014-10-20 12:29:58 +0100150void plat_gic_init(void);
Sandrine Bailleux01b916b2014-07-17 16:06:39 +0100151
152/* Declarations for plat_topology.c */
153int plat_setup_topology(void);
154int plat_get_max_afflvl(void);
155unsigned int plat_get_aff_count(unsigned int aff_lvl, unsigned long mpidr);
156unsigned int plat_get_aff_state(unsigned int aff_lvl, unsigned long mpidr);
157
158/* Declarations for plat_io_storage.c */
159void io_setup(void);
160int plat_get_image_source(const char *image_name,
161 uintptr_t *dev_handle,
162 uintptr_t *image_spec);
163
Juan Castilloef538c62014-09-04 14:43:09 +0100164/* Declarations for security.c */
165void plat_security_setup(void);
166
Sandrine Bailleux01b916b2014-07-17 16:06:39 +0100167/*
168 * Before calling this function BL2 is loaded in memory and its entrypoint
169 * is set by load_image. This is a placeholder for the platform to change
170 * the entrypoint of BL2 and set SPSR and security state.
171 * On Juno we are only setting the security state, entrypoint
172 */
173void bl1_plat_set_bl2_ep_info(struct image_info *image,
174 struct entry_point_info *ep);
175
176/*
177 * Before calling this function BL3-1 is loaded in memory and its entrypoint
178 * is set by load_image. This is a placeholder for the platform to change
179 * the entrypoint of BL3-1 and set SPSR and security state.
180 * On Juno we are only setting the security state, entrypoint
181 */
182void bl2_plat_set_bl31_ep_info(struct image_info *image,
183 struct entry_point_info *ep);
184
185/*
186 * Before calling this function BL3-2 is loaded in memory and its entrypoint
187 * is set by load_image. This is a placeholder for the platform to change
188 * the entrypoint of BL3-2 and set SPSR and security state.
189 * On Juno we are only setting the security state, entrypoint
190 */
191void bl2_plat_set_bl32_ep_info(struct image_info *image,
192 struct entry_point_info *ep);
193
194/*
195 * Before calling this function BL3-3 is loaded in memory and its entrypoint
196 * is set by load_image. This is a placeholder for the platform to change
197 * the entrypoint of BL3-3 and set SPSR and security state.
198 * On Juno we are only setting the security state, entrypoint
199 */
200void bl2_plat_set_bl33_ep_info(struct image_info *image,
201 struct entry_point_info *ep);
202
203/* Gets the memory layout for BL3-2 */
204void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info);
205
206/* Gets the memory layout for BL3-3 */
207void bl2_plat_get_bl33_meminfo(struct meminfo *mem_info);
208
209#endif /* __JUNO_PRIVATE_H__ */