blob: 8c232ba3193fee57de369674e2479268269b0ffb [file] [log] [blame]
Masahiro Yamada574388c2016-09-03 11:37:40 +09001/*
Masahiro Yamada542ed412020-01-17 13:46:48 +09002 * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
Masahiro Yamada574388c2016-09-03 11:37:40 +09003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Masahiro Yamada574388c2016-09-03 11:37:40 +09007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Masahiro Yamada574388c2016-09-03 11:37:40 +09009#include <platform_def.h>
10
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <arch.h>
12#include <common/desc_image_load.h>
13
Masahiro Yamada574388c2016-09-03 11:37:40 +090014#include "uniphier.h"
15
Masahiro Yamada542ed412020-01-17 13:46:48 +090016#define UNIPHIER_BL33_OFFSET 0x04000000UL
17#define UNIPHIER_BL33_MAX_SIZE 0x00100000UL
18
19#define UNIPHIER_SCP_OFFSET 0x04100000UL
20#define UNIPHIER_SCP_MAX_SIZE 0x00020000UL
21
Masahiro Yamada574388c2016-09-03 11:37:40 +090022static 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 Yamada542ed412020-01-17 13:46:48 +090028 .image_info.image_base = UNIPHIER_SCP_OFFSET,
Masahiro Yamada574388c2016-09-03 11:37:40 +090029 .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 Yamada542ed412020-01-17 13:46:48 +090042 .image_info.image_base = UNIPHIER_BL31_OFFSET,
43 .image_info.image_max_size = UNIPHIER_BL31_MAX_SIZE,
Masahiro Yamada574388c2016-09-03 11:37:40 +090044
45 SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
46 VERSION_2, entry_point_info_t,
47 SECURE | EXECUTABLE | EP_FIRST_EXE),
Masahiro Yamada542ed412020-01-17 13:46:48 +090048 .ep_info.pc = UNIPHIER_BL31_OFFSET,
Masahiro Yamada574388c2016-09-03 11:37:40 +090049 .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 Yamada542ed412020-01-17 13:46:48 +090064 .image_info.image_base = UNIPHIER_BL32_OFFSET,
65 .image_info.image_max_size = UNIPHIER_BL32_MAX_SIZE,
Masahiro Yamada574388c2016-09-03 11:37:40 +090066
67 SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
68 VERSION_2, entry_point_info_t,
69 SECURE | EXECUTABLE),
Masahiro Yamada542ed412020-01-17 13:46:48 +090070 .ep_info.pc = UNIPHIER_BL32_OFFSET,
Masahiro Yamada574388c2016-09-03 11:37:40 +090071 .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 Yamada542ed412020-01-17 13:46:48 +090082 .image_info.image_base = UNIPHIER_BL33_OFFSET,
Masahiro Yamada574388c2016-09-03 11:37:40 +090083 .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 Yamada542ed412020-01-17 13:46:48 +090088 .ep_info.pc = UNIPHIER_BL33_OFFSET,
Masahiro Yamada7b748132019-07-25 10:57:38 +090089 .ep_info.spsr = SPSR_64(MODE_EL2, MODE_SP_ELX,
Masahiro Yamada574388c2016-09-03 11:37:40 +090090 DISABLE_ALL_EXCEPTIONS),
91
92 .next_handoff_image_id = INVALID_IMAGE_ID,
93 },
94};
95REGISTER_BL_IMAGE_DESCS(uniphier_image_descs)
96
Masahiro Yamada542ed412020-01-17 13:46:48 +090097/*
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 */
102void 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 Yamada4c91c802018-02-01 21:37:40 +0900112struct image_info *uniphier_get_image_info(unsigned int image_id)
Masahiro Yamada574388c2016-09-03 11:37:40 +0900113{
114 struct bl_mem_params_node *desc;
115
Masahiro Yamada4c91c802018-02-01 21:37:40 +0900116 desc = get_bl_mem_params_node(image_id);
117 assert(desc);
118 return &desc->image_info;
Masahiro Yamada574388c2016-09-03 11:37:40 +0900119}