16fc729afSOlivier Houchard /* $NetBSD: cpufunc.h,v 1.29 2003/09/06 09:08:35 rearnsha Exp $ */ 26fc729afSOlivier Houchard 3d8315c79SWarner Losh /*- 46fc729afSOlivier Houchard * Copyright (c) 1997 Mark Brinicombe. 56fc729afSOlivier Houchard * Copyright (c) 1997 Causality Limited 66fc729afSOlivier Houchard * All rights reserved. 76fc729afSOlivier Houchard * 86fc729afSOlivier Houchard * Redistribution and use in source and binary forms, with or without 96fc729afSOlivier Houchard * modification, are permitted provided that the following conditions 106fc729afSOlivier Houchard * are met: 116fc729afSOlivier Houchard * 1. Redistributions of source code must retain the above copyright 126fc729afSOlivier Houchard * notice, this list of conditions and the following disclaimer. 136fc729afSOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright 146fc729afSOlivier Houchard * notice, this list of conditions and the following disclaimer in the 156fc729afSOlivier Houchard * documentation and/or other materials provided with the distribution. 166fc729afSOlivier Houchard * 3. All advertising materials mentioning features or use of this software 176fc729afSOlivier Houchard * must display the following acknowledgement: 186fc729afSOlivier Houchard * This product includes software developed by Causality Limited. 196fc729afSOlivier Houchard * 4. The name of Causality Limited may not be used to endorse or promote 206fc729afSOlivier Houchard * products derived from this software without specific prior written 216fc729afSOlivier Houchard * permission. 226fc729afSOlivier Houchard * 236fc729afSOlivier Houchard * THIS SOFTWARE IS PROVIDED BY CAUSALITY LIMITED ``AS IS'' AND ANY EXPRESS 246fc729afSOlivier Houchard * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 256fc729afSOlivier Houchard * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 266fc729afSOlivier Houchard * DISCLAIMED. IN NO EVENT SHALL CAUSALITY LIMITED BE LIABLE FOR ANY DIRECT, 276fc729afSOlivier Houchard * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 286fc729afSOlivier Houchard * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 296fc729afSOlivier Houchard * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 306fc729afSOlivier Houchard * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 316fc729afSOlivier Houchard * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 326fc729afSOlivier Houchard * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 336fc729afSOlivier Houchard * SUCH DAMAGE. 346fc729afSOlivier Houchard * 356fc729afSOlivier Houchard * RiscBSD kernel project 366fc729afSOlivier Houchard * 376fc729afSOlivier Houchard * cpufunc.h 386fc729afSOlivier Houchard * 396fc729afSOlivier Houchard * Prototypes for cpu, mmu and tlb related functions. 406fc729afSOlivier Houchard * 416fc729afSOlivier Houchard * $FreeBSD$ 426fc729afSOlivier Houchard */ 436fc729afSOlivier Houchard 446fc729afSOlivier Houchard #ifndef _MACHINE_CPUFUNC_H_ 456fc729afSOlivier Houchard #define _MACHINE_CPUFUNC_H_ 466fc729afSOlivier Houchard 476fc729afSOlivier Houchard #ifdef _KERNEL 486fc729afSOlivier Houchard 496fc729afSOlivier Houchard #include <sys/types.h> 506fc729afSOlivier Houchard #include <machine/cpuconf.h> 514628245bSOlivier Houchard #include <machine/katelib.h> /* For in[bwl] and out[bwl] */ 526fc729afSOlivier Houchard 534628245bSOlivier Houchard static __inline void 544628245bSOlivier Houchard breakpoint(void) 554628245bSOlivier Houchard { 563488a2f7SOlivier Houchard __asm(".word 0xe7ffffff"); 574628245bSOlivier Houchard } 58be687a0dSOlivier Houchard 596fc729afSOlivier Houchard struct cpu_functions { 606fc729afSOlivier Houchard 616fc729afSOlivier Houchard /* CPU functions */ 626fc729afSOlivier Houchard 636fc729afSOlivier Houchard u_int (*cf_id) (void); 646fc729afSOlivier Houchard void (*cf_cpwait) (void); 656fc729afSOlivier Houchard 666fc729afSOlivier Houchard /* MMU functions */ 676fc729afSOlivier Houchard 686fc729afSOlivier Houchard u_int (*cf_control) (u_int bic, u_int eor); 696fc729afSOlivier Houchard void (*cf_domains) (u_int domains); 706fc729afSOlivier Houchard void (*cf_setttb) (u_int ttb); 716fc729afSOlivier Houchard u_int (*cf_faultstatus) (void); 726fc729afSOlivier Houchard u_int (*cf_faultaddress) (void); 736fc729afSOlivier Houchard 746fc729afSOlivier Houchard /* TLB functions */ 756fc729afSOlivier Houchard 766fc729afSOlivier Houchard void (*cf_tlb_flushID) (void); 776fc729afSOlivier Houchard void (*cf_tlb_flushID_SE) (u_int va); 786fc729afSOlivier Houchard void (*cf_tlb_flushI) (void); 796fc729afSOlivier Houchard void (*cf_tlb_flushI_SE) (u_int va); 806fc729afSOlivier Houchard void (*cf_tlb_flushD) (void); 816fc729afSOlivier Houchard void (*cf_tlb_flushD_SE) (u_int va); 826fc729afSOlivier Houchard 836fc729afSOlivier Houchard /* 846fc729afSOlivier Houchard * Cache operations: 856fc729afSOlivier Houchard * 866fc729afSOlivier Houchard * We define the following primitives: 876fc729afSOlivier Houchard * 886fc729afSOlivier Houchard * icache_sync_all Synchronize I-cache 896fc729afSOlivier Houchard * icache_sync_range Synchronize I-cache range 906fc729afSOlivier Houchard * 916fc729afSOlivier Houchard * dcache_wbinv_all Write-back and Invalidate D-cache 926fc729afSOlivier Houchard * dcache_wbinv_range Write-back and Invalidate D-cache range 936fc729afSOlivier Houchard * dcache_inv_range Invalidate D-cache range 946fc729afSOlivier Houchard * dcache_wb_range Write-back D-cache range 956fc729afSOlivier Houchard * 966fc729afSOlivier Houchard * idcache_wbinv_all Write-back and Invalidate D-cache, 976fc729afSOlivier Houchard * Invalidate I-cache 986fc729afSOlivier Houchard * idcache_wbinv_range Write-back and Invalidate D-cache, 996fc729afSOlivier Houchard * Invalidate I-cache range 1006fc729afSOlivier Houchard * 1016fc729afSOlivier Houchard * Note that the ARM term for "write-back" is "clean". We use 1026fc729afSOlivier Houchard * the term "write-back" since it's a more common way to describe 1036fc729afSOlivier Houchard * the operation. 1046fc729afSOlivier Houchard * 1056fc729afSOlivier Houchard * There are some rules that must be followed: 1066fc729afSOlivier Houchard * 1076fc729afSOlivier Houchard * I-cache Synch (all or range): 1086fc729afSOlivier Houchard * The goal is to synchronize the instruction stream, 1096fc729afSOlivier Houchard * so you may beed to write-back dirty D-cache blocks 1106fc729afSOlivier Houchard * first. If a range is requested, and you can't 1116fc729afSOlivier Houchard * synchronize just a range, you have to hit the whole 1126fc729afSOlivier Houchard * thing. 1136fc729afSOlivier Houchard * 1146fc729afSOlivier Houchard * D-cache Write-Back and Invalidate range: 1156fc729afSOlivier Houchard * If you can't WB-Inv a range, you must WB-Inv the 1166fc729afSOlivier Houchard * entire D-cache. 1176fc729afSOlivier Houchard * 1186fc729afSOlivier Houchard * D-cache Invalidate: 1196fc729afSOlivier Houchard * If you can't Inv the D-cache, you must Write-Back 1206fc729afSOlivier Houchard * and Invalidate. Code that uses this operation 1216fc729afSOlivier Houchard * MUST NOT assume that the D-cache will not be written 1226fc729afSOlivier Houchard * back to memory. 1236fc729afSOlivier Houchard * 1246fc729afSOlivier Houchard * D-cache Write-Back: 1256fc729afSOlivier Houchard * If you can't Write-back without doing an Inv, 1266fc729afSOlivier Houchard * that's fine. Then treat this as a WB-Inv. 1276fc729afSOlivier Houchard * Skipping the invalidate is merely an optimization. 1286fc729afSOlivier Houchard * 1296fc729afSOlivier Houchard * All operations: 1306fc729afSOlivier Houchard * Valid virtual addresses must be passed to each 1316fc729afSOlivier Houchard * cache operation. 1326fc729afSOlivier Houchard */ 1336fc729afSOlivier Houchard void (*cf_icache_sync_all) (void); 1346fc729afSOlivier Houchard void (*cf_icache_sync_range) (vm_offset_t, vm_size_t); 1356fc729afSOlivier Houchard 1366fc729afSOlivier Houchard void (*cf_dcache_wbinv_all) (void); 1376fc729afSOlivier Houchard void (*cf_dcache_wbinv_range) (vm_offset_t, vm_size_t); 1386fc729afSOlivier Houchard void (*cf_dcache_inv_range) (vm_offset_t, vm_size_t); 1396fc729afSOlivier Houchard void (*cf_dcache_wb_range) (vm_offset_t, vm_size_t); 1406fc729afSOlivier Houchard 1416fc729afSOlivier Houchard void (*cf_idcache_wbinv_all) (void); 1426fc729afSOlivier Houchard void (*cf_idcache_wbinv_range) (vm_offset_t, vm_size_t); 143425b5be3SOlivier Houchard void (*cf_l2cache_wbinv_all) (void); 144425b5be3SOlivier Houchard void (*cf_l2cache_wbinv_range) (vm_offset_t, vm_size_t); 145425b5be3SOlivier Houchard void (*cf_l2cache_inv_range) (vm_offset_t, vm_size_t); 146425b5be3SOlivier Houchard void (*cf_l2cache_wb_range) (vm_offset_t, vm_size_t); 1476fc729afSOlivier Houchard 1486fc729afSOlivier Houchard /* Other functions */ 1496fc729afSOlivier Houchard 1506fc729afSOlivier Houchard void (*cf_flush_prefetchbuf) (void); 1516fc729afSOlivier Houchard void (*cf_drain_writebuf) (void); 1526fc729afSOlivier Houchard void (*cf_flush_brnchtgt_C) (void); 1536fc729afSOlivier Houchard void (*cf_flush_brnchtgt_E) (u_int va); 1546fc729afSOlivier Houchard 1556fc729afSOlivier Houchard void (*cf_sleep) (int mode); 1566fc729afSOlivier Houchard 1576fc729afSOlivier Houchard /* Soft functions */ 1586fc729afSOlivier Houchard 1596fc729afSOlivier Houchard int (*cf_dataabt_fixup) (void *arg); 1606fc729afSOlivier Houchard int (*cf_prefetchabt_fixup) (void *arg); 1616fc729afSOlivier Houchard 1626fc729afSOlivier Houchard void (*cf_context_switch) (void); 1636fc729afSOlivier Houchard 1646fc729afSOlivier Houchard void (*cf_setup) (char *string); 1656fc729afSOlivier Houchard }; 1666fc729afSOlivier Houchard 1676fc729afSOlivier Houchard extern struct cpu_functions cpufuncs; 1686fc729afSOlivier Houchard extern u_int cputype; 1696fc729afSOlivier Houchard 1706fc729afSOlivier Houchard #define cpu_id() cpufuncs.cf_id() 1716fc729afSOlivier Houchard #define cpu_cpwait() cpufuncs.cf_cpwait() 1726fc729afSOlivier Houchard 1736fc729afSOlivier Houchard #define cpu_control(c, e) cpufuncs.cf_control(c, e) 1746fc729afSOlivier Houchard #define cpu_domains(d) cpufuncs.cf_domains(d) 1756fc729afSOlivier Houchard #define cpu_setttb(t) cpufuncs.cf_setttb(t) 1766fc729afSOlivier Houchard #define cpu_faultstatus() cpufuncs.cf_faultstatus() 1776fc729afSOlivier Houchard #define cpu_faultaddress() cpufuncs.cf_faultaddress() 1786fc729afSOlivier Houchard 1796fc729afSOlivier Houchard #define cpu_tlb_flushID() cpufuncs.cf_tlb_flushID() 1806fc729afSOlivier Houchard #define cpu_tlb_flushID_SE(e) cpufuncs.cf_tlb_flushID_SE(e) 1816fc729afSOlivier Houchard #define cpu_tlb_flushI() cpufuncs.cf_tlb_flushI() 1826fc729afSOlivier Houchard #define cpu_tlb_flushI_SE(e) cpufuncs.cf_tlb_flushI_SE(e) 1836fc729afSOlivier Houchard #define cpu_tlb_flushD() cpufuncs.cf_tlb_flushD() 1846fc729afSOlivier Houchard #define cpu_tlb_flushD_SE(e) cpufuncs.cf_tlb_flushD_SE(e) 1856fc729afSOlivier Houchard 1866fc729afSOlivier Houchard #define cpu_icache_sync_all() cpufuncs.cf_icache_sync_all() 1876fc729afSOlivier Houchard #define cpu_icache_sync_range(a, s) cpufuncs.cf_icache_sync_range((a), (s)) 1886fc729afSOlivier Houchard 1896fc729afSOlivier Houchard #define cpu_dcache_wbinv_all() cpufuncs.cf_dcache_wbinv_all() 1906fc729afSOlivier Houchard #define cpu_dcache_wbinv_range(a, s) cpufuncs.cf_dcache_wbinv_range((a), (s)) 1916fc729afSOlivier Houchard #define cpu_dcache_inv_range(a, s) cpufuncs.cf_dcache_inv_range((a), (s)) 1926fc729afSOlivier Houchard #define cpu_dcache_wb_range(a, s) cpufuncs.cf_dcache_wb_range((a), (s)) 1936fc729afSOlivier Houchard 1946fc729afSOlivier Houchard #define cpu_idcache_wbinv_all() cpufuncs.cf_idcache_wbinv_all() 1956fc729afSOlivier Houchard #define cpu_idcache_wbinv_range(a, s) cpufuncs.cf_idcache_wbinv_range((a), (s)) 196425b5be3SOlivier Houchard #define cpu_l2cache_wbinv_all() cpufuncs.cf_l2cache_wbinv_all() 197425b5be3SOlivier Houchard #define cpu_l2cache_wb_range(a, s) cpufuncs.cf_l2cache_wb_range((a), (s)) 198425b5be3SOlivier Houchard #define cpu_l2cache_inv_range(a, s) cpufuncs.cf_l2cache_inv_range((a), (s)) 199425b5be3SOlivier Houchard #define cpu_l2cache_wbinv_range(a, s) cpufuncs.cf_l2cache_wbinv_range((a), (s)) 2006fc729afSOlivier Houchard 2016fc729afSOlivier Houchard #define cpu_flush_prefetchbuf() cpufuncs.cf_flush_prefetchbuf() 2026fc729afSOlivier Houchard #define cpu_drain_writebuf() cpufuncs.cf_drain_writebuf() 2036fc729afSOlivier Houchard #define cpu_flush_brnchtgt_C() cpufuncs.cf_flush_brnchtgt_C() 2046fc729afSOlivier Houchard #define cpu_flush_brnchtgt_E(e) cpufuncs.cf_flush_brnchtgt_E(e) 2056fc729afSOlivier Houchard 2066fc729afSOlivier Houchard #define cpu_sleep(m) cpufuncs.cf_sleep(m) 2076fc729afSOlivier Houchard 2086fc729afSOlivier Houchard #define cpu_dataabt_fixup(a) cpufuncs.cf_dataabt_fixup(a) 2096fc729afSOlivier Houchard #define cpu_prefetchabt_fixup(a) cpufuncs.cf_prefetchabt_fixup(a) 2106fc729afSOlivier Houchard #define ABORT_FIXUP_OK 0 /* fixup succeeded */ 2116fc729afSOlivier Houchard #define ABORT_FIXUP_FAILED 1 /* fixup failed */ 2126fc729afSOlivier Houchard #define ABORT_FIXUP_RETURN 2 /* abort handler should return */ 2136fc729afSOlivier Houchard 2146fc729afSOlivier Houchard #define cpu_setup(a) cpufuncs.cf_setup(a) 2156fc729afSOlivier Houchard 2166fc729afSOlivier Houchard int set_cpufuncs (void); 2176fc729afSOlivier Houchard #define ARCHITECTURE_NOT_PRESENT 1 /* known but not configured */ 2186fc729afSOlivier Houchard #define ARCHITECTURE_NOT_SUPPORTED 2 /* not known */ 2196fc729afSOlivier Houchard 2206fc729afSOlivier Houchard void cpufunc_nullop (void); 2216fc729afSOlivier Houchard int cpufunc_null_fixup (void *); 2226fc729afSOlivier Houchard int early_abort_fixup (void *); 2236fc729afSOlivier Houchard int late_abort_fixup (void *); 2246fc729afSOlivier Houchard u_int cpufunc_id (void); 2256fc729afSOlivier Houchard u_int cpufunc_control (u_int clear, u_int bic); 2266fc729afSOlivier Houchard void cpufunc_domains (u_int domains); 2276fc729afSOlivier Houchard u_int cpufunc_faultstatus (void); 2286fc729afSOlivier Houchard u_int cpufunc_faultaddress (void); 2296fc729afSOlivier Houchard 2306fc729afSOlivier Houchard #ifdef CPU_ARM3 2316fc729afSOlivier Houchard u_int arm3_control (u_int clear, u_int bic); 2326fc729afSOlivier Houchard void arm3_cache_flush (void); 2336fc729afSOlivier Houchard #endif /* CPU_ARM3 */ 2346fc729afSOlivier Houchard 2356fc729afSOlivier Houchard #if defined(CPU_ARM6) || defined(CPU_ARM7) 2366fc729afSOlivier Houchard void arm67_setttb (u_int ttb); 2376fc729afSOlivier Houchard void arm67_tlb_flush (void); 2386fc729afSOlivier Houchard void arm67_tlb_purge (u_int va); 2396fc729afSOlivier Houchard void arm67_cache_flush (void); 2406fc729afSOlivier Houchard void arm67_context_switch (void); 2416fc729afSOlivier Houchard #endif /* CPU_ARM6 || CPU_ARM7 */ 2426fc729afSOlivier Houchard 2436fc729afSOlivier Houchard #ifdef CPU_ARM6 2446fc729afSOlivier Houchard void arm6_setup (char *string); 2456fc729afSOlivier Houchard #endif /* CPU_ARM6 */ 2466fc729afSOlivier Houchard 2476fc729afSOlivier Houchard #ifdef CPU_ARM7 2486fc729afSOlivier Houchard void arm7_setup (char *string); 2496fc729afSOlivier Houchard #endif /* CPU_ARM7 */ 2506fc729afSOlivier Houchard 2516fc729afSOlivier Houchard #ifdef CPU_ARM7TDMI 2526fc729afSOlivier Houchard int arm7_dataabt_fixup (void *arg); 2536fc729afSOlivier Houchard void arm7tdmi_setup (char *string); 2546fc729afSOlivier Houchard void arm7tdmi_setttb (u_int ttb); 2556fc729afSOlivier Houchard void arm7tdmi_tlb_flushID (void); 2566fc729afSOlivier Houchard void arm7tdmi_tlb_flushID_SE (u_int va); 2576fc729afSOlivier Houchard void arm7tdmi_cache_flushID (void); 2586fc729afSOlivier Houchard void arm7tdmi_context_switch (void); 2596fc729afSOlivier Houchard #endif /* CPU_ARM7TDMI */ 2606fc729afSOlivier Houchard 2616fc729afSOlivier Houchard #ifdef CPU_ARM8 2626fc729afSOlivier Houchard void arm8_setttb (u_int ttb); 2636fc729afSOlivier Houchard void arm8_tlb_flushID (void); 2646fc729afSOlivier Houchard void arm8_tlb_flushID_SE (u_int va); 2656fc729afSOlivier Houchard void arm8_cache_flushID (void); 2666fc729afSOlivier Houchard void arm8_cache_flushID_E (u_int entry); 2676fc729afSOlivier Houchard void arm8_cache_cleanID (void); 2686fc729afSOlivier Houchard void arm8_cache_cleanID_E (u_int entry); 2696fc729afSOlivier Houchard void arm8_cache_purgeID (void); 2706fc729afSOlivier Houchard void arm8_cache_purgeID_E (u_int entry); 2716fc729afSOlivier Houchard 2726fc729afSOlivier Houchard void arm8_cache_syncI (void); 2736fc729afSOlivier Houchard void arm8_cache_cleanID_rng (vm_offset_t start, vm_size_t end); 2746fc729afSOlivier Houchard void arm8_cache_cleanD_rng (vm_offset_t start, vm_size_t end); 2756fc729afSOlivier Houchard void arm8_cache_purgeID_rng (vm_offset_t start, vm_size_t end); 2766fc729afSOlivier Houchard void arm8_cache_purgeD_rng (vm_offset_t start, vm_size_t end); 2776fc729afSOlivier Houchard void arm8_cache_syncI_rng (vm_offset_t start, vm_size_t end); 2786fc729afSOlivier Houchard 2796fc729afSOlivier Houchard void arm8_context_switch (void); 2806fc729afSOlivier Houchard 2816fc729afSOlivier Houchard void arm8_setup (char *string); 2826fc729afSOlivier Houchard 2836fc729afSOlivier Houchard u_int arm8_clock_config (u_int, u_int); 2846fc729afSOlivier Houchard #endif 2856fc729afSOlivier Houchard 2866fc729afSOlivier Houchard #ifdef CPU_SA110 2876fc729afSOlivier Houchard void sa110_setup (char *string); 2886fc729afSOlivier Houchard void sa110_context_switch (void); 2896fc729afSOlivier Houchard #endif /* CPU_SA110 */ 2906fc729afSOlivier Houchard 2916fc729afSOlivier Houchard #if defined(CPU_SA1100) || defined(CPU_SA1110) 2926fc729afSOlivier Houchard void sa11x0_drain_readbuf (void); 2936fc729afSOlivier Houchard 2946fc729afSOlivier Houchard void sa11x0_context_switch (void); 2956fc729afSOlivier Houchard void sa11x0_cpu_sleep (int mode); 2966fc729afSOlivier Houchard 2976fc729afSOlivier Houchard void sa11x0_setup (char *string); 2986fc729afSOlivier Houchard #endif 2996fc729afSOlivier Houchard 3006fc729afSOlivier Houchard #if defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110) 3016fc729afSOlivier Houchard void sa1_setttb (u_int ttb); 3026fc729afSOlivier Houchard 3036fc729afSOlivier Houchard void sa1_tlb_flushID_SE (u_int va); 3046fc729afSOlivier Houchard 3056fc729afSOlivier Houchard void sa1_cache_flushID (void); 3066fc729afSOlivier Houchard void sa1_cache_flushI (void); 3076fc729afSOlivier Houchard void sa1_cache_flushD (void); 3086fc729afSOlivier Houchard void sa1_cache_flushD_SE (u_int entry); 3096fc729afSOlivier Houchard 3106fc729afSOlivier Houchard void sa1_cache_cleanID (void); 3116fc729afSOlivier Houchard void sa1_cache_cleanD (void); 3126fc729afSOlivier Houchard void sa1_cache_cleanD_E (u_int entry); 3136fc729afSOlivier Houchard 3146fc729afSOlivier Houchard void sa1_cache_purgeID (void); 3156fc729afSOlivier Houchard void sa1_cache_purgeID_E (u_int entry); 3166fc729afSOlivier Houchard void sa1_cache_purgeD (void); 3176fc729afSOlivier Houchard void sa1_cache_purgeD_E (u_int entry); 3186fc729afSOlivier Houchard 3196fc729afSOlivier Houchard void sa1_cache_syncI (void); 3206fc729afSOlivier Houchard void sa1_cache_cleanID_rng (vm_offset_t start, vm_size_t end); 3216fc729afSOlivier Houchard void sa1_cache_cleanD_rng (vm_offset_t start, vm_size_t end); 3226fc729afSOlivier Houchard void sa1_cache_purgeID_rng (vm_offset_t start, vm_size_t end); 3236fc729afSOlivier Houchard void sa1_cache_purgeD_rng (vm_offset_t start, vm_size_t end); 3246fc729afSOlivier Houchard void sa1_cache_syncI_rng (vm_offset_t start, vm_size_t end); 3256fc729afSOlivier Houchard 3266fc729afSOlivier Houchard #endif 3276fc729afSOlivier Houchard 3286fc729afSOlivier Houchard #ifdef CPU_ARM9 3296fc729afSOlivier Houchard void arm9_setttb (u_int); 3306fc729afSOlivier Houchard 3316fc729afSOlivier Houchard void arm9_tlb_flushID_SE (u_int va); 3326fc729afSOlivier Houchard 3334eaa43e6SKevin Lo void arm9_icache_sync_all (void); 3344eaa43e6SKevin Lo void arm9_icache_sync_range (vm_offset_t, vm_size_t); 3356fc729afSOlivier Houchard 3364eaa43e6SKevin Lo void arm9_dcache_wbinv_all (void); 3374eaa43e6SKevin Lo void arm9_dcache_wbinv_range (vm_offset_t, vm_size_t); 3384eaa43e6SKevin Lo void arm9_dcache_inv_range (vm_offset_t, vm_size_t); 3394eaa43e6SKevin Lo void arm9_dcache_wb_range (vm_offset_t, vm_size_t); 3406fc729afSOlivier Houchard 3414eaa43e6SKevin Lo void arm9_idcache_wbinv_all (void); 3424eaa43e6SKevin Lo void arm9_idcache_wbinv_range (vm_offset_t, vm_size_t); 3436fc729afSOlivier Houchard 3446fc729afSOlivier Houchard void arm9_context_switch (void); 3456fc729afSOlivier Houchard 3466fc729afSOlivier Houchard void arm9_setup (char *string); 347094df973SOlivier Houchard 348094df973SOlivier Houchard extern unsigned arm9_dcache_sets_max; 349094df973SOlivier Houchard extern unsigned arm9_dcache_sets_inc; 350094df973SOlivier Houchard extern unsigned arm9_dcache_index_max; 351094df973SOlivier Houchard extern unsigned arm9_dcache_index_inc; 3526fc729afSOlivier Houchard #endif 3536fc729afSOlivier Houchard 35463b25978SWarner Losh #if defined(CPU_ARM9E) || defined(CPU_ARM10) 3556fc729afSOlivier Houchard void arm10_setttb (u_int); 3566fc729afSOlivier Houchard 3576fc729afSOlivier Houchard void arm10_tlb_flushID_SE (u_int); 3586fc729afSOlivier Houchard void arm10_tlb_flushI_SE (u_int); 3596fc729afSOlivier Houchard 3606fc729afSOlivier Houchard void arm10_icache_sync_all (void); 3616fc729afSOlivier Houchard void arm10_icache_sync_range (vm_offset_t, vm_size_t); 3626fc729afSOlivier Houchard 3636fc729afSOlivier Houchard void arm10_dcache_wbinv_all (void); 3646fc729afSOlivier Houchard void arm10_dcache_wbinv_range (vm_offset_t, vm_size_t); 3656fc729afSOlivier Houchard void arm10_dcache_inv_range (vm_offset_t, vm_size_t); 3666fc729afSOlivier Houchard void arm10_dcache_wb_range (vm_offset_t, vm_size_t); 3676fc729afSOlivier Houchard 3686fc729afSOlivier Houchard void arm10_idcache_wbinv_all (void); 3696fc729afSOlivier Houchard void arm10_idcache_wbinv_range (vm_offset_t, vm_size_t); 3706fc729afSOlivier Houchard 3716fc729afSOlivier Houchard void arm10_context_switch (void); 3726fc729afSOlivier Houchard 3736fc729afSOlivier Houchard void arm10_setup (char *string); 3746fc729afSOlivier Houchard 3756fc729afSOlivier Houchard extern unsigned arm10_dcache_sets_max; 3766fc729afSOlivier Houchard extern unsigned arm10_dcache_sets_inc; 3776fc729afSOlivier Houchard extern unsigned arm10_dcache_index_max; 3786fc729afSOlivier Houchard extern unsigned arm10_dcache_index_inc; 3796fc729afSOlivier Houchard #endif 3806fc729afSOlivier Houchard 38163b25978SWarner Losh #ifdef CPU_ARM11 38263b25978SWarner Losh void arm11_setttb (u_int); 38363b25978SWarner Losh 38463b25978SWarner Losh void arm11_tlb_flushID_SE (u_int); 38563b25978SWarner Losh void arm11_tlb_flushI_SE (u_int); 38663b25978SWarner Losh 38763b25978SWarner Losh void arm11_context_switch (void); 38863b25978SWarner Losh 38963b25978SWarner Losh void arm11_setup (char *string); 39063b25978SWarner Losh void arm11_tlb_flushID (void); 39163b25978SWarner Losh void arm11_tlb_flushI (void); 39263b25978SWarner Losh void arm11_tlb_flushD (void); 39363b25978SWarner Losh void arm11_tlb_flushD_SE (u_int va); 39463b25978SWarner Losh 39563b25978SWarner Losh void arm11_drain_writebuf (void); 39663b25978SWarner Losh #endif 39763b25978SWarner Losh 39863b25978SWarner Losh #if defined(CPU_ARM9E) || defined (CPU_ARM10) 39963b25978SWarner Losh void armv5_ec_setttb(u_int); 40063b25978SWarner Losh 40163b25978SWarner Losh void armv5_ec_icache_sync_all(void); 40263b25978SWarner Losh void armv5_ec_icache_sync_range(vm_offset_t, vm_size_t); 40363b25978SWarner Losh 40463b25978SWarner Losh void armv5_ec_dcache_wbinv_all(void); 40563b25978SWarner Losh void armv5_ec_dcache_wbinv_range(vm_offset_t, vm_size_t); 40663b25978SWarner Losh void armv5_ec_dcache_inv_range(vm_offset_t, vm_size_t); 40763b25978SWarner Losh void armv5_ec_dcache_wb_range(vm_offset_t, vm_size_t); 40863b25978SWarner Losh 40963b25978SWarner Losh void armv5_ec_idcache_wbinv_all(void); 41063b25978SWarner Losh void armv5_ec_idcache_wbinv_range(vm_offset_t, vm_size_t); 41163b25978SWarner Losh #endif 41263b25978SWarner Losh 41363b25978SWarner Losh #if defined (CPU_ARM10) || defined (CPU_ARM11) 41463b25978SWarner Losh void armv5_setttb(u_int); 41563b25978SWarner Losh 41663b25978SWarner Losh void armv5_icache_sync_all(void); 41763b25978SWarner Losh void armv5_icache_sync_range(vm_offset_t, vm_size_t); 41863b25978SWarner Losh 41963b25978SWarner Losh void armv5_dcache_wbinv_all(void); 42063b25978SWarner Losh void armv5_dcache_wbinv_range(vm_offset_t, vm_size_t); 42163b25978SWarner Losh void armv5_dcache_inv_range(vm_offset_t, vm_size_t); 42263b25978SWarner Losh void armv5_dcache_wb_range(vm_offset_t, vm_size_t); 42363b25978SWarner Losh 42463b25978SWarner Losh void armv5_idcache_wbinv_all(void); 42563b25978SWarner Losh void armv5_idcache_wbinv_range(vm_offset_t, vm_size_t); 42663b25978SWarner Losh 42763b25978SWarner Losh extern unsigned armv5_dcache_sets_max; 42863b25978SWarner Losh extern unsigned armv5_dcache_sets_inc; 42963b25978SWarner Losh extern unsigned armv5_dcache_index_max; 43063b25978SWarner Losh extern unsigned armv5_dcache_index_inc; 43163b25978SWarner Losh #endif 43263b25978SWarner Losh 43363b25978SWarner Losh #if defined(CPU_ARM9) || defined(CPU_ARM9E) || defined(CPU_ARM10) || \ 43463b25978SWarner Losh defined(CPU_SA110) || defined(CPU_SA1100) || defined(CPU_SA1110) || \ 4356fc729afSOlivier Houchard defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \ 43611d1528cSOlivier Houchard defined(CPU_XSCALE_PXA2X0) || defined(CPU_XSCALE_IXP425) || \ 437676b1fbdSOlivier Houchard defined(CPU_XSCALE_80219) || defined(CPU_XSCALE_81342) 4386fc729afSOlivier Houchard 4396fc729afSOlivier Houchard void armv4_tlb_flushID (void); 4406fc729afSOlivier Houchard void armv4_tlb_flushI (void); 4416fc729afSOlivier Houchard void armv4_tlb_flushD (void); 4426fc729afSOlivier Houchard void armv4_tlb_flushD_SE (u_int va); 4436fc729afSOlivier Houchard 4446fc729afSOlivier Houchard void armv4_drain_writebuf (void); 4456fc729afSOlivier Houchard #endif 4466fc729afSOlivier Houchard 4476fc729afSOlivier Houchard #if defined(CPU_IXP12X0) 4486fc729afSOlivier Houchard void ixp12x0_drain_readbuf (void); 4496fc729afSOlivier Houchard void ixp12x0_context_switch (void); 4506fc729afSOlivier Houchard void ixp12x0_setup (char *string); 4516fc729afSOlivier Houchard #endif 4526fc729afSOlivier Houchard 4536fc729afSOlivier Houchard #if defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \ 45411d1528cSOlivier Houchard defined(CPU_XSCALE_PXA2X0) || defined(CPU_XSCALE_IXP425) || \ 455676b1fbdSOlivier Houchard defined(CPU_XSCALE_80219) || defined(CPU_XSCALE_81342) 4566fc729afSOlivier Houchard void xscale_cpwait (void); 4576fc729afSOlivier Houchard 4586fc729afSOlivier Houchard void xscale_cpu_sleep (int mode); 4596fc729afSOlivier Houchard 4606fc729afSOlivier Houchard u_int xscale_control (u_int clear, u_int bic); 4616fc729afSOlivier Houchard 4626fc729afSOlivier Houchard void xscale_setttb (u_int ttb); 4636fc729afSOlivier Houchard 4646fc729afSOlivier Houchard void xscale_tlb_flushID_SE (u_int va); 4656fc729afSOlivier Houchard 4666fc729afSOlivier Houchard void xscale_cache_flushID (void); 4676fc729afSOlivier Houchard void xscale_cache_flushI (void); 4686fc729afSOlivier Houchard void xscale_cache_flushD (void); 4696fc729afSOlivier Houchard void xscale_cache_flushD_SE (u_int entry); 4706fc729afSOlivier Houchard 4716fc729afSOlivier Houchard void xscale_cache_cleanID (void); 4726fc729afSOlivier Houchard void xscale_cache_cleanD (void); 4736fc729afSOlivier Houchard void xscale_cache_cleanD_E (u_int entry); 4746fc729afSOlivier Houchard 4756fc729afSOlivier Houchard void xscale_cache_clean_minidata (void); 4766fc729afSOlivier Houchard 4776fc729afSOlivier Houchard void xscale_cache_purgeID (void); 4786fc729afSOlivier Houchard void xscale_cache_purgeID_E (u_int entry); 4796fc729afSOlivier Houchard void xscale_cache_purgeD (void); 4806fc729afSOlivier Houchard void xscale_cache_purgeD_E (u_int entry); 4816fc729afSOlivier Houchard 4826fc729afSOlivier Houchard void xscale_cache_syncI (void); 4836fc729afSOlivier Houchard void xscale_cache_cleanID_rng (vm_offset_t start, vm_size_t end); 4846fc729afSOlivier Houchard void xscale_cache_cleanD_rng (vm_offset_t start, vm_size_t end); 4856fc729afSOlivier Houchard void xscale_cache_purgeID_rng (vm_offset_t start, vm_size_t end); 4866fc729afSOlivier Houchard void xscale_cache_purgeD_rng (vm_offset_t start, vm_size_t end); 4876fc729afSOlivier Houchard void xscale_cache_syncI_rng (vm_offset_t start, vm_size_t end); 4886fc729afSOlivier Houchard void xscale_cache_flushD_rng (vm_offset_t start, vm_size_t end); 4896fc729afSOlivier Houchard 4906fc729afSOlivier Houchard void xscale_context_switch (void); 4916fc729afSOlivier Houchard 4926fc729afSOlivier Houchard void xscale_setup (char *string); 49311d1528cSOlivier Houchard #endif /* CPU_XSCALE_80200 || CPU_XSCALE_80321 || CPU_XSCALE_PXA2X0 || CPU_XSCALE_IXP425 49411d1528cSOlivier Houchard CPU_XSCALE_80219 */ 4956fc729afSOlivier Houchard 496676b1fbdSOlivier Houchard #ifdef CPU_XSCALE_81342 497676b1fbdSOlivier Houchard 498425b5be3SOlivier Houchard void xscalec3_l2cache_purge (void); 499425b5be3SOlivier Houchard void xscalec3_cache_purgeID (void); 500425b5be3SOlivier Houchard void xscalec3_cache_purgeD (void); 501676b1fbdSOlivier Houchard void xscalec3_cache_cleanID (void); 502676b1fbdSOlivier Houchard void xscalec3_cache_cleanD (void); 503676b1fbdSOlivier Houchard void xscalec3_cache_syncI (void); 504425b5be3SOlivier Houchard 505676b1fbdSOlivier Houchard void xscalec3_cache_purgeID_rng (vm_offset_t start, vm_size_t end); 506676b1fbdSOlivier Houchard void xscalec3_cache_purgeD_rng (vm_offset_t start, vm_size_t end); 507425b5be3SOlivier Houchard void xscalec3_cache_cleanID_rng (vm_offset_t start, vm_size_t end); 508425b5be3SOlivier Houchard void xscalec3_cache_cleanD_rng (vm_offset_t start, vm_size_t end); 509425b5be3SOlivier Houchard void xscalec3_cache_syncI_rng (vm_offset_t start, vm_size_t end); 510425b5be3SOlivier Houchard 511425b5be3SOlivier Houchard void xscalec3_l2cache_flush_rng (vm_offset_t, vm_size_t); 512425b5be3SOlivier Houchard void xscalec3_l2cache_clean_rng (vm_offset_t start, vm_size_t end); 513425b5be3SOlivier Houchard void xscalec3_l2cache_purge_rng (vm_offset_t start, vm_size_t end); 514676b1fbdSOlivier Houchard 515676b1fbdSOlivier Houchard 516676b1fbdSOlivier Houchard void xscalec3_setttb (u_int ttb); 517676b1fbdSOlivier Houchard void xscalec3_context_switch (void); 518676b1fbdSOlivier Houchard 519676b1fbdSOlivier Houchard #endif /* CPU_XSCALE_81342 */ 520676b1fbdSOlivier Houchard 5216fc729afSOlivier Houchard #define tlb_flush cpu_tlb_flushID 5226fc729afSOlivier Houchard #define setttb cpu_setttb 5236fc729afSOlivier Houchard #define drain_writebuf cpu_drain_writebuf 5246fc729afSOlivier Houchard 5256fc729afSOlivier Houchard /* 5266fc729afSOlivier Houchard * Macros for manipulating CPU interrupts 5276fc729afSOlivier Houchard */ 5286fc729afSOlivier Houchard static __inline u_int32_t __set_cpsr_c(u_int bic, u_int eor) __attribute__((__unused__)); 5296fc729afSOlivier Houchard 5306fc729afSOlivier Houchard static __inline u_int32_t 5316fc729afSOlivier Houchard __set_cpsr_c(u_int bic, u_int eor) 5326fc729afSOlivier Houchard { 5336fc729afSOlivier Houchard u_int32_t tmp, ret; 5346fc729afSOlivier Houchard 5356fc729afSOlivier Houchard __asm __volatile( 5366fc729afSOlivier Houchard "mrs %0, cpsr\n" /* Get the CPSR */ 5376fc729afSOlivier Houchard "bic %1, %0, %2\n" /* Clear bits */ 5386fc729afSOlivier Houchard "eor %1, %1, %3\n" /* XOR bits */ 5396fc729afSOlivier Houchard "msr cpsr_c, %1\n" /* Set the control field of CPSR */ 5406fc729afSOlivier Houchard : "=&r" (ret), "=&r" (tmp) 54124e01b0cSOlivier Houchard : "r" (bic), "r" (eor) : "memory"); 5426fc729afSOlivier Houchard 5436fc729afSOlivier Houchard return ret; 5446fc729afSOlivier Houchard } 5456fc729afSOlivier Houchard 5466fc729afSOlivier Houchard #define disable_interrupts(mask) \ 5476fc729afSOlivier Houchard (__set_cpsr_c((mask) & (I32_bit | F32_bit), \ 5486fc729afSOlivier Houchard (mask) & (I32_bit | F32_bit))) 5496fc729afSOlivier Houchard 5506fc729afSOlivier Houchard #define enable_interrupts(mask) \ 55127b45ae8SOlivier Houchard (__set_cpsr_c((mask) & (I32_bit | F32_bit), 0)) 5526fc729afSOlivier Houchard 5536fc729afSOlivier Houchard #define restore_interrupts(old_cpsr) \ 5546fc729afSOlivier Houchard (__set_cpsr_c((I32_bit | F32_bit), (old_cpsr) & (I32_bit | F32_bit))) 5556fc729afSOlivier Houchard 55624e01b0cSOlivier Houchard #define intr_disable() \ 55724e01b0cSOlivier Houchard disable_interrupts(I32_bit | F32_bit) 55824e01b0cSOlivier Houchard #define intr_restore(s) \ 55924e01b0cSOlivier Houchard restore_interrupts(s) 5606fc729afSOlivier Houchard /* Functions to manipulate the CPSR. */ 5616fc729afSOlivier Houchard u_int SetCPSR(u_int bic, u_int eor); 5626fc729afSOlivier Houchard u_int GetCPSR(void); 5636fc729afSOlivier Houchard 5646fc729afSOlivier Houchard /* 5656fc729afSOlivier Houchard * Functions to manipulate cpu r13 5666fc729afSOlivier Houchard * (in arm/arm32/setstack.S) 5676fc729afSOlivier Houchard */ 5686fc729afSOlivier Houchard 5694eaa43e6SKevin Lo void set_stackptr (u_int mode, u_int address); 5704eaa43e6SKevin Lo u_int get_stackptr (u_int mode); 5716fc729afSOlivier Houchard 5726fc729afSOlivier Houchard /* 5736fc729afSOlivier Houchard * Miscellany 5746fc729afSOlivier Houchard */ 5756fc729afSOlivier Houchard 5764eaa43e6SKevin Lo int get_pc_str_offset (void); 5776fc729afSOlivier Houchard 5786fc729afSOlivier Houchard /* 5796fc729afSOlivier Houchard * CPU functions from locore.S 5806fc729afSOlivier Houchard */ 5816fc729afSOlivier Houchard 5824eaa43e6SKevin Lo void cpu_reset (void) __attribute__((__noreturn__)); 5836fc729afSOlivier Houchard 5846fc729afSOlivier Houchard /* 5856fc729afSOlivier Houchard * Cache info variables. 5866fc729afSOlivier Houchard */ 5876fc729afSOlivier Houchard 5886fc729afSOlivier Houchard /* PRIMARY CACHE VARIABLES */ 5896fc729afSOlivier Houchard extern int arm_picache_size; 5906fc729afSOlivier Houchard extern int arm_picache_line_size; 5916fc729afSOlivier Houchard extern int arm_picache_ways; 5926fc729afSOlivier Houchard 5936fc729afSOlivier Houchard extern int arm_pdcache_size; /* and unified */ 5946fc729afSOlivier Houchard extern int arm_pdcache_line_size; 5956fc729afSOlivier Houchard extern int arm_pdcache_ways; 5966fc729afSOlivier Houchard 5976fc729afSOlivier Houchard extern int arm_pcache_type; 5986fc729afSOlivier Houchard extern int arm_pcache_unified; 5996fc729afSOlivier Houchard 6006fc729afSOlivier Houchard extern int arm_dcache_align; 6016fc729afSOlivier Houchard extern int arm_dcache_align_mask; 6026fc729afSOlivier Houchard 6036fc729afSOlivier Houchard #endif /* _KERNEL */ 6046fc729afSOlivier Houchard #endif /* _MACHINE_CPUFUNC_H_ */ 6056fc729afSOlivier Houchard 6066fc729afSOlivier Houchard /* End of cpufunc.h */ 607