Home | History | Annotate | Download | only in qemu
      1 /*
      2  * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
      3  *
      4  * SPDX-License-Identifier: BSD-3-Clause
      5  */
      6 
      7 #include <desc_image_load.h>
      8 #include <platform.h>
      9 #include <platform_def.h>
     10 
     11 /*******************************************************************************
     12  * Following descriptor provides BL image/ep information that gets used
     13  * by BL2 to load the images and also subset of this information is
     14  * passed to next BL image. The image loading sequence is managed by
     15  * populating the images in required loading order. The image execution
     16  * sequence is managed by populating the `next_handoff_image_id` with
     17  * the next executable image id.
     18  ******************************************************************************/
     19 static bl_mem_params_node_t bl2_mem_params_descs[] = {
     20 #ifdef EL3_PAYLOAD_BASE
     21 	/* Fill EL3 payload related information (BL31 is EL3 payload) */
     22 	{ .image_id = BL31_IMAGE_ID,
     23 
     24 	  SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
     25 				entry_point_info_t,
     26 				SECURE | EXECUTABLE | EP_FIRST_EXE),
     27 	  .ep_info.pc = EL3_PAYLOAD_BASE,
     28 	  .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
     29 				  DISABLE_ALL_EXCEPTIONS),
     30 
     31 	  SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
     32 				IMAGE_ATTRIB_PLAT_SETUP | IMAGE_ATTRIB_SKIP_LOADING),
     33 
     34 	  .next_handoff_image_id = INVALID_IMAGE_ID,
     35 	},
     36 #else /* EL3_PAYLOAD_BASE */
     37 	/* Fill BL31 related information */
     38 	{ .image_id = BL31_IMAGE_ID,
     39 
     40 	  SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
     41 				entry_point_info_t,
     42 				SECURE | EXECUTABLE | EP_FIRST_EXE),
     43 	  .ep_info.pc = BL31_BASE,
     44 	  .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
     45 				  DISABLE_ALL_EXCEPTIONS),
     46 # if DEBUG
     47 	  .ep_info.args.arg1 = QEMU_BL31_PLAT_PARAM_VAL,
     48 # endif
     49 	  SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
     50 				IMAGE_ATTRIB_PLAT_SETUP),
     51 	  .image_info.image_base = BL31_BASE,
     52 	  .image_info.image_max_size = BL31_LIMIT - BL31_BASE,
     53 
     54 # ifdef QEMU_LOAD_BL32
     55 	  .next_handoff_image_id = BL32_IMAGE_ID,
     56 # else
     57 	  .next_handoff_image_id = BL33_IMAGE_ID,
     58 # endif
     59 	},
     60 # ifdef QEMU_LOAD_BL32
     61 	/* Fill BL32 related information */
     62 	{ .image_id = BL32_IMAGE_ID,
     63 
     64 	  SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
     65 				entry_point_info_t, SECURE | EXECUTABLE),
     66 	  .ep_info.pc = BL32_BASE,
     67 
     68 	  SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
     69 				0),
     70 	  .image_info.image_base = BL32_BASE,
     71 	  .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
     72 
     73 	  .next_handoff_image_id = BL33_IMAGE_ID,
     74 	},
     75 
     76 	/*
     77 	 * Fill BL32 external 1 related information.
     78 	 * A typical use for extra1 image is with OP-TEE where it is the
     79 	 * pager image.
     80 	 */
     81 	{ .image_id = BL32_EXTRA1_IMAGE_ID,
     82 
     83 	   SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
     84 				 entry_point_info_t, SECURE | NON_EXECUTABLE),
     85 
     86 	   SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
     87 				 image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
     88 	   .image_info.image_base = BL32_BASE,
     89 	   .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
     90 
     91 	   .next_handoff_image_id = INVALID_IMAGE_ID,
     92 	},
     93 
     94 	/*
     95 	 * Fill BL32 external 2 related information.
     96 	 * A typical use for extra2 image is with OP-TEE where it is the
     97 	 * paged image.
     98 	 */
     99 	{ .image_id = BL32_EXTRA2_IMAGE_ID,
    100 
    101 	   SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
    102 				 entry_point_info_t, SECURE | NON_EXECUTABLE),
    103 
    104 	   SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
    105 				 image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
    106 #ifdef SPD_opteed
    107 	   .image_info.image_base = QEMU_OPTEE_PAGEABLE_LOAD_BASE,
    108 	   .image_info.image_max_size = QEMU_OPTEE_PAGEABLE_LOAD_SIZE,
    109 #endif
    110 	   .next_handoff_image_id = INVALID_IMAGE_ID,
    111 	},
    112 # endif /* QEMU_LOAD_BL32 */
    113 
    114 	/* Fill BL33 related information */
    115 	{ .image_id = BL33_IMAGE_ID,
    116 	  SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
    117 				entry_point_info_t, NON_SECURE | EXECUTABLE),
    118 # ifdef PRELOADED_BL33_BASE
    119 	  .ep_info.pc = PRELOADED_BL33_BASE,
    120 
    121 	  SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
    122 				IMAGE_ATTRIB_SKIP_LOADING),
    123 # else /* PRELOADED_BL33_BASE */
    124 	  .ep_info.pc = NS_IMAGE_OFFSET,
    125 
    126 	  SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
    127 				0),
    128 	  .image_info.image_base = NS_IMAGE_OFFSET,
    129 	  .image_info.image_max_size = NS_DRAM0_BASE + NS_DRAM0_SIZE -
    130 				       NS_IMAGE_OFFSET,
    131 # endif /* !PRELOADED_BL33_BASE */
    132 
    133 	  .next_handoff_image_id = INVALID_IMAGE_ID,
    134 	}
    135 #endif /* !EL3_PAYLOAD_BASE */
    136 };
    137 
    138 REGISTER_BL_IMAGE_DESCS(bl2_mem_params_descs)
    139