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 | |
Andrew Thoelke | 2f5dcfe | 2014-04-28 12:06:18 +0100 | [diff] [blame^] | 81 | extern void disable_mmu_el3(void); |
| 82 | extern void disable_mmu_icache_el3(void); |
| 83 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 84 | /******************************************************************************* |
| 85 | * Misc. accessor prototypes |
| 86 | ******************************************************************************/ |
| 87 | extern void enable_irq(void); |
| 88 | extern void enable_fiq(void); |
| 89 | extern void enable_serror(void); |
Sandrine Bailleux | 3738274 | 2013-11-18 17:26:59 +0000 | [diff] [blame] | 90 | extern void enable_debug_exceptions(void); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 91 | |
| 92 | extern void disable_irq(void); |
| 93 | extern void disable_fiq(void); |
| 94 | extern void disable_serror(void); |
Sandrine Bailleux | 3738274 | 2013-11-18 17:26:59 +0000 | [diff] [blame] | 95 | extern void disable_debug_exceptions(void); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 96 | |
| 97 | extern unsigned long read_id_pfr1_el1(void); |
| 98 | extern unsigned long read_id_aa64pfr0_el1(void); |
| 99 | extern unsigned long read_current_el(void); |
| 100 | extern unsigned long read_daif(void); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 101 | extern unsigned long read_spsr_el1(void); |
| 102 | extern unsigned long read_spsr_el2(void); |
| 103 | extern unsigned long read_spsr_el3(void); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 104 | extern unsigned long read_elr_el1(void); |
| 105 | extern unsigned long read_elr_el2(void); |
| 106 | extern unsigned long read_elr_el3(void); |
| 107 | |
| 108 | extern void write_daif(unsigned long); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 109 | extern void write_spsr_el1(unsigned long); |
| 110 | extern void write_spsr_el2(unsigned long); |
| 111 | extern void write_spsr_el3(unsigned long); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 112 | extern void write_elr_el1(unsigned long); |
| 113 | extern void write_elr_el2(unsigned long); |
| 114 | extern void write_elr_el3(unsigned long); |
| 115 | |
| 116 | extern void wfi(void); |
| 117 | extern void wfe(void); |
| 118 | extern void rfe(void); |
| 119 | extern void sev(void); |
| 120 | extern void dsb(void); |
| 121 | extern void isb(void); |
| 122 | |
| 123 | extern unsigned int get_afflvl_shift(unsigned int); |
| 124 | extern unsigned int mpidr_mask_lower_afflvls(unsigned long, unsigned int); |
| 125 | |
Achin Gupta | e4d084e | 2014-02-19 17:18:23 +0000 | [diff] [blame] | 126 | extern void __dead2 eret(unsigned long, unsigned long, |
| 127 | unsigned long, unsigned long, |
| 128 | unsigned long, unsigned long, |
| 129 | unsigned long, unsigned long); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 130 | |
Achin Gupta | e4d084e | 2014-02-19 17:18:23 +0000 | [diff] [blame] | 131 | extern void __dead2 smc(unsigned long, unsigned long, |
| 132 | unsigned long, unsigned long, |
| 133 | unsigned long, unsigned long, |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 134 | unsigned long, unsigned long); |
| 135 | |
| 136 | /******************************************************************************* |
| 137 | * System register accessor prototypes |
| 138 | ******************************************************************************/ |
| 139 | extern unsigned long read_midr(void); |
| 140 | extern unsigned long read_mpidr(void); |
| 141 | |
| 142 | extern unsigned long read_scr(void); |
| 143 | extern unsigned long read_hcr(void); |
| 144 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 145 | extern unsigned long read_vbar_el1(void); |
| 146 | extern unsigned long read_vbar_el2(void); |
| 147 | extern unsigned long read_vbar_el3(void); |
| 148 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 149 | extern unsigned long read_sctlr_el1(void); |
| 150 | extern unsigned long read_sctlr_el2(void); |
| 151 | extern unsigned long read_sctlr_el3(void); |
| 152 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 153 | extern unsigned long read_actlr_el1(void); |
| 154 | extern unsigned long read_actlr_el2(void); |
| 155 | extern unsigned long read_actlr_el3(void); |
| 156 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 157 | extern unsigned long read_esr_el1(void); |
| 158 | extern unsigned long read_esr_el2(void); |
| 159 | extern unsigned long read_esr_el3(void); |
| 160 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 161 | extern unsigned long read_afsr0_el1(void); |
| 162 | extern unsigned long read_afsr0_el2(void); |
| 163 | extern unsigned long read_afsr0_el3(void); |
| 164 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 165 | extern unsigned long read_afsr1_el1(void); |
| 166 | extern unsigned long read_afsr1_el2(void); |
| 167 | extern unsigned long read_afsr1_el3(void); |
| 168 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 169 | extern unsigned long read_far_el1(void); |
| 170 | extern unsigned long read_far_el2(void); |
| 171 | extern unsigned long read_far_el3(void); |
| 172 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 173 | extern unsigned long read_mair_el1(void); |
| 174 | extern unsigned long read_mair_el2(void); |
| 175 | extern unsigned long read_mair_el3(void); |
| 176 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 177 | extern unsigned long read_amair_el1(void); |
| 178 | extern unsigned long read_amair_el2(void); |
| 179 | extern unsigned long read_amair_el3(void); |
| 180 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 181 | extern unsigned long read_rvbar_el1(void); |
| 182 | extern unsigned long read_rvbar_el2(void); |
| 183 | extern unsigned long read_rvbar_el3(void); |
| 184 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 185 | extern unsigned long read_rmr_el1(void); |
| 186 | extern unsigned long read_rmr_el2(void); |
| 187 | extern unsigned long read_rmr_el3(void); |
| 188 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 189 | extern unsigned long read_tcr_el1(void); |
| 190 | extern unsigned long read_tcr_el2(void); |
| 191 | extern unsigned long read_tcr_el3(void); |
| 192 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 193 | extern unsigned long read_ttbr0_el1(void); |
| 194 | extern unsigned long read_ttbr0_el2(void); |
| 195 | extern unsigned long read_ttbr0_el3(void); |
| 196 | |
| 197 | extern unsigned long read_ttbr1(void); |
| 198 | extern unsigned long read_ttbr1_el1(void); |
| 199 | extern unsigned long read_ttbr1_el2(void); |
| 200 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 201 | extern unsigned long read_cptr_el2(void); |
| 202 | extern unsigned long read_cptr_el3(void); |
| 203 | |
| 204 | extern unsigned long read_cpacr(void); |
| 205 | extern unsigned long read_cpuectlr(void); |
| 206 | extern unsigned int read_cntfrq_el0(void); |
| 207 | extern unsigned long read_cnthctl_el2(void); |
| 208 | |
| 209 | extern void write_scr(unsigned long); |
| 210 | extern void write_hcr(unsigned long); |
| 211 | extern void write_cpacr(unsigned long); |
| 212 | extern void write_cntfrq_el0(unsigned int); |
| 213 | extern void write_cnthctl_el2(unsigned long); |
| 214 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 215 | extern void write_vbar_el1(unsigned long); |
| 216 | extern void write_vbar_el2(unsigned long); |
| 217 | extern void write_vbar_el3(unsigned long); |
| 218 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 219 | extern void write_sctlr_el1(unsigned long); |
| 220 | extern void write_sctlr_el2(unsigned long); |
| 221 | extern void write_sctlr_el3(unsigned long); |
| 222 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 223 | extern void write_actlr_el1(unsigned long); |
| 224 | extern void write_actlr_el2(unsigned long); |
| 225 | extern void write_actlr_el3(unsigned long); |
| 226 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 227 | extern void write_esr_el1(unsigned long); |
| 228 | extern void write_esr_el2(unsigned long); |
| 229 | extern void write_esr_el3(unsigned long); |
| 230 | |
| 231 | extern void write_afsr0(unsigned long); |
| 232 | extern void write_afsr0_el1(unsigned long); |
| 233 | extern void write_afsr0_el2(unsigned long); |
| 234 | extern void write_afsr0_el3(unsigned long); |
| 235 | |
| 236 | extern void write_afsr1(unsigned long); |
| 237 | extern void write_afsr1_el1(unsigned long); |
| 238 | extern void write_afsr1_el2(unsigned long); |
| 239 | extern void write_afsr1_el3(unsigned long); |
| 240 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 241 | extern void write_far_el1(unsigned long); |
| 242 | extern void write_far_el2(unsigned long); |
| 243 | extern void write_far_el3(unsigned long); |
| 244 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 245 | extern void write_mair_el1(unsigned long); |
| 246 | extern void write_mair_el2(unsigned long); |
| 247 | extern void write_mair_el3(unsigned long); |
| 248 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 249 | extern void write_amair_el1(unsigned long); |
| 250 | extern void write_amair_el2(unsigned long); |
| 251 | extern void write_amair_el3(unsigned long); |
| 252 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 253 | extern void write_rmr_el1(unsigned long); |
| 254 | extern void write_rmr_el2(unsigned long); |
| 255 | extern void write_rmr_el3(unsigned long); |
| 256 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 257 | extern void write_tcr_el1(unsigned long); |
| 258 | extern void write_tcr_el2(unsigned long); |
| 259 | extern void write_tcr_el3(unsigned long); |
| 260 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 261 | extern void write_ttbr0_el1(unsigned long); |
| 262 | extern void write_ttbr0_el2(unsigned long); |
| 263 | extern void write_ttbr0_el3(unsigned long); |
| 264 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 265 | extern void write_ttbr1_el1(unsigned long); |
| 266 | extern void write_ttbr1_el2(unsigned long); |
| 267 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 268 | extern void write_cpuectlr(unsigned long); |
| 269 | extern void write_cptr_el2(unsigned long); |
| 270 | extern void write_cptr_el3(unsigned long); |
| 271 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 272 | |
| 273 | #endif /* __ARCH_HELPERS_H__ */ |