blob: 0a398d08164f7b395a366efcd65ac6ba70359fa1 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Dan Handleye83b0ca2014-01-14 18:17:09 +00002 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef __ARCH_HELPERS_H__
32#define __ARCH_HELPERS_H__
33
Dan Handley2bd4ef22014-04-09 13:14:54 +010034#include <cdefs.h> /* For __dead2 */
Achin Gupta4f6ad662013-10-25 09:08:21 +010035
Achin Gupta4f6ad662013-10-25 09:08:21 +010036
37/*******************************************************************************
Achin Guptaa0cd9892014-02-09 13:30:38 +000038 * Aarch64 translation tables manipulation helper prototypes
39 ******************************************************************************/
40extern unsigned long create_table_desc(unsigned long *next_table_ptr);
41extern unsigned long create_block_desc(unsigned long desc,
42 unsigned long addr,
43 unsigned int level);
44extern unsigned long create_device_block(unsigned long output_addr,
45 unsigned int level,
46 unsigned int ns);
47extern unsigned long create_romem_block(unsigned long output_addr,
48 unsigned int level,
49 unsigned int ns);
50extern unsigned long create_rwmem_block(unsigned long output_addr,
51 unsigned int level,
52 unsigned int ns);
53
54/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +010055 * TLB maintenance accessor prototypes
56 ******************************************************************************/
Achin Gupta4f6ad662013-10-25 09:08:21 +010057extern void tlbialle1(void);
58extern void tlbialle1is(void);
59extern void tlbialle2(void);
60extern void tlbialle2is(void);
61extern void tlbialle3(void);
62extern void tlbialle3is(void);
63extern void tlbivmalle1(void);
64
65/*******************************************************************************
66 * Cache maintenance accessor prototypes
67 ******************************************************************************/
68extern void dcisw(unsigned long);
69extern void dccisw(unsigned long);
70extern void dccsw(unsigned long);
71extern void dccvac(unsigned long);
72extern void dcivac(unsigned long);
73extern void dccivac(unsigned long);
74extern void dccvau(unsigned long);
75extern void dczva(unsigned long);
76extern void flush_dcache_range(unsigned long, unsigned long);
77extern void inv_dcache_range(unsigned long, unsigned long);
78extern void dcsw_op_louis(unsigned int);
79extern void dcsw_op_all(unsigned int);
80
Andrew Thoelke438c63a2014-04-28 12:06:18 +010081extern void disable_mmu_el3(void);
82extern void disable_mmu_icache_el3(void);
83
Achin Gupta4f6ad662013-10-25 09:08:21 +010084/*******************************************************************************
85 * Misc. accessor prototypes
86 ******************************************************************************/
87extern void enable_irq(void);
88extern void enable_fiq(void);
89extern void enable_serror(void);
Sandrine Bailleux37382742013-11-18 17:26:59 +000090extern void enable_debug_exceptions(void);
Achin Gupta4f6ad662013-10-25 09:08:21 +010091
92extern void disable_irq(void);
93extern void disable_fiq(void);
94extern void disable_serror(void);
Sandrine Bailleux37382742013-11-18 17:26:59 +000095extern void disable_debug_exceptions(void);
Achin Gupta4f6ad662013-10-25 09:08:21 +010096
97extern unsigned long read_id_pfr1_el1(void);
98extern unsigned long read_id_aa64pfr0_el1(void);
99extern unsigned long read_current_el(void);
100extern unsigned long read_daif(void);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100101extern unsigned long read_spsr_el1(void);
102extern unsigned long read_spsr_el2(void);
103extern unsigned long read_spsr_el3(void);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100104extern unsigned long read_elr_el1(void);
105extern unsigned long read_elr_el2(void);
106extern unsigned long read_elr_el3(void);
107
108extern void write_daif(unsigned long);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100109extern void write_spsr_el1(unsigned long);
110extern void write_spsr_el2(unsigned long);
111extern void write_spsr_el3(unsigned long);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100112extern void write_elr_el1(unsigned long);
113extern void write_elr_el2(unsigned long);
114extern void write_elr_el3(unsigned long);
115
116extern void wfi(void);
117extern void wfe(void);
118extern void rfe(void);
119extern void sev(void);
120extern void dsb(void);
121extern void isb(void);
122
123extern unsigned int get_afflvl_shift(unsigned int);
124extern unsigned int mpidr_mask_lower_afflvls(unsigned long, unsigned int);
125
Achin Guptae4d084e2014-02-19 17:18:23 +0000126extern void __dead2 eret(unsigned long, unsigned long,
127 unsigned long, unsigned long,
128 unsigned long, unsigned long,
129 unsigned long, unsigned long);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100130
Achin Guptae4d084e2014-02-19 17:18:23 +0000131extern void __dead2 smc(unsigned long, unsigned long,
132 unsigned long, unsigned long,
133 unsigned long, unsigned long,
Achin Gupta4f6ad662013-10-25 09:08:21 +0100134 unsigned long, unsigned long);
135
136/*******************************************************************************
137 * System register accessor prototypes
138 ******************************************************************************/
139extern unsigned long read_midr(void);
140extern unsigned long read_mpidr(void);
141
142extern unsigned long read_scr(void);
143extern unsigned long read_hcr(void);
144
Achin Gupta4f6ad662013-10-25 09:08:21 +0100145extern unsigned long read_vbar_el1(void);
146extern unsigned long read_vbar_el2(void);
147extern unsigned long read_vbar_el3(void);
148
Achin Gupta4f6ad662013-10-25 09:08:21 +0100149extern unsigned long read_sctlr_el1(void);
150extern unsigned long read_sctlr_el2(void);
151extern unsigned long read_sctlr_el3(void);
152
Achin Gupta4f6ad662013-10-25 09:08:21 +0100153extern unsigned long read_actlr_el1(void);
154extern unsigned long read_actlr_el2(void);
155extern unsigned long read_actlr_el3(void);
156
Achin Gupta4f6ad662013-10-25 09:08:21 +0100157extern unsigned long read_esr_el1(void);
158extern unsigned long read_esr_el2(void);
159extern unsigned long read_esr_el3(void);
160
Achin Gupta4f6ad662013-10-25 09:08:21 +0100161extern unsigned long read_afsr0_el1(void);
162extern unsigned long read_afsr0_el2(void);
163extern unsigned long read_afsr0_el3(void);
164
Achin Gupta4f6ad662013-10-25 09:08:21 +0100165extern unsigned long read_afsr1_el1(void);
166extern unsigned long read_afsr1_el2(void);
167extern unsigned long read_afsr1_el3(void);
168
Achin Gupta4f6ad662013-10-25 09:08:21 +0100169extern unsigned long read_far_el1(void);
170extern unsigned long read_far_el2(void);
171extern unsigned long read_far_el3(void);
172
Achin Gupta4f6ad662013-10-25 09:08:21 +0100173extern unsigned long read_mair_el1(void);
174extern unsigned long read_mair_el2(void);
175extern unsigned long read_mair_el3(void);
176
Achin Gupta4f6ad662013-10-25 09:08:21 +0100177extern unsigned long read_amair_el1(void);
178extern unsigned long read_amair_el2(void);
179extern unsigned long read_amair_el3(void);
180
Achin Gupta4f6ad662013-10-25 09:08:21 +0100181extern unsigned long read_rvbar_el1(void);
182extern unsigned long read_rvbar_el2(void);
183extern unsigned long read_rvbar_el3(void);
184
Achin Gupta4f6ad662013-10-25 09:08:21 +0100185extern unsigned long read_rmr_el1(void);
186extern unsigned long read_rmr_el2(void);
187extern unsigned long read_rmr_el3(void);
188
Achin Gupta4f6ad662013-10-25 09:08:21 +0100189extern unsigned long read_tcr_el1(void);
190extern unsigned long read_tcr_el2(void);
191extern unsigned long read_tcr_el3(void);
192
Achin Gupta4f6ad662013-10-25 09:08:21 +0100193extern unsigned long read_ttbr0_el1(void);
194extern unsigned long read_ttbr0_el2(void);
195extern unsigned long read_ttbr0_el3(void);
196
Achin Gupta4f6ad662013-10-25 09:08:21 +0100197extern unsigned long read_ttbr1_el1(void);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100198
Achin Gupta4f6ad662013-10-25 09:08:21 +0100199extern unsigned long read_cptr_el2(void);
200extern unsigned long read_cptr_el3(void);
201
202extern unsigned long read_cpacr(void);
203extern unsigned long read_cpuectlr(void);
204extern unsigned int read_cntfrq_el0(void);
205extern unsigned long read_cnthctl_el2(void);
206
Soby Mathew5e5c2072014-04-07 15:28:55 +0100207extern unsigned long read_tpidr_el3(void);
208
Achin Gupta4f6ad662013-10-25 09:08:21 +0100209extern void write_scr(unsigned long);
210extern void write_hcr(unsigned long);
211extern void write_cpacr(unsigned long);
212extern void write_cntfrq_el0(unsigned int);
213extern void write_cnthctl_el2(unsigned long);
214
Achin Gupta4f6ad662013-10-25 09:08:21 +0100215extern void write_vbar_el1(unsigned long);
216extern void write_vbar_el2(unsigned long);
217extern void write_vbar_el3(unsigned long);
218
Achin Gupta4f6ad662013-10-25 09:08:21 +0100219extern void write_sctlr_el1(unsigned long);
220extern void write_sctlr_el2(unsigned long);
221extern void write_sctlr_el3(unsigned long);
222
Achin Gupta4f6ad662013-10-25 09:08:21 +0100223extern void write_actlr_el1(unsigned long);
224extern void write_actlr_el2(unsigned long);
225extern void write_actlr_el3(unsigned long);
226
Achin Gupta4f6ad662013-10-25 09:08:21 +0100227extern void write_esr_el1(unsigned long);
228extern void write_esr_el2(unsigned long);
229extern void write_esr_el3(unsigned long);
230
Achin Gupta4f6ad662013-10-25 09:08:21 +0100231extern void write_afsr0_el1(unsigned long);
232extern void write_afsr0_el2(unsigned long);
233extern void write_afsr0_el3(unsigned long);
234
Achin Gupta4f6ad662013-10-25 09:08:21 +0100235extern void write_afsr1_el1(unsigned long);
236extern void write_afsr1_el2(unsigned long);
237extern void write_afsr1_el3(unsigned long);
238
Achin Gupta4f6ad662013-10-25 09:08:21 +0100239extern void write_far_el1(unsigned long);
240extern void write_far_el2(unsigned long);
241extern void write_far_el3(unsigned long);
242
Achin Gupta4f6ad662013-10-25 09:08:21 +0100243extern void write_mair_el1(unsigned long);
244extern void write_mair_el2(unsigned long);
245extern void write_mair_el3(unsigned long);
246
Achin Gupta4f6ad662013-10-25 09:08:21 +0100247extern void write_amair_el1(unsigned long);
248extern void write_amair_el2(unsigned long);
249extern void write_amair_el3(unsigned long);
250
Achin Gupta4f6ad662013-10-25 09:08:21 +0100251extern void write_rmr_el1(unsigned long);
252extern void write_rmr_el2(unsigned long);
253extern void write_rmr_el3(unsigned long);
254
Achin Gupta4f6ad662013-10-25 09:08:21 +0100255extern void write_tcr_el1(unsigned long);
256extern void write_tcr_el2(unsigned long);
257extern void write_tcr_el3(unsigned long);
258
Achin Gupta4f6ad662013-10-25 09:08:21 +0100259extern void write_ttbr0_el1(unsigned long);
260extern void write_ttbr0_el2(unsigned long);
261extern void write_ttbr0_el3(unsigned long);
262
Achin Gupta4f6ad662013-10-25 09:08:21 +0100263extern void write_ttbr1_el1(unsigned long);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100264
Achin Gupta4f6ad662013-10-25 09:08:21 +0100265extern void write_cpuectlr(unsigned long);
266extern void write_cptr_el2(unsigned long);
267extern void write_cptr_el3(unsigned long);
268
Soby Mathew5e5c2072014-04-07 15:28:55 +0100269extern void write_tpidr_el3(unsigned long);
270
Sandrine Bailleux25232af2014-05-09 11:23:11 +0100271#define IS_IN_EL(x) \
272 (GET_EL(read_current_el()) == MODE_EL##x)
273
274#define IS_IN_EL1() IS_IN_EL(1)
275#define IS_IN_EL3() IS_IN_EL(3)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100276
Soby Mathew5e5c2072014-04-07 15:28:55 +0100277
Achin Gupta4f6ad662013-10-25 09:08:21 +0100278#endif /* __ARCH_HELPERS_H__ */