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