xref: /rk3399_ARM-atf/include/common/bl_common.h (revision 7260022636e3b0d3ef641cbda135d98f9a7df177)
14ecca339SDan Handley /*
2843ddee4SYatharth Kochar  * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
34ecca339SDan Handley  *
44ecca339SDan Handley  * Redistribution and use in source and binary forms, with or without
54ecca339SDan Handley  * modification, are permitted provided that the following conditions are met:
64ecca339SDan Handley  *
74ecca339SDan Handley  * Redistributions of source code must retain the above copyright notice, this
84ecca339SDan Handley  * list of conditions and the following disclaimer.
94ecca339SDan Handley  *
104ecca339SDan Handley  * Redistributions in binary form must reproduce the above copyright notice,
114ecca339SDan Handley  * this list of conditions and the following disclaimer in the documentation
124ecca339SDan Handley  * and/or other materials provided with the distribution.
134ecca339SDan Handley  *
144ecca339SDan Handley  * Neither the name of ARM nor the names of its contributors may be used
154ecca339SDan Handley  * to endorse or promote products derived from this software without specific
164ecca339SDan Handley  * prior written permission.
174ecca339SDan Handley  *
184ecca339SDan Handley  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
194ecca339SDan Handley  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
204ecca339SDan Handley  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
214ecca339SDan Handley  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
224ecca339SDan Handley  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
234ecca339SDan Handley  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
244ecca339SDan Handley  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
254ecca339SDan Handley  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
264ecca339SDan Handley  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
274ecca339SDan Handley  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
284ecca339SDan Handley  * POSSIBILITY OF SUCH DAMAGE.
294ecca339SDan Handley  */
304ecca339SDan Handley 
314ecca339SDan Handley #ifndef __BL_COMMON_H__
324ecca339SDan Handley #define __BL_COMMON_H__
334ecca339SDan Handley 
344112bfa0SVikram Kanigiri #define SECURE		0x0
354112bfa0SVikram Kanigiri #define NON_SECURE	0x1
36d3280bebSJuan Castillo #define sec_state_is_valid(s) (((s) == SECURE) || ((s) == NON_SECURE))
374ecca339SDan Handley 
384ecca339SDan Handley #define UP	1
394ecca339SDan Handley #define DOWN	0
404ecca339SDan Handley 
414ecca339SDan Handley /*******************************************************************************
428f55dfb4SSandrine Bailleux  * Constants to identify the location of a memory region in a given memory
438f55dfb4SSandrine Bailleux  * layout.
444ecca339SDan Handley ******************************************************************************/
458f55dfb4SSandrine Bailleux #define TOP	0x1
468f55dfb4SSandrine Bailleux #define BOTTOM	!TOP
474ecca339SDan Handley 
4829fb905dSVikram Kanigiri /*******************************************************************************
4929fb905dSVikram Kanigiri  * Constants that allow assembler code to access members of and the
504112bfa0SVikram Kanigiri  * 'entry_point_info' structure at their correct offsets.
5129fb905dSVikram Kanigiri  ******************************************************************************/
524112bfa0SVikram Kanigiri #define ENTRY_POINT_INFO_PC_OFFSET	0x08
53e33b78a6SSoby Mathew #ifdef AARCH32
54e33b78a6SSoby Mathew #define ENTRY_POINT_INFO_ARGS_OFFSET	0x10
55e33b78a6SSoby Mathew #else
564112bfa0SVikram Kanigiri #define ENTRY_POINT_INFO_ARGS_OFFSET	0x18
57e33b78a6SSoby Mathew #endif
584112bfa0SVikram Kanigiri 
597baff11fSYatharth Kochar /* The following are used to set/get image attributes. */
607baff11fSYatharth Kochar #define PARAM_EP_SECURITY_MASK		(0x1)
617baff11fSYatharth Kochar 
624112bfa0SVikram Kanigiri #define GET_SECURITY_STATE(x) (x & PARAM_EP_SECURITY_MASK)
634112bfa0SVikram Kanigiri #define SET_SECURITY_STATE(x, security) \
644112bfa0SVikram Kanigiri 			((x) = ((x) & ~PARAM_EP_SECURITY_MASK) | (security))
654112bfa0SVikram Kanigiri 
667baff11fSYatharth Kochar 
677baff11fSYatharth Kochar /*
687baff11fSYatharth Kochar  * The following are used for image state attributes.
697baff11fSYatharth Kochar  * Image can only be in one of the following state.
707baff11fSYatharth Kochar  */
717baff11fSYatharth Kochar #define IMAGE_STATE_RESET			0
727baff11fSYatharth Kochar #define IMAGE_STATE_COPIED			1
737baff11fSYatharth Kochar #define IMAGE_STATE_COPYING			2
747baff11fSYatharth Kochar #define IMAGE_STATE_AUTHENTICATED		3
757baff11fSYatharth Kochar #define IMAGE_STATE_EXECUTED			4
767baff11fSYatharth Kochar #define IMAGE_STATE_INTERRUPTED			5
777baff11fSYatharth Kochar 
78167a9357SAndrew Thoelke #define EP_EE_MASK	0x2
79167a9357SAndrew Thoelke #define EP_EE_LITTLE	0x0
80167a9357SAndrew Thoelke #define EP_EE_BIG	0x2
81167a9357SAndrew Thoelke #define EP_GET_EE(x) (x & EP_EE_MASK)
82167a9357SAndrew Thoelke #define EP_SET_EE(x, ee) ((x) = ((x) & ~EP_EE_MASK) | (ee))
83167a9357SAndrew Thoelke 
84167a9357SAndrew Thoelke #define EP_ST_MASK	0x4
85167a9357SAndrew Thoelke #define EP_ST_DISABLE	0x0
86167a9357SAndrew Thoelke #define EP_ST_ENABLE	0x4
87167a9357SAndrew Thoelke #define EP_GET_ST(x) (x & EP_ST_MASK)
88167a9357SAndrew Thoelke #define EP_SET_ST(x, ee) ((x) = ((x) & ~EP_ST_MASK) | (ee))
89167a9357SAndrew Thoelke 
90843ddee4SYatharth Kochar #define EP_EXE_MASK	0x8
91843ddee4SYatharth Kochar #define NON_EXECUTABLE	0x0
92843ddee4SYatharth Kochar #define EXECUTABLE	0x8
93843ddee4SYatharth Kochar #define EP_GET_EXE(x) (x & EP_EXE_MASK)
94843ddee4SYatharth Kochar #define EP_SET_EXE(x, ee) ((x) = ((x) & ~EP_EXE_MASK) | (ee))
95843ddee4SYatharth Kochar 
96*72600226SYatharth Kochar #define EP_FIRST_EXE_MASK	0x10
97*72600226SYatharth Kochar #define EP_FIRST_EXE		0x10
98*72600226SYatharth Kochar #define EP_GET_FIRST_EXE(x) ((x) & EP_FIRST_EXE_MASK)
99*72600226SYatharth Kochar #define EP_SET_FIRST_EXE(x, ee) ((x) = ((x) & ~EP_FIRST_EXE_MASK) | (ee))
100*72600226SYatharth Kochar 
1014112bfa0SVikram Kanigiri #define PARAM_EP		0x01
1024112bfa0SVikram Kanigiri #define PARAM_IMAGE_BINARY	0x02
1034112bfa0SVikram Kanigiri #define PARAM_BL31		0x03
104*72600226SYatharth Kochar #define PARAM_BL_LOAD_INFO	0x04
105*72600226SYatharth Kochar #define PARAM_BL_PARAMS		0x05
106*72600226SYatharth Kochar 
107*72600226SYatharth Kochar #define IMAGE_ATTRIB_SKIP_LOADING	0x02
108*72600226SYatharth Kochar #define IMAGE_ATTRIB_PLAT_SETUP		0x04
1094112bfa0SVikram Kanigiri 
1104112bfa0SVikram Kanigiri #define VERSION_1	0x01
111*72600226SYatharth Kochar #define VERSION_2	0x02
1124112bfa0SVikram Kanigiri 
1137baff11fSYatharth Kochar #define INVALID_IMAGE_ID		(0xFFFFFFFF)
1147baff11fSYatharth Kochar 
1154112bfa0SVikram Kanigiri #define SET_PARAM_HEAD(_p, _type, _ver, _attr) do { \
1164112bfa0SVikram Kanigiri 	(_p)->h.type = (uint8_t)(_type); \
1174112bfa0SVikram Kanigiri 	(_p)->h.version = (uint8_t)(_ver); \
1184112bfa0SVikram Kanigiri 	(_p)->h.size = (uint16_t)sizeof(*_p); \
1194112bfa0SVikram Kanigiri 	(_p)->h.attr = (uint32_t)(_attr) ; \
1204112bfa0SVikram Kanigiri 	} while (0)
1214ecca339SDan Handley 
122843ddee4SYatharth Kochar /* Following is used for populating structure members statically. */
123843ddee4SYatharth Kochar #define SET_STATIC_PARAM_HEAD(_p, _type, _ver, _p_type, _attr)	\
124843ddee4SYatharth Kochar 	._p.h.type = (uint8_t)(_type), \
125843ddee4SYatharth Kochar 	._p.h.version = (uint8_t)(_ver), \
126843ddee4SYatharth Kochar 	._p.h.size = (uint16_t)sizeof(_p_type), \
127843ddee4SYatharth Kochar 	._p.h.attr = (uint32_t)(_attr)
128843ddee4SYatharth Kochar 
129843ddee4SYatharth Kochar 
130bbf8f6f9SYatharth Kochar /*******************************************************************************
131bbf8f6f9SYatharth Kochar  * Constants to indicate type of exception to the common exception handler.
132bbf8f6f9SYatharth Kochar  ******************************************************************************/
133bbf8f6f9SYatharth Kochar #define SYNC_EXCEPTION_SP_EL0		0x0
134bbf8f6f9SYatharth Kochar #define IRQ_SP_EL0			0x1
135bbf8f6f9SYatharth Kochar #define FIQ_SP_EL0			0x2
136bbf8f6f9SYatharth Kochar #define SERROR_SP_EL0			0x3
137bbf8f6f9SYatharth Kochar #define SYNC_EXCEPTION_SP_ELX		0x4
138bbf8f6f9SYatharth Kochar #define IRQ_SP_ELX			0x5
139bbf8f6f9SYatharth Kochar #define FIQ_SP_ELX			0x6
140bbf8f6f9SYatharth Kochar #define SERROR_SP_ELX			0x7
141bbf8f6f9SYatharth Kochar #define SYNC_EXCEPTION_AARCH64		0x8
142bbf8f6f9SYatharth Kochar #define IRQ_AARCH64			0x9
143bbf8f6f9SYatharth Kochar #define FIQ_AARCH64			0xa
144bbf8f6f9SYatharth Kochar #define SERROR_AARCH64			0xb
145bbf8f6f9SYatharth Kochar #define SYNC_EXCEPTION_AARCH32		0xc
146bbf8f6f9SYatharth Kochar #define IRQ_AARCH32			0xd
147bbf8f6f9SYatharth Kochar #define FIQ_AARCH32			0xe
148bbf8f6f9SYatharth Kochar #define SERROR_AARCH32			0xf
149bbf8f6f9SYatharth Kochar 
1504ecca339SDan Handley #ifndef __ASSEMBLY__
15197043ac9SDan Handley #include <cdefs.h> /* For __dead2 */
15229fb905dSVikram Kanigiri #include <cassert.h>
1534112bfa0SVikram Kanigiri #include <stdint.h>
1548f55dfb4SSandrine Bailleux #include <stddef.h>
1554c0d0390SSoby Mathew #include <types.h>
156ed81f3ebSSandrine Bailleux #include <utils.h> /* To retain compatibility */
157a7e98ad5SVikram Kanigiri 
15890b3a6acSDan Handley /*
15990b3a6acSDan Handley  * Declarations of linker defined symbols to help determine memory layout of
16090b3a6acSDan Handley  * BL images
16190b3a6acSDan Handley  */
1625d1c104fSSandrine Bailleux #if SEPARATE_CODE_AND_RODATA
1634c0d0390SSoby Mathew extern uintptr_t __TEXT_START__;
1644c0d0390SSoby Mathew extern uintptr_t __TEXT_END__;
1654c0d0390SSoby Mathew extern uintptr_t __RODATA_START__;
1664c0d0390SSoby Mathew extern uintptr_t __RODATA_END__;
1675d1c104fSSandrine Bailleux #else
1684c0d0390SSoby Mathew extern uintptr_t __RO_START__;
1694c0d0390SSoby Mathew extern uintptr_t __RO_END__;
1705d1c104fSSandrine Bailleux #endif
1715d1c104fSSandrine Bailleux 
17290b3a6acSDan Handley #if IMAGE_BL2
1734c0d0390SSoby Mathew extern uintptr_t __BL2_END__;
1749003fa0bSYatharth Kochar #elif IMAGE_BL2U
1754c0d0390SSoby Mathew extern uintptr_t __BL2U_END__;
17690b3a6acSDan Handley #elif IMAGE_BL31
1774c0d0390SSoby Mathew extern uintptr_t __BL31_END__;
17890b3a6acSDan Handley #elif IMAGE_BL32
1794c0d0390SSoby Mathew extern uintptr_t __BL32_END__;
18090b3a6acSDan Handley #endif /* IMAGE_BLX */
18190b3a6acSDan Handley 
18290b3a6acSDan Handley #if USE_COHERENT_MEM
1834c0d0390SSoby Mathew extern uintptr_t __COHERENT_RAM_START__;
1844c0d0390SSoby Mathew extern uintptr_t __COHERENT_RAM_END__;
18590b3a6acSDan Handley #endif
18690b3a6acSDan Handley 
18790b3a6acSDan Handley 
1884ecca339SDan Handley /*******************************************************************************
1894ecca339SDan Handley  * Structure used for telling the next BL how much of a particular type of
1904ecca339SDan Handley  * memory is available for its use and how much is already used.
1914ecca339SDan Handley  ******************************************************************************/
192fb037bfbSDan Handley typedef struct meminfo {
1934c0d0390SSoby Mathew 	uintptr_t total_base;
1948f55dfb4SSandrine Bailleux 	size_t total_size;
195*72600226SYatharth Kochar #if !LOAD_IMAGE_V2
1964c0d0390SSoby Mathew 	uintptr_t free_base;
1978f55dfb4SSandrine Bailleux 	size_t free_size;
198*72600226SYatharth Kochar #endif
199fb037bfbSDan Handley } meminfo_t;
2004ecca339SDan Handley 
201fb037bfbSDan Handley typedef struct aapcs64_params {
2024c0d0390SSoby Mathew 	u_register_t arg0;
2034c0d0390SSoby Mathew 	u_register_t arg1;
2044c0d0390SSoby Mathew 	u_register_t arg2;
2054c0d0390SSoby Mathew 	u_register_t arg3;
2064c0d0390SSoby Mathew 	u_register_t arg4;
2074c0d0390SSoby Mathew 	u_register_t arg5;
2084c0d0390SSoby Mathew 	u_register_t arg6;
2094c0d0390SSoby Mathew 	u_register_t arg7;
210fb037bfbSDan Handley } aapcs64_params_t;
2114ecca339SDan Handley 
212e33b78a6SSoby Mathew typedef struct aapcs32_params {
213e33b78a6SSoby Mathew 	u_register_t arg0;
214e33b78a6SSoby Mathew 	u_register_t arg1;
215e33b78a6SSoby Mathew 	u_register_t arg2;
216e33b78a6SSoby Mathew 	u_register_t arg3;
217e33b78a6SSoby Mathew } aapcs32_params_t;
218e33b78a6SSoby Mathew 
2194112bfa0SVikram Kanigiri /***************************************************************************
2204112bfa0SVikram Kanigiri  * This structure provides version information and the size of the
2214112bfa0SVikram Kanigiri  * structure, attributes for the structure it represents
2224112bfa0SVikram Kanigiri  ***************************************************************************/
2234112bfa0SVikram Kanigiri typedef struct param_header {
2244112bfa0SVikram Kanigiri 	uint8_t type;		/* type of the structure */
2254112bfa0SVikram Kanigiri 	uint8_t version;    /* version of this structure */
2264112bfa0SVikram Kanigiri 	uint16_t size;      /* size of this structure in bytes */
2274112bfa0SVikram Kanigiri 	uint32_t attr;      /* attributes: unused bits SBZ */
2284112bfa0SVikram Kanigiri } param_header_t;
2294112bfa0SVikram Kanigiri 
2304112bfa0SVikram Kanigiri /*****************************************************************************
2314112bfa0SVikram Kanigiri  * This structure represents the superset of information needed while
2324112bfa0SVikram Kanigiri  * switching exception levels. The only two mechanisms to do so are
2334112bfa0SVikram Kanigiri  * ERET & SMC. Security state is indicated using bit zero of header
2344112bfa0SVikram Kanigiri  * attribute
235b313d755SSoby Mathew  * NOTE: BL1 expects entrypoint followed by spsr at an offset from the start
236b313d755SSoby Mathew  * of this structure defined by the macro `ENTRY_POINT_INFO_PC_OFFSET` while
237b313d755SSoby Mathew  * processing SMC to jump to BL31.
2384112bfa0SVikram Kanigiri  *****************************************************************************/
2394112bfa0SVikram Kanigiri typedef struct entry_point_info {
2404112bfa0SVikram Kanigiri 	param_header_t h;
2414112bfa0SVikram Kanigiri 	uintptr_t pc;
2424112bfa0SVikram Kanigiri 	uint32_t spsr;
243e33b78a6SSoby Mathew #ifdef AARCH32
244e33b78a6SSoby Mathew 	aapcs32_params_t args;
245e33b78a6SSoby Mathew #else
246fb037bfbSDan Handley 	aapcs64_params_t args;
247e33b78a6SSoby Mathew #endif
2484112bfa0SVikram Kanigiri } entry_point_info_t;
2494112bfa0SVikram Kanigiri 
2504112bfa0SVikram Kanigiri /*****************************************************************************
2514112bfa0SVikram Kanigiri  * Image info binary provides information from the image loader that
2524112bfa0SVikram Kanigiri  * can be used by the firmware to manage available trusted RAM.
2534112bfa0SVikram Kanigiri  * More advanced firmware image formats can provide additional
2544112bfa0SVikram Kanigiri  * information that enables optimization or greater flexibility in the
2554112bfa0SVikram Kanigiri  * common firmware code
2564112bfa0SVikram Kanigiri  *****************************************************************************/
2574112bfa0SVikram Kanigiri typedef struct image_info {
2584112bfa0SVikram Kanigiri 	param_header_t h;
2594112bfa0SVikram Kanigiri 	uintptr_t image_base;   /* physical address of base of image */
2604112bfa0SVikram Kanigiri 	uint32_t image_size;    /* bytes read from image file */
261*72600226SYatharth Kochar #if LOAD_IMAGE_V2
262*72600226SYatharth Kochar 	uint32_t image_max_size;
263*72600226SYatharth Kochar #endif
2644112bfa0SVikram Kanigiri } image_info_t;
2654ecca339SDan Handley 
2667baff11fSYatharth Kochar /*****************************************************************************
2677baff11fSYatharth Kochar  * The image descriptor struct definition.
2687baff11fSYatharth Kochar  *****************************************************************************/
2697baff11fSYatharth Kochar typedef struct image_desc {
2707baff11fSYatharth Kochar 	/* Contains unique image id for the image. */
2717baff11fSYatharth Kochar 	unsigned int image_id;
2727baff11fSYatharth Kochar 	/*
2737baff11fSYatharth Kochar 	 * This member contains Image state information.
2747baff11fSYatharth Kochar 	 * Refer IMAGE_STATE_XXX defined above.
2757baff11fSYatharth Kochar 	 */
2767baff11fSYatharth Kochar 	unsigned int state;
277843ddee4SYatharth Kochar 	uint32_t copied_size;	/* image size copied in blocks */
278b313d755SSoby Mathew 	image_info_t image_info;
279b313d755SSoby Mathew 	entry_point_info_t ep_info;
2807baff11fSYatharth Kochar } image_desc_t;
2817baff11fSYatharth Kochar 
282*72600226SYatharth Kochar #if LOAD_IMAGE_V2
283*72600226SYatharth Kochar /* BL image node in the BL image loading sequence */
284*72600226SYatharth Kochar typedef struct bl_load_info_node {
285*72600226SYatharth Kochar 	unsigned int image_id;
286*72600226SYatharth Kochar 	image_info_t *image_info;
287*72600226SYatharth Kochar 	struct bl_load_info_node *next_load_info;
288*72600226SYatharth Kochar } bl_load_info_node_t;
289*72600226SYatharth Kochar 
290*72600226SYatharth Kochar /* BL image head node in the BL image loading sequence */
291*72600226SYatharth Kochar typedef struct bl_load_info {
292*72600226SYatharth Kochar 	param_header_t h;
293*72600226SYatharth Kochar 	bl_load_info_node_t *head;
294*72600226SYatharth Kochar } bl_load_info_t;
295*72600226SYatharth Kochar 
296*72600226SYatharth Kochar /* BL image node in the BL image execution sequence */
297*72600226SYatharth Kochar typedef struct bl_params_node {
298*72600226SYatharth Kochar 	unsigned int image_id;
299*72600226SYatharth Kochar 	image_info_t *image_info;
300*72600226SYatharth Kochar 	entry_point_info_t *ep_info;
301*72600226SYatharth Kochar 	struct bl_params_node *next_params_info;
302*72600226SYatharth Kochar } bl_params_node_t;
303*72600226SYatharth Kochar 
304*72600226SYatharth Kochar /*
305*72600226SYatharth Kochar  * BL image head node in the BL image execution sequence
306*72600226SYatharth Kochar  * It is also used to pass information to next BL image.
307*72600226SYatharth Kochar  */
308*72600226SYatharth Kochar typedef struct bl_params {
309*72600226SYatharth Kochar 	param_header_t h;
310*72600226SYatharth Kochar 	bl_params_node_t *head;
311*72600226SYatharth Kochar } bl_params_t;
312*72600226SYatharth Kochar 
313*72600226SYatharth Kochar #else /* LOAD_IMAGE_V2 */
314*72600226SYatharth Kochar 
3154ecca339SDan Handley /*******************************************************************************
3164ecca339SDan Handley  * This structure represents the superset of information that can be passed to
3174ecca339SDan Handley  * BL31 e.g. while passing control to it from BL2. The BL32 parameters will be
3184112bfa0SVikram Kanigiri  * populated only if BL2 detects its presence. A pointer to a structure of this
319d178637dSJuan Castillo  * type should be passed in X0 to BL31's cold boot entrypoint.
3204112bfa0SVikram Kanigiri  *
321d178637dSJuan Castillo  * Use of this structure and the X0 parameter is not mandatory: the BL31
3224112bfa0SVikram Kanigiri  * platform code can use other mechanisms to provide the necessary information
323d178637dSJuan Castillo  * about BL32 and BL33 to the common and SPD code.
3244112bfa0SVikram Kanigiri  *
325d178637dSJuan Castillo  * BL31 image information is mandatory if this structure is used. If either of
326d178637dSJuan Castillo  * the optional BL32 and BL33 image information is not provided, this is
3274112bfa0SVikram Kanigiri  * indicated by the respective image_info pointers being zero.
3284ecca339SDan Handley  ******************************************************************************/
3294112bfa0SVikram Kanigiri typedef struct bl31_params {
3304112bfa0SVikram Kanigiri 	param_header_t h;
3314112bfa0SVikram Kanigiri 	image_info_t *bl31_image_info;
3324112bfa0SVikram Kanigiri 	entry_point_info_t *bl32_ep_info;
3334112bfa0SVikram Kanigiri 	image_info_t *bl32_image_info;
3344112bfa0SVikram Kanigiri 	entry_point_info_t *bl33_ep_info;
3354112bfa0SVikram Kanigiri 	image_info_t *bl33_image_info;
3364112bfa0SVikram Kanigiri } bl31_params_t;
3374112bfa0SVikram Kanigiri 
338*72600226SYatharth Kochar #endif /* LOAD_IMAGE_V2 */
3394112bfa0SVikram Kanigiri 
34029fb905dSVikram Kanigiri /*
3414112bfa0SVikram Kanigiri  * Compile time assertions related to the 'entry_point_info' structure to
34229fb905dSVikram Kanigiri  * ensure that the assembler and the compiler view of the offsets of
34329fb905dSVikram Kanigiri  * the structure members is the same.
34429fb905dSVikram Kanigiri  */
3454112bfa0SVikram Kanigiri CASSERT(ENTRY_POINT_INFO_PC_OFFSET ==
3464112bfa0SVikram Kanigiri 		__builtin_offsetof(entry_point_info_t, pc), \
34729fb905dSVikram Kanigiri 		assert_BL31_pc_offset_mismatch);
34829fb905dSVikram Kanigiri 
3494112bfa0SVikram Kanigiri CASSERT(ENTRY_POINT_INFO_ARGS_OFFSET == \
3504112bfa0SVikram Kanigiri 		__builtin_offsetof(entry_point_info_t, args), \
35129fb905dSVikram Kanigiri 		assert_BL31_args_offset_mismatch);
35229fb905dSVikram Kanigiri 
3534c0d0390SSoby Mathew CASSERT(sizeof(uintptr_t) ==
3544112bfa0SVikram Kanigiri 		__builtin_offsetof(entry_point_info_t, spsr) - \
3554112bfa0SVikram Kanigiri 		__builtin_offsetof(entry_point_info_t, pc), \
35629fb905dSVikram Kanigiri 		assert_entrypoint_and_spsr_should_be_adjacent);
35729fb905dSVikram Kanigiri 
3584ecca339SDan Handley /*******************************************************************************
3594ecca339SDan Handley  * Function & variable prototypes
3604ecca339SDan Handley  ******************************************************************************/
3614c0d0390SSoby Mathew size_t image_size(unsigned int image_id);
362*72600226SYatharth Kochar 
363*72600226SYatharth Kochar #if LOAD_IMAGE_V2
364*72600226SYatharth Kochar 
365*72600226SYatharth Kochar int load_image(unsigned int image_id, image_info_t *image_data);
366*72600226SYatharth Kochar int load_auth_image(unsigned int image_id, image_info_t *image_data);
367*72600226SYatharth Kochar 
368*72600226SYatharth Kochar #else
369*72600226SYatharth Kochar 
370*72600226SYatharth Kochar uintptr_t page_align(uintptr_t, unsigned);
3718f55dfb4SSandrine Bailleux int load_image(meminfo_t *mem_layout,
37216948ae1SJuan Castillo 	       unsigned int image_id,
3731779ba6bSJuan Castillo 	       uintptr_t image_base,
3741779ba6bSJuan Castillo 	       image_info_t *image_data,
3751779ba6bSJuan Castillo 	       entry_point_info_t *entry_point_info);
3761779ba6bSJuan Castillo int load_auth_image(meminfo_t *mem_layout,
377*72600226SYatharth Kochar 		    unsigned int image_id,
3781779ba6bSJuan Castillo 		    uintptr_t image_base,
3798f55dfb4SSandrine Bailleux 		    image_info_t *image_data,
3808f55dfb4SSandrine Bailleux 		    entry_point_info_t *entry_point_info);
3814c0d0390SSoby Mathew void reserve_mem(uintptr_t *free_base, size_t *free_size,
3824c0d0390SSoby Mathew 		uintptr_t addr, size_t size);
3838f55dfb4SSandrine Bailleux 
384*72600226SYatharth Kochar #endif /* LOAD_IMAGE_V2 */
385*72600226SYatharth Kochar 
386*72600226SYatharth Kochar extern const char build_message[];
387*72600226SYatharth Kochar extern const char version_string[];
388*72600226SYatharth Kochar 
38968a68c92SSandrine Bailleux void print_entry_point_info(const entry_point_info_t *ep_info);
39068a68c92SSandrine Bailleux 
3914ecca339SDan Handley #endif /*__ASSEMBLY__*/
3924ecca339SDan Handley 
3934ecca339SDan Handley #endif /* __BL_COMMON_H__ */
394