blob: 9a5944cadb94a66c1a46d9e4c735df40b4ea15c7 [file] [log] [blame]
Sandrine Bailleux798140d2014-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 Mathew523d6332015-01-08 18:02:19 +000034#include <bakery_lock.h>
Sandrine Bailleux798140d2014-07-17 16:06:39 +010035#include <bl_common.h>
Soby Mathew523d6332015-01-08 18:02:19 +000036#include <cpu_data.h>
Sandrine Bailleux798140d2014-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 Mathew523d6332015-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 Bailleux798140d2014-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,
Soby Mathew2ae20432015-01-08 18:02:44 +0000137 unsigned long ro_limit
138#if USE_COHERENT_MEM
139 , unsigned long coh_start,
140 unsigned long coh_limit
141#endif
142 );
Sandrine Bailleux798140d2014-07-17 16:06:39 +0100143void configure_mmu_el3(unsigned long total_base,
144 unsigned long total_size,
145 unsigned long ro_start,
Soby Mathew2ae20432015-01-08 18:02:44 +0000146 unsigned long ro_limit
147#if USE_COHERENT_MEM
148 , unsigned long coh_start,
149 unsigned long coh_limit
150#endif
151 );
Sandrine Bailleux798140d2014-07-17 16:06:39 +0100152void plat_report_exception(unsigned long type);
153unsigned long plat_get_ns_image_entrypoint(void);
154unsigned long platform_get_stack(unsigned long mpidr);
155uint64_t plat_get_syscnt_freq(void);
Juan Castillob3286c02014-10-20 12:29:58 +0100156void plat_gic_init(void);
Sandrine Bailleux798140d2014-07-17 16:06:39 +0100157
158/* Declarations for plat_topology.c */
159int plat_setup_topology(void);
Sandrine Bailleux798140d2014-07-17 16:06:39 +0100160unsigned int plat_get_aff_count(unsigned int aff_lvl, unsigned long mpidr);
161unsigned int plat_get_aff_state(unsigned int aff_lvl, unsigned long mpidr);
162
163/* Declarations for plat_io_storage.c */
164void io_setup(void);
165int plat_get_image_source(const char *image_name,
166 uintptr_t *dev_handle,
167 uintptr_t *image_spec);
168
Juan Castillo6b672f52014-09-04 14:43:09 +0100169/* Declarations for security.c */
170void plat_security_setup(void);
171
Sandrine Bailleux798140d2014-07-17 16:06:39 +0100172/*
173 * Before calling this function BL2 is loaded in memory and its entrypoint
174 * is set by load_image. This is a placeholder for the platform to change
175 * the entrypoint of BL2 and set SPSR and security state.
176 * On Juno we are only setting the security state, entrypoint
177 */
178void bl1_plat_set_bl2_ep_info(struct image_info *image,
179 struct entry_point_info *ep);
180
181/*
182 * Before calling this function BL3-1 is loaded in memory and its entrypoint
183 * is set by load_image. This is a placeholder for the platform to change
184 * the entrypoint of BL3-1 and set SPSR and security state.
185 * On Juno we are only setting the security state, entrypoint
186 */
187void bl2_plat_set_bl31_ep_info(struct image_info *image,
188 struct entry_point_info *ep);
189
190/*
191 * Before calling this function BL3-2 is loaded in memory and its entrypoint
192 * is set by load_image. This is a placeholder for the platform to change
193 * the entrypoint of BL3-2 and set SPSR and security state.
194 * On Juno we are only setting the security state, entrypoint
195 */
196void bl2_plat_set_bl32_ep_info(struct image_info *image,
197 struct entry_point_info *ep);
198
199/*
200 * Before calling this function BL3-3 is loaded in memory and its entrypoint
201 * is set by load_image. This is a placeholder for the platform to change
202 * the entrypoint of BL3-3 and set SPSR and security state.
203 * On Juno we are only setting the security state, entrypoint
204 */
205void bl2_plat_set_bl33_ep_info(struct image_info *image,
206 struct entry_point_info *ep);
207
208/* Gets the memory layout for BL3-2 */
209void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info);
210
211/* Gets the memory layout for BL3-3 */
212void bl2_plat_get_bl33_meminfo(struct meminfo *mem_info);
213
214#endif /* __JUNO_PRIVATE_H__ */