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