blob: f55c0033c2bfb9d9820a8428821615d7e0a4315b [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
34#include <arch.h>
35
Achin Gupta4f6ad662013-10-25 09:08:21 +010036#ifndef __ASSEMBLY__
Achin Guptae4d084e2014-02-19 17:18:23 +000037#include <stdio.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010038
39/*******************************************************************************
Achin Guptaa0cd9892014-02-09 13:30:38 +000040 * Aarch64 translation tables manipulation helper prototypes
41 ******************************************************************************/
42extern unsigned long create_table_desc(unsigned long *next_table_ptr);
43extern unsigned long create_block_desc(unsigned long desc,
44 unsigned long addr,
45 unsigned int level);
46extern unsigned long create_device_block(unsigned long output_addr,
47 unsigned int level,
48 unsigned int ns);
49extern unsigned long create_romem_block(unsigned long output_addr,
50 unsigned int level,
51 unsigned int ns);
52extern unsigned long create_rwmem_block(unsigned long output_addr,
53 unsigned int level,
54 unsigned int ns);
55
56/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +010057 * TLB maintenance accessor prototypes
58 ******************************************************************************/
Achin Gupta4f6ad662013-10-25 09:08:21 +010059extern void tlbialle1(void);
60extern void tlbialle1is(void);
61extern void tlbialle2(void);
62extern void tlbialle2is(void);
63extern void tlbialle3(void);
64extern void tlbialle3is(void);
65extern void tlbivmalle1(void);
66
67/*******************************************************************************
68 * Cache maintenance accessor prototypes
69 ******************************************************************************/
70extern void dcisw(unsigned long);
71extern void dccisw(unsigned long);
72extern void dccsw(unsigned long);
73extern void dccvac(unsigned long);
74extern void dcivac(unsigned long);
75extern void dccivac(unsigned long);
76extern void dccvau(unsigned long);
77extern void dczva(unsigned long);
78extern void flush_dcache_range(unsigned long, unsigned long);
79extern void inv_dcache_range(unsigned long, unsigned long);
80extern void dcsw_op_louis(unsigned int);
81extern void dcsw_op_all(unsigned int);
82
83/*******************************************************************************
84 * Misc. accessor prototypes
85 ******************************************************************************/
86extern void enable_irq(void);
87extern void enable_fiq(void);
88extern void enable_serror(void);
Sandrine Bailleux37382742013-11-18 17:26:59 +000089extern void enable_debug_exceptions(void);
Achin Gupta4f6ad662013-10-25 09:08:21 +010090
91extern void disable_irq(void);
92extern void disable_fiq(void);
93extern void disable_serror(void);
Sandrine Bailleux37382742013-11-18 17:26:59 +000094extern void disable_debug_exceptions(void);
Achin Gupta4f6ad662013-10-25 09:08:21 +010095
96extern unsigned long read_id_pfr1_el1(void);
97extern unsigned long read_id_aa64pfr0_el1(void);
98extern unsigned long read_current_el(void);
99extern unsigned long read_daif(void);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100100extern unsigned long read_spsr_el1(void);
101extern unsigned long read_spsr_el2(void);
102extern unsigned long read_spsr_el3(void);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100103extern unsigned long read_elr_el1(void);
104extern unsigned long read_elr_el2(void);
105extern unsigned long read_elr_el3(void);
106
107extern void write_daif(unsigned long);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100108extern void write_spsr_el1(unsigned long);
109extern void write_spsr_el2(unsigned long);
110extern void write_spsr_el3(unsigned long);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100111extern void write_elr_el1(unsigned long);
112extern void write_elr_el2(unsigned long);
113extern void write_elr_el3(unsigned long);
114
115extern void wfi(void);
116extern void wfe(void);
117extern void rfe(void);
118extern void sev(void);
119extern void dsb(void);
120extern void isb(void);
121
122extern unsigned int get_afflvl_shift(unsigned int);
123extern unsigned int mpidr_mask_lower_afflvls(unsigned long, unsigned int);
124
Achin Guptae4d084e2014-02-19 17:18:23 +0000125extern void __dead2 eret(unsigned long, unsigned long,
126 unsigned long, unsigned long,
127 unsigned long, unsigned long,
128 unsigned long, unsigned long);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100129
Achin Guptae4d084e2014-02-19 17:18:23 +0000130extern void __dead2 smc(unsigned long, unsigned long,
131 unsigned long, unsigned long,
132 unsigned long, unsigned long,
Achin Gupta4f6ad662013-10-25 09:08:21 +0100133 unsigned long, unsigned long);
134
135/*******************************************************************************
136 * System register accessor prototypes
137 ******************************************************************************/
138extern unsigned long read_midr(void);
139extern unsigned long read_mpidr(void);
140
141extern unsigned long read_scr(void);
142extern unsigned long read_hcr(void);
143
Achin Gupta4f6ad662013-10-25 09:08:21 +0100144extern unsigned long read_vbar_el1(void);
145extern unsigned long read_vbar_el2(void);
146extern unsigned long read_vbar_el3(void);
147
Achin Gupta4f6ad662013-10-25 09:08:21 +0100148extern unsigned long read_sctlr_el1(void);
149extern unsigned long read_sctlr_el2(void);
150extern unsigned long read_sctlr_el3(void);
151
Achin Gupta4f6ad662013-10-25 09:08:21 +0100152extern unsigned long read_actlr_el1(void);
153extern unsigned long read_actlr_el2(void);
154extern unsigned long read_actlr_el3(void);
155
Achin Gupta4f6ad662013-10-25 09:08:21 +0100156extern unsigned long read_esr_el1(void);
157extern unsigned long read_esr_el2(void);
158extern unsigned long read_esr_el3(void);
159
Achin Gupta4f6ad662013-10-25 09:08:21 +0100160extern unsigned long read_afsr0_el1(void);
161extern unsigned long read_afsr0_el2(void);
162extern unsigned long read_afsr0_el3(void);
163
Achin Gupta4f6ad662013-10-25 09:08:21 +0100164extern unsigned long read_afsr1_el1(void);
165extern unsigned long read_afsr1_el2(void);
166extern unsigned long read_afsr1_el3(void);
167
Achin Gupta4f6ad662013-10-25 09:08:21 +0100168extern unsigned long read_far_el1(void);
169extern unsigned long read_far_el2(void);
170extern unsigned long read_far_el3(void);
171
Achin Gupta4f6ad662013-10-25 09:08:21 +0100172extern unsigned long read_mair_el1(void);
173extern unsigned long read_mair_el2(void);
174extern unsigned long read_mair_el3(void);
175
Achin Gupta4f6ad662013-10-25 09:08:21 +0100176extern unsigned long read_amair_el1(void);
177extern unsigned long read_amair_el2(void);
178extern unsigned long read_amair_el3(void);
179
Achin Gupta4f6ad662013-10-25 09:08:21 +0100180extern unsigned long read_rvbar_el1(void);
181extern unsigned long read_rvbar_el2(void);
182extern unsigned long read_rvbar_el3(void);
183
Achin Gupta4f6ad662013-10-25 09:08:21 +0100184extern unsigned long read_rmr_el1(void);
185extern unsigned long read_rmr_el2(void);
186extern unsigned long read_rmr_el3(void);
187
Achin Gupta4f6ad662013-10-25 09:08:21 +0100188extern unsigned long read_tcr_el1(void);
189extern unsigned long read_tcr_el2(void);
190extern unsigned long read_tcr_el3(void);
191
Achin Gupta4f6ad662013-10-25 09:08:21 +0100192extern unsigned long read_ttbr0_el1(void);
193extern unsigned long read_ttbr0_el2(void);
194extern unsigned long read_ttbr0_el3(void);
195
196extern unsigned long read_ttbr1(void);
197extern unsigned long read_ttbr1_el1(void);
198extern unsigned long read_ttbr1_el2(void);
199
Achin Gupta4f6ad662013-10-25 09:08:21 +0100200extern unsigned long read_cptr_el2(void);
201extern unsigned long read_cptr_el3(void);
202
203extern unsigned long read_cpacr(void);
204extern unsigned long read_cpuectlr(void);
205extern unsigned int read_cntfrq_el0(void);
206extern unsigned long read_cnthctl_el2(void);
207
208extern void write_scr(unsigned long);
209extern void write_hcr(unsigned long);
210extern void write_cpacr(unsigned long);
211extern void write_cntfrq_el0(unsigned int);
212extern void write_cnthctl_el2(unsigned long);
213
Achin Gupta4f6ad662013-10-25 09:08:21 +0100214extern void write_vbar_el1(unsigned long);
215extern void write_vbar_el2(unsigned long);
216extern void write_vbar_el3(unsigned long);
217
Achin Gupta4f6ad662013-10-25 09:08:21 +0100218extern void write_sctlr_el1(unsigned long);
219extern void write_sctlr_el2(unsigned long);
220extern void write_sctlr_el3(unsigned long);
221
Achin Gupta4f6ad662013-10-25 09:08:21 +0100222extern void write_actlr_el1(unsigned long);
223extern void write_actlr_el2(unsigned long);
224extern void write_actlr_el3(unsigned long);
225
Achin Gupta4f6ad662013-10-25 09:08:21 +0100226extern void write_esr_el1(unsigned long);
227extern void write_esr_el2(unsigned long);
228extern void write_esr_el3(unsigned long);
229
230extern void write_afsr0(unsigned long);
231extern void write_afsr0_el1(unsigned long);
232extern void write_afsr0_el2(unsigned long);
233extern void write_afsr0_el3(unsigned long);
234
235extern void write_afsr1(unsigned long);
236extern void write_afsr1_el1(unsigned long);
237extern void write_afsr1_el2(unsigned long);
238extern void write_afsr1_el3(unsigned long);
239
Achin Gupta4f6ad662013-10-25 09:08:21 +0100240extern void write_far_el1(unsigned long);
241extern void write_far_el2(unsigned long);
242extern void write_far_el3(unsigned long);
243
Achin Gupta4f6ad662013-10-25 09:08:21 +0100244extern void write_mair_el1(unsigned long);
245extern void write_mair_el2(unsigned long);
246extern void write_mair_el3(unsigned long);
247
Achin Gupta4f6ad662013-10-25 09:08:21 +0100248extern void write_amair_el1(unsigned long);
249extern void write_amair_el2(unsigned long);
250extern void write_amair_el3(unsigned long);
251
Achin Gupta4f6ad662013-10-25 09:08:21 +0100252extern void write_rmr_el1(unsigned long);
253extern void write_rmr_el2(unsigned long);
254extern void write_rmr_el3(unsigned long);
255
Achin Gupta4f6ad662013-10-25 09:08:21 +0100256extern void write_tcr_el1(unsigned long);
257extern void write_tcr_el2(unsigned long);
258extern void write_tcr_el3(unsigned long);
259
Achin Gupta4f6ad662013-10-25 09:08:21 +0100260extern void write_ttbr0_el1(unsigned long);
261extern void write_ttbr0_el2(unsigned long);
262extern void write_ttbr0_el3(unsigned long);
263
Achin Gupta4f6ad662013-10-25 09:08:21 +0100264extern void write_ttbr1_el1(unsigned long);
265extern void write_ttbr1_el2(unsigned long);
266
Achin Gupta4f6ad662013-10-25 09:08:21 +0100267extern void write_cpuectlr(unsigned long);
268extern void write_cptr_el2(unsigned long);
269extern void write_cptr_el3(unsigned long);
270
271#endif /*__ASSEMBLY__*/
272
273#endif /* __ARCH_HELPERS_H__ */