1 /* cpufunc.h,v 1.40.22.4 2007/11/08 10:59:33 matt Exp */ 2 3 /* 4 * Copyright (c) 1997 Mark Brinicombe. 5 * Copyright (c) 1997 Causality Limited 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Causality Limited. 19 * 4. The name of Causality Limited may not be used to endorse or promote 20 * products derived from this software without specific prior written 21 * permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY CAUSALITY LIMITED ``AS IS'' AND ANY EXPRESS 24 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL CAUSALITY LIMITED BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * RiscBSD kernel project 36 * 37 * cpufunc.h 38 * 39 * Prototypes for cpu, mmu and tlb related functions. 40 */ 41 42 #ifndef _ARM32_CPUFUNC_H_ 43 #define _ARM32_CPUFUNC_H_ 44 45 #ifdef _KERNEL 46 47 #include <sys/types.h> 48 #include <arm/armreg.h> 49 #include <arm/cpuconf.h> 50 #include <arm/armreg.h> 51 52 struct cpu_functions { 53 54 /* CPU functions */ 55 56 u_int (*cf_id) (void); 57 void (*cf_cpwait) (void); 58 59 /* MMU functions */ 60 61 u_int (*cf_control) (u_int, u_int); 62 void (*cf_domains) (u_int); 63 void (*cf_setttb) (u_int); 64 u_int (*cf_faultstatus) (void); 65 u_int (*cf_faultaddress) (void); 66 67 /* TLB functions */ 68 69 void (*cf_tlb_flushID) (void); 70 void (*cf_tlb_flushID_SE) (u_int); 71 void (*cf_tlb_flushI) (void); 72 void (*cf_tlb_flushI_SE) (u_int); 73 void (*cf_tlb_flushD) (void); 74 void (*cf_tlb_flushD_SE) (u_int); 75 76 /* 77 * Cache operations: 78 * 79 * We define the following primitives: 80 * 81 * icache_sync_all Synchronize I-cache 82 * icache_sync_range Synchronize I-cache range 83 * 84 * dcache_wbinv_all Write-back and Invalidate D-cache 85 * dcache_wbinv_range Write-back and Invalidate D-cache range 86 * dcache_inv_range Invalidate D-cache range 87 * dcache_wb_range Write-back D-cache range 88 * 89 * idcache_wbinv_all Write-back and Invalidate D-cache, 90 * Invalidate I-cache 91 * idcache_wbinv_range Write-back and Invalidate D-cache, 92 * Invalidate I-cache range 93 * 94 * Note that the ARM term for "write-back" is "clean". We use 95 * the term "write-back" since it's a more common way to describe 96 * the operation. 97 * 98 * There are some rules that must be followed: 99 * 100 * I-cache Synch (all or range): 101 * The goal is to synchronize the instruction stream, 102 * so you may beed to write-back dirty D-cache blocks 103 * first. If a range is requested, and you can't 104 * synchronize just a range, you have to hit the whole 105 * thing. 106 * 107 * D-cache Write-Back and Invalidate range: 108 * If you can't WB-Inv a range, you must WB-Inv the 109 * entire D-cache. 110 * 111 * D-cache Invalidate: 112 * If you can't Inv the D-cache, you must Write-Back 113 * and Invalidate. Code that uses this operation 114 * MUST NOT assume that the D-cache will not be written 115 * back to memory. 116 * 117 * D-cache Write-Back: 118 * If you can't Write-back without doing an Inv, 119 * that's fine. Then treat this as a WB-Inv. 120 * Skipping the invalidate is merely an optimization. 121 * 122 * All operations: 123 * Valid virtual addresses must be passed to each 124 * cache operation. 125 */ 126 void (*cf_icache_sync_all) (void); 127 void (*cf_icache_sync_range) (vaddr_t, vsize_t); 128 129 void (*cf_dcache_wbinv_all) (void); 130 void (*cf_dcache_wbinv_range)(vaddr_t, vsize_t); 131 void (*cf_dcache_inv_range) (vaddr_t, vsize_t); 132 void (*cf_dcache_wb_range) (vaddr_t, vsize_t); 133 134 void (*cf_idcache_wbinv_all) (void); 135 void (*cf_idcache_wbinv_range)(vaddr_t, vsize_t); 136 137 /* Other functions */ 138 139 void (*cf_flush_prefetchbuf) (void); 140 void (*cf_drain_writebuf) (void); 141 void (*cf_flush_brnchtgt_C) (void); 142 void (*cf_flush_brnchtgt_E) (u_int); 143 144 void (*cf_sleep) (int mode); 145 146 /* Soft functions */ 147 148 int (*cf_dataabt_fixup) (void *); 149 int (*cf_prefetchabt_fixup) (void *); 150 151 void (*cf_context_switch) (u_int); 152 153 void (*cf_setup) (char *); 154 }; 155 156 extern struct cpu_functions cpufuncs; 157 extern u_int cputype; 158 159 #define cpu_id() cpufuncs.cf_id() 160 161 #define cpu_control(c, e) cpufuncs.cf_control(c, e) 162 #define cpu_domains(d) cpufuncs.cf_domains(d) 163 #define cpu_setttb(t) cpufuncs.cf_setttb(t) 164 #define cpu_faultstatus() cpufuncs.cf_faultstatus() 165 #define cpu_faultaddress() cpufuncs.cf_faultaddress() 166 167 #define cpu_tlb_flushID() cpufuncs.cf_tlb_flushID() 168 #define cpu_tlb_flushID_SE(e) cpufuncs.cf_tlb_flushID_SE(e) 169 #define cpu_tlb_flushI() cpufuncs.cf_tlb_flushI() 170 #define cpu_tlb_flushI_SE(e) cpufuncs.cf_tlb_flushI_SE(e) 171 #define cpu_tlb_flushD() cpufuncs.cf_tlb_flushD() 172 #define cpu_tlb_flushD_SE(e) cpufuncs.cf_tlb_flushD_SE(e) 173 174 #define cpu_icache_sync_all() cpufuncs.cf_icache_sync_all() 175 #define cpu_icache_sync_range(a, s) cpufuncs.cf_icache_sync_range((a), (s)) 176 177 #define cpu_dcache_wbinv_all() cpufuncs.cf_dcache_wbinv_all() 178 #define cpu_dcache_wbinv_range(a, s) cpufuncs.cf_dcache_wbinv_range((a), (s)) 179 #define cpu_dcache_inv_range(a, s) cpufuncs.cf_dcache_inv_range((a), (s)) 180 #define cpu_dcache_wb_range(a, s) cpufuncs.cf_dcache_wb_range((a), (s)) 181 182 #define cpu_idcache_wbinv_all() cpufuncs.cf_idcache_wbinv_all() 183 #define cpu_idcache_wbinv_range(a, s) cpufuncs.cf_idcache_wbinv_range((a), (s)) 184 185 #define cpu_flush_prefetchbuf() cpufuncs.cf_flush_prefetchbuf() 186 #define cpu_drain_writebuf() cpufuncs.cf_drain_writebuf() 187 #define cpu_flush_brnchtgt_C() cpufuncs.cf_flush_brnchtgt_C() 188 #define cpu_flush_brnchtgt_E(e) cpufuncs.cf_flush_brnchtgt_E(e) 189 190 #define cpu_sleep(m) cpufuncs.cf_sleep(m) 191 192 #define cpu_dataabt_fixup(a) cpufuncs.cf_dataabt_fixup(a) 193 #define cpu_prefetchabt_fixup(a) cpufuncs.cf_prefetchabt_fixup(a) 194 #define ABORT_FIXUP_OK 0 /* fixup succeeded */ 195 #define ABORT_FIXUP_FAILED 1 /* fixup failed */ 196 #define ABORT_FIXUP_RETURN 2 /* abort handler should return */ 197 198 #define cpu_context_switch(a) cpufuncs.cf_context_switch(a) 199 #define cpu_setup(a) cpufuncs.cf_setup(a) 200 201 int set_cpufuncs (void); 202 int set_cpufuncs_id (u_int); 203 #define ARCHITECTURE_NOT_PRESENT 1 /* known but not configured */ 204 #define ARCHITECTURE_NOT_SUPPORTED 2 /* not known */ 205 206 void cpufunc_nullop (void); 207 int cpufunc_null_fixup (void *); 208 int early_abort_fixup (void *); 209 int late_abort_fixup (void *); 210 u_int cpufunc_id (void); 211 u_int cpufunc_control (u_int, u_int); 212 void cpufunc_domains (u_int); 213 u_int cpufunc_faultstatus (void); 214 u_int cpufunc_faultaddress (void); 215 216 #ifdef CPU_ARM2 217 u_int arm2_id (void); 218 #endif /* CPU_ARM2 */ 219 220 #ifdef CPU_ARM250 221 u_int arm250_id (void); 222 #endif 223 224 #ifdef CPU_ARM3 225 u_int arm3_control (u_int, u_int); 226 void arm3_cache_flush (void); 227 #endif /* CPU_ARM3 */ 228 229 #if defined(CPU_ARM6) || defined(CPU_ARM7) 230 void arm67_setttb (u_int); 231 void arm67_tlb_flush (void); 232 void arm67_tlb_purge (u_int); 233 void arm67_cache_flush (void); 234 void arm67_context_switch (u_int); 235 #endif /* CPU_ARM6 || CPU_ARM7 */ 236 237 #ifdef CPU_ARM6 238 void arm6_setup (char *); 239 #endif /* CPU_ARM6 */ 240 241 #ifdef CPU_ARM7 242 void arm7_setup (char *); 243 #endif /* CPU_ARM7 */ 244 245 #ifdef CPU_ARM7TDMI 246 int arm7_dataabt_fixup (void *); 247 void arm7tdmi_setup (char *); 248 void arm7tdmi_setttb (u_int); 249 void arm7tdmi_tlb_flushID (void); 250 void arm7tdmi_tlb_flushID_SE (u_int); 251 void arm7tdmi_cache_flushID (void); 252 void arm7tdmi_context_switch (u_int); 253 #endif /* CPU_ARM7TDMI */ 254 255 #ifdef CPU_ARM8 256 void arm8_setttb (u_int); 257 void arm8_tlb_flushID (void); 258 void arm8_tlb_flushID_SE (u_int); 259 void arm8_cache_flushID (void); 260 void arm8_cache_flushID_E (u_int); 261 void arm8_cache_cleanID (void); 262 void arm8_cache_cleanID_E (u_int); 263 void arm8_cache_purgeID (void); 264 void arm8_cache_purgeID_E (u_int entry); 265 266 void arm8_cache_syncI (void); 267 void arm8_cache_cleanID_rng (vaddr_t, vsize_t); 268 void arm8_cache_cleanD_rng (vaddr_t, vsize_t); 269 void arm8_cache_purgeID_rng (vaddr_t, vsize_t); 270 void arm8_cache_purgeD_rng (vaddr_t, vsize_t); 271 void arm8_cache_syncI_rng (vaddr_t, vsize_t); 272 273 void arm8_context_switch (u_int); 274 275 void arm8_setup (char *); 276 277 u_int arm8_clock_config (u_int, u_int); 278 #endif 279 280 #ifdef CPU_SA110 281 void sa110_setup (char *); 282 void sa110_context_switch (u_int); 283 #endif /* CPU_SA110 */ 284 285 #if defined(CPU_SA1100) || defined(CPU_SA1110) 286 void sa11x0_drain_readbuf (void); 287 288 void sa11x0_context_switch (u_int); 289 void sa11x0_cpu_sleep (int); 290 291 void sa11x0_setup (char *); 292 #endif 293 294 #if defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110) 295 void sa1_setttb (u_int); 296 297 void sa1_tlb_flushID_SE (u_int); 298 299 void sa1_cache_flushID (void); 300 void sa1_cache_flushI (void); 301 void sa1_cache_flushD (void); 302 void sa1_cache_flushD_SE (u_int); 303 304 void sa1_cache_cleanID (void); 305 void sa1_cache_cleanD (void); 306 void sa1_cache_cleanD_E (u_int); 307 308 void sa1_cache_purgeID (void); 309 void sa1_cache_purgeID_E (u_int); 310 void sa1_cache_purgeD (void); 311 void sa1_cache_purgeD_E (u_int); 312 313 void sa1_cache_syncI (void); 314 void sa1_cache_cleanID_rng (vaddr_t, vsize_t); 315 void sa1_cache_cleanD_rng (vaddr_t, vsize_t); 316 void sa1_cache_purgeID_rng (vaddr_t, vsize_t); 317 void sa1_cache_purgeD_rng (vaddr_t, vsize_t); 318 void sa1_cache_syncI_rng (vaddr_t, vsize_t); 319 320 #endif 321 322 #ifdef CPU_ARM9 323 void arm9_setttb (u_int); 324 325 void arm9_tlb_flushID_SE (u_int); 326 327 void arm9_icache_sync_all (void); 328 void arm9_icache_sync_range (vaddr_t, vsize_t); 329 330 void arm9_dcache_wbinv_all (void); 331 void arm9_dcache_wbinv_range (vaddr_t, vsize_t); 332 void arm9_dcache_inv_range (vaddr_t, vsize_t); 333 void arm9_dcache_wb_range (vaddr_t, vsize_t); 334 335 void arm9_idcache_wbinv_all (void); 336 void arm9_idcache_wbinv_range (vaddr_t, vsize_t); 337 338 void arm9_context_switch (u_int); 339 340 void arm9_setup (char *); 341 342 extern unsigned arm9_dcache_sets_max; 343 extern unsigned arm9_dcache_sets_inc; 344 extern unsigned arm9_dcache_index_max; 345 extern unsigned arm9_dcache_index_inc; 346 #endif 347 348 #if defined(CPU_ARM9E) || defined(CPU_ARM10) 349 void arm10_tlb_flushID_SE (u_int); 350 void arm10_tlb_flushI_SE (u_int); 351 352 void arm10_context_switch (u_int); 353 354 void arm10_setup (char *); 355 #endif 356 357 #if defined(CPU_ARM9E) || defined (CPU_ARM10) 358 void armv5_ec_setttb (u_int); 359 360 void armv5_ec_icache_sync_all (void); 361 void armv5_ec_icache_sync_range (vaddr_t, vsize_t); 362 363 void armv5_ec_dcache_wbinv_all (void); 364 void armv5_ec_dcache_wbinv_range (vaddr_t, vsize_t); 365 void armv5_ec_dcache_inv_range (vaddr_t, vsize_t); 366 void armv5_ec_dcache_wb_range (vaddr_t, vsize_t); 367 368 void armv5_ec_idcache_wbinv_all (void); 369 void armv5_ec_idcache_wbinv_range (vaddr_t, vsize_t); 370 #endif 371 372 #if defined (CPU_ARM10) 373 void armv5_setttb (u_int); 374 375 void armv5_icache_sync_all (void); 376 void armv5_icache_sync_range (vaddr_t, vsize_t); 377 378 void armv5_dcache_wbinv_all (void); 379 void armv5_dcache_wbinv_range (vaddr_t, vsize_t); 380 void armv5_dcache_inv_range (vaddr_t, vsize_t); 381 void armv5_dcache_wb_range (vaddr_t, vsize_t); 382 383 void armv5_idcache_wbinv_all (void); 384 void armv5_idcache_wbinv_range (vaddr_t, vsize_t); 385 386 extern unsigned armv5_dcache_sets_max; 387 extern unsigned armv5_dcache_sets_inc; 388 extern unsigned armv5_dcache_index_max; 389 extern unsigned armv5_dcache_index_inc; 390 #endif 391 392 #if defined(CPU_ARM11) 393 void arm11_setttb (u_int); 394 395 void arm11_tlb_flushID_SE (u_int); 396 void arm11_tlb_flushI_SE (u_int); 397 398 void arm11_context_switch (u_int); 399 400 void arm11_cpu_sleep (int); 401 void arm11_setup (char *string); 402 void arm11_tlb_flushID (void); 403 void arm11_tlb_flushI (void); 404 void arm11_tlb_flushD (void); 405 void arm11_tlb_flushD_SE (u_int va); 406 407 void armv11_dcache_wbinv_all (void); 408 void armv11_idcache_wbinv_all(void); 409 410 void arm11_drain_writebuf (void); 411 void arm11_sleep (int); 412 413 void armv6_setttb (u_int); 414 415 void armv6_icache_sync_all (void); 416 void armv6_icache_sync_range (vaddr_t, vsize_t); 417 418 void armv6_dcache_wbinv_all (void); 419 void armv6_dcache_wbinv_range (vaddr_t, vsize_t); 420 void armv6_dcache_inv_range (vaddr_t, vsize_t); 421 void armv6_dcache_wb_range (vaddr_t, vsize_t); 422 423 void armv6_idcache_wbinv_all (void); 424 void armv6_idcache_wbinv_range (vaddr_t, vsize_t); 425 #endif 426 427 #if defined(CPU_ARM1136) 428 void arm1136_setttb (u_int); 429 void arm1136_idcache_wbinv_all (void); 430 void arm1136_dcache_wbinv_all (void); 431 void arm1136_icache_sync_all (void); 432 void arm1136_flush_prefetchbuf (void); 433 void arm1136_icache_sync_range (vaddr_t, vsize_t); 434 void arm1136_idcache_wbinv_range (vaddr_t, vsize_t); 435 void arm1136_setup (char *string); 436 void arm1136_sleep_rev0 (int); /* for errata 336501 */ 437 #endif 438 439 440 #if defined(CPU_ARM9) || defined(CPU_ARM9E) || defined(CPU_ARM10) || \ 441 defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110) || \ 442 defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \ 443 defined(__CPU_XSCALE_PXA2XX) || defined(CPU_XSCALE_IXP425) 444 445 void armv4_tlb_flushID (void); 446 void armv4_tlb_flushI (void); 447 void armv4_tlb_flushD (void); 448 void armv4_tlb_flushD_SE (u_int); 449 450 void armv4_drain_writebuf (void); 451 #endif 452 453 #if defined(CPU_IXP12X0) 454 void ixp12x0_drain_readbuf (void); 455 void ixp12x0_context_switch (u_int); 456 void ixp12x0_setup (char *); 457 #endif 458 459 #if defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \ 460 defined(__CPU_XSCALE_PXA2XX) || defined(CPU_XSCALE_IXP425) 461 462 void xscale_cpwait (void); 463 #define cpu_cpwait() cpufuncs.cf_cpwait() 464 465 void xscale_cpu_sleep (int); 466 467 u_int xscale_control (u_int, u_int); 468 469 void xscale_setttb (u_int); 470 471 void xscale_tlb_flushID_SE (u_int); 472 473 void xscale_cache_flushID (void); 474 void xscale_cache_flushI (void); 475 void xscale_cache_flushD (void); 476 void xscale_cache_flushD_SE (u_int); 477 478 void xscale_cache_cleanID (void); 479 void xscale_cache_cleanD (void); 480 void xscale_cache_cleanD_E (u_int); 481 482 void xscale_cache_clean_minidata (void); 483 484 void xscale_cache_purgeID (void); 485 void xscale_cache_purgeID_E (u_int); 486 void xscale_cache_purgeD (void); 487 void xscale_cache_purgeD_E (u_int); 488 489 void xscale_cache_syncI (void); 490 void xscale_cache_cleanID_rng (vaddr_t, vsize_t); 491 void xscale_cache_cleanD_rng (vaddr_t, vsize_t); 492 void xscale_cache_purgeID_rng (vaddr_t, vsize_t); 493 void xscale_cache_purgeD_rng (vaddr_t, vsize_t); 494 void xscale_cache_syncI_rng (vaddr_t, vsize_t); 495 void xscale_cache_flushD_rng (vaddr_t, vsize_t); 496 497 void xscale_context_switch (u_int); 498 499 void xscale_setup (char *); 500 #endif /* CPU_XSCALE_80200 || CPU_XSCALE_80321 || __CPU_XSCALE_PXA2XX || CPU_XSCALE_IXP425 */ 501 502 #define tlb_flush cpu_tlb_flushID 503 #define setttb cpu_setttb 504 #define drain_writebuf cpu_drain_writebuf 505 506 #ifndef cpu_cpwait 507 #define cpu_cpwait() 508 #endif 509 510 /* 511 * Macros for manipulating CPU interrupts 512 */ 513 #ifdef __PROG32 514 static __inline u_int32_t __set_cpsr_c(uint32_t bic, uint32_t eor) __attribute__((__unused__)); 515 static __inline u_int32_t disable_interrupts(uint32_t mask) __attribute__((__unused__)); 516 static __inline u_int32_t enable_interrupts(uint32_t mask) __attribute__((__unused__)); 517 518 static __inline uint32_t 519 __set_cpsr_c(uint32_t bic, uint32_t eor) 520 { 521 uint32_t tmp, ret; 522 523 __asm volatile( 524 "mrs %0, cpsr\n" /* Get the CPSR */ 525 "bic %1, %0, %2\n" /* Clear bits */ 526 "eor %1, %1, %3\n" /* XOR bits */ 527 "msr cpsr_c, %1\n" /* Set the control field of CPSR */ 528 : "=&r" (ret), "=&r" (tmp) 529 : "r" (bic), "r" (eor) : "memory"); 530 531 return ret; 532 } 533 534 static __inline uint32_t 535 disable_interrupts(uint32_t mask) 536 { 537 uint32_t tmp, ret; 538 mask &= (I32_bit | F32_bit); 539 540 __asm volatile( 541 "mrs %0, cpsr\n" /* Get the CPSR */ 542 "orr %1, %0, %2\n" /* set bits */ 543 "msr cpsr_c, %1\n" /* Set the control field of CPSR */ 544 : "=&r" (ret), "=&r" (tmp) 545 : "r" (mask) 546 : "memory"); 547 548 return ret; 549 } 550 551 static __inline uint32_t 552 enable_interrupts(uint32_t mask) 553 { 554 uint32_t ret, tmp; 555 mask &= (I32_bit | F32_bit); 556 557 __asm volatile( 558 "mrs %0, cpsr\n" /* Get the CPSR */ 559 "bic %1, %0, %2\n" /* Clear bits */ 560 "msr cpsr_c, %1\n" /* Set the control field of CPSR */ 561 : "=&r" (ret), "=&r" (tmp) 562 : "r" (mask) 563 : "memory"); 564 565 return ret; 566 } 567 568 #define restore_interrupts(old_cpsr) \ 569 (__set_cpsr_c((I32_bit | F32_bit), (old_cpsr) & (I32_bit | F32_bit))) 570 571 static inline void cpsie(register_t psw) __attribute__((__unused__)); 572 static inline register_t cpsid(register_t psw) __attribute__((__unused__)); 573 574 static inline void 575 cpsie(register_t psw) 576 { 577 if (!__builtin_constant_p(psw)) { 578 enable_interrupts(psw); 579 return; 580 } 581 switch (psw & (I32_bit|F32_bit)) { 582 case I32_bit: __asm("cpsie\ti"); break; 583 case F32_bit: __asm("cpsie\tf"); break; 584 case I32_bit|F32_bit: __asm("cpsie\tif"); break; 585 } 586 } 587 588 static inline register_t 589 cpsid(register_t psw) 590 { 591 register_t oldpsw; 592 if (!__builtin_constant_p(psw)) 593 return disable_interrupts(psw); 594 595 __asm("mrs %0, cpsr" : "=r"(oldpsw)); 596 switch (psw & (I32_bit|F32_bit)) { 597 case I32_bit: __asm("cpsid\ti"); break; 598 case F32_bit: __asm("cpsid\tf"); break; 599 case I32_bit|F32_bit: __asm("cpsid\tif"); break; 600 } 601 return oldpsw; 602 } 603 604 #else /* ! __PROG32 */ 605 #define disable_interrupts(mask) \ 606 (set_r15((mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE), \ 607 (mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE))) 608 609 #define enable_interrupts(mask) \ 610 (set_r15((mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE), 0)) 611 612 #define restore_interrupts(old_r15) \ 613 (set_r15((R15_IRQ_DISABLE | R15_FIQ_DISABLE), \ 614 (old_r15) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE))) 615 #endif /* __PROG32 */ 616 617 #ifdef __PROG32 618 /* Functions to manipulate the CPSR. */ 619 u_int SetCPSR(u_int, u_int); 620 u_int GetCPSR(void); 621 #else 622 /* Functions to manipulate the processor control bits in r15. */ 623 u_int set_r15(u_int, u_int); 624 u_int get_r15(void); 625 #endif /* __PROG32 */ 626 627 /* 628 * Functions to manipulate cpu r13 629 * (in arm/arm32/setstack.S) 630 */ 631 632 void set_stackptr (u_int, u_int); 633 u_int get_stackptr (u_int); 634 635 /* 636 * Miscellany 637 */ 638 639 int get_pc_str_offset (void); 640 641 /* 642 * CPU functions from locore.S 643 */ 644 645 void cpu_reset (void) __attribute__((__noreturn__)); 646 647 /* 648 * Cache info variables. 649 */ 650 651 /* PRIMARY CACHE VARIABLES */ 652 extern int arm_picache_size; 653 extern int arm_picache_line_size; 654 extern int arm_picache_ways; 655 656 extern int arm_pdcache_size; /* and unified */ 657 extern int arm_pdcache_line_size; 658 extern int arm_pdcache_ways; 659 extern int arm_cache_prefer_mask; 660 661 extern int arm_pcache_type; 662 extern int arm_pcache_unified; 663 664 extern int arm_dcache_align; 665 extern int arm_dcache_align_mask; 666 667 #endif /* _KERNEL */ 668 #endif /* _ARM32_CPUFUNC_H_ */ 669 670 /* End of cpufunc.h */ 671