15f0cdb05SDan Handley /* 267487846SSoby Mathew * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. 35f0cdb05SDan Handley * 45f0cdb05SDan Handley * Redistribution and use in source and binary forms, with or without 55f0cdb05SDan Handley * modification, are permitted provided that the following conditions are met: 65f0cdb05SDan Handley * 75f0cdb05SDan Handley * Redistributions of source code must retain the above copyright notice, this 85f0cdb05SDan Handley * list of conditions and the following disclaimer. 95f0cdb05SDan Handley * 105f0cdb05SDan Handley * Redistributions in binary form must reproduce the above copyright notice, 115f0cdb05SDan Handley * this list of conditions and the following disclaimer in the documentation 125f0cdb05SDan Handley * and/or other materials provided with the distribution. 135f0cdb05SDan Handley * 145f0cdb05SDan Handley * Neither the name of ARM nor the names of its contributors may be used 155f0cdb05SDan Handley * to endorse or promote products derived from this software without specific 165f0cdb05SDan Handley * prior written permission. 175f0cdb05SDan Handley * 185f0cdb05SDan Handley * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 195f0cdb05SDan Handley * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 205f0cdb05SDan Handley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 215f0cdb05SDan Handley * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 225f0cdb05SDan Handley * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 235f0cdb05SDan Handley * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 245f0cdb05SDan Handley * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 255f0cdb05SDan Handley * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 265f0cdb05SDan Handley * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 275f0cdb05SDan Handley * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 285f0cdb05SDan Handley * POSSIBILITY OF SUCH DAMAGE. 295f0cdb05SDan Handley */ 305f0cdb05SDan Handley 315f0cdb05SDan Handley #ifndef __PLATFORM_H__ 325f0cdb05SDan Handley #define __PLATFORM_H__ 335f0cdb05SDan Handley 3467487846SSoby Mathew #include <psci.h> 355f0cdb05SDan Handley #include <stdint.h> 3667487846SSoby Mathew #include <types.h> 375f0cdb05SDan Handley 385f0cdb05SDan Handley 395f0cdb05SDan Handley /******************************************************************************* 405f0cdb05SDan Handley * Forward declarations 415f0cdb05SDan Handley ******************************************************************************/ 425f0cdb05SDan Handley struct meminfo; 435f0cdb05SDan Handley struct image_info; 445f0cdb05SDan Handley struct entry_point_info; 45dec5e0d1SDan Handley struct bl31_params; 46*7baff11fSYatharth Kochar struct image_desc; 475f0cdb05SDan Handley 485f0cdb05SDan Handley /******************************************************************************* 4995cfd4adSJuan Castillo * plat_get_rotpk_info() flags 5095cfd4adSJuan Castillo ******************************************************************************/ 5195cfd4adSJuan Castillo #define ROTPK_IS_HASH (1 << 0) 5295cfd4adSJuan Castillo 5395cfd4adSJuan Castillo /******************************************************************************* 54dec5e0d1SDan Handley * Function declarations 555f0cdb05SDan Handley ******************************************************************************/ 56dec5e0d1SDan Handley /******************************************************************************* 57dec5e0d1SDan Handley * Mandatory common functions 58dec5e0d1SDan Handley ******************************************************************************/ 59dec5e0d1SDan Handley uint64_t plat_get_syscnt_freq(void); 6016948ae1SJuan Castillo int plat_get_image_source(unsigned int image_id, 61dec5e0d1SDan Handley uintptr_t *dev_handle, 62dec5e0d1SDan Handley uintptr_t *image_spec); 635f0cdb05SDan Handley unsigned long plat_get_ns_image_entrypoint(void); 6467487846SSoby Mathew unsigned int plat_my_core_pos(void); 6567487846SSoby Mathew int plat_core_pos_by_mpidr(u_register_t mpidr); 66dec5e0d1SDan Handley 67dec5e0d1SDan Handley /******************************************************************************* 68dec5e0d1SDan Handley * Mandatory interrupt management functions 69dec5e0d1SDan Handley ******************************************************************************/ 709865ac15SDan Handley uint32_t plat_ic_get_pending_interrupt_id(void); 719865ac15SDan Handley uint32_t plat_ic_get_pending_interrupt_type(void); 729865ac15SDan Handley uint32_t plat_ic_acknowledge_interrupt(void); 739865ac15SDan Handley uint32_t plat_ic_get_interrupt_type(uint32_t id); 749865ac15SDan Handley void plat_ic_end_of_interrupt(uint32_t id); 755f0cdb05SDan Handley uint32_t plat_interrupt_type_to_line(uint32_t type, 765f0cdb05SDan Handley uint32_t security_state); 775f0cdb05SDan Handley 78dec5e0d1SDan Handley /******************************************************************************* 79dec5e0d1SDan Handley * Optional common functions (may be overridden) 80dec5e0d1SDan Handley ******************************************************************************/ 8167487846SSoby Mathew unsigned long plat_get_my_stack(void); 82dec5e0d1SDan Handley void plat_report_exception(unsigned long); 8344804252SSandrine Bailleux int plat_crash_console_init(void); 84c67b09bdSSoby Mathew int plat_crash_console_putc(int c); 8540fc6cd1SJuan Castillo void plat_error_handler(int err) __dead2; 86dec5e0d1SDan Handley 87dec5e0d1SDan Handley /******************************************************************************* 88dec5e0d1SDan Handley * Mandatory BL1 functions 89dec5e0d1SDan Handley ******************************************************************************/ 905a06bb7eSDan Handley void bl1_early_platform_setup(void); 91dec5e0d1SDan Handley void bl1_plat_arch_setup(void); 92dec5e0d1SDan Handley void bl1_platform_setup(void); 93dec5e0d1SDan Handley struct meminfo *bl1_plat_sec_mem_layout(void); 945f0cdb05SDan Handley 95dec5e0d1SDan Handley /******************************************************************************* 96dec5e0d1SDan Handley * Optional BL1 functions (may be overridden) 97dec5e0d1SDan Handley ******************************************************************************/ 988f55dfb4SSandrine Bailleux void bl1_init_bl2_mem_layout(const struct meminfo *bl1_mem_layout, 998f55dfb4SSandrine Bailleux struct meminfo *bl2_mem_layout); 100*7baff11fSYatharth Kochar /* 101*7baff11fSYatharth Kochar * The following functions are used for image loading process in BL1. 102*7baff11fSYatharth Kochar */ 103*7baff11fSYatharth Kochar void bl1_plat_set_ep_info(unsigned int image_id, 104*7baff11fSYatharth Kochar struct entry_point_info *ep_info); 105*7baff11fSYatharth Kochar unsigned int bl1_plat_get_next_image_id(void); 106*7baff11fSYatharth Kochar struct image_desc *bl1_plat_get_image_desc(unsigned int image_id); 107dec5e0d1SDan Handley 108dec5e0d1SDan Handley /******************************************************************************* 109dec5e0d1SDan Handley * Mandatory BL2 functions 110dec5e0d1SDan Handley ******************************************************************************/ 1115a06bb7eSDan Handley void bl2_early_platform_setup(struct meminfo *mem_layout); 112dec5e0d1SDan Handley void bl2_plat_arch_setup(void); 113dec5e0d1SDan Handley void bl2_platform_setup(void); 114dec5e0d1SDan Handley struct meminfo *bl2_plat_sec_mem_layout(void); 115dec5e0d1SDan Handley 116dec5e0d1SDan Handley /* 117dec5e0d1SDan Handley * This function returns a pointer to the shared memory that the platform has 118dec5e0d1SDan Handley * kept aside to pass trusted firmware related information that BL3-1 119dec5e0d1SDan Handley * could need 120dec5e0d1SDan Handley */ 121dec5e0d1SDan Handley struct bl31_params *bl2_plat_get_bl31_params(void); 122dec5e0d1SDan Handley 123dec5e0d1SDan Handley /* 124dec5e0d1SDan Handley * This function returns a pointer to the shared memory that the platform 125dec5e0d1SDan Handley * has kept to point to entry point information of BL31 to BL2 126dec5e0d1SDan Handley */ 127dec5e0d1SDan Handley struct entry_point_info *bl2_plat_get_bl31_ep_info(void); 128dec5e0d1SDan Handley 129dec5e0d1SDan Handley /* 130dec5e0d1SDan Handley * This function flushes to main memory all the params that are 131dec5e0d1SDan Handley * passed to BL3-1 132dec5e0d1SDan Handley */ 133dec5e0d1SDan Handley void bl2_plat_flush_bl31_params(void); 134dec5e0d1SDan Handley 1355f0cdb05SDan Handley /* 13693d81d64SSandrine Bailleux * The next 2 functions allow the platform to change the entrypoint information 13793d81d64SSandrine Bailleux * for the mandatory 3rd level BL images, BL3-1 and BL3-3. This is done after 13893d81d64SSandrine Bailleux * BL2 has loaded those images into memory but before BL3-1 is executed. 1395f0cdb05SDan Handley */ 1405f0cdb05SDan Handley void bl2_plat_set_bl31_ep_info(struct image_info *image, 1415f0cdb05SDan Handley struct entry_point_info *ep); 1425f0cdb05SDan Handley 1435f0cdb05SDan Handley void bl2_plat_set_bl33_ep_info(struct image_info *image, 1445f0cdb05SDan Handley struct entry_point_info *ep); 1455f0cdb05SDan Handley 14693d81d64SSandrine Bailleux /* Gets the memory layout for BL3-3 */ 1475f0cdb05SDan Handley void bl2_plat_get_bl33_meminfo(struct meminfo *mem_info); 1485f0cdb05SDan Handley 149dec5e0d1SDan Handley /******************************************************************************* 15093d81d64SSandrine Bailleux * Conditionally mandatory BL2 functions: must be implemented if BL3-0 image 15193d81d64SSandrine Bailleux * is supported 15293d81d64SSandrine Bailleux ******************************************************************************/ 15393d81d64SSandrine Bailleux /* Gets the memory layout for BL3-0 */ 15493d81d64SSandrine Bailleux void bl2_plat_get_bl30_meminfo(struct meminfo *mem_info); 15593d81d64SSandrine Bailleux 15693d81d64SSandrine Bailleux /* 15793d81d64SSandrine Bailleux * This function is called after loading BL3-0 image and it is used to perform 15893d81d64SSandrine Bailleux * any platform-specific actions required to handle the SCP firmware. 15993d81d64SSandrine Bailleux */ 16093d81d64SSandrine Bailleux int bl2_plat_handle_bl30(struct image_info *bl30_image_info); 16193d81d64SSandrine Bailleux 16293d81d64SSandrine Bailleux /******************************************************************************* 16393d81d64SSandrine Bailleux * Conditionally mandatory BL2 functions: must be implemented if BL3-2 image 16493d81d64SSandrine Bailleux * is supported 16593d81d64SSandrine Bailleux ******************************************************************************/ 16693d81d64SSandrine Bailleux void bl2_plat_set_bl32_ep_info(struct image_info *image, 16793d81d64SSandrine Bailleux struct entry_point_info *ep); 16893d81d64SSandrine Bailleux 16993d81d64SSandrine Bailleux /* Gets the memory layout for BL3-2 */ 17093d81d64SSandrine Bailleux void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info); 17193d81d64SSandrine Bailleux 17293d81d64SSandrine Bailleux /******************************************************************************* 173dec5e0d1SDan Handley * Optional BL2 functions (may be overridden) 174dec5e0d1SDan Handley ******************************************************************************/ 175dec5e0d1SDan Handley 176dec5e0d1SDan Handley /******************************************************************************* 177dec5e0d1SDan Handley * Mandatory BL3-1 functions 178dec5e0d1SDan Handley ******************************************************************************/ 179dec5e0d1SDan Handley void bl31_early_platform_setup(struct bl31_params *from_bl2, 180dec5e0d1SDan Handley void *plat_params_from_bl2); 181dec5e0d1SDan Handley void bl31_plat_arch_setup(void); 182dec5e0d1SDan Handley void bl31_platform_setup(void); 1839865ac15SDan Handley struct entry_point_info *bl31_plat_get_next_image_ep_info(uint32_t type); 184dec5e0d1SDan Handley 185dec5e0d1SDan Handley /******************************************************************************* 186dec5e0d1SDan Handley * Mandatory PSCI functions (BL3-1) 187dec5e0d1SDan Handley ******************************************************************************/ 18867487846SSoby Mathew int plat_setup_psci_ops(uintptr_t sec_entrypoint, 18967487846SSoby Mathew const struct plat_psci_ops **); 19067487846SSoby Mathew const unsigned char *plat_get_power_domain_tree_desc(void); 19167487846SSoby Mathew 19267487846SSoby Mathew /******************************************************************************* 19367487846SSoby Mathew * Optional PSCI functions (BL3-1). 19467487846SSoby Mathew ******************************************************************************/ 19567487846SSoby Mathew plat_local_state_t plat_get_target_pwr_state(unsigned int lvl, 19667487846SSoby Mathew const plat_local_state_t *states, 19767487846SSoby Mathew unsigned int ncpu); 198dec5e0d1SDan Handley 199dec5e0d1SDan Handley /******************************************************************************* 200dff8e47aSDan Handley * Optional BL3-1 functions (may be overridden) 201dff8e47aSDan Handley ******************************************************************************/ 202afff8cbdSAchin Gupta void bl31_plat_enable_mmu(uint32_t flags); 203dff8e47aSDan Handley 204dff8e47aSDan Handley /******************************************************************************* 205dff8e47aSDan Handley * Optional BL3-2 functions (may be overridden) 206dff8e47aSDan Handley ******************************************************************************/ 207afff8cbdSAchin Gupta void bl32_plat_enable_mmu(uint32_t flags); 208dff8e47aSDan Handley 2096eadf762SJuan Castillo /******************************************************************************* 21095cfd4adSJuan Castillo * Trusted Board Boot functions 2116eadf762SJuan Castillo ******************************************************************************/ 21295cfd4adSJuan Castillo int plat_get_rotpk_info(void *cookie, void **key_ptr, unsigned int *key_len, 21395cfd4adSJuan Castillo unsigned int *flags); 2146eadf762SJuan Castillo 21567487846SSoby Mathew #if ENABLE_PLAT_COMPAT 21667487846SSoby Mathew /* 21767487846SSoby Mathew * The below declarations are to enable compatibility for the platform ports 21867487846SSoby Mathew * using the old platform interface. 21967487846SSoby Mathew */ 22067487846SSoby Mathew 22167487846SSoby Mathew /******************************************************************************* 22267487846SSoby Mathew * Optional common functions (may be overridden) 22367487846SSoby Mathew ******************************************************************************/ 22467487846SSoby Mathew unsigned int platform_get_core_pos(unsigned long mpidr); 22567487846SSoby Mathew 22667487846SSoby Mathew /******************************************************************************* 22767487846SSoby Mathew * Mandatory PSCI Compatibility functions (BL3-1) 22867487846SSoby Mathew ******************************************************************************/ 22967487846SSoby Mathew int platform_setup_pm(const plat_pm_ops_t **); 23067487846SSoby Mathew 23167487846SSoby Mathew unsigned int plat_get_aff_count(unsigned int, unsigned long); 23267487846SSoby Mathew unsigned int plat_get_aff_state(unsigned int, unsigned long); 2335c8babcdSSoby Mathew #else 2345c8babcdSSoby Mathew /* 2355c8babcdSSoby Mathew * The below function enable Trusted Firmware components like SPDs which 2365c8babcdSSoby Mathew * haven't migrated to the new platform API to compile on platforms which 2375c8babcdSSoby Mathew * have the compatibility layer disabled. 2385c8babcdSSoby Mathew */ 2395c8babcdSSoby Mathew unsigned int platform_get_core_pos(unsigned long mpidr) __warn_deprecated; 24067487846SSoby Mathew 2415c8babcdSSoby Mathew #endif /* __ENABLE_PLAT_COMPAT__ */ 2425f0cdb05SDan Handley #endif /* __PLATFORM_H__ */ 243