15f0cdb05SDan Handley /* 25f0cdb05SDan Handley * Copyright (c) 2013-2014, 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 345f0cdb05SDan Handley #include <stdint.h> 355f0cdb05SDan Handley 365f0cdb05SDan Handley 375f0cdb05SDan Handley /******************************************************************************* 385f0cdb05SDan Handley * Forward declarations 395f0cdb05SDan Handley ******************************************************************************/ 405f0cdb05SDan Handley struct plat_pm_ops; 415f0cdb05SDan Handley struct meminfo; 425f0cdb05SDan Handley struct image_info; 435f0cdb05SDan Handley struct entry_point_info; 44dec5e0d1SDan Handley struct bl31_params; 455f0cdb05SDan Handley 465f0cdb05SDan Handley /******************************************************************************* 47dec5e0d1SDan Handley * Function declarations 485f0cdb05SDan Handley ******************************************************************************/ 49dec5e0d1SDan Handley /******************************************************************************* 50dec5e0d1SDan Handley * Mandatory common functions 51dec5e0d1SDan Handley ******************************************************************************/ 52dec5e0d1SDan Handley uint64_t plat_get_syscnt_freq(void); 53dec5e0d1SDan Handley int plat_get_image_source(const char *image_name, 54dec5e0d1SDan Handley uintptr_t *dev_handle, 55dec5e0d1SDan Handley uintptr_t *image_spec); 565f0cdb05SDan Handley unsigned long plat_get_ns_image_entrypoint(void); 57dec5e0d1SDan Handley 58dec5e0d1SDan Handley /******************************************************************************* 59dec5e0d1SDan Handley * Mandatory interrupt management functions 60dec5e0d1SDan Handley ******************************************************************************/ 619865ac15SDan Handley uint32_t plat_ic_get_pending_interrupt_id(void); 629865ac15SDan Handley uint32_t plat_ic_get_pending_interrupt_type(void); 639865ac15SDan Handley uint32_t plat_ic_acknowledge_interrupt(void); 649865ac15SDan Handley uint32_t plat_ic_get_interrupt_type(uint32_t id); 659865ac15SDan Handley void plat_ic_end_of_interrupt(uint32_t id); 665f0cdb05SDan Handley uint32_t plat_interrupt_type_to_line(uint32_t type, 675f0cdb05SDan Handley uint32_t security_state); 685f0cdb05SDan Handley 69dec5e0d1SDan Handley /******************************************************************************* 70dec5e0d1SDan Handley * Optional common functions (may be overridden) 71dec5e0d1SDan Handley ******************************************************************************/ 72dec5e0d1SDan Handley unsigned int platform_get_core_pos(unsigned long mpidr); 73dec5e0d1SDan Handley unsigned long platform_get_stack(unsigned long mpidr); 74dec5e0d1SDan Handley void plat_report_exception(unsigned long); 75dec5e0d1SDan Handley 76dec5e0d1SDan Handley /******************************************************************************* 77dec5e0d1SDan Handley * Mandatory BL1 functions 78dec5e0d1SDan Handley ******************************************************************************/ 79dec5e0d1SDan Handley void bl1_plat_arch_setup(void); 80dec5e0d1SDan Handley void bl1_platform_setup(void); 81dec5e0d1SDan Handley struct meminfo *bl1_plat_sec_mem_layout(void); 825f0cdb05SDan Handley 835f0cdb05SDan Handley /* 840ad46911SDan Handley * This function allows the platform to change the entrypoint information for 850ad46911SDan Handley * BL2, after BL1 has loaded BL2 into memory but before BL2 is executed. 865f0cdb05SDan Handley */ 875f0cdb05SDan Handley void bl1_plat_set_bl2_ep_info(struct image_info *image, 885f0cdb05SDan Handley struct entry_point_info *ep); 895f0cdb05SDan Handley 90dec5e0d1SDan Handley /******************************************************************************* 91dec5e0d1SDan Handley * Optional BL1 functions (may be overridden) 92dec5e0d1SDan Handley ******************************************************************************/ 938f55dfb4SSandrine Bailleux void bl1_init_bl2_mem_layout(const struct meminfo *bl1_mem_layout, 948f55dfb4SSandrine Bailleux struct meminfo *bl2_mem_layout); 95dec5e0d1SDan Handley 96dec5e0d1SDan Handley /******************************************************************************* 97dec5e0d1SDan Handley * Mandatory BL2 functions 98dec5e0d1SDan Handley ******************************************************************************/ 99dec5e0d1SDan Handley void bl2_plat_arch_setup(void); 100dec5e0d1SDan Handley void bl2_platform_setup(void); 101dec5e0d1SDan Handley struct meminfo *bl2_plat_sec_mem_layout(void); 102dec5e0d1SDan Handley 103dec5e0d1SDan Handley /* 104dec5e0d1SDan Handley * This function returns a pointer to the shared memory that the platform has 105dec5e0d1SDan Handley * kept aside to pass trusted firmware related information that BL3-1 106dec5e0d1SDan Handley * could need 107dec5e0d1SDan Handley */ 108dec5e0d1SDan Handley struct bl31_params *bl2_plat_get_bl31_params(void); 109dec5e0d1SDan Handley 110dec5e0d1SDan Handley /* 111dec5e0d1SDan Handley * This function returns a pointer to the shared memory that the platform 112dec5e0d1SDan Handley * has kept to point to entry point information of BL31 to BL2 113dec5e0d1SDan Handley */ 114dec5e0d1SDan Handley struct entry_point_info *bl2_plat_get_bl31_ep_info(void); 115dec5e0d1SDan Handley 116dec5e0d1SDan Handley /* 117dec5e0d1SDan Handley * This function flushes to main memory all the params that are 118dec5e0d1SDan Handley * passed to BL3-1 119dec5e0d1SDan Handley */ 120dec5e0d1SDan Handley void bl2_plat_flush_bl31_params(void); 121dec5e0d1SDan Handley 1225f0cdb05SDan Handley /* 12393d81d64SSandrine Bailleux * The next 2 functions allow the platform to change the entrypoint information 12493d81d64SSandrine Bailleux * for the mandatory 3rd level BL images, BL3-1 and BL3-3. This is done after 12593d81d64SSandrine Bailleux * BL2 has loaded those images into memory but before BL3-1 is executed. 1265f0cdb05SDan Handley */ 1275f0cdb05SDan Handley void bl2_plat_set_bl31_ep_info(struct image_info *image, 1285f0cdb05SDan Handley struct entry_point_info *ep); 1295f0cdb05SDan Handley 1305f0cdb05SDan Handley void bl2_plat_set_bl33_ep_info(struct image_info *image, 1315f0cdb05SDan Handley struct entry_point_info *ep); 1325f0cdb05SDan Handley 13393d81d64SSandrine Bailleux /* Gets the memory layout for BL3-3 */ 1345f0cdb05SDan Handley void bl2_plat_get_bl33_meminfo(struct meminfo *mem_info); 1355f0cdb05SDan Handley 136dec5e0d1SDan Handley /******************************************************************************* 13793d81d64SSandrine Bailleux * Conditionally mandatory BL2 functions: must be implemented if BL3-0 image 13893d81d64SSandrine Bailleux * is supported 13993d81d64SSandrine Bailleux ******************************************************************************/ 14093d81d64SSandrine Bailleux /* Gets the memory layout for BL3-0 */ 14193d81d64SSandrine Bailleux void bl2_plat_get_bl30_meminfo(struct meminfo *mem_info); 14293d81d64SSandrine Bailleux 14393d81d64SSandrine Bailleux /* 14493d81d64SSandrine Bailleux * This function is called after loading BL3-0 image and it is used to perform 14593d81d64SSandrine Bailleux * any platform-specific actions required to handle the SCP firmware. 14693d81d64SSandrine Bailleux */ 14793d81d64SSandrine Bailleux int bl2_plat_handle_bl30(struct image_info *bl30_image_info); 14893d81d64SSandrine Bailleux 14993d81d64SSandrine Bailleux /******************************************************************************* 15093d81d64SSandrine Bailleux * Conditionally mandatory BL2 functions: must be implemented if BL3-2 image 15193d81d64SSandrine Bailleux * is supported 15293d81d64SSandrine Bailleux ******************************************************************************/ 15393d81d64SSandrine Bailleux void bl2_plat_set_bl32_ep_info(struct image_info *image, 15493d81d64SSandrine Bailleux struct entry_point_info *ep); 15593d81d64SSandrine Bailleux 15693d81d64SSandrine Bailleux /* Gets the memory layout for BL3-2 */ 15793d81d64SSandrine Bailleux void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info); 15893d81d64SSandrine Bailleux 15993d81d64SSandrine Bailleux /******************************************************************************* 160dec5e0d1SDan Handley * Optional BL2 functions (may be overridden) 161dec5e0d1SDan Handley ******************************************************************************/ 162dec5e0d1SDan Handley 163dec5e0d1SDan Handley /******************************************************************************* 164dec5e0d1SDan Handley * Mandatory BL3-1 functions 165dec5e0d1SDan Handley ******************************************************************************/ 166dec5e0d1SDan Handley void bl31_early_platform_setup(struct bl31_params *from_bl2, 167dec5e0d1SDan Handley void *plat_params_from_bl2); 168dec5e0d1SDan Handley void bl31_plat_arch_setup(void); 169dec5e0d1SDan Handley void bl31_platform_setup(void); 1709865ac15SDan Handley struct entry_point_info *bl31_plat_get_next_image_ep_info(uint32_t type); 171dec5e0d1SDan Handley 172dec5e0d1SDan Handley /******************************************************************************* 173dec5e0d1SDan Handley * Mandatory PSCI functions (BL3-1) 174dec5e0d1SDan Handley ******************************************************************************/ 175dec5e0d1SDan Handley int platform_setup_pm(const struct plat_pm_ops **); 176dec5e0d1SDan Handley int plat_get_max_afflvl(void); 177dec5e0d1SDan Handley unsigned int plat_get_aff_count(unsigned int, unsigned long); 178dec5e0d1SDan Handley unsigned int plat_get_aff_state(unsigned int, unsigned long); 179dec5e0d1SDan Handley 180dec5e0d1SDan Handley /******************************************************************************* 181dff8e47aSDan Handley * Optional BL3-1 functions (may be overridden) 182dff8e47aSDan Handley ******************************************************************************/ 183*afff8cbdSAchin Gupta void bl31_plat_enable_mmu(uint32_t flags); 184dff8e47aSDan Handley 185dff8e47aSDan Handley /******************************************************************************* 186dec5e0d1SDan Handley * Mandatory BL3-2 functions (only if platform contains a BL3-2) 187dec5e0d1SDan Handley ******************************************************************************/ 188dec5e0d1SDan Handley void bl32_platform_setup(void); 1895f0cdb05SDan Handley 190dff8e47aSDan Handley /******************************************************************************* 191dff8e47aSDan Handley * Optional BL3-2 functions (may be overridden) 192dff8e47aSDan Handley ******************************************************************************/ 193*afff8cbdSAchin Gupta void bl32_plat_enable_mmu(uint32_t flags); 194dff8e47aSDan Handley 1955f0cdb05SDan Handley #endif /* __PLATFORM_H__ */ 196