Home | History | Annotate | Line # | Download | only in include
cpufunc.h revision 1.73
      1  1.45      matt /*	cpufunc.h,v 1.40.22.4 2007/11/08 10:59:33 matt Exp	*/
      2   1.1   reinoud 
      3   1.1   reinoud /*
      4   1.1   reinoud  * Copyright (c) 1997 Mark Brinicombe.
      5   1.1   reinoud  * Copyright (c) 1997 Causality Limited
      6   1.1   reinoud  * All rights reserved.
      7   1.1   reinoud  *
      8   1.1   reinoud  * Redistribution and use in source and binary forms, with or without
      9   1.1   reinoud  * modification, are permitted provided that the following conditions
     10   1.1   reinoud  * are met:
     11   1.1   reinoud  * 1. Redistributions of source code must retain the above copyright
     12   1.1   reinoud  *    notice, this list of conditions and the following disclaimer.
     13   1.1   reinoud  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1   reinoud  *    notice, this list of conditions and the following disclaimer in the
     15   1.1   reinoud  *    documentation and/or other materials provided with the distribution.
     16   1.1   reinoud  * 3. All advertising materials mentioning features or use of this software
     17   1.1   reinoud  *    must display the following acknowledgement:
     18   1.1   reinoud  *	This product includes software developed by Causality Limited.
     19   1.1   reinoud  * 4. The name of Causality Limited may not be used to endorse or promote
     20   1.1   reinoud  *    products derived from this software without specific prior written
     21   1.1   reinoud  *    permission.
     22   1.1   reinoud  *
     23   1.1   reinoud  * THIS SOFTWARE IS PROVIDED BY CAUSALITY LIMITED ``AS IS'' AND ANY EXPRESS
     24   1.1   reinoud  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     25   1.1   reinoud  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     26   1.1   reinoud  * DISCLAIMED. IN NO EVENT SHALL CAUSALITY LIMITED BE LIABLE FOR ANY DIRECT,
     27   1.1   reinoud  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     28   1.1   reinoud  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     29   1.1   reinoud  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30   1.1   reinoud  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31   1.1   reinoud  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32   1.1   reinoud  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33   1.1   reinoud  * SUCH DAMAGE.
     34   1.1   reinoud  *
     35   1.1   reinoud  * RiscBSD kernel project
     36   1.1   reinoud  *
     37   1.1   reinoud  * cpufunc.h
     38   1.1   reinoud  *
     39   1.1   reinoud  * Prototypes for cpu, mmu and tlb related functions.
     40   1.1   reinoud  */
     41   1.1   reinoud 
     42  1.65      matt #ifndef _ARM_CPUFUNC_H_
     43  1.65      matt #define _ARM_CPUFUNC_H_
     44   1.1   reinoud 
     45  1.21   thorpej #ifdef _KERNEL
     46  1.21   thorpej 
     47   1.1   reinoud #include <sys/types.h>
     48  1.45      matt #include <arm/armreg.h>
     49  1.21   thorpej #include <arm/cpuconf.h>
     50  1.44    dogcow #include <arm/armreg.h>
     51   1.1   reinoud 
     52   1.1   reinoud struct cpu_functions {
     53   1.1   reinoud 
     54   1.1   reinoud 	/* CPU functions */
     55  1.32       uwe 
     56  1.39     bjh21 	u_int	(*cf_id)		(void);
     57  1.39     bjh21 	void	(*cf_cpwait)		(void);
     58   1.1   reinoud 
     59   1.1   reinoud 	/* MMU functions */
     60   1.1   reinoud 
     61  1.39     bjh21 	u_int	(*cf_control)		(u_int, u_int);
     62  1.39     bjh21 	void	(*cf_domains)		(u_int);
     63  1.69      matt #if defined(ARM_MMU_EXTENDED)
     64  1.69      matt 	void	(*cf_setttb)		(u_int, tlb_asid_t);
     65  1.69      matt #else
     66  1.60      matt 	void	(*cf_setttb)		(u_int, bool);
     67  1.69      matt #endif
     68  1.39     bjh21 	u_int	(*cf_faultstatus)	(void);
     69  1.39     bjh21 	u_int	(*cf_faultaddress)	(void);
     70   1.1   reinoud 
     71   1.1   reinoud 	/* TLB functions */
     72   1.1   reinoud 
     73  1.39     bjh21 	void	(*cf_tlb_flushID)	(void);
     74  1.66      matt 	void	(*cf_tlb_flushID_SE)	(vaddr_t);
     75  1.39     bjh21 	void	(*cf_tlb_flushI)	(void);
     76  1.66      matt 	void	(*cf_tlb_flushI_SE)	(vaddr_t);
     77  1.39     bjh21 	void	(*cf_tlb_flushD)	(void);
     78  1.66      matt 	void	(*cf_tlb_flushD_SE)	(vaddr_t);
     79   1.1   reinoud 
     80  1.17   thorpej 	/*
     81  1.17   thorpej 	 * Cache operations:
     82  1.17   thorpej 	 *
     83  1.17   thorpej 	 * We define the following primitives:
     84  1.17   thorpej 	 *
     85  1.17   thorpej 	 *	icache_sync_all		Synchronize I-cache
     86  1.17   thorpej 	 *	icache_sync_range	Synchronize I-cache range
     87  1.17   thorpej 	 *
     88  1.17   thorpej 	 *	dcache_wbinv_all	Write-back and Invalidate D-cache
     89  1.17   thorpej 	 *	dcache_wbinv_range	Write-back and Invalidate D-cache range
     90  1.17   thorpej 	 *	dcache_inv_range	Invalidate D-cache range
     91  1.17   thorpej 	 *	dcache_wb_range		Write-back D-cache range
     92  1.17   thorpej 	 *
     93  1.17   thorpej 	 *	idcache_wbinv_all	Write-back and Invalidate D-cache,
     94  1.17   thorpej 	 *				Invalidate I-cache
     95  1.17   thorpej 	 *	idcache_wbinv_range	Write-back and Invalidate D-cache,
     96  1.17   thorpej 	 *				Invalidate I-cache range
     97  1.17   thorpej 	 *
     98  1.17   thorpej 	 * Note that the ARM term for "write-back" is "clean".  We use
     99  1.17   thorpej 	 * the term "write-back" since it's a more common way to describe
    100  1.17   thorpej 	 * the operation.
    101  1.17   thorpej 	 *
    102  1.17   thorpej 	 * There are some rules that must be followed:
    103  1.17   thorpej 	 *
    104  1.17   thorpej 	 *	I-cache Synch (all or range):
    105  1.17   thorpej 	 *		The goal is to synchronize the instruction stream,
    106  1.17   thorpej 	 *		so you may beed to write-back dirty D-cache blocks
    107  1.17   thorpej 	 *		first.  If a range is requested, and you can't
    108  1.17   thorpej 	 *		synchronize just a range, you have to hit the whole
    109  1.17   thorpej 	 *		thing.
    110  1.17   thorpej 	 *
    111  1.17   thorpej 	 *	D-cache Write-Back and Invalidate range:
    112  1.17   thorpej 	 *		If you can't WB-Inv a range, you must WB-Inv the
    113  1.17   thorpej 	 *		entire D-cache.
    114  1.17   thorpej 	 *
    115  1.17   thorpej 	 *	D-cache Invalidate:
    116  1.17   thorpej 	 *		If you can't Inv the D-cache, you must Write-Back
    117  1.17   thorpej 	 *		and Invalidate.  Code that uses this operation
    118  1.17   thorpej 	 *		MUST NOT assume that the D-cache will not be written
    119  1.17   thorpej 	 *		back to memory.
    120  1.17   thorpej 	 *
    121  1.17   thorpej 	 *	D-cache Write-Back:
    122  1.17   thorpej 	 *		If you can't Write-back without doing an Inv,
    123  1.17   thorpej 	 *		that's fine.  Then treat this as a WB-Inv.
    124  1.17   thorpej 	 *		Skipping the invalidate is merely an optimization.
    125  1.17   thorpej 	 *
    126  1.17   thorpej 	 *	All operations:
    127  1.17   thorpej 	 *		Valid virtual addresses must be passed to each
    128  1.17   thorpej 	 *		cache operation.
    129  1.17   thorpej 	 */
    130  1.39     bjh21 	void	(*cf_icache_sync_all)	(void);
    131  1.39     bjh21 	void	(*cf_icache_sync_range)	(vaddr_t, vsize_t);
    132  1.17   thorpej 
    133  1.39     bjh21 	void	(*cf_dcache_wbinv_all)	(void);
    134  1.39     bjh21 	void	(*cf_dcache_wbinv_range)(vaddr_t, vsize_t);
    135  1.39     bjh21 	void	(*cf_dcache_inv_range)	(vaddr_t, vsize_t);
    136  1.39     bjh21 	void	(*cf_dcache_wb_range)	(vaddr_t, vsize_t);
    137   1.1   reinoud 
    138  1.59      matt 	void	(*cf_sdcache_wbinv_range)(vaddr_t, paddr_t, psize_t);
    139  1.59      matt 	void	(*cf_sdcache_inv_range)	(vaddr_t, paddr_t, psize_t);
    140  1.59      matt 	void	(*cf_sdcache_wb_range)	(vaddr_t, paddr_t, psize_t);
    141  1.59      matt 
    142  1.39     bjh21 	void	(*cf_idcache_wbinv_all)	(void);
    143  1.39     bjh21 	void	(*cf_idcache_wbinv_range)(vaddr_t, vsize_t);
    144   1.1   reinoud 
    145   1.1   reinoud 	/* Other functions */
    146   1.1   reinoud 
    147  1.39     bjh21 	void	(*cf_flush_prefetchbuf)	(void);
    148  1.39     bjh21 	void	(*cf_drain_writebuf)	(void);
    149  1.39     bjh21 	void	(*cf_flush_brnchtgt_C)	(void);
    150  1.39     bjh21 	void	(*cf_flush_brnchtgt_E)	(u_int);
    151   1.1   reinoud 
    152  1.39     bjh21 	void	(*cf_sleep)		(int mode);
    153   1.1   reinoud 
    154   1.1   reinoud 	/* Soft functions */
    155   1.1   reinoud 
    156  1.39     bjh21 	int	(*cf_dataabt_fixup)	(void *);
    157  1.39     bjh21 	int	(*cf_prefetchabt_fixup)	(void *);
    158   1.1   reinoud 
    159  1.69      matt #if defined(ARM_MMU_EXTENDED)
    160  1.69      matt 	void	(*cf_context_switch)	(u_int, tlb_asid_t);
    161  1.69      matt #else
    162  1.41       scw 	void	(*cf_context_switch)	(u_int);
    163  1.69      matt #endif
    164   1.1   reinoud 
    165  1.39     bjh21 	void	(*cf_setup)		(char *);
    166   1.1   reinoud };
    167   1.1   reinoud 
    168   1.1   reinoud extern struct cpu_functions cpufuncs;
    169   1.1   reinoud extern u_int cputype;
    170   1.1   reinoud 
    171   1.1   reinoud #define cpu_id()		cpufuncs.cf_id()
    172   1.1   reinoud 
    173   1.1   reinoud #define cpu_control(c, e)	cpufuncs.cf_control(c, e)
    174   1.1   reinoud #define cpu_domains(d)		cpufuncs.cf_domains(d)
    175  1.60      matt #define cpu_setttb(t, f)	cpufuncs.cf_setttb(t, f)
    176   1.1   reinoud #define cpu_faultstatus()	cpufuncs.cf_faultstatus()
    177   1.1   reinoud #define cpu_faultaddress()	cpufuncs.cf_faultaddress()
    178   1.1   reinoud 
    179   1.1   reinoud #define	cpu_tlb_flushID()	cpufuncs.cf_tlb_flushID()
    180   1.1   reinoud #define	cpu_tlb_flushID_SE(e)	cpufuncs.cf_tlb_flushID_SE(e)
    181   1.1   reinoud #define	cpu_tlb_flushI()	cpufuncs.cf_tlb_flushI()
    182   1.1   reinoud #define	cpu_tlb_flushI_SE(e)	cpufuncs.cf_tlb_flushI_SE(e)
    183   1.1   reinoud #define	cpu_tlb_flushD()	cpufuncs.cf_tlb_flushD()
    184   1.1   reinoud #define	cpu_tlb_flushD_SE(e)	cpufuncs.cf_tlb_flushD_SE(e)
    185   1.1   reinoud 
    186  1.17   thorpej #define	cpu_icache_sync_all()	cpufuncs.cf_icache_sync_all()
    187  1.17   thorpej #define	cpu_icache_sync_range(a, s) cpufuncs.cf_icache_sync_range((a), (s))
    188  1.17   thorpej 
    189  1.17   thorpej #define	cpu_dcache_wbinv_all()	cpufuncs.cf_dcache_wbinv_all()
    190  1.17   thorpej #define	cpu_dcache_wbinv_range(a, s) cpufuncs.cf_dcache_wbinv_range((a), (s))
    191  1.17   thorpej #define	cpu_dcache_inv_range(a, s) cpufuncs.cf_dcache_inv_range((a), (s))
    192  1.17   thorpej #define	cpu_dcache_wb_range(a, s) cpufuncs.cf_dcache_wb_range((a), (s))
    193  1.17   thorpej 
    194  1.59      matt #define	cpu_sdcache_wbinv_range(a, b, s) cpufuncs.cf_sdcache_wbinv_range((a), (b), (s))
    195  1.59      matt #define	cpu_sdcache_inv_range(a, b, s) cpufuncs.cf_sdcache_inv_range((a), (b), (s))
    196  1.59      matt #define	cpu_sdcache_wb_range(a, b, s) cpufuncs.cf_sdcache_wb_range((a), (b), (s))
    197  1.59      matt 
    198  1.17   thorpej #define	cpu_idcache_wbinv_all()	cpufuncs.cf_idcache_wbinv_all()
    199  1.17   thorpej #define	cpu_idcache_wbinv_range(a, s) cpufuncs.cf_idcache_wbinv_range((a), (s))
    200   1.1   reinoud 
    201   1.1   reinoud #define	cpu_flush_prefetchbuf()	cpufuncs.cf_flush_prefetchbuf()
    202   1.1   reinoud #define	cpu_drain_writebuf()	cpufuncs.cf_drain_writebuf()
    203   1.1   reinoud #define	cpu_flush_brnchtgt_C()	cpufuncs.cf_flush_brnchtgt_C()
    204   1.1   reinoud #define	cpu_flush_brnchtgt_E(e)	cpufuncs.cf_flush_brnchtgt_E(e)
    205   1.1   reinoud 
    206   1.1   reinoud #define cpu_sleep(m)		cpufuncs.cf_sleep(m)
    207   1.1   reinoud 
    208   1.1   reinoud #define cpu_dataabt_fixup(a)		cpufuncs.cf_dataabt_fixup(a)
    209   1.1   reinoud #define cpu_prefetchabt_fixup(a)	cpufuncs.cf_prefetchabt_fixup(a)
    210   1.7       wiz #define ABORT_FIXUP_OK		0	/* fixup succeeded */
    211   1.1   reinoud #define ABORT_FIXUP_FAILED	1	/* fixup failed */
    212   1.1   reinoud #define ABORT_FIXUP_RETURN	2	/* abort handler should return */
    213   1.1   reinoud 
    214  1.41       scw #define cpu_context_switch(a)		cpufuncs.cf_context_switch(a)
    215   1.1   reinoud #define cpu_setup(a)			cpufuncs.cf_setup(a)
    216   1.1   reinoud 
    217  1.39     bjh21 int	set_cpufuncs		(void);
    218  1.40     bjh21 int	set_cpufuncs_id		(u_int);
    219   1.1   reinoud #define ARCHITECTURE_NOT_PRESENT	1	/* known but not configured */
    220   1.1   reinoud #define ARCHITECTURE_NOT_SUPPORTED	2	/* not known */
    221   1.1   reinoud 
    222  1.39     bjh21 void	cpufunc_nullop		(void);
    223  1.39     bjh21 int	cpufunc_null_fixup	(void *);
    224  1.39     bjh21 int	early_abort_fixup	(void *);
    225  1.39     bjh21 int	late_abort_fixup	(void *);
    226  1.39     bjh21 u_int	cpufunc_id		(void);
    227  1.39     bjh21 u_int	cpufunc_control		(u_int, u_int);
    228  1.39     bjh21 void	cpufunc_domains		(u_int);
    229  1.39     bjh21 u_int	cpufunc_faultstatus	(void);
    230  1.39     bjh21 u_int	cpufunc_faultaddress	(void);
    231   1.3     bjh21 
    232   1.1   reinoud #define tlb_flush	cpu_tlb_flushID
    233   1.1   reinoud #define setttb		cpu_setttb
    234   1.1   reinoud #define drain_writebuf	cpu_drain_writebuf
    235   1.1   reinoud 
    236  1.73      matt 
    237  1.73      matt #if defined(CPU_XSCALE)
    238  1.73      matt #define	cpu_cpwait()		cpufuncs.cf_cpwait()
    239  1.73      matt #endif
    240  1.73      matt 
    241  1.43     chris #ifndef cpu_cpwait
    242  1.43     chris #define	cpu_cpwait()
    243  1.43     chris #endif
    244  1.43     chris 
    245   1.1   reinoud /*
    246   1.1   reinoud  * Macros for manipulating CPU interrupts
    247   1.1   reinoud  */
    248  1.15   thorpej #ifdef __PROG32
    249  1.62     skrll static __inline uint32_t __set_cpsr_c(uint32_t bic, uint32_t eor) __attribute__((__unused__));
    250  1.62     skrll static __inline uint32_t disable_interrupts(uint32_t mask) __attribute__((__unused__));
    251  1.62     skrll static __inline uint32_t enable_interrupts(uint32_t mask) __attribute__((__unused__));
    252  1.25    briggs 
    253  1.43     chris static __inline uint32_t
    254  1.43     chris __set_cpsr_c(uint32_t bic, uint32_t eor)
    255  1.25    briggs {
    256  1.43     chris 	uint32_t	tmp, ret;
    257  1.25    briggs 
    258  1.36     perry 	__asm volatile(
    259  1.25    briggs 		"mrs     %0, cpsr\n"	/* Get the CPSR */
    260  1.25    briggs 		"bic	 %1, %0, %2\n"	/* Clear bits */
    261  1.25    briggs 		"eor	 %1, %1, %3\n"	/* XOR bits */
    262  1.25    briggs 		"msr     cpsr_c, %1\n"	/* Set the control field of CPSR */
    263  1.25    briggs 	: "=&r" (ret), "=&r" (tmp)
    264  1.31  rearnsha 	: "r" (bic), "r" (eor) : "memory");
    265  1.25    briggs 
    266  1.25    briggs 	return ret;
    267  1.25    briggs }
    268  1.25    briggs 
    269  1.43     chris static __inline uint32_t
    270  1.43     chris disable_interrupts(uint32_t mask)
    271  1.43     chris {
    272  1.43     chris 	uint32_t	tmp, ret;
    273  1.43     chris 	mask &= (I32_bit | F32_bit);
    274  1.43     chris 
    275  1.43     chris 	__asm volatile(
    276  1.43     chris 		"mrs     %0, cpsr\n"	/* Get the CPSR */
    277  1.43     chris 		"orr	 %1, %0, %2\n"	/* set bits */
    278  1.43     chris 		"msr     cpsr_c, %1\n"	/* Set the control field of CPSR */
    279  1.43     chris 	: "=&r" (ret), "=&r" (tmp)
    280  1.43     chris 	: "r" (mask)
    281  1.43     chris 	: "memory");
    282  1.43     chris 
    283  1.43     chris 	return ret;
    284  1.43     chris }
    285  1.43     chris 
    286  1.43     chris static __inline uint32_t
    287  1.43     chris enable_interrupts(uint32_t mask)
    288  1.43     chris {
    289  1.69      matt 	uint32_t	ret;
    290  1.43     chris 	mask &= (I32_bit | F32_bit);
    291  1.43     chris 
    292  1.69      matt 	/* Get the CPSR */
    293  1.69      matt 	__asm __volatile("mrs\t%0, cpsr\n" : "=r"(ret));
    294  1.69      matt #ifdef _ARM_ARCH_6
    295  1.69      matt 	if (__builtin_constant_p(mask)) {
    296  1.69      matt 		switch (mask) {
    297  1.69      matt 		case I32_bit | F32_bit:
    298  1.69      matt 			__asm __volatile("cpsie\tif");
    299  1.69      matt 			break;
    300  1.69      matt 		case I32_bit:
    301  1.69      matt 			__asm __volatile("cpsie\ti");
    302  1.69      matt 			break;
    303  1.69      matt 		case F32_bit:
    304  1.69      matt 			__asm __volatile("cpsie\tf");
    305  1.69      matt 			break;
    306  1.69      matt 		default:
    307  1.69      matt 			break;
    308  1.69      matt 		}
    309  1.69      matt 		return ret;
    310  1.69      matt 	}
    311  1.69      matt #endif /* _ARM_ARCH_6 */
    312  1.69      matt 
    313  1.69      matt 	/* Set the control field of CPSR */
    314  1.69      matt 	__asm volatile("msr\tcpsr_c, %0" :: "r"(ret & ~mask));
    315   1.1   reinoud 
    316  1.43     chris 	return ret;
    317  1.43     chris }
    318   1.1   reinoud 
    319  1.15   thorpej #define restore_interrupts(old_cpsr)					\
    320  1.25    briggs 	(__set_cpsr_c((I32_bit | F32_bit), (old_cpsr) & (I32_bit | F32_bit)))
    321  1.45      matt 
    322  1.45      matt static inline void cpsie(register_t psw) __attribute__((__unused__));
    323  1.45      matt static inline register_t cpsid(register_t psw) __attribute__((__unused__));
    324  1.45      matt 
    325  1.45      matt static inline void
    326  1.45      matt cpsie(register_t psw)
    327  1.45      matt {
    328  1.49      matt #ifdef _ARM_ARCH_6
    329  1.45      matt 	if (!__builtin_constant_p(psw)) {
    330  1.45      matt 		enable_interrupts(psw);
    331  1.45      matt 		return;
    332  1.45      matt 	}
    333  1.45      matt 	switch (psw & (I32_bit|F32_bit)) {
    334  1.45      matt 	case I32_bit:		__asm("cpsie\ti"); break;
    335  1.45      matt 	case F32_bit:		__asm("cpsie\tf"); break;
    336  1.45      matt 	case I32_bit|F32_bit:	__asm("cpsie\tif"); break;
    337  1.45      matt 	}
    338  1.48     cliff #else
    339  1.48     cliff 	enable_interrupts(psw);
    340  1.48     cliff #endif
    341  1.45      matt }
    342  1.45      matt 
    343  1.45      matt static inline register_t
    344  1.45      matt cpsid(register_t psw)
    345  1.45      matt {
    346  1.49      matt #ifdef _ARM_ARCH_6
    347  1.45      matt 	register_t oldpsw;
    348  1.45      matt 	if (!__builtin_constant_p(psw))
    349  1.45      matt 		return disable_interrupts(psw);
    350  1.45      matt 
    351  1.45      matt 	__asm("mrs	%0, cpsr" : "=r"(oldpsw));
    352  1.45      matt 	switch (psw & (I32_bit|F32_bit)) {
    353  1.45      matt 	case I32_bit:		__asm("cpsid\ti"); break;
    354  1.45      matt 	case F32_bit:		__asm("cpsid\tf"); break;
    355  1.45      matt 	case I32_bit|F32_bit:	__asm("cpsid\tif"); break;
    356  1.45      matt 	}
    357  1.45      matt 	return oldpsw;
    358  1.48     cliff #else
    359  1.48     cliff 	return disable_interrupts(psw);
    360  1.48     cliff #endif
    361  1.45      matt }
    362  1.45      matt 
    363  1.15   thorpej #else /* ! __PROG32 */
    364  1.15   thorpej #define	disable_interrupts(mask)					\
    365  1.15   thorpej 	(set_r15((mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE),		\
    366  1.15   thorpej 		 (mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE)))
    367  1.15   thorpej 
    368  1.15   thorpej #define	enable_interrupts(mask)						\
    369  1.15   thorpej 	(set_r15((mask) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE), 0))
    370  1.15   thorpej 
    371  1.15   thorpej #define	restore_interrupts(old_r15)					\
    372  1.15   thorpej 	(set_r15((R15_IRQ_DISABLE | R15_FIQ_DISABLE),			\
    373  1.15   thorpej 		 (old_r15) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE)))
    374  1.15   thorpej #endif /* __PROG32 */
    375  1.15   thorpej 
    376  1.15   thorpej #ifdef __PROG32
    377  1.15   thorpej /* Functions to manipulate the CPSR. */
    378  1.32       uwe u_int	SetCPSR(u_int, u_int);
    379  1.15   thorpej u_int	GetCPSR(void);
    380  1.15   thorpej #else
    381  1.15   thorpej /* Functions to manipulate the processor control bits in r15. */
    382  1.32       uwe u_int	set_r15(u_int, u_int);
    383  1.15   thorpej u_int	get_r15(void);
    384  1.15   thorpej #endif /* __PROG32 */
    385   1.1   reinoud 
    386   1.1   reinoud 
    387   1.1   reinoud /*
    388   1.1   reinoud  * CPU functions from locore.S
    389   1.1   reinoud  */
    390   1.1   reinoud 
    391  1.58      matt void cpu_reset		(void) __dead;
    392  1.14   thorpej 
    393  1.14   thorpej /*
    394  1.14   thorpej  * Cache info variables.
    395  1.14   thorpej  */
    396  1.67      matt #define	CACHE_TYPE_VIVT		0
    397  1.67      matt #define	CACHE_TYPE_xxPT		1
    398  1.67      matt #define	CACHE_TYPE_VIPT		1
    399  1.67      matt #define	CACHE_TYPE_PIxx		2
    400  1.67      matt #define	CACHE_TYPE_PIPT		3
    401  1.14   thorpej 
    402  1.14   thorpej /* PRIMARY CACHE VARIABLES */
    403  1.58      matt struct arm_cache_info {
    404  1.58      matt 	u_int icache_size;
    405  1.58      matt 	u_int icache_line_size;
    406  1.58      matt 	u_int icache_ways;
    407  1.68      matt 	u_int icache_way_size;
    408  1.58      matt 	u_int icache_sets;
    409  1.58      matt 
    410  1.58      matt 	u_int dcache_size;
    411  1.58      matt 	u_int dcache_line_size;
    412  1.58      matt 	u_int dcache_ways;
    413  1.68      matt 	u_int dcache_way_size;
    414  1.58      matt 	u_int dcache_sets;
    415  1.58      matt 
    416  1.69      matt 	uint8_t cache_type;
    417  1.58      matt 	bool cache_unified;
    418  1.67      matt 	uint8_t icache_type;
    419  1.67      matt 	uint8_t dcache_type;
    420  1.58      matt };
    421  1.58      matt 
    422  1.58      matt extern u_int arm_cache_prefer_mask;
    423  1.58      matt extern u_int arm_dcache_align;
    424  1.58      matt extern u_int arm_dcache_align_mask;
    425   1.1   reinoud 
    426  1.58      matt extern struct arm_cache_info arm_pcache;
    427  1.58      matt extern struct arm_cache_info arm_scache;
    428   1.1   reinoud #endif	/* _KERNEL */
    429  1.55  christos 
    430  1.55  christos #if defined(_KERNEL) || defined(_KMEMUSER)
    431  1.55  christos /*
    432  1.55  christos  * Miscellany
    433  1.55  christos  */
    434  1.55  christos 
    435  1.55  christos int get_pc_str_offset	(void);
    436  1.55  christos 
    437  1.55  christos /*
    438  1.55  christos  * Functions to manipulate cpu r13
    439  1.55  christos  * (in arm/arm32/setstack.S)
    440  1.55  christos  */
    441  1.55  christos 
    442  1.55  christos void set_stackptr	(u_int, u_int);
    443  1.55  christos u_int get_stackptr	(u_int);
    444  1.55  christos 
    445  1.55  christos #endif /* _KERNEL || _KMEMUSER */
    446  1.55  christos 
    447  1.65      matt #endif	/* _ARM_CPUFUNC_H_ */
    448   1.1   reinoud 
    449   1.1   reinoud /* End of cpufunc.h */
    450