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 * 1074b7fcd31SIan Lepore * ID-cache Invalidate All: 1084b7fcd31SIan Lepore * Unlike other functions, this one must never write back. 1094b7fcd31SIan Lepore * It is used to intialize the MMU when it is in an unknown 1104b7fcd31SIan Lepore * state (such as when it may have lines tagged as valid 1114b7fcd31SIan Lepore * that belong to a previous set of mappings). 1124b7fcd31SIan Lepore * 1136fc729afSOlivier Houchard * I-cache Synch (all or range): 1146fc729afSOlivier Houchard * The goal is to synchronize the instruction stream, 1156fc729afSOlivier Houchard * so you may beed to write-back dirty D-cache blocks 1166fc729afSOlivier Houchard * first. If a range is requested, and you can't 1176fc729afSOlivier Houchard * synchronize just a range, you have to hit the whole 1186fc729afSOlivier Houchard * thing. 1196fc729afSOlivier Houchard * 1206fc729afSOlivier Houchard * D-cache Write-Back and Invalidate range: 1216fc729afSOlivier Houchard * If you can't WB-Inv a range, you must WB-Inv the 1226fc729afSOlivier Houchard * entire D-cache. 1236fc729afSOlivier Houchard * 1246fc729afSOlivier Houchard * D-cache Invalidate: 1256fc729afSOlivier Houchard * If you can't Inv the D-cache, you must Write-Back 1266fc729afSOlivier Houchard * and Invalidate. Code that uses this operation 1276fc729afSOlivier Houchard * MUST NOT assume that the D-cache will not be written 1286fc729afSOlivier Houchard * back to memory. 1296fc729afSOlivier Houchard * 1306fc729afSOlivier Houchard * D-cache Write-Back: 1316fc729afSOlivier Houchard * If you can't Write-back without doing an Inv, 1326fc729afSOlivier Houchard * that's fine. Then treat this as a WB-Inv. 1336fc729afSOlivier Houchard * Skipping the invalidate is merely an optimization. 1346fc729afSOlivier Houchard * 1356fc729afSOlivier Houchard * All operations: 1366fc729afSOlivier Houchard * Valid virtual addresses must be passed to each 1376fc729afSOlivier Houchard * cache operation. 1386fc729afSOlivier Houchard */ 1396fc729afSOlivier Houchard void (*cf_icache_sync_all) (void); 1406fc729afSOlivier Houchard void (*cf_icache_sync_range) (vm_offset_t, vm_size_t); 1416fc729afSOlivier Houchard 1426fc729afSOlivier Houchard void (*cf_dcache_wbinv_all) (void); 1436fc729afSOlivier Houchard void (*cf_dcache_wbinv_range) (vm_offset_t, vm_size_t); 1446fc729afSOlivier Houchard void (*cf_dcache_inv_range) (vm_offset_t, vm_size_t); 1456fc729afSOlivier Houchard void (*cf_dcache_wb_range) (vm_offset_t, vm_size_t); 1466fc729afSOlivier Houchard 1474b7fcd31SIan Lepore void (*cf_idcache_inv_all) (void); 1486fc729afSOlivier Houchard void (*cf_idcache_wbinv_all) (void); 1496fc729afSOlivier Houchard void (*cf_idcache_wbinv_range) (vm_offset_t, vm_size_t); 150425b5be3SOlivier Houchard void (*cf_l2cache_wbinv_all) (void); 151425b5be3SOlivier Houchard void (*cf_l2cache_wbinv_range) (vm_offset_t, vm_size_t); 152425b5be3SOlivier Houchard void (*cf_l2cache_inv_range) (vm_offset_t, vm_size_t); 153425b5be3SOlivier Houchard void (*cf_l2cache_wb_range) (vm_offset_t, vm_size_t); 154b07d0cbcSIan Lepore void (*cf_l2cache_drain_writebuf) (void); 1556fc729afSOlivier Houchard 1566fc729afSOlivier Houchard /* Other functions */ 1576fc729afSOlivier Houchard 1586fc729afSOlivier Houchard void (*cf_flush_prefetchbuf) (void); 1596fc729afSOlivier Houchard void (*cf_drain_writebuf) (void); 1606fc729afSOlivier Houchard void (*cf_flush_brnchtgt_C) (void); 1616fc729afSOlivier Houchard void (*cf_flush_brnchtgt_E) (u_int va); 1626fc729afSOlivier Houchard 1636fc729afSOlivier Houchard void (*cf_sleep) (int mode); 1646fc729afSOlivier Houchard 1656fc729afSOlivier Houchard /* Soft functions */ 1666fc729afSOlivier Houchard 1676fc729afSOlivier Houchard int (*cf_dataabt_fixup) (void *arg); 1686fc729afSOlivier Houchard int (*cf_prefetchabt_fixup) (void *arg); 1696fc729afSOlivier Houchard 1706fc729afSOlivier Houchard void (*cf_context_switch) (void); 1716fc729afSOlivier Houchard 1729a25f3e8SAndrew Turner void (*cf_setup) (void); 1736fc729afSOlivier Houchard }; 1746fc729afSOlivier Houchard 1756fc729afSOlivier Houchard extern struct cpu_functions cpufuncs; 1766fc729afSOlivier Houchard extern u_int cputype; 1776fc729afSOlivier Houchard 178fcb56067SGeorge V. Neville-Neil #define cpu_ident() cpufuncs.cf_id() 1796fc729afSOlivier Houchard #define cpu_cpwait() cpufuncs.cf_cpwait() 1806fc729afSOlivier Houchard 1816fc729afSOlivier Houchard #define cpu_control(c, e) cpufuncs.cf_control(c, e) 1826fc729afSOlivier Houchard #define cpu_domains(d) cpufuncs.cf_domains(d) 1836fc729afSOlivier Houchard #define cpu_setttb(t) cpufuncs.cf_setttb(t) 1846fc729afSOlivier Houchard #define cpu_faultstatus() cpufuncs.cf_faultstatus() 1856fc729afSOlivier Houchard #define cpu_faultaddress() cpufuncs.cf_faultaddress() 1866fc729afSOlivier Houchard 187cf1a573fSOleksandr Tymoshenko #ifndef SMP 188cf1a573fSOleksandr Tymoshenko 1896fc729afSOlivier Houchard #define cpu_tlb_flushID() cpufuncs.cf_tlb_flushID() 1906fc729afSOlivier Houchard #define cpu_tlb_flushID_SE(e) cpufuncs.cf_tlb_flushID_SE(e) 1916fc729afSOlivier Houchard #define cpu_tlb_flushI() cpufuncs.cf_tlb_flushI() 1926fc729afSOlivier Houchard #define cpu_tlb_flushI_SE(e) cpufuncs.cf_tlb_flushI_SE(e) 1936fc729afSOlivier Houchard #define cpu_tlb_flushD() cpufuncs.cf_tlb_flushD() 1946fc729afSOlivier Houchard #define cpu_tlb_flushD_SE(e) cpufuncs.cf_tlb_flushD_SE(e) 1956fc729afSOlivier Houchard 196cf1a573fSOleksandr Tymoshenko #else 197cf1a573fSOleksandr Tymoshenko void tlb_broadcast(int); 198cf1a573fSOleksandr Tymoshenko 199543c9e95SGanbold Tsagaankhuu #if defined(CPU_CORTEXA) || defined(CPU_MV_PJ4B) || defined(CPU_KRAIT) 200cf1a573fSOleksandr Tymoshenko #define TLB_BROADCAST /* No need to explicitely send an IPI */ 201cf1a573fSOleksandr Tymoshenko #else 202cf1a573fSOleksandr Tymoshenko #define TLB_BROADCAST tlb_broadcast(7) 203cf1a573fSOleksandr Tymoshenko #endif 204cf1a573fSOleksandr Tymoshenko 205cf1a573fSOleksandr Tymoshenko #define cpu_tlb_flushID() do { \ 206cf1a573fSOleksandr Tymoshenko cpufuncs.cf_tlb_flushID(); \ 207cf1a573fSOleksandr Tymoshenko TLB_BROADCAST; \ 208cf1a573fSOleksandr Tymoshenko } while(0) 209cf1a573fSOleksandr Tymoshenko 210cf1a573fSOleksandr Tymoshenko #define cpu_tlb_flushID_SE(e) do { \ 211cf1a573fSOleksandr Tymoshenko cpufuncs.cf_tlb_flushID_SE(e); \ 212cf1a573fSOleksandr Tymoshenko TLB_BROADCAST; \ 213cf1a573fSOleksandr Tymoshenko } while(0) 214cf1a573fSOleksandr Tymoshenko 215cf1a573fSOleksandr Tymoshenko 216cf1a573fSOleksandr Tymoshenko #define cpu_tlb_flushI() do { \ 217cf1a573fSOleksandr Tymoshenko cpufuncs.cf_tlb_flushI(); \ 218cf1a573fSOleksandr Tymoshenko TLB_BROADCAST; \ 219cf1a573fSOleksandr Tymoshenko } while(0) 220cf1a573fSOleksandr Tymoshenko 221cf1a573fSOleksandr Tymoshenko 222cf1a573fSOleksandr Tymoshenko #define cpu_tlb_flushI_SE(e) do { \ 223cf1a573fSOleksandr Tymoshenko cpufuncs.cf_tlb_flushI_SE(e); \ 224cf1a573fSOleksandr Tymoshenko TLB_BROADCAST; \ 225cf1a573fSOleksandr Tymoshenko } while(0) 226cf1a573fSOleksandr Tymoshenko 227cf1a573fSOleksandr Tymoshenko 228cf1a573fSOleksandr Tymoshenko #define cpu_tlb_flushD() do { \ 229cf1a573fSOleksandr Tymoshenko cpufuncs.cf_tlb_flushD(); \ 230cf1a573fSOleksandr Tymoshenko TLB_BROADCAST; \ 231cf1a573fSOleksandr Tymoshenko } while(0) 232cf1a573fSOleksandr Tymoshenko 233cf1a573fSOleksandr Tymoshenko 234cf1a573fSOleksandr Tymoshenko #define cpu_tlb_flushD_SE(e) do { \ 235cf1a573fSOleksandr Tymoshenko cpufuncs.cf_tlb_flushD_SE(e); \ 236cf1a573fSOleksandr Tymoshenko TLB_BROADCAST; \ 237cf1a573fSOleksandr Tymoshenko } while(0) 238cf1a573fSOleksandr Tymoshenko 239cf1a573fSOleksandr Tymoshenko #endif 240cf1a573fSOleksandr Tymoshenko 2416fc729afSOlivier Houchard #define cpu_icache_sync_all() cpufuncs.cf_icache_sync_all() 2426fc729afSOlivier Houchard #define cpu_icache_sync_range(a, s) cpufuncs.cf_icache_sync_range((a), (s)) 2436fc729afSOlivier Houchard 2446fc729afSOlivier Houchard #define cpu_dcache_wbinv_all() cpufuncs.cf_dcache_wbinv_all() 2456fc729afSOlivier Houchard #define cpu_dcache_wbinv_range(a, s) cpufuncs.cf_dcache_wbinv_range((a), (s)) 2466fc729afSOlivier Houchard #define cpu_dcache_inv_range(a, s) cpufuncs.cf_dcache_inv_range((a), (s)) 2476fc729afSOlivier Houchard #define cpu_dcache_wb_range(a, s) cpufuncs.cf_dcache_wb_range((a), (s)) 2486fc729afSOlivier Houchard 2494b7fcd31SIan Lepore #define cpu_idcache_inv_all() cpufuncs.cf_idcache_inv_all() 2506fc729afSOlivier Houchard #define cpu_idcache_wbinv_all() cpufuncs.cf_idcache_wbinv_all() 2516fc729afSOlivier Houchard #define cpu_idcache_wbinv_range(a, s) cpufuncs.cf_idcache_wbinv_range((a), (s)) 252425b5be3SOlivier Houchard #define cpu_l2cache_wbinv_all() cpufuncs.cf_l2cache_wbinv_all() 253425b5be3SOlivier Houchard #define cpu_l2cache_wb_range(a, s) cpufuncs.cf_l2cache_wb_range((a), (s)) 254425b5be3SOlivier Houchard #define cpu_l2cache_inv_range(a, s) cpufuncs.cf_l2cache_inv_range((a), (s)) 255425b5be3SOlivier Houchard #define cpu_l2cache_wbinv_range(a, s) cpufuncs.cf_l2cache_wbinv_range((a), (s)) 256b07d0cbcSIan Lepore #define cpu_l2cache_drain_writebuf() cpufuncs.cf_l2cache_drain_writebuf() 2576fc729afSOlivier Houchard 2586fc729afSOlivier Houchard #define cpu_flush_prefetchbuf() cpufuncs.cf_flush_prefetchbuf() 2596fc729afSOlivier Houchard #define cpu_drain_writebuf() cpufuncs.cf_drain_writebuf() 2606fc729afSOlivier Houchard #define cpu_flush_brnchtgt_C() cpufuncs.cf_flush_brnchtgt_C() 2616fc729afSOlivier Houchard #define cpu_flush_brnchtgt_E(e) cpufuncs.cf_flush_brnchtgt_E(e) 2626fc729afSOlivier Houchard 2636fc729afSOlivier Houchard #define cpu_sleep(m) cpufuncs.cf_sleep(m) 2646fc729afSOlivier Houchard 2656fc729afSOlivier Houchard #define cpu_dataabt_fixup(a) cpufuncs.cf_dataabt_fixup(a) 2666fc729afSOlivier Houchard #define cpu_prefetchabt_fixup(a) cpufuncs.cf_prefetchabt_fixup(a) 2676fc729afSOlivier Houchard #define ABORT_FIXUP_OK 0 /* fixup succeeded */ 2686fc729afSOlivier Houchard #define ABORT_FIXUP_FAILED 1 /* fixup failed */ 2696fc729afSOlivier Houchard #define ABORT_FIXUP_RETURN 2 /* abort handler should return */ 2706fc729afSOlivier Houchard 2719a25f3e8SAndrew Turner #define cpu_setup() cpufuncs.cf_setup() 2726fc729afSOlivier Houchard 2736fc729afSOlivier Houchard int set_cpufuncs (void); 2746fc729afSOlivier Houchard #define ARCHITECTURE_NOT_PRESENT 1 /* known but not configured */ 2756fc729afSOlivier Houchard #define ARCHITECTURE_NOT_SUPPORTED 2 /* not known */ 2766fc729afSOlivier Houchard 2776fc729afSOlivier Houchard void cpufunc_nullop (void); 2786fc729afSOlivier Houchard int cpufunc_null_fixup (void *); 2796fc729afSOlivier Houchard int early_abort_fixup (void *); 2806fc729afSOlivier Houchard int late_abort_fixup (void *); 2816fc729afSOlivier Houchard u_int cpufunc_id (void); 282cf1a573fSOleksandr Tymoshenko u_int cpufunc_cpuid (void); 2836fc729afSOlivier Houchard u_int cpufunc_control (u_int clear, u_int bic); 2846fc729afSOlivier Houchard void cpufunc_domains (u_int domains); 2856fc729afSOlivier Houchard u_int cpufunc_faultstatus (void); 2866fc729afSOlivier Houchard u_int cpufunc_faultaddress (void); 287cf1a573fSOleksandr Tymoshenko u_int cpu_pfr (int); 2886fc729afSOlivier Houchard 28964c68f1cSKevin Lo #if defined(CPU_FA526) || defined(CPU_FA626TE) 2909a25f3e8SAndrew Turner void fa526_setup (void); 291381a19ccSRui Paulo void fa526_setttb (u_int ttb); 292381a19ccSRui Paulo void fa526_context_switch (void); 293381a19ccSRui Paulo void fa526_cpu_sleep (int); 294381a19ccSRui Paulo void fa526_tlb_flushI_SE (u_int); 295381a19ccSRui Paulo void fa526_tlb_flushID_SE (u_int); 296381a19ccSRui Paulo void fa526_flush_prefetchbuf (void); 297381a19ccSRui Paulo void fa526_flush_brnchtgt_E (u_int); 298381a19ccSRui Paulo 299381a19ccSRui Paulo void fa526_icache_sync_all (void); 300381a19ccSRui Paulo void fa526_icache_sync_range(vm_offset_t start, vm_size_t end); 301381a19ccSRui Paulo void fa526_dcache_wbinv_all (void); 302381a19ccSRui Paulo void fa526_dcache_wbinv_range(vm_offset_t start, vm_size_t end); 303381a19ccSRui Paulo void fa526_dcache_inv_range (vm_offset_t start, vm_size_t end); 304381a19ccSRui Paulo void fa526_dcache_wb_range (vm_offset_t start, vm_size_t end); 305381a19ccSRui Paulo void fa526_idcache_wbinv_all(void); 306381a19ccSRui Paulo void fa526_idcache_wbinv_range(vm_offset_t start, vm_size_t end); 307381a19ccSRui Paulo #endif 308381a19ccSRui Paulo 309381a19ccSRui Paulo 3106fc729afSOlivier Houchard #ifdef CPU_ARM9 3116fc729afSOlivier Houchard void arm9_setttb (u_int); 3126fc729afSOlivier Houchard 3136fc729afSOlivier Houchard void arm9_tlb_flushID_SE (u_int va); 3146fc729afSOlivier Houchard 3154eaa43e6SKevin Lo void arm9_icache_sync_all (void); 3164eaa43e6SKevin Lo void arm9_icache_sync_range (vm_offset_t, vm_size_t); 3176fc729afSOlivier Houchard 3184eaa43e6SKevin Lo void arm9_dcache_wbinv_all (void); 3194eaa43e6SKevin Lo void arm9_dcache_wbinv_range (vm_offset_t, vm_size_t); 3204eaa43e6SKevin Lo void arm9_dcache_inv_range (vm_offset_t, vm_size_t); 3214eaa43e6SKevin Lo void arm9_dcache_wb_range (vm_offset_t, vm_size_t); 3226fc729afSOlivier Houchard 3234eaa43e6SKevin Lo void arm9_idcache_wbinv_all (void); 3244eaa43e6SKevin Lo void arm9_idcache_wbinv_range (vm_offset_t, vm_size_t); 3256fc729afSOlivier Houchard 3266fc729afSOlivier Houchard void arm9_context_switch (void); 3276fc729afSOlivier Houchard 3289a25f3e8SAndrew Turner void arm9_setup (void); 329094df973SOlivier Houchard 330094df973SOlivier Houchard extern unsigned arm9_dcache_sets_max; 331094df973SOlivier Houchard extern unsigned arm9_dcache_sets_inc; 332094df973SOlivier Houchard extern unsigned arm9_dcache_index_max; 333094df973SOlivier Houchard extern unsigned arm9_dcache_index_inc; 3346fc729afSOlivier Houchard #endif 3356fc729afSOlivier Houchard 3367a959e49SAndrew Turner #if defined(CPU_ARM9E) 3376fc729afSOlivier Houchard void arm10_tlb_flushID_SE (u_int); 3386fc729afSOlivier Houchard void arm10_tlb_flushI_SE (u_int); 3396fc729afSOlivier Houchard 3406fc729afSOlivier Houchard void arm10_context_switch (void); 3416fc729afSOlivier Houchard 3429a25f3e8SAndrew Turner void arm10_setup (void); 3436fc729afSOlivier Houchard 3441ee5b3b4SRafal Jaworowski u_int sheeva_control_ext (u_int, u_int); 345cfa892b5SAlexander Motin void sheeva_cpu_sleep (int); 3461ee5b3b4SRafal Jaworowski void sheeva_setttb (u_int); 3471ee5b3b4SRafal Jaworowski void sheeva_dcache_wbinv_range (vm_offset_t, vm_size_t); 3481ee5b3b4SRafal Jaworowski void sheeva_dcache_inv_range (vm_offset_t, vm_size_t); 3491ee5b3b4SRafal Jaworowski void sheeva_dcache_wb_range (vm_offset_t, vm_size_t); 3501ee5b3b4SRafal Jaworowski void sheeva_idcache_wbinv_range (vm_offset_t, vm_size_t); 351ba6faad6SRafal Jaworowski 3521ee5b3b4SRafal Jaworowski void sheeva_l2cache_wbinv_range (vm_offset_t, vm_size_t); 3531ee5b3b4SRafal Jaworowski void sheeva_l2cache_inv_range (vm_offset_t, vm_size_t); 3541ee5b3b4SRafal Jaworowski void sheeva_l2cache_wb_range (vm_offset_t, vm_size_t); 3551ee5b3b4SRafal Jaworowski void sheeva_l2cache_wbinv_all (void); 3566fc729afSOlivier Houchard #endif 3576fc729afSOlivier Houchard 35865328620SAndrew Turner #if defined(CPU_MV_PJ4B) 359cf1a573fSOleksandr Tymoshenko void armv6_idcache_wbinv_all (void); 36065328620SAndrew Turner #endif 36165328620SAndrew Turner #if defined(CPU_MV_PJ4B) || defined(CPU_CORTEXA) || defined(CPU_KRAIT) 362cf1a573fSOleksandr Tymoshenko void armv7_setttb (u_int); 363cf1a573fSOleksandr Tymoshenko void armv7_tlb_flushID (void); 364cf1a573fSOleksandr Tymoshenko void armv7_tlb_flushID_SE (u_int); 365457e64a0SIan Lepore void armv7_icache_sync_all (void); 366cf1a573fSOleksandr Tymoshenko void armv7_icache_sync_range (vm_offset_t, vm_size_t); 367cf1a573fSOleksandr Tymoshenko void armv7_idcache_wbinv_range (vm_offset_t, vm_size_t); 3684b7fcd31SIan Lepore void armv7_idcache_inv_all (void); 369cf1a573fSOleksandr Tymoshenko void armv7_dcache_wbinv_all (void); 370cf1a573fSOleksandr Tymoshenko void armv7_idcache_wbinv_all (void); 371cf1a573fSOleksandr Tymoshenko void armv7_dcache_wbinv_range (vm_offset_t, vm_size_t); 372cf1a573fSOleksandr Tymoshenko void armv7_dcache_inv_range (vm_offset_t, vm_size_t); 373cf1a573fSOleksandr Tymoshenko void armv7_dcache_wb_range (vm_offset_t, vm_size_t); 374cf1a573fSOleksandr Tymoshenko void armv7_cpu_sleep (int); 3759a25f3e8SAndrew Turner void armv7_setup (void); 376cf1a573fSOleksandr Tymoshenko void armv7_context_switch (void); 377cf1a573fSOleksandr Tymoshenko void armv7_drain_writebuf (void); 378cf1a573fSOleksandr Tymoshenko void armv7_sev (void); 3796afdadfdSIan Lepore void armv7_sleep (int unused); 380cf1a573fSOleksandr Tymoshenko u_int armv7_auxctrl (u_int, u_int); 381cf1a573fSOleksandr Tymoshenko 382cf1a573fSOleksandr Tymoshenko void armadaxp_idcache_wbinv_all (void); 383cf1a573fSOleksandr Tymoshenko 3849a25f3e8SAndrew Turner void cortexa_setup (void); 38563b25978SWarner Losh #endif 386*37b25ee6SAndrew Turner #if defined(CPU_MV_PJ4B) 387*37b25ee6SAndrew Turner void pj4b_config (void); 388*37b25ee6SAndrew Turner void pj4bv7_setup (void); 389*37b25ee6SAndrew Turner #endif 39063b25978SWarner Losh 391930798f3SAndrew Turner #if defined(CPU_ARM1176) 39265328620SAndrew Turner void arm11_tlb_flushID (void); 39365328620SAndrew Turner void arm11_tlb_flushID_SE (u_int); 39465328620SAndrew Turner void arm11_tlb_flushI (void); 39565328620SAndrew Turner void arm11_tlb_flushI_SE (u_int); 39665328620SAndrew Turner void arm11_tlb_flushD (void); 39765328620SAndrew Turner void arm11_tlb_flushD_SE (u_int va); 39865328620SAndrew Turner 39965328620SAndrew Turner void arm11_context_switch (void); 40065328620SAndrew Turner 40165328620SAndrew Turner void arm11_drain_writebuf (void); 40265328620SAndrew Turner 40365328620SAndrew Turner void armv6_dcache_wbinv_range (vm_offset_t, vm_size_t); 40465328620SAndrew Turner void armv6_dcache_inv_range (vm_offset_t, vm_size_t); 40565328620SAndrew Turner void armv6_dcache_wb_range (vm_offset_t, vm_size_t); 40665328620SAndrew Turner 40765328620SAndrew Turner void armv6_idcache_inv_all (void); 40865328620SAndrew Turner 409c5f8f894SOleksandr Tymoshenko void arm11x6_setttb (u_int); 410c5f8f894SOleksandr Tymoshenko void arm11x6_idcache_wbinv_all (void); 411c5f8f894SOleksandr Tymoshenko void arm11x6_dcache_wbinv_all (void); 412c5f8f894SOleksandr Tymoshenko void arm11x6_icache_sync_all (void); 413c5f8f894SOleksandr Tymoshenko void arm11x6_flush_prefetchbuf (void); 414c5f8f894SOleksandr Tymoshenko void arm11x6_icache_sync_range (vm_offset_t, vm_size_t); 415c5f8f894SOleksandr Tymoshenko void arm11x6_idcache_wbinv_range (vm_offset_t, vm_size_t); 4169a25f3e8SAndrew Turner void arm11x6_setup (void); 417c5f8f894SOleksandr Tymoshenko void arm11x6_sleep (int); /* no ref. for errata */ 418c5f8f894SOleksandr Tymoshenko #endif 419c5f8f894SOleksandr Tymoshenko 4207a959e49SAndrew Turner #if defined(CPU_ARM9E) 42163b25978SWarner Losh void armv5_ec_setttb(u_int); 42263b25978SWarner Losh 42363b25978SWarner Losh void armv5_ec_icache_sync_all(void); 42463b25978SWarner Losh void armv5_ec_icache_sync_range(vm_offset_t, vm_size_t); 42563b25978SWarner Losh 42663b25978SWarner Losh void armv5_ec_dcache_wbinv_all(void); 42763b25978SWarner Losh void armv5_ec_dcache_wbinv_range(vm_offset_t, vm_size_t); 42863b25978SWarner Losh void armv5_ec_dcache_inv_range(vm_offset_t, vm_size_t); 42963b25978SWarner Losh void armv5_ec_dcache_wb_range(vm_offset_t, vm_size_t); 43063b25978SWarner Losh 43163b25978SWarner Losh void armv5_ec_idcache_wbinv_all(void); 43263b25978SWarner Losh void armv5_ec_idcache_wbinv_range(vm_offset_t, vm_size_t); 43363b25978SWarner Losh #endif 43463b25978SWarner Losh 4357a959e49SAndrew Turner #if defined(CPU_ARM9) || defined(CPU_ARM9E) || \ 4366fc729afSOlivier Houchard defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \ 43764c68f1cSKevin Lo defined(CPU_FA526) || defined(CPU_FA626TE) || \ 43811d1528cSOlivier Houchard defined(CPU_XSCALE_PXA2X0) || defined(CPU_XSCALE_IXP425) || \ 439676b1fbdSOlivier Houchard defined(CPU_XSCALE_80219) || defined(CPU_XSCALE_81342) 4406fc729afSOlivier Houchard 4416fc729afSOlivier Houchard void armv4_tlb_flushID (void); 4426fc729afSOlivier Houchard void armv4_tlb_flushI (void); 4436fc729afSOlivier Houchard void armv4_tlb_flushD (void); 4446fc729afSOlivier Houchard void armv4_tlb_flushD_SE (u_int va); 4456fc729afSOlivier Houchard 4466fc729afSOlivier Houchard void armv4_drain_writebuf (void); 4474b7fcd31SIan Lepore void armv4_idcache_inv_all (void); 4486fc729afSOlivier Houchard #endif 4496fc729afSOlivier Houchard 4506fc729afSOlivier Houchard #if defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \ 45111d1528cSOlivier Houchard defined(CPU_XSCALE_PXA2X0) || defined(CPU_XSCALE_IXP425) || \ 452676b1fbdSOlivier Houchard defined(CPU_XSCALE_80219) || defined(CPU_XSCALE_81342) 4536fc729afSOlivier Houchard void xscale_cpwait (void); 4546fc729afSOlivier Houchard 4556fc729afSOlivier Houchard void xscale_cpu_sleep (int mode); 4566fc729afSOlivier Houchard 4576fc729afSOlivier Houchard u_int xscale_control (u_int clear, u_int bic); 4586fc729afSOlivier Houchard 4596fc729afSOlivier Houchard void xscale_setttb (u_int ttb); 4606fc729afSOlivier Houchard 4616fc729afSOlivier Houchard void xscale_tlb_flushID_SE (u_int va); 4626fc729afSOlivier Houchard 4636fc729afSOlivier Houchard void xscale_cache_flushID (void); 4646fc729afSOlivier Houchard void xscale_cache_flushI (void); 4656fc729afSOlivier Houchard void xscale_cache_flushD (void); 4666fc729afSOlivier Houchard void xscale_cache_flushD_SE (u_int entry); 4676fc729afSOlivier Houchard 4686fc729afSOlivier Houchard void xscale_cache_cleanID (void); 4696fc729afSOlivier Houchard void xscale_cache_cleanD (void); 4706fc729afSOlivier Houchard void xscale_cache_cleanD_E (u_int entry); 4716fc729afSOlivier Houchard 4726fc729afSOlivier Houchard void xscale_cache_clean_minidata (void); 4736fc729afSOlivier Houchard 4746fc729afSOlivier Houchard void xscale_cache_purgeID (void); 4756fc729afSOlivier Houchard void xscale_cache_purgeID_E (u_int entry); 4766fc729afSOlivier Houchard void xscale_cache_purgeD (void); 4776fc729afSOlivier Houchard void xscale_cache_purgeD_E (u_int entry); 4786fc729afSOlivier Houchard 4796fc729afSOlivier Houchard void xscale_cache_syncI (void); 4806fc729afSOlivier Houchard void xscale_cache_cleanID_rng (vm_offset_t start, vm_size_t end); 4816fc729afSOlivier Houchard void xscale_cache_cleanD_rng (vm_offset_t start, vm_size_t end); 4826fc729afSOlivier Houchard void xscale_cache_purgeID_rng (vm_offset_t start, vm_size_t end); 4836fc729afSOlivier Houchard void xscale_cache_purgeD_rng (vm_offset_t start, vm_size_t end); 4846fc729afSOlivier Houchard void xscale_cache_syncI_rng (vm_offset_t start, vm_size_t end); 4856fc729afSOlivier Houchard void xscale_cache_flushD_rng (vm_offset_t start, vm_size_t end); 4866fc729afSOlivier Houchard 4876fc729afSOlivier Houchard void xscale_context_switch (void); 4886fc729afSOlivier Houchard 4899a25f3e8SAndrew Turner void xscale_setup (void); 49011d1528cSOlivier Houchard #endif /* CPU_XSCALE_80200 || CPU_XSCALE_80321 || CPU_XSCALE_PXA2X0 || CPU_XSCALE_IXP425 49111d1528cSOlivier Houchard CPU_XSCALE_80219 */ 4926fc729afSOlivier Houchard 493676b1fbdSOlivier Houchard #ifdef CPU_XSCALE_81342 494676b1fbdSOlivier Houchard 495425b5be3SOlivier Houchard void xscalec3_l2cache_purge (void); 496425b5be3SOlivier Houchard void xscalec3_cache_purgeID (void); 497425b5be3SOlivier Houchard void xscalec3_cache_purgeD (void); 498676b1fbdSOlivier Houchard void xscalec3_cache_cleanID (void); 499676b1fbdSOlivier Houchard void xscalec3_cache_cleanD (void); 500676b1fbdSOlivier Houchard void xscalec3_cache_syncI (void); 501425b5be3SOlivier Houchard 502676b1fbdSOlivier Houchard void xscalec3_cache_purgeID_rng (vm_offset_t start, vm_size_t end); 503676b1fbdSOlivier Houchard void xscalec3_cache_purgeD_rng (vm_offset_t start, vm_size_t end); 504425b5be3SOlivier Houchard void xscalec3_cache_cleanID_rng (vm_offset_t start, vm_size_t end); 505425b5be3SOlivier Houchard void xscalec3_cache_cleanD_rng (vm_offset_t start, vm_size_t end); 506425b5be3SOlivier Houchard void xscalec3_cache_syncI_rng (vm_offset_t start, vm_size_t end); 507425b5be3SOlivier Houchard 508425b5be3SOlivier Houchard void xscalec3_l2cache_flush_rng (vm_offset_t, vm_size_t); 509425b5be3SOlivier Houchard void xscalec3_l2cache_clean_rng (vm_offset_t start, vm_size_t end); 510425b5be3SOlivier Houchard void xscalec3_l2cache_purge_rng (vm_offset_t start, vm_size_t end); 511676b1fbdSOlivier Houchard 512676b1fbdSOlivier Houchard 513676b1fbdSOlivier Houchard void xscalec3_setttb (u_int ttb); 514676b1fbdSOlivier Houchard void xscalec3_context_switch (void); 515676b1fbdSOlivier Houchard 516676b1fbdSOlivier Houchard #endif /* CPU_XSCALE_81342 */ 517676b1fbdSOlivier Houchard 5186fc729afSOlivier Houchard #define setttb cpu_setttb 5196fc729afSOlivier Houchard #define drain_writebuf cpu_drain_writebuf 5206fc729afSOlivier Houchard 5216fc729afSOlivier Houchard /* 5226fc729afSOlivier Houchard * Macros for manipulating CPU interrupts 5236fc729afSOlivier Houchard */ 5246fc729afSOlivier Houchard static __inline u_int32_t __set_cpsr_c(u_int bic, u_int eor) __attribute__((__unused__)); 5256fc729afSOlivier Houchard 5266fc729afSOlivier Houchard static __inline u_int32_t 5276fc729afSOlivier Houchard __set_cpsr_c(u_int bic, u_int eor) 5286fc729afSOlivier Houchard { 5296fc729afSOlivier Houchard u_int32_t tmp, ret; 5306fc729afSOlivier Houchard 5316fc729afSOlivier Houchard __asm __volatile( 5326fc729afSOlivier Houchard "mrs %0, cpsr\n" /* Get the CPSR */ 5336fc729afSOlivier Houchard "bic %1, %0, %2\n" /* Clear bits */ 5346fc729afSOlivier Houchard "eor %1, %1, %3\n" /* XOR bits */ 5356fc729afSOlivier Houchard "msr cpsr_c, %1\n" /* Set the control field of CPSR */ 5366fc729afSOlivier Houchard : "=&r" (ret), "=&r" (tmp) 53724e01b0cSOlivier Houchard : "r" (bic), "r" (eor) : "memory"); 5386fc729afSOlivier Houchard 5396fc729afSOlivier Houchard return ret; 5406fc729afSOlivier Houchard } 5416fc729afSOlivier Houchard 542dfad9244SMarcel Moolenaar #define ARM_CPSR_F32 (1 << 6) /* FIQ disable */ 543dfad9244SMarcel Moolenaar #define ARM_CPSR_I32 (1 << 7) /* IRQ disable */ 544dfad9244SMarcel Moolenaar 5456fc729afSOlivier Houchard #define disable_interrupts(mask) \ 546dfad9244SMarcel Moolenaar (__set_cpsr_c((mask) & (ARM_CPSR_I32 | ARM_CPSR_F32), \ 547dfad9244SMarcel Moolenaar (mask) & (ARM_CPSR_I32 | ARM_CPSR_F32))) 5486fc729afSOlivier Houchard 5496fc729afSOlivier Houchard #define enable_interrupts(mask) \ 550dfad9244SMarcel Moolenaar (__set_cpsr_c((mask) & (ARM_CPSR_I32 | ARM_CPSR_F32), 0)) 5516fc729afSOlivier Houchard 5526fc729afSOlivier Houchard #define restore_interrupts(old_cpsr) \ 553dfad9244SMarcel Moolenaar (__set_cpsr_c((ARM_CPSR_I32 | ARM_CPSR_F32), \ 554dfad9244SMarcel Moolenaar (old_cpsr) & (ARM_CPSR_I32 | ARM_CPSR_F32))) 5556fc729afSOlivier Houchard 556dfad9244SMarcel Moolenaar static __inline register_t 557dfad9244SMarcel Moolenaar intr_disable(void) 558dfad9244SMarcel Moolenaar { 559dfad9244SMarcel Moolenaar register_t s; 560dfad9244SMarcel Moolenaar 561dfad9244SMarcel Moolenaar s = disable_interrupts(ARM_CPSR_I32 | ARM_CPSR_F32); 562dfad9244SMarcel Moolenaar return (s); 563dfad9244SMarcel Moolenaar } 564dfad9244SMarcel Moolenaar 565dfad9244SMarcel Moolenaar static __inline void 566dfad9244SMarcel Moolenaar intr_restore(register_t s) 567dfad9244SMarcel Moolenaar { 568dfad9244SMarcel Moolenaar 569dfad9244SMarcel Moolenaar restore_interrupts(s); 570dfad9244SMarcel Moolenaar } 571dfad9244SMarcel Moolenaar 5726fc729afSOlivier Houchard /* Functions to manipulate the CPSR. */ 5736fc729afSOlivier Houchard u_int SetCPSR(u_int bic, u_int eor); 5746fc729afSOlivier Houchard u_int GetCPSR(void); 5756fc729afSOlivier Houchard 5766fc729afSOlivier Houchard /* 5776fc729afSOlivier Houchard * Functions to manipulate cpu r13 5786fc729afSOlivier Houchard * (in arm/arm32/setstack.S) 5796fc729afSOlivier Houchard */ 5806fc729afSOlivier Houchard 5814eaa43e6SKevin Lo void set_stackptr (u_int mode, u_int address); 5824eaa43e6SKevin Lo u_int get_stackptr (u_int mode); 5836fc729afSOlivier Houchard 5846fc729afSOlivier Houchard /* 5856fc729afSOlivier Houchard * Miscellany 5866fc729afSOlivier Houchard */ 5876fc729afSOlivier Houchard 5884eaa43e6SKevin Lo int get_pc_str_offset (void); 5896fc729afSOlivier Houchard 5906fc729afSOlivier Houchard /* 5916fc729afSOlivier Houchard * CPU functions from locore.S 5926fc729afSOlivier Houchard */ 5936fc729afSOlivier Houchard 5944eaa43e6SKevin Lo void cpu_reset (void) __attribute__((__noreturn__)); 5956fc729afSOlivier Houchard 5966fc729afSOlivier Houchard /* 5976fc729afSOlivier Houchard * Cache info variables. 5986fc729afSOlivier Houchard */ 5996fc729afSOlivier Houchard 6006fc729afSOlivier Houchard /* PRIMARY CACHE VARIABLES */ 6016fc729afSOlivier Houchard extern int arm_picache_size; 6026fc729afSOlivier Houchard extern int arm_picache_line_size; 6036fc729afSOlivier Houchard extern int arm_picache_ways; 6046fc729afSOlivier Houchard 6056fc729afSOlivier Houchard extern int arm_pdcache_size; /* and unified */ 6066fc729afSOlivier Houchard extern int arm_pdcache_line_size; 6076fc729afSOlivier Houchard extern int arm_pdcache_ways; 6086fc729afSOlivier Houchard 6096fc729afSOlivier Houchard extern int arm_pcache_type; 6106fc729afSOlivier Houchard extern int arm_pcache_unified; 6116fc729afSOlivier Houchard 6126fc729afSOlivier Houchard extern int arm_dcache_align; 6136fc729afSOlivier Houchard extern int arm_dcache_align_mask; 6146fc729afSOlivier Houchard 615cf1a573fSOleksandr Tymoshenko extern u_int arm_cache_level; 616cf1a573fSOleksandr Tymoshenko extern u_int arm_cache_loc; 617cf1a573fSOleksandr Tymoshenko extern u_int arm_cache_type[14]; 618cf1a573fSOleksandr Tymoshenko 6196fc729afSOlivier Houchard #endif /* _KERNEL */ 6206fc729afSOlivier Houchard #endif /* _MACHINE_CPUFUNC_H_ */ 6216fc729afSOlivier Houchard 6226fc729afSOlivier Houchard /* End of cpufunc.h */ 623