blob: e8dfb997d8504ddab59553951339cec75a607b42 [file] [log] [blame]
Dan Handley5f0cdb02014-05-14 17:44:19 +01001/*
dp-arm04c1db12017-01-31 13:01:04 +00002 * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
Dan Handley5f0cdb02014-05-14 17:44:19 +01003 *
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 __PLATFORM_H__
32#define __PLATFORM_H__
33
Soby Mathew67487842015-07-13 14:10:57 +010034#include <psci.h>
Dan Handley5f0cdb02014-05-14 17:44:19 +010035#include <stdint.h>
Soby Mathew67487842015-07-13 14:10:57 +010036#include <types.h>
Dan Handley5f0cdb02014-05-14 17:44:19 +010037
38
39/*******************************************************************************
40 * Forward declarations
41 ******************************************************************************/
dp-armd35dee22016-12-12 14:48:13 +000042struct auth_img_desc_s;
Dan Handley5f0cdb02014-05-14 17:44:19 +010043struct meminfo;
44struct image_info;
45struct entry_point_info;
Dan Handleydec5e0d2014-05-15 14:11:36 +010046struct bl31_params;
Yatharth Kochar7baff112015-10-09 18:06:13 +010047struct image_desc;
Yatharth Kochar72600222016-09-12 16:08:41 +010048struct bl_load_info;
49struct bl_params;
Dan Handley5f0cdb02014-05-14 17:44:19 +010050
51/*******************************************************************************
Juan Castillo95cfd4a2015-04-14 12:49:03 +010052 * plat_get_rotpk_info() flags
53 ******************************************************************************/
54#define ROTPK_IS_HASH (1 << 0)
Soby Mathew04943d32016-05-24 15:05:15 +010055/* Flag used to skip verification of the certificate ROTPK while the platform
56 ROTPK is not deployed */
57#define ROTPK_NOT_DEPLOYED (1 << 1)
Juan Castillo95cfd4a2015-04-14 12:49:03 +010058
59/*******************************************************************************
Dan Handleydec5e0d2014-05-15 14:11:36 +010060 * Function declarations
Dan Handley5f0cdb02014-05-14 17:44:19 +010061 ******************************************************************************/
Dan Handleydec5e0d2014-05-15 14:11:36 +010062/*******************************************************************************
63 * Mandatory common functions
64 ******************************************************************************/
Antonio Nino Diazd4486392016-05-18 16:53:31 +010065unsigned long long plat_get_syscnt_freq(void) __deprecated;
66unsigned int plat_get_syscnt_freq2(void);
67
Juan Castillo16948ae2015-04-13 17:36:19 +010068int plat_get_image_source(unsigned int image_id,
Dan Handleydec5e0d2014-05-15 14:11:36 +010069 uintptr_t *dev_handle,
70 uintptr_t *image_spec);
Soby Mathewa0ad6012016-03-23 10:11:10 +000071uintptr_t plat_get_ns_image_entrypoint(void);
Soby Mathew67487842015-07-13 14:10:57 +010072unsigned int plat_my_core_pos(void);
73int plat_core_pos_by_mpidr(u_register_t mpidr);
Dan Handleydec5e0d2014-05-15 14:11:36 +010074
75/*******************************************************************************
76 * Mandatory interrupt management functions
77 ******************************************************************************/
Dan Handley9865ac12014-05-27 16:17:21 +010078uint32_t plat_ic_get_pending_interrupt_id(void);
79uint32_t plat_ic_get_pending_interrupt_type(void);
80uint32_t plat_ic_acknowledge_interrupt(void);
81uint32_t plat_ic_get_interrupt_type(uint32_t id);
82void plat_ic_end_of_interrupt(uint32_t id);
Dan Handley5f0cdb02014-05-14 17:44:19 +010083uint32_t plat_interrupt_type_to_line(uint32_t type,
84 uint32_t security_state);
85
Dan Handleydec5e0d2014-05-15 14:11:36 +010086/*******************************************************************************
87 * Optional common functions (may be overridden)
88 ******************************************************************************/
Soby Mathew4c0d0392016-06-16 14:52:04 +010089uintptr_t plat_get_my_stack(void);
Yatharth Kochar1a0a3f02016-06-28 16:58:26 +010090void plat_report_exception(unsigned int exception_type);
Sandrine Bailleux44804252014-08-06 11:27:23 +010091int plat_crash_console_init(void);
Soby Mathewc67b09b2014-07-14 16:57:23 +010092int plat_crash_console_putc(int c);
Antonio Nino Diaz801cf932017-02-17 17:11:27 +000093int plat_crash_console_flush(void);
Juan Castillo40fc6cd2015-09-25 15:41:14 +010094void plat_error_handler(int err) __dead2;
Antonio Nino Diaz1c3ea102016-02-01 13:57:25 +000095void plat_panic_handler(void) __dead2;
Dan Handleydec5e0d2014-05-15 14:11:36 +010096
97/*******************************************************************************
98 * Mandatory BL1 functions
99 ******************************************************************************/
Dan Handley5a06bb72014-08-04 11:41:20 +0100100void bl1_early_platform_setup(void);
Dan Handleydec5e0d2014-05-15 14:11:36 +0100101void bl1_plat_arch_setup(void);
102void bl1_platform_setup(void);
103struct meminfo *bl1_plat_sec_mem_layout(void);
Dan Handley5f0cdb02014-05-14 17:44:19 +0100104
Yatharth Kochar48bfb882015-10-10 19:06:53 +0100105/*
106 * The following function is mandatory when the
107 * firmware update feature is used.
108 */
109int bl1_plat_mem_check(uintptr_t mem_base, unsigned int mem_size,
110 unsigned int flags);
111
Dan Handleydec5e0d2014-05-15 14:11:36 +0100112/*******************************************************************************
113 * Optional BL1 functions (may be overridden)
114 ******************************************************************************/
Sandrine Bailleux8f55dfb2014-06-24 14:02:34 +0100115void bl1_init_bl2_mem_layout(const struct meminfo *bl1_mem_layout,
116 struct meminfo *bl2_mem_layout);
Yatharth Kochar48bfb882015-10-10 19:06:53 +0100117
Yatharth Kochar7baff112015-10-09 18:06:13 +0100118/*
119 * The following functions are used for image loading process in BL1.
120 */
121void bl1_plat_set_ep_info(unsigned int image_id,
122 struct entry_point_info *ep_info);
Yatharth Kochar48bfb882015-10-10 19:06:53 +0100123/*
124 * The following functions are mandatory when firmware update
125 * feature is used and optional otherwise.
126 */
Yatharth Kochar7baff112015-10-09 18:06:13 +0100127unsigned int bl1_plat_get_next_image_id(void);
128struct image_desc *bl1_plat_get_image_desc(unsigned int image_id);
Dan Handleydec5e0d2014-05-15 14:11:36 +0100129
Yatharth Kochar48bfb882015-10-10 19:06:53 +0100130/*
131 * The following functions are used by firmware update
132 * feature and may optionally be overridden.
133 */
Dan Handley1f37b942015-12-15 14:28:24 +0000134__dead2 void bl1_plat_fwu_done(void *client_cookie, void *reserved);
Yatharth Kochar48bfb882015-10-10 19:06:53 +0100135
136
Dan Handleydec5e0d2014-05-15 14:11:36 +0100137/*******************************************************************************
138 * Mandatory BL2 functions
139 ******************************************************************************/
Dan Handley5a06bb72014-08-04 11:41:20 +0100140void bl2_early_platform_setup(struct meminfo *mem_layout);
Dan Handleydec5e0d2014-05-15 14:11:36 +0100141void bl2_plat_arch_setup(void);
142void bl2_platform_setup(void);
143struct meminfo *bl2_plat_sec_mem_layout(void);
144
Yatharth Kochar72600222016-09-12 16:08:41 +0100145#if LOAD_IMAGE_V2
146/*
147 * This function can be used by the platforms to update/use image
148 * information for given `image_id`.
149 */
150int bl2_plat_handle_post_image_load(unsigned int image_id);
151
152#else /* LOAD_IMAGE_V2 */
153
Dan Handleydec5e0d2014-05-15 14:11:36 +0100154/*
155 * This function returns a pointer to the shared memory that the platform has
Juan Castillod1786372015-12-14 09:35:25 +0000156 * kept aside to pass trusted firmware related information that BL31
Dan Handleydec5e0d2014-05-15 14:11:36 +0100157 * could need
158 */
159struct bl31_params *bl2_plat_get_bl31_params(void);
160
161/*
162 * This function returns a pointer to the shared memory that the platform
163 * has kept to point to entry point information of BL31 to BL2
164 */
165struct entry_point_info *bl2_plat_get_bl31_ep_info(void);
166
167/*
168 * This function flushes to main memory all the params that are
Juan Castillod1786372015-12-14 09:35:25 +0000169 * passed to BL31
Dan Handleydec5e0d2014-05-15 14:11:36 +0100170 */
171void bl2_plat_flush_bl31_params(void);
172
Dan Handley5f0cdb02014-05-14 17:44:19 +0100173/*
Sandrine Bailleux93d81d62014-06-24 14:19:36 +0100174 * The next 2 functions allow the platform to change the entrypoint information
Juan Castillod1786372015-12-14 09:35:25 +0000175 * for the mandatory 3rd level BL images, BL31 and BL33. This is done after
176 * BL2 has loaded those images into memory but before BL31 is executed.
Dan Handley5f0cdb02014-05-14 17:44:19 +0100177 */
178void bl2_plat_set_bl31_ep_info(struct image_info *image,
179 struct entry_point_info *ep);
180
Dan Handley5f0cdb02014-05-14 17:44:19 +0100181void bl2_plat_set_bl33_ep_info(struct image_info *image,
182 struct entry_point_info *ep);
183
Juan Castillod1786372015-12-14 09:35:25 +0000184/* Gets the memory layout for BL33 */
Dan Handley5f0cdb02014-05-14 17:44:19 +0100185void bl2_plat_get_bl33_meminfo(struct meminfo *mem_info);
186
Dan Handleydec5e0d2014-05-15 14:11:36 +0100187/*******************************************************************************
Juan Castillof59821d2015-12-10 15:49:17 +0000188 * Conditionally mandatory BL2 functions: must be implemented if SCP_BL2 image
Sandrine Bailleux93d81d62014-06-24 14:19:36 +0100189 * is supported
190 ******************************************************************************/
Juan Castillof59821d2015-12-10 15:49:17 +0000191/* Gets the memory layout for SCP_BL2 */
192void bl2_plat_get_scp_bl2_meminfo(struct meminfo *mem_info);
Sandrine Bailleux93d81d62014-06-24 14:19:36 +0100193
194/*
Juan Castillof59821d2015-12-10 15:49:17 +0000195 * This function is called after loading SCP_BL2 image and it is used to perform
Sandrine Bailleux93d81d62014-06-24 14:19:36 +0100196 * any platform-specific actions required to handle the SCP firmware.
197 */
Juan Castillof59821d2015-12-10 15:49:17 +0000198int bl2_plat_handle_scp_bl2(struct image_info *scp_bl2_image_info);
Sandrine Bailleux93d81d62014-06-24 14:19:36 +0100199
200/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000201 * Conditionally mandatory BL2 functions: must be implemented if BL32 image
Sandrine Bailleux93d81d62014-06-24 14:19:36 +0100202 * is supported
203 ******************************************************************************/
204void bl2_plat_set_bl32_ep_info(struct image_info *image,
205 struct entry_point_info *ep);
206
Juan Castillod1786372015-12-14 09:35:25 +0000207/* Gets the memory layout for BL32 */
Sandrine Bailleux93d81d62014-06-24 14:19:36 +0100208void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info);
209
Yatharth Kochar72600222016-09-12 16:08:41 +0100210#endif /* LOAD_IMAGE_V2 */
211
Sandrine Bailleux93d81d62014-06-24 14:19:36 +0100212/*******************************************************************************
Dan Handleydec5e0d2014-05-15 14:11:36 +0100213 * Optional BL2 functions (may be overridden)
214 ******************************************************************************/
215
216/*******************************************************************************
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100217 * Mandatory BL2U functions.
218 ******************************************************************************/
219void bl2u_early_platform_setup(struct meminfo *mem_layout,
220 void *plat_info);
221void bl2u_plat_arch_setup(void);
222void bl2u_platform_setup(void);
223
224/*******************************************************************************
225 * Conditionally mandatory BL2U functions for CSS platforms.
226 ******************************************************************************/
227/*
228 * This function is used to perform any platform-specific actions required to
229 * handle the BL2U_SCP firmware.
230 */
231int bl2u_plat_handle_scp_bl2u(void);
232
233/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000234 * Mandatory BL31 functions
Dan Handleydec5e0d2014-05-15 14:11:36 +0100235 ******************************************************************************/
Yatharth Kochar72600222016-09-12 16:08:41 +0100236#if LOAD_IMAGE_V2
237void bl31_early_platform_setup(void *from_bl2,
238 void *plat_params_from_bl2);
239#else
Dan Handleydec5e0d2014-05-15 14:11:36 +0100240void bl31_early_platform_setup(struct bl31_params *from_bl2,
241 void *plat_params_from_bl2);
Yatharth Kochar72600222016-09-12 16:08:41 +0100242#endif
Dan Handleydec5e0d2014-05-15 14:11:36 +0100243void bl31_plat_arch_setup(void);
244void bl31_platform_setup(void);
Soby Mathew78e61612015-12-09 11:28:43 +0000245void bl31_plat_runtime_setup(void);
Dan Handley9865ac12014-05-27 16:17:21 +0100246struct entry_point_info *bl31_plat_get_next_image_ep_info(uint32_t type);
Dan Handleydec5e0d2014-05-15 14:11:36 +0100247
248/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000249 * Mandatory PSCI functions (BL31)
Dan Handleydec5e0d2014-05-15 14:11:36 +0100250 ******************************************************************************/
Soby Mathew67487842015-07-13 14:10:57 +0100251int plat_setup_psci_ops(uintptr_t sec_entrypoint,
252 const struct plat_psci_ops **);
253const unsigned char *plat_get_power_domain_tree_desc(void);
254
255/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000256 * Optional PSCI functions (BL31).
Soby Mathew67487842015-07-13 14:10:57 +0100257 ******************************************************************************/
dp-arm04c1db12017-01-31 13:01:04 +0000258void plat_psci_stat_accounting_start(const psci_power_state_t *state_info);
259void plat_psci_stat_accounting_stop(const psci_power_state_t *state_info);
260u_register_t plat_psci_stat_get_residency(unsigned int lvl,
261 const psci_power_state_t *state_info,
262 int last_cpu_index);
Soby Mathew67487842015-07-13 14:10:57 +0100263plat_local_state_t plat_get_target_pwr_state(unsigned int lvl,
264 const plat_local_state_t *states,
265 unsigned int ncpu);
Dan Handleydec5e0d2014-05-15 14:11:36 +0100266
267/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000268 * Optional BL31 functions (may be overridden)
Dan Handleydff8e472014-05-16 14:08:45 +0100269 ******************************************************************************/
Achin Guptaafff8cb2014-06-26 08:59:07 +0100270void bl31_plat_enable_mmu(uint32_t flags);
Dan Handleydff8e472014-05-16 14:08:45 +0100271
272/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000273 * Optional BL32 functions (may be overridden)
Dan Handleydff8e472014-05-16 14:08:45 +0100274 ******************************************************************************/
Achin Guptaafff8cb2014-06-26 08:59:07 +0100275void bl32_plat_enable_mmu(uint32_t flags);
Dan Handleydff8e472014-05-16 14:08:45 +0100276
Juan Castillo6eadf762015-01-07 10:39:25 +0000277/*******************************************************************************
Juan Castillo95cfd4a2015-04-14 12:49:03 +0100278 * Trusted Board Boot functions
Juan Castillo6eadf762015-01-07 10:39:25 +0000279 ******************************************************************************/
Juan Castillo95cfd4a2015-04-14 12:49:03 +0100280int plat_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len,
281 unsigned int *flags);
Juan Castillo48279d52016-01-22 11:05:57 +0000282int plat_get_nv_ctr(void *cookie, unsigned int *nv_ctr);
283int plat_set_nv_ctr(void *cookie, unsigned int nv_ctr);
dp-armd35dee22016-12-12 14:48:13 +0000284int plat_set_nv_ctr2(void *cookie, const struct auth_img_desc_s *img_desc,
285 unsigned int nv_ctr);
Juan Castillo6eadf762015-01-07 10:39:25 +0000286
Yatharth Kochar72600222016-09-12 16:08:41 +0100287#if LOAD_IMAGE_V2
288/*******************************************************************************
289 * Mandatory BL image load functions(may be overridden).
290 ******************************************************************************/
291/*
292 * This function returns pointer to the list of images that the
293 * platform has populated to load.
294 */
295struct bl_load_info *plat_get_bl_image_load_info(void);
296
297/*
298 * This function returns a pointer to the shared memory that the
299 * platform has kept aside to pass trusted firmware related
300 * information that next BL image could need.
301 */
302struct bl_params *plat_get_next_bl_params(void);
303
304/*
305 * This function flushes to main memory all the params that are
306 * passed to next image.
307 */
308void plat_flush_next_bl_params(void);
309
310#endif /* LOAD_IMAGE_V2 */
311
Soby Mathew67487842015-07-13 14:10:57 +0100312#if ENABLE_PLAT_COMPAT
313/*
314 * The below declarations are to enable compatibility for the platform ports
315 * using the old platform interface.
316 */
317
318/*******************************************************************************
319 * Optional common functions (may be overridden)
320 ******************************************************************************/
321unsigned int platform_get_core_pos(unsigned long mpidr);
322
323/*******************************************************************************
Juan Castillod1786372015-12-14 09:35:25 +0000324 * Mandatory PSCI Compatibility functions (BL31)
Soby Mathew67487842015-07-13 14:10:57 +0100325 ******************************************************************************/
326int platform_setup_pm(const plat_pm_ops_t **);
327
328unsigned int plat_get_aff_count(unsigned int, unsigned long);
329unsigned int plat_get_aff_state(unsigned int, unsigned long);
Soby Mathew5c8babc2015-07-13 16:26:11 +0100330#else
331/*
332 * The below function enable Trusted Firmware components like SPDs which
333 * haven't migrated to the new platform API to compile on platforms which
334 * have the compatibility layer disabled.
335 */
Soren Brinkmann70ecb562016-01-14 10:02:33 -0800336unsigned int platform_get_core_pos(unsigned long mpidr) __deprecated;
Soby Mathew67487842015-07-13 14:10:57 +0100337
Soby Mathew5c8babc2015-07-13 16:26:11 +0100338#endif /* __ENABLE_PLAT_COMPAT__ */
Dan Handley5f0cdb02014-05-14 17:44:19 +0100339#endif /* __PLATFORM_H__ */