plat_arm.h 7.09 KB
Newer Older
1
/*
2
 * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of ARM nor the names of its contributors may be used
 * to endorse or promote products derived from this software without specific
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef __PLAT_ARM_H__
#define __PLAT_ARM_H__

#include <bakery_lock.h>
#include <cassert.h>
#include <cpu_data.h>
#include <stdint.h>
37
#include <utils.h>
38
#include <xlat_tables.h>
39

40
41
42
43
44
/*******************************************************************************
 * Forward declarations
 ******************************************************************************/
struct bl31_params;
struct meminfo;
45
struct image_info;
46

47
48
49
50
51
52
53
54
#define ARM_CASSERT_MMAP						\
	CASSERT((ARRAY_SIZE(plat_arm_mmap) + ARM_BL_REGIONS)		\
		<= MAX_MMAP_REGIONS,					\
		assert_max_mmap_regions);

/*
 * Utility functions common to ARM standard platforms
 */
55
56
57
58
59
60
void arm_setup_page_tables(uintptr_t total_base,
			size_t total_size,
			uintptr_t code_start,
			uintptr_t code_limit,
			uintptr_t rodata_start,
			uintptr_t rodata_limit
61
#if USE_COHERENT_MEM
62
63
			, uintptr_t coh_start,
			uintptr_t coh_limit
64
65
66
67
68
69
70
71
#endif
);

#if IMAGE_BL31
/*
 * Use this macro to instantiate lock before it is used in below
 * arm_lock_xxx() macros
 */
72
#define ARM_INSTANTIATE_LOCK	DEFINE_BAKERY_LOCK(arm_lock);
73
74
75
76
77
78
79
80
81
82
83

/*
 * These are wrapper macros to the Coherent Memory Bakery Lock API.
 */
#define arm_lock_init()		bakery_lock_init(&arm_lock)
#define arm_lock_get()		bakery_lock_get(&arm_lock)
#define arm_lock_release()	bakery_lock_release(&arm_lock)

#else

/*
84
 * Empty macros for all other BL stages other than BL31
85
86
87
88
89
90
91
92
 */
#define ARM_INSTANTIATE_LOCK
#define arm_lock_init()
#define arm_lock_get()
#define arm_lock_release()

#endif /* IMAGE_BL31 */

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#if ARM_RECOM_STATE_ID_ENC
/*
 * Macros used to parse state information from State-ID if it is using the
 * recommended encoding for State-ID.
 */
#define ARM_LOCAL_PSTATE_WIDTH		4
#define ARM_LOCAL_PSTATE_MASK		((1 << ARM_LOCAL_PSTATE_WIDTH) - 1)

/* Macros to construct the composite power state */

/* Make composite power state parameter till power level 0 */
#if PSCI_EXTENDED_STATE_ID

#define arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type) \
		(((lvl0_state) << PSTATE_ID_SHIFT) | ((type) << PSTATE_TYPE_SHIFT))
#else
#define arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type) \
		(((lvl0_state) << PSTATE_ID_SHIFT) | \
		((pwr_lvl) << PSTATE_PWR_LVL_SHIFT) | \
		((type) << PSTATE_TYPE_SHIFT))
#endif /* __PSCI_EXTENDED_STATE_ID__ */

/* Make composite power state parameter till power level 1 */
#define arm_make_pwrstate_lvl1(lvl1_state, lvl0_state, pwr_lvl, type) \
		(((lvl1_state) << ARM_LOCAL_PSTATE_WIDTH) | \
		arm_make_pwrstate_lvl0(lvl0_state, pwr_lvl, type))

120
121
122
123
124
/* Make composite power state parameter till power level 2 */
#define arm_make_pwrstate_lvl2(lvl2_state, lvl1_state, lvl0_state, pwr_lvl, type) \
		(((lvl2_state) << (ARM_LOCAL_PSTATE_WIDTH * 2)) | \
		arm_make_pwrstate_lvl1(lvl1_state, lvl0_state, pwr_lvl, type))

125
126
#endif /* __ARM_RECOM_STATE_ID_ENC__ */

127
128
129
130
131

/* IO storage utility functions */
void arm_io_setup(void);

/* Security utility functions */
132
void arm_tzc400_setup(void);
133
134
struct tzc_dmc500_driver_data;
void arm_tzc_dmc500_setup(struct tzc_dmc500_driver_data *plat_driver_data);
135

136
137
138
/* Systimer utility function */
void arm_configure_sys_timer(void);

139
/* PM utility functions */
140
141
int arm_validate_power_state(unsigned int power_state,
			    psci_power_state_t *req_state);
142
int arm_validate_ns_entrypoint(uintptr_t entrypoint);
143
void arm_system_pwr_domain_resume(void);
144
void arm_program_trusted_mailbox(uintptr_t address);
145
146
147

/* Topology utility function */
int arm_check_mpidr(u_register_t mpidr);
148
149
150
151
152
153
154

/* BL1 utility functions */
void arm_bl1_early_platform_setup(void);
void arm_bl1_platform_setup(void);
void arm_bl1_plat_arch_setup(void);

/* BL2 utility functions */
155
void arm_bl2_early_platform_setup(struct meminfo *mem_layout);
156
157
158
159
160
void arm_bl2_platform_setup(void);
void arm_bl2_plat_arch_setup(void);
uint32_t arm_get_spsr_for_bl32_entry(void);
uint32_t arm_get_spsr_for_bl33_entry(void);

161
162
163
164
165
166
/* BL2U utility functions */
void arm_bl2u_early_platform_setup(struct meminfo *mem_layout,
				void *plat_info);
void arm_bl2u_platform_setup(void);
void arm_bl2u_plat_arch_setup(void);

167
/* BL31 utility functions */
168
169
170
171
#if LOAD_IMAGE_V2
void arm_bl31_early_platform_setup(void *from_bl2,
				void *plat_params_from_bl2);
#else
172
void arm_bl31_early_platform_setup(struct bl31_params *from_bl2,
173
				void *plat_params_from_bl2);
174
#endif /* LOAD_IMAGE_V2 */
175
void arm_bl31_platform_setup(void);
176
void arm_bl31_plat_runtime_setup(void);
177
178
179
180
181
void arm_bl31_plat_arch_setup(void);

/* TSP utility functions */
void arm_tsp_early_platform_setup(void);

182
183
184
/* SP_MIN utility functions */
void arm_sp_min_early_platform_setup(void);

185
186
/* FIP TOC validity check */
int arm_io_is_toc_valid(void);
187
188
189
190

/*
 * Mandatory functions required in ARM standard platforms
 */
191
unsigned int plat_arm_get_cluster_core_count(u_register_t mpidr);
192
void plat_arm_gic_driver_init(void);
193
void plat_arm_gic_init(void);
194
195
196
void plat_arm_gic_cpuif_enable(void);
void plat_arm_gic_cpuif_disable(void);
void plat_arm_gic_pcpu_init(void);
197
198
void plat_arm_security_setup(void);
void plat_arm_pwrc_setup(void);
199
200
201
void plat_arm_interconnect_init(void);
void plat_arm_interconnect_enter_coherency(void);
void plat_arm_interconnect_exit_coherency(void);
202

203
204
205
206
207
208
209
210
#if LOAD_IMAGE_V2
/*
 * This function is called after loading SCP_BL2 image and it is used to perform
 * any platform-specific actions required to handle the SCP firmware.
 */
int plat_arm_bl2_handle_scp_bl2(struct image_info *scp_bl2_image_info);
#endif

211
212
213
214
215
/*
 * Optional functions required in ARM standard platforms
 */
void plat_arm_io_setup(void);
int plat_arm_get_alt_image_source(
216
217
218
	unsigned int image_id,
	uintptr_t *dev_handle,
	uintptr_t *image_spec);
219
unsigned int plat_arm_calc_core_pos(u_register_t mpidr);
220
const mmap_region_t *plat_arm_get_mmap(void);
221
222

#endif /* __PLAT_ARM_H__ */