xref: /rk3399_ARM-atf/include/common/bl_common.h (revision 3d8256b2a1ef1195aed86bef7378e83d0a61a91b)
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 
9672600226SYatharth Kochar #define EP_FIRST_EXE_MASK	0x10
9772600226SYatharth Kochar #define EP_FIRST_EXE		0x10
9872600226SYatharth Kochar #define EP_GET_FIRST_EXE(x) ((x) & EP_FIRST_EXE_MASK)
9972600226SYatharth Kochar #define EP_SET_FIRST_EXE(x, ee) ((x) = ((x) & ~EP_FIRST_EXE_MASK) | (ee))
10072600226SYatharth Kochar 
1014112bfa0SVikram Kanigiri #define PARAM_EP		0x01
1024112bfa0SVikram Kanigiri #define PARAM_IMAGE_BINARY	0x02
1034112bfa0SVikram Kanigiri #define PARAM_BL31		0x03
10472600226SYatharth Kochar #define PARAM_BL_LOAD_INFO	0x04
10572600226SYatharth Kochar #define PARAM_BL_PARAMS		0x05
106f426fc05SSoby Mathew #define PARAM_PSCI_LIB_ARGS	0x06
10772600226SYatharth Kochar 
10872600226SYatharth Kochar #define IMAGE_ATTRIB_SKIP_LOADING	0x02
10972600226SYatharth Kochar #define IMAGE_ATTRIB_PLAT_SETUP		0x04
1104112bfa0SVikram Kanigiri 
1114112bfa0SVikram Kanigiri #define VERSION_1	0x01
11272600226SYatharth Kochar #define VERSION_2	0x02
1134112bfa0SVikram Kanigiri 
1147baff11fSYatharth Kochar #define INVALID_IMAGE_ID		(0xFFFFFFFF)
1157baff11fSYatharth Kochar 
1164112bfa0SVikram Kanigiri #define SET_PARAM_HEAD(_p, _type, _ver, _attr) do { \
1174112bfa0SVikram Kanigiri 	(_p)->h.type = (uint8_t)(_type); \
1184112bfa0SVikram Kanigiri 	(_p)->h.version = (uint8_t)(_ver); \
1194112bfa0SVikram Kanigiri 	(_p)->h.size = (uint16_t)sizeof(*_p); \
1204112bfa0SVikram Kanigiri 	(_p)->h.attr = (uint32_t)(_attr) ; \
1214112bfa0SVikram Kanigiri 	} while (0)
1224ecca339SDan Handley 
123843ddee4SYatharth Kochar /* Following is used for populating structure members statically. */
124843ddee4SYatharth Kochar #define SET_STATIC_PARAM_HEAD(_p, _type, _ver, _p_type, _attr)	\
125843ddee4SYatharth Kochar 	._p.h.type = (uint8_t)(_type), \
126843ddee4SYatharth Kochar 	._p.h.version = (uint8_t)(_ver), \
127843ddee4SYatharth Kochar 	._p.h.size = (uint16_t)sizeof(_p_type), \
128843ddee4SYatharth Kochar 	._p.h.attr = (uint32_t)(_attr)
129843ddee4SYatharth Kochar 
130843ddee4SYatharth Kochar 
131bbf8f6f9SYatharth Kochar /*******************************************************************************
132bbf8f6f9SYatharth Kochar  * Constants to indicate type of exception to the common exception handler.
133bbf8f6f9SYatharth Kochar  ******************************************************************************/
134bbf8f6f9SYatharth Kochar #define SYNC_EXCEPTION_SP_EL0		0x0
135bbf8f6f9SYatharth Kochar #define IRQ_SP_EL0			0x1
136bbf8f6f9SYatharth Kochar #define FIQ_SP_EL0			0x2
137bbf8f6f9SYatharth Kochar #define SERROR_SP_EL0			0x3
138bbf8f6f9SYatharth Kochar #define SYNC_EXCEPTION_SP_ELX		0x4
139bbf8f6f9SYatharth Kochar #define IRQ_SP_ELX			0x5
140bbf8f6f9SYatharth Kochar #define FIQ_SP_ELX			0x6
141bbf8f6f9SYatharth Kochar #define SERROR_SP_ELX			0x7
142bbf8f6f9SYatharth Kochar #define SYNC_EXCEPTION_AARCH64		0x8
143bbf8f6f9SYatharth Kochar #define IRQ_AARCH64			0x9
144bbf8f6f9SYatharth Kochar #define FIQ_AARCH64			0xa
145bbf8f6f9SYatharth Kochar #define SERROR_AARCH64			0xb
146bbf8f6f9SYatharth Kochar #define SYNC_EXCEPTION_AARCH32		0xc
147bbf8f6f9SYatharth Kochar #define IRQ_AARCH32			0xd
148bbf8f6f9SYatharth Kochar #define FIQ_AARCH32			0xe
149bbf8f6f9SYatharth Kochar #define SERROR_AARCH32			0xf
150bbf8f6f9SYatharth Kochar 
1514ecca339SDan Handley #ifndef __ASSEMBLY__
15297043ac9SDan Handley #include <cdefs.h> /* For __dead2 */
15329fb905dSVikram Kanigiri #include <cassert.h>
1544112bfa0SVikram Kanigiri #include <stdint.h>
1558f55dfb4SSandrine Bailleux #include <stddef.h>
1564c0d0390SSoby Mathew #include <types.h>
157ed81f3ebSSandrine Bailleux #include <utils.h> /* To retain compatibility */
158a7e98ad5SVikram Kanigiri 
15990b3a6acSDan Handley /*
16090b3a6acSDan Handley  * Declarations of linker defined symbols to help determine memory layout of
16190b3a6acSDan Handley  * BL images
16290b3a6acSDan Handley  */
1635d1c104fSSandrine Bailleux #if SEPARATE_CODE_AND_RODATA
1644c0d0390SSoby Mathew extern uintptr_t __TEXT_START__;
1654c0d0390SSoby Mathew extern uintptr_t __TEXT_END__;
1664c0d0390SSoby Mathew extern uintptr_t __RODATA_START__;
1674c0d0390SSoby Mathew extern uintptr_t __RODATA_END__;
1685d1c104fSSandrine Bailleux #else
1694c0d0390SSoby Mathew extern uintptr_t __RO_START__;
1704c0d0390SSoby Mathew extern uintptr_t __RO_END__;
1715d1c104fSSandrine Bailleux #endif
1725d1c104fSSandrine Bailleux 
173*3d8256b2SMasahiro Yamada #if defined(IMAGE_BL2)
1744c0d0390SSoby Mathew extern uintptr_t __BL2_END__;
175*3d8256b2SMasahiro Yamada #elif defined(IMAGE_BL2U)
1764c0d0390SSoby Mathew extern uintptr_t __BL2U_END__;
177*3d8256b2SMasahiro Yamada #elif defined(IMAGE_BL31)
1784c0d0390SSoby Mathew extern uintptr_t __BL31_END__;
179*3d8256b2SMasahiro Yamada #elif defined(IMAGE_BL32)
1804c0d0390SSoby Mathew extern uintptr_t __BL32_END__;
18190b3a6acSDan Handley #endif /* IMAGE_BLX */
18290b3a6acSDan Handley 
18390b3a6acSDan Handley #if USE_COHERENT_MEM
1844c0d0390SSoby Mathew extern uintptr_t __COHERENT_RAM_START__;
1854c0d0390SSoby Mathew extern uintptr_t __COHERENT_RAM_END__;
18690b3a6acSDan Handley #endif
18790b3a6acSDan Handley 
18890b3a6acSDan Handley 
1894ecca339SDan Handley /*******************************************************************************
1904ecca339SDan Handley  * Structure used for telling the next BL how much of a particular type of
1914ecca339SDan Handley  * memory is available for its use and how much is already used.
1924ecca339SDan Handley  ******************************************************************************/
193fb037bfbSDan Handley typedef struct meminfo {
1944c0d0390SSoby Mathew 	uintptr_t total_base;
1958f55dfb4SSandrine Bailleux 	size_t total_size;
19672600226SYatharth Kochar #if !LOAD_IMAGE_V2
1974c0d0390SSoby Mathew 	uintptr_t free_base;
1988f55dfb4SSandrine Bailleux 	size_t free_size;
19972600226SYatharth Kochar #endif
200fb037bfbSDan Handley } meminfo_t;
2014ecca339SDan Handley 
202fb037bfbSDan Handley typedef struct aapcs64_params {
2034c0d0390SSoby Mathew 	u_register_t arg0;
2044c0d0390SSoby Mathew 	u_register_t arg1;
2054c0d0390SSoby Mathew 	u_register_t arg2;
2064c0d0390SSoby Mathew 	u_register_t arg3;
2074c0d0390SSoby Mathew 	u_register_t arg4;
2084c0d0390SSoby Mathew 	u_register_t arg5;
2094c0d0390SSoby Mathew 	u_register_t arg6;
2104c0d0390SSoby Mathew 	u_register_t arg7;
211fb037bfbSDan Handley } aapcs64_params_t;
2124ecca339SDan Handley 
213e33b78a6SSoby Mathew typedef struct aapcs32_params {
214e33b78a6SSoby Mathew 	u_register_t arg0;
215e33b78a6SSoby Mathew 	u_register_t arg1;
216e33b78a6SSoby Mathew 	u_register_t arg2;
217e33b78a6SSoby Mathew 	u_register_t arg3;
218e33b78a6SSoby Mathew } aapcs32_params_t;
219e33b78a6SSoby Mathew 
2204112bfa0SVikram Kanigiri /***************************************************************************
2214112bfa0SVikram Kanigiri  * This structure provides version information and the size of the
2224112bfa0SVikram Kanigiri  * structure, attributes for the structure it represents
2234112bfa0SVikram Kanigiri  ***************************************************************************/
2244112bfa0SVikram Kanigiri typedef struct param_header {
2254112bfa0SVikram Kanigiri 	uint8_t type;		/* type of the structure */
2264112bfa0SVikram Kanigiri 	uint8_t version;    /* version of this structure */
2274112bfa0SVikram Kanigiri 	uint16_t size;      /* size of this structure in bytes */
2284112bfa0SVikram Kanigiri 	uint32_t attr;      /* attributes: unused bits SBZ */
2294112bfa0SVikram Kanigiri } param_header_t;
2304112bfa0SVikram Kanigiri 
2314112bfa0SVikram Kanigiri /*****************************************************************************
2324112bfa0SVikram Kanigiri  * This structure represents the superset of information needed while
2334112bfa0SVikram Kanigiri  * switching exception levels. The only two mechanisms to do so are
2344112bfa0SVikram Kanigiri  * ERET & SMC. Security state is indicated using bit zero of header
2354112bfa0SVikram Kanigiri  * attribute
236b313d755SSoby Mathew  * NOTE: BL1 expects entrypoint followed by spsr at an offset from the start
237b313d755SSoby Mathew  * of this structure defined by the macro `ENTRY_POINT_INFO_PC_OFFSET` while
238b313d755SSoby Mathew  * processing SMC to jump to BL31.
2394112bfa0SVikram Kanigiri  *****************************************************************************/
2404112bfa0SVikram Kanigiri typedef struct entry_point_info {
2414112bfa0SVikram Kanigiri 	param_header_t h;
2424112bfa0SVikram Kanigiri 	uintptr_t pc;
2434112bfa0SVikram Kanigiri 	uint32_t spsr;
244e33b78a6SSoby Mathew #ifdef AARCH32
245e33b78a6SSoby Mathew 	aapcs32_params_t args;
246e33b78a6SSoby Mathew #else
247fb037bfbSDan Handley 	aapcs64_params_t args;
248e33b78a6SSoby Mathew #endif
2494112bfa0SVikram Kanigiri } entry_point_info_t;
2504112bfa0SVikram Kanigiri 
2514112bfa0SVikram Kanigiri /*****************************************************************************
2524112bfa0SVikram Kanigiri  * Image info binary provides information from the image loader that
2534112bfa0SVikram Kanigiri  * can be used by the firmware to manage available trusted RAM.
2544112bfa0SVikram Kanigiri  * More advanced firmware image formats can provide additional
2554112bfa0SVikram Kanigiri  * information that enables optimization or greater flexibility in the
2564112bfa0SVikram Kanigiri  * common firmware code
2574112bfa0SVikram Kanigiri  *****************************************************************************/
2584112bfa0SVikram Kanigiri typedef struct image_info {
2594112bfa0SVikram Kanigiri 	param_header_t h;
2604112bfa0SVikram Kanigiri 	uintptr_t image_base;   /* physical address of base of image */
2614112bfa0SVikram Kanigiri 	uint32_t image_size;    /* bytes read from image file */
26272600226SYatharth Kochar #if LOAD_IMAGE_V2
26372600226SYatharth Kochar 	uint32_t image_max_size;
26472600226SYatharth Kochar #endif
2654112bfa0SVikram Kanigiri } image_info_t;
2664ecca339SDan Handley 
2677baff11fSYatharth Kochar /*****************************************************************************
2687baff11fSYatharth Kochar  * The image descriptor struct definition.
2697baff11fSYatharth Kochar  *****************************************************************************/
2707baff11fSYatharth Kochar typedef struct image_desc {
2717baff11fSYatharth Kochar 	/* Contains unique image id for the image. */
2727baff11fSYatharth Kochar 	unsigned int image_id;
2737baff11fSYatharth Kochar 	/*
2747baff11fSYatharth Kochar 	 * This member contains Image state information.
2757baff11fSYatharth Kochar 	 * Refer IMAGE_STATE_XXX defined above.
2767baff11fSYatharth Kochar 	 */
2777baff11fSYatharth Kochar 	unsigned int state;
278843ddee4SYatharth Kochar 	uint32_t copied_size;	/* image size copied in blocks */
279b313d755SSoby Mathew 	image_info_t image_info;
280b313d755SSoby Mathew 	entry_point_info_t ep_info;
2817baff11fSYatharth Kochar } image_desc_t;
2827baff11fSYatharth Kochar 
28372600226SYatharth Kochar #if LOAD_IMAGE_V2
28472600226SYatharth Kochar /* BL image node in the BL image loading sequence */
28572600226SYatharth Kochar typedef struct bl_load_info_node {
28672600226SYatharth Kochar 	unsigned int image_id;
28772600226SYatharth Kochar 	image_info_t *image_info;
28872600226SYatharth Kochar 	struct bl_load_info_node *next_load_info;
28972600226SYatharth Kochar } bl_load_info_node_t;
29072600226SYatharth Kochar 
29172600226SYatharth Kochar /* BL image head node in the BL image loading sequence */
29272600226SYatharth Kochar typedef struct bl_load_info {
29372600226SYatharth Kochar 	param_header_t h;
29472600226SYatharth Kochar 	bl_load_info_node_t *head;
29572600226SYatharth Kochar } bl_load_info_t;
29672600226SYatharth Kochar 
29772600226SYatharth Kochar /* BL image node in the BL image execution sequence */
29872600226SYatharth Kochar typedef struct bl_params_node {
29972600226SYatharth Kochar 	unsigned int image_id;
30072600226SYatharth Kochar 	image_info_t *image_info;
30172600226SYatharth Kochar 	entry_point_info_t *ep_info;
30272600226SYatharth Kochar 	struct bl_params_node *next_params_info;
30372600226SYatharth Kochar } bl_params_node_t;
30472600226SYatharth Kochar 
30572600226SYatharth Kochar /*
30672600226SYatharth Kochar  * BL image head node in the BL image execution sequence
30772600226SYatharth Kochar  * It is also used to pass information to next BL image.
30872600226SYatharth Kochar  */
30972600226SYatharth Kochar typedef struct bl_params {
31072600226SYatharth Kochar 	param_header_t h;
31172600226SYatharth Kochar 	bl_params_node_t *head;
31272600226SYatharth Kochar } bl_params_t;
31372600226SYatharth Kochar 
31472600226SYatharth Kochar #else /* LOAD_IMAGE_V2 */
31572600226SYatharth Kochar 
3164ecca339SDan Handley /*******************************************************************************
3174ecca339SDan Handley  * This structure represents the superset of information that can be passed to
3184ecca339SDan Handley  * BL31 e.g. while passing control to it from BL2. The BL32 parameters will be
3194112bfa0SVikram Kanigiri  * populated only if BL2 detects its presence. A pointer to a structure of this
320d178637dSJuan Castillo  * type should be passed in X0 to BL31's cold boot entrypoint.
3214112bfa0SVikram Kanigiri  *
322d178637dSJuan Castillo  * Use of this structure and the X0 parameter is not mandatory: the BL31
3234112bfa0SVikram Kanigiri  * platform code can use other mechanisms to provide the necessary information
324d178637dSJuan Castillo  * about BL32 and BL33 to the common and SPD code.
3254112bfa0SVikram Kanigiri  *
326d178637dSJuan Castillo  * BL31 image information is mandatory if this structure is used. If either of
327d178637dSJuan Castillo  * the optional BL32 and BL33 image information is not provided, this is
3284112bfa0SVikram Kanigiri  * indicated by the respective image_info pointers being zero.
3294ecca339SDan Handley  ******************************************************************************/
3304112bfa0SVikram Kanigiri typedef struct bl31_params {
3314112bfa0SVikram Kanigiri 	param_header_t h;
3324112bfa0SVikram Kanigiri 	image_info_t *bl31_image_info;
3334112bfa0SVikram Kanigiri 	entry_point_info_t *bl32_ep_info;
3344112bfa0SVikram Kanigiri 	image_info_t *bl32_image_info;
3354112bfa0SVikram Kanigiri 	entry_point_info_t *bl33_ep_info;
3364112bfa0SVikram Kanigiri 	image_info_t *bl33_image_info;
3374112bfa0SVikram Kanigiri } bl31_params_t;
3384112bfa0SVikram Kanigiri 
33972600226SYatharth Kochar #endif /* LOAD_IMAGE_V2 */
3404112bfa0SVikram Kanigiri 
34129fb905dSVikram Kanigiri /*
3424112bfa0SVikram Kanigiri  * Compile time assertions related to the 'entry_point_info' structure to
34329fb905dSVikram Kanigiri  * ensure that the assembler and the compiler view of the offsets of
34429fb905dSVikram Kanigiri  * the structure members is the same.
34529fb905dSVikram Kanigiri  */
3464112bfa0SVikram Kanigiri CASSERT(ENTRY_POINT_INFO_PC_OFFSET ==
3474112bfa0SVikram Kanigiri 		__builtin_offsetof(entry_point_info_t, pc), \
34829fb905dSVikram Kanigiri 		assert_BL31_pc_offset_mismatch);
34929fb905dSVikram Kanigiri 
3504112bfa0SVikram Kanigiri CASSERT(ENTRY_POINT_INFO_ARGS_OFFSET == \
3514112bfa0SVikram Kanigiri 		__builtin_offsetof(entry_point_info_t, args), \
35229fb905dSVikram Kanigiri 		assert_BL31_args_offset_mismatch);
35329fb905dSVikram Kanigiri 
3544c0d0390SSoby Mathew CASSERT(sizeof(uintptr_t) ==
3554112bfa0SVikram Kanigiri 		__builtin_offsetof(entry_point_info_t, spsr) - \
3564112bfa0SVikram Kanigiri 		__builtin_offsetof(entry_point_info_t, pc), \
35729fb905dSVikram Kanigiri 		assert_entrypoint_and_spsr_should_be_adjacent);
35829fb905dSVikram Kanigiri 
3594ecca339SDan Handley /*******************************************************************************
3604ecca339SDan Handley  * Function & variable prototypes
3614ecca339SDan Handley  ******************************************************************************/
3624c0d0390SSoby Mathew size_t image_size(unsigned int image_id);
36372600226SYatharth Kochar 
36499c5ebafSSandrine Bailleux int is_mem_free(uintptr_t free_base, size_t free_size,
36599c5ebafSSandrine Bailleux 		uintptr_t addr, size_t size);
36699c5ebafSSandrine Bailleux 
36772600226SYatharth Kochar #if LOAD_IMAGE_V2
36872600226SYatharth Kochar 
36972600226SYatharth Kochar int load_image(unsigned int image_id, image_info_t *image_data);
37072600226SYatharth Kochar int load_auth_image(unsigned int image_id, image_info_t *image_data);
37172600226SYatharth Kochar 
37272600226SYatharth Kochar #else
37372600226SYatharth Kochar 
37472600226SYatharth Kochar uintptr_t page_align(uintptr_t, unsigned);
3758f55dfb4SSandrine Bailleux int load_image(meminfo_t *mem_layout,
37616948ae1SJuan Castillo 	       unsigned int image_id,
3771779ba6bSJuan Castillo 	       uintptr_t image_base,
3781779ba6bSJuan Castillo 	       image_info_t *image_data,
3791779ba6bSJuan Castillo 	       entry_point_info_t *entry_point_info);
3801779ba6bSJuan Castillo int load_auth_image(meminfo_t *mem_layout,
38172600226SYatharth Kochar 		    unsigned int image_id,
3821779ba6bSJuan Castillo 		    uintptr_t image_base,
3838f55dfb4SSandrine Bailleux 		    image_info_t *image_data,
3848f55dfb4SSandrine Bailleux 		    entry_point_info_t *entry_point_info);
3854c0d0390SSoby Mathew void reserve_mem(uintptr_t *free_base, size_t *free_size,
3864c0d0390SSoby Mathew 		uintptr_t addr, size_t size);
3878f55dfb4SSandrine Bailleux 
38872600226SYatharth Kochar #endif /* LOAD_IMAGE_V2 */
38972600226SYatharth Kochar 
39072600226SYatharth Kochar extern const char build_message[];
39172600226SYatharth Kochar extern const char version_string[];
39272600226SYatharth Kochar 
39368a68c92SSandrine Bailleux void print_entry_point_info(const entry_point_info_t *ep_info);
39468a68c92SSandrine Bailleux 
3954ecca339SDan Handley #endif /*__ASSEMBLY__*/
3964ecca339SDan Handley 
3974ecca339SDan Handley #endif /* __BL_COMMON_H__ */
398