Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Dan Handley | e83b0ca | 2014-01-14 18:17:09 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
| 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 Handley | 97043ac | 2014-04-09 13:14:54 +0100 | [diff] [blame^] | 34 | #include <cdefs.h> /* For __dead2 */ |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 35 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 36 | |
| 37 | /******************************************************************************* |
Achin Gupta | a0cd989 | 2014-02-09 13:30:38 +0000 | [diff] [blame] | 38 | * Aarch64 translation tables manipulation helper prototypes |
| 39 | ******************************************************************************/ |
| 40 | extern unsigned long create_table_desc(unsigned long *next_table_ptr); |
| 41 | extern unsigned long create_block_desc(unsigned long desc, |
| 42 | unsigned long addr, |
| 43 | unsigned int level); |
| 44 | extern unsigned long create_device_block(unsigned long output_addr, |
| 45 | unsigned int level, |
| 46 | unsigned int ns); |
| 47 | extern unsigned long create_romem_block(unsigned long output_addr, |
| 48 | unsigned int level, |
| 49 | unsigned int ns); |
| 50 | extern unsigned long create_rwmem_block(unsigned long output_addr, |
| 51 | unsigned int level, |
| 52 | unsigned int ns); |
| 53 | |
| 54 | /******************************************************************************* |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 55 | * TLB maintenance accessor prototypes |
| 56 | ******************************************************************************/ |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 57 | extern void tlbialle1(void); |
| 58 | extern void tlbialle1is(void); |
| 59 | extern void tlbialle2(void); |
| 60 | extern void tlbialle2is(void); |
| 61 | extern void tlbialle3(void); |
| 62 | extern void tlbialle3is(void); |
| 63 | extern void tlbivmalle1(void); |
| 64 | |
| 65 | /******************************************************************************* |
| 66 | * Cache maintenance accessor prototypes |
| 67 | ******************************************************************************/ |
| 68 | extern void dcisw(unsigned long); |
| 69 | extern void dccisw(unsigned long); |
| 70 | extern void dccsw(unsigned long); |
| 71 | extern void dccvac(unsigned long); |
| 72 | extern void dcivac(unsigned long); |
| 73 | extern void dccivac(unsigned long); |
| 74 | extern void dccvau(unsigned long); |
| 75 | extern void dczva(unsigned long); |
| 76 | extern void flush_dcache_range(unsigned long, unsigned long); |
| 77 | extern void inv_dcache_range(unsigned long, unsigned long); |
| 78 | extern void dcsw_op_louis(unsigned int); |
| 79 | extern void dcsw_op_all(unsigned int); |
| 80 | |
| 81 | /******************************************************************************* |
| 82 | * Misc. accessor prototypes |
| 83 | ******************************************************************************/ |
| 84 | extern void enable_irq(void); |
| 85 | extern void enable_fiq(void); |
| 86 | extern void enable_serror(void); |
Sandrine Bailleux | 3738274 | 2013-11-18 17:26:59 +0000 | [diff] [blame] | 87 | extern void enable_debug_exceptions(void); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 88 | |
| 89 | extern void disable_irq(void); |
| 90 | extern void disable_fiq(void); |
| 91 | extern void disable_serror(void); |
Sandrine Bailleux | 3738274 | 2013-11-18 17:26:59 +0000 | [diff] [blame] | 92 | extern void disable_debug_exceptions(void); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 93 | |
| 94 | extern unsigned long read_id_pfr1_el1(void); |
| 95 | extern unsigned long read_id_aa64pfr0_el1(void); |
| 96 | extern unsigned long read_current_el(void); |
| 97 | extern unsigned long read_daif(void); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 98 | extern unsigned long read_spsr_el1(void); |
| 99 | extern unsigned long read_spsr_el2(void); |
| 100 | extern unsigned long read_spsr_el3(void); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 101 | extern unsigned long read_elr_el1(void); |
| 102 | extern unsigned long read_elr_el2(void); |
| 103 | extern unsigned long read_elr_el3(void); |
| 104 | |
| 105 | extern void write_daif(unsigned long); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 106 | extern void write_spsr_el1(unsigned long); |
| 107 | extern void write_spsr_el2(unsigned long); |
| 108 | extern void write_spsr_el3(unsigned long); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 109 | extern void write_elr_el1(unsigned long); |
| 110 | extern void write_elr_el2(unsigned long); |
| 111 | extern void write_elr_el3(unsigned long); |
| 112 | |
| 113 | extern void wfi(void); |
| 114 | extern void wfe(void); |
| 115 | extern void rfe(void); |
| 116 | extern void sev(void); |
| 117 | extern void dsb(void); |
| 118 | extern void isb(void); |
| 119 | |
| 120 | extern unsigned int get_afflvl_shift(unsigned int); |
| 121 | extern unsigned int mpidr_mask_lower_afflvls(unsigned long, unsigned int); |
| 122 | |
Achin Gupta | e4d084e | 2014-02-19 17:18:23 +0000 | [diff] [blame] | 123 | extern void __dead2 eret(unsigned long, unsigned long, |
| 124 | unsigned long, unsigned long, |
| 125 | unsigned long, unsigned long, |
| 126 | unsigned long, unsigned long); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 127 | |
Achin Gupta | e4d084e | 2014-02-19 17:18:23 +0000 | [diff] [blame] | 128 | extern void __dead2 smc(unsigned long, unsigned long, |
| 129 | unsigned long, unsigned long, |
| 130 | unsigned long, unsigned long, |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 131 | unsigned long, unsigned long); |
| 132 | |
| 133 | /******************************************************************************* |
| 134 | * System register accessor prototypes |
| 135 | ******************************************************************************/ |
| 136 | extern unsigned long read_midr(void); |
| 137 | extern unsigned long read_mpidr(void); |
| 138 | |
| 139 | extern unsigned long read_scr(void); |
| 140 | extern unsigned long read_hcr(void); |
| 141 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 142 | extern unsigned long read_vbar_el1(void); |
| 143 | extern unsigned long read_vbar_el2(void); |
| 144 | extern unsigned long read_vbar_el3(void); |
| 145 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 146 | extern unsigned long read_sctlr_el1(void); |
| 147 | extern unsigned long read_sctlr_el2(void); |
| 148 | extern unsigned long read_sctlr_el3(void); |
| 149 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 150 | extern unsigned long read_actlr_el1(void); |
| 151 | extern unsigned long read_actlr_el2(void); |
| 152 | extern unsigned long read_actlr_el3(void); |
| 153 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 154 | extern unsigned long read_esr_el1(void); |
| 155 | extern unsigned long read_esr_el2(void); |
| 156 | extern unsigned long read_esr_el3(void); |
| 157 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 158 | extern unsigned long read_afsr0_el1(void); |
| 159 | extern unsigned long read_afsr0_el2(void); |
| 160 | extern unsigned long read_afsr0_el3(void); |
| 161 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 162 | extern unsigned long read_afsr1_el1(void); |
| 163 | extern unsigned long read_afsr1_el2(void); |
| 164 | extern unsigned long read_afsr1_el3(void); |
| 165 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 166 | extern unsigned long read_far_el1(void); |
| 167 | extern unsigned long read_far_el2(void); |
| 168 | extern unsigned long read_far_el3(void); |
| 169 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 170 | extern unsigned long read_mair_el1(void); |
| 171 | extern unsigned long read_mair_el2(void); |
| 172 | extern unsigned long read_mair_el3(void); |
| 173 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 174 | extern unsigned long read_amair_el1(void); |
| 175 | extern unsigned long read_amair_el2(void); |
| 176 | extern unsigned long read_amair_el3(void); |
| 177 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 178 | extern unsigned long read_rvbar_el1(void); |
| 179 | extern unsigned long read_rvbar_el2(void); |
| 180 | extern unsigned long read_rvbar_el3(void); |
| 181 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 182 | extern unsigned long read_rmr_el1(void); |
| 183 | extern unsigned long read_rmr_el2(void); |
| 184 | extern unsigned long read_rmr_el3(void); |
| 185 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 186 | extern unsigned long read_tcr_el1(void); |
| 187 | extern unsigned long read_tcr_el2(void); |
| 188 | extern unsigned long read_tcr_el3(void); |
| 189 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 190 | extern unsigned long read_ttbr0_el1(void); |
| 191 | extern unsigned long read_ttbr0_el2(void); |
| 192 | extern unsigned long read_ttbr0_el3(void); |
| 193 | |
| 194 | extern unsigned long read_ttbr1(void); |
| 195 | extern unsigned long read_ttbr1_el1(void); |
| 196 | extern unsigned long read_ttbr1_el2(void); |
| 197 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 198 | extern unsigned long read_cptr_el2(void); |
| 199 | extern unsigned long read_cptr_el3(void); |
| 200 | |
| 201 | extern unsigned long read_cpacr(void); |
| 202 | extern unsigned long read_cpuectlr(void); |
| 203 | extern unsigned int read_cntfrq_el0(void); |
| 204 | extern unsigned long read_cnthctl_el2(void); |
| 205 | |
| 206 | extern void write_scr(unsigned long); |
| 207 | extern void write_hcr(unsigned long); |
| 208 | extern void write_cpacr(unsigned long); |
| 209 | extern void write_cntfrq_el0(unsigned int); |
| 210 | extern void write_cnthctl_el2(unsigned long); |
| 211 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 212 | extern void write_vbar_el1(unsigned long); |
| 213 | extern void write_vbar_el2(unsigned long); |
| 214 | extern void write_vbar_el3(unsigned long); |
| 215 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 216 | extern void write_sctlr_el1(unsigned long); |
| 217 | extern void write_sctlr_el2(unsigned long); |
| 218 | extern void write_sctlr_el3(unsigned long); |
| 219 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 220 | extern void write_actlr_el1(unsigned long); |
| 221 | extern void write_actlr_el2(unsigned long); |
| 222 | extern void write_actlr_el3(unsigned long); |
| 223 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 224 | extern void write_esr_el1(unsigned long); |
| 225 | extern void write_esr_el2(unsigned long); |
| 226 | extern void write_esr_el3(unsigned long); |
| 227 | |
| 228 | extern void write_afsr0(unsigned long); |
| 229 | extern void write_afsr0_el1(unsigned long); |
| 230 | extern void write_afsr0_el2(unsigned long); |
| 231 | extern void write_afsr0_el3(unsigned long); |
| 232 | |
| 233 | extern void write_afsr1(unsigned long); |
| 234 | extern void write_afsr1_el1(unsigned long); |
| 235 | extern void write_afsr1_el2(unsigned long); |
| 236 | extern void write_afsr1_el3(unsigned long); |
| 237 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 238 | extern void write_far_el1(unsigned long); |
| 239 | extern void write_far_el2(unsigned long); |
| 240 | extern void write_far_el3(unsigned long); |
| 241 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 242 | extern void write_mair_el1(unsigned long); |
| 243 | extern void write_mair_el2(unsigned long); |
| 244 | extern void write_mair_el3(unsigned long); |
| 245 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 246 | extern void write_amair_el1(unsigned long); |
| 247 | extern void write_amair_el2(unsigned long); |
| 248 | extern void write_amair_el3(unsigned long); |
| 249 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 250 | extern void write_rmr_el1(unsigned long); |
| 251 | extern void write_rmr_el2(unsigned long); |
| 252 | extern void write_rmr_el3(unsigned long); |
| 253 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 254 | extern void write_tcr_el1(unsigned long); |
| 255 | extern void write_tcr_el2(unsigned long); |
| 256 | extern void write_tcr_el3(unsigned long); |
| 257 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 258 | extern void write_ttbr0_el1(unsigned long); |
| 259 | extern void write_ttbr0_el2(unsigned long); |
| 260 | extern void write_ttbr0_el3(unsigned long); |
| 261 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 262 | extern void write_ttbr1_el1(unsigned long); |
| 263 | extern void write_ttbr1_el2(unsigned long); |
| 264 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 265 | extern void write_cpuectlr(unsigned long); |
| 266 | extern void write_cptr_el2(unsigned long); |
| 267 | extern void write_cptr_el3(unsigned long); |
| 268 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 269 | |
| 270 | #endif /* __ARCH_HELPERS_H__ */ |