Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 2 | * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 9 | #include <platform_def.h> |
| 10 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <arch.h> |
| 12 | #include <common/desc_image_load.h> |
| 13 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 14 | #include "uniphier.h" |
| 15 | |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 16 | #define UNIPHIER_BL33_OFFSET 0x04000000UL |
Masahiro Yamada | 65870bd | 2020-06-05 10:29:17 +0900 | [diff] [blame] | 17 | #define UNIPHIER_BL33_MAX_SIZE 0x00800000UL |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 18 | |
Masahiro Yamada | 65870bd | 2020-06-05 10:29:17 +0900 | [diff] [blame] | 19 | #define UNIPHIER_SCP_OFFSET 0x04800000UL |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 20 | #define UNIPHIER_SCP_MAX_SIZE 0x00020000UL |
| 21 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 22 | static struct bl_mem_params_node uniphier_image_descs[] = { |
| 23 | { |
| 24 | .image_id = SCP_BL2_IMAGE_ID, |
| 25 | |
| 26 | SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, |
| 27 | VERSION_2, image_info_t, 0), |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 28 | .image_info.image_base = UNIPHIER_SCP_OFFSET, |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 29 | .image_info.image_max_size = UNIPHIER_SCP_MAX_SIZE, |
| 30 | |
| 31 | SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, |
| 32 | VERSION_2, entry_point_info_t, |
| 33 | NON_SECURE | NON_EXECUTABLE), |
| 34 | |
| 35 | .next_handoff_image_id = INVALID_IMAGE_ID, |
| 36 | }, |
| 37 | { |
| 38 | .image_id = BL31_IMAGE_ID, |
| 39 | |
| 40 | SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, |
| 41 | VERSION_2, image_info_t, 0), |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 42 | .image_info.image_base = UNIPHIER_BL31_OFFSET, |
| 43 | .image_info.image_max_size = UNIPHIER_BL31_MAX_SIZE, |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 44 | |
| 45 | SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, |
| 46 | VERSION_2, entry_point_info_t, |
| 47 | SECURE | EXECUTABLE | EP_FIRST_EXE), |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 48 | .ep_info.pc = UNIPHIER_BL31_OFFSET, |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 49 | .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX, |
| 50 | DISABLE_ALL_EXCEPTIONS), |
| 51 | |
| 52 | #ifdef UNIPHIER_LOAD_BL32 |
| 53 | .next_handoff_image_id = BL32_IMAGE_ID, |
| 54 | #else |
| 55 | .next_handoff_image_id = BL33_IMAGE_ID, |
| 56 | #endif |
| 57 | }, |
| 58 | #ifdef UNIPHIER_LOAD_BL32 |
| 59 | { |
| 60 | .image_id = BL32_IMAGE_ID, |
| 61 | |
| 62 | SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, |
| 63 | VERSION_2, image_info_t, 0), |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 64 | .image_info.image_base = UNIPHIER_BL32_OFFSET, |
| 65 | .image_info.image_max_size = UNIPHIER_BL32_MAX_SIZE, |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 66 | |
| 67 | SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, |
| 68 | VERSION_2, entry_point_info_t, |
| 69 | SECURE | EXECUTABLE), |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 70 | .ep_info.pc = UNIPHIER_BL32_OFFSET, |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 71 | .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX, |
| 72 | DISABLE_ALL_EXCEPTIONS), |
| 73 | |
| 74 | .next_handoff_image_id = BL33_IMAGE_ID, |
| 75 | }, |
| 76 | #endif |
| 77 | { |
| 78 | .image_id = BL33_IMAGE_ID, |
| 79 | |
| 80 | SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, |
| 81 | VERSION_2, image_info_t, 0), |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 82 | .image_info.image_base = UNIPHIER_BL33_OFFSET, |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 83 | .image_info.image_max_size = UNIPHIER_BL33_MAX_SIZE, |
| 84 | |
| 85 | SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, |
| 86 | VERSION_2, entry_point_info_t, |
| 87 | NON_SECURE | EXECUTABLE), |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 88 | .ep_info.pc = UNIPHIER_BL33_OFFSET, |
Masahiro Yamada | 7b74813 | 2019-07-25 10:57:38 +0900 | [diff] [blame] | 89 | .ep_info.spsr = SPSR_64(MODE_EL2, MODE_SP_ELX, |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 90 | DISABLE_ALL_EXCEPTIONS), |
| 91 | |
| 92 | .next_handoff_image_id = INVALID_IMAGE_ID, |
| 93 | }, |
| 94 | }; |
| 95 | REGISTER_BL_IMAGE_DESCS(uniphier_image_descs) |
| 96 | |
Masahiro Yamada | 542ed41 | 2020-01-17 13:46:48 +0900 | [diff] [blame] | 97 | /* |
| 98 | * image_info.image_base and ep_info.pc are the offset from the memory base. |
| 99 | * When ENABLE_PIE is set, we never know the real memory base at link-time. |
| 100 | * Fix-up the addresses by adding the run-time detected base. |
| 101 | */ |
| 102 | void uniphier_init_image_descs(uintptr_t mem_base) |
| 103 | { |
| 104 | int i; |
| 105 | |
| 106 | for (i = 0; i < ARRAY_SIZE(uniphier_image_descs); i++) { |
| 107 | uniphier_image_descs[i].image_info.image_base += mem_base; |
| 108 | uniphier_image_descs[i].ep_info.pc += mem_base; |
| 109 | } |
| 110 | } |
| 111 | |
Masahiro Yamada | 4c91c80 | 2018-02-01 21:37:40 +0900 | [diff] [blame] | 112 | struct image_info *uniphier_get_image_info(unsigned int image_id) |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 113 | { |
| 114 | struct bl_mem_params_node *desc; |
| 115 | |
Masahiro Yamada | 4c91c80 | 2018-02-01 21:37:40 +0900 | [diff] [blame] | 116 | desc = get_bl_mem_params_node(image_id); |
| 117 | assert(desc); |
| 118 | return &desc->image_info; |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 119 | } |