xref: /netbsd-src/sys/arch/arm/include/armreg.h (revision c9219daa3bb1c69c43af7a27070ee85807486b0d)
1*c9219daaSryo /*	$NetBSD: armreg.h,v 1.136 2022/12/03 20:24:21 ryo Exp $	*/
21178bf42Sbjh21 
31178bf42Sbjh21 /*
41178bf42Sbjh21  * Copyright (c) 1998, 2001 Ben Harris
51178bf42Sbjh21  * Copyright (c) 1994-1996 Mark Brinicombe.
61178bf42Sbjh21  * Copyright (c) 1994 Brini.
71178bf42Sbjh21  * All rights reserved.
81178bf42Sbjh21  *
91178bf42Sbjh21  * This code is derived from software written for Brini by Mark Brinicombe
101178bf42Sbjh21  *
111178bf42Sbjh21  * Redistribution and use in source and binary forms, with or without
121178bf42Sbjh21  * modification, are permitted provided that the following conditions
131178bf42Sbjh21  * are met:
141178bf42Sbjh21  * 1. Redistributions of source code must retain the above copyright
151178bf42Sbjh21  *    notice, this list of conditions and the following disclaimer.
161178bf42Sbjh21  * 2. Redistributions in binary form must reproduce the above copyright
171178bf42Sbjh21  *    notice, this list of conditions and the following disclaimer in the
181178bf42Sbjh21  *    documentation and/or other materials provided with the distribution.
191178bf42Sbjh21  * 3. All advertising materials mentioning features or use of this software
201178bf42Sbjh21  *    must display the following acknowledgement:
211178bf42Sbjh21  *	This product includes software developed by Brini.
221178bf42Sbjh21  * 4. The name of the company nor the name of the author may be used to
231178bf42Sbjh21  *    endorse or promote products derived from this software without specific
241178bf42Sbjh21  *    prior written permission.
251178bf42Sbjh21  *
261178bf42Sbjh21  * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
271178bf42Sbjh21  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
281178bf42Sbjh21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
291178bf42Sbjh21  * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
301178bf42Sbjh21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
311178bf42Sbjh21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
321178bf42Sbjh21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331178bf42Sbjh21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341178bf42Sbjh21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351178bf42Sbjh21  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361178bf42Sbjh21  * SUCH DAMAGE.
371178bf42Sbjh21  */
381178bf42Sbjh21 
391178bf42Sbjh21 #ifndef _ARM_ARMREG_H
401178bf42Sbjh21 #define _ARM_ARMREG_H
411178bf42Sbjh21 
422c083542Sryo #include <arm/cputypes.h>
432c083542Sryo 
44fe33aa27Sryo #ifdef __arm__
45fe33aa27Sryo 
461178bf42Sbjh21 /*
471178bf42Sbjh21  * ARM Process Status Register
481178bf42Sbjh21  *
491178bf42Sbjh21  * The picture in the ARM manuals looks like this:
501178bf42Sbjh21  *       3 3 2 2 2 2
511178bf42Sbjh21  *       1 0 9 8 7 6                                   8 7 6 5 4       0
521178bf42Sbjh21  *      +-+-+-+-+-+-------------------------------------+-+-+-+---------+
531178bf42Sbjh21  *      |N|Z|C|V|Q|                reserved             |I|F|T|M M M M M|
541178bf42Sbjh21  *      | | | | | |                                     | | | |4 3 2 1 0|
551178bf42Sbjh21  *      +-+-+-+-+-+-------------------------------------+-+-+-+---------+
561178bf42Sbjh21  */
571178bf42Sbjh21 
581178bf42Sbjh21 #define	PSR_FLAGS 0xf0000000	/* flags */
591178bf42Sbjh21 #define PSR_N_bit (1 << 31)	/* negative */
601178bf42Sbjh21 #define PSR_Z_bit (1 << 30)	/* zero */
611178bf42Sbjh21 #define PSR_C_bit (1 << 29)	/* carry */
621178bf42Sbjh21 #define PSR_V_bit (1 << 28)	/* overflow */
631178bf42Sbjh21 
641178bf42Sbjh21 #define PSR_Q_bit (1 << 27)	/* saturation */
655f4d3632Smatt #define PSR_IT1_bit (1 << 26)
665f4d3632Smatt #define PSR_IT0_bit (1 << 25)
675f4d3632Smatt #define PSR_J_bit (1 << 24)	/* Jazelle mode */
685f4d3632Smatt #define PSR_GE_bits (15 << 16)	/* SIMD GE bits */
695f4d3632Smatt #define PSR_IT7_bit (1 << 15)
705f4d3632Smatt #define PSR_IT6_bit (1 << 14)
715f4d3632Smatt #define PSR_IT5_bit (1 << 13)
725f4d3632Smatt #define PSR_IT4_bit (1 << 12)
735f4d3632Smatt #define PSR_IT3_bit (1 << 11)
745f4d3632Smatt #define PSR_IT2_bit (1 << 10)
755f4d3632Smatt #define PSR_E_BIT (1 << 9)	/* Endian state */
765f4d3632Smatt #define PSR_A_BIT (1 << 8)	/* Async abort disable */
771178bf42Sbjh21 
781178bf42Sbjh21 #define I32_bit (1 << 7)	/* IRQ disable */
791178bf42Sbjh21 #define F32_bit (1 << 6)	/* FIQ disable */
8004ddff9cSmatt #define IF32_bits (3 << 6)	/* IRQ/FIQ disable */
811178bf42Sbjh21 
821178bf42Sbjh21 #define PSR_T_bit (1 << 5)	/* Thumb state */
831178bf42Sbjh21 
841178bf42Sbjh21 #define PSR_MODE	0x0000001f	/* mode mask */
851178bf42Sbjh21 #define PSR_USR32_MODE	0x00000010
861178bf42Sbjh21 #define PSR_FIQ32_MODE	0x00000011
871178bf42Sbjh21 #define PSR_IRQ32_MODE	0x00000012
881178bf42Sbjh21 #define PSR_SVC32_MODE	0x00000013
895aeff471Smatt #define PSR_MON32_MODE	0x00000016
901178bf42Sbjh21 #define PSR_ABT32_MODE	0x00000017
917eecb733Smatt #define PSR_HYP32_MODE	0x0000001a
921178bf42Sbjh21 #define PSR_UND32_MODE	0x0000001b
931178bf42Sbjh21 #define PSR_SYS32_MODE	0x0000001f
941178bf42Sbjh21 #define PSR_32_MODE	0x00000010
951178bf42Sbjh21 
961178bf42Sbjh21 #define R15_FLAGS	0xf0000000
971178bf42Sbjh21 #define R15_FLAG_N	0x80000000
981178bf42Sbjh21 #define R15_FLAG_Z	0x40000000
991178bf42Sbjh21 #define R15_FLAG_C	0x20000000
1001178bf42Sbjh21 #define R15_FLAG_V	0x10000000
1011178bf42Sbjh21 
1021178bf42Sbjh21 /*
1031178bf42Sbjh21  * Co-processor 15:  The system control co-processor.
1041178bf42Sbjh21  */
1051178bf42Sbjh21 
1061178bf42Sbjh21 #define ARM_CP15_CPU_ID		0
1071178bf42Sbjh21 
108d625d3f3Srkujawa /* CPUID registers */
10949daa07bSmatt #define ARM_ISA3_SYNCHPRIM_MASK	0x0000f000
11049daa07bSmatt #define ARM_ISA4_SYNCHPRIM_MASK	0x00f00000
11149daa07bSmatt #define ARM_ISA3_SYNCHPRIM_LDREX	0x10	// LDREX
11249daa07bSmatt #define ARM_ISA3_SYNCHPRIM_LDREXPLUS	0x13	// +CLREX/LDREXB/LDREXH
11349daa07bSmatt #define ARM_ISA3_SYNCHPRIM_LDREXD	0x20	// +LDREXD
114d625d3f3Srkujawa #define ARM_PFR0_THUMBEE_MASK	0x0000f000
11523b9975cSmatt #define ARM_PFR1_GTIMER_MASK	0x000f0000
11623b9975cSmatt #define ARM_PFR1_VIRT_MASK	0x0000f000
1178a300ad3Smatt #define ARM_PFR1_SEC_MASK	0x000000f0
1181178bf42Sbjh21 
11963e3c57fSmatt /* Media and VFP Feature registers */
12063e3c57fSmatt #define ARM_MVFR0_ROUNDING_MASK		0xf0000000
12163e3c57fSmatt #define ARM_MVFR0_SHORTVEC_MASK		0x0f000000
12263e3c57fSmatt #define ARM_MVFR0_SQRT_MASK		0x00f00000
12363e3c57fSmatt #define ARM_MVFR0_DIVIDE_MASK		0x000f0000
12463e3c57fSmatt #define ARM_MVFR0_EXCEPT_MASK		0x0000f000
12563e3c57fSmatt #define ARM_MVFR0_DFLOAT_MASK		0x00000f00
12663e3c57fSmatt #define ARM_MVFR0_SFLOAT_MASK		0x000000f0
12763e3c57fSmatt #define ARM_MVFR0_ASIMD_MASK		0x0000000f
12863e3c57fSmatt #define ARM_MVFR1_ASIMD_FMACS_MASK	0xf0000000
12963e3c57fSmatt #define ARM_MVFR1_VFP_HPFP_MASK		0x0f000000
13063e3c57fSmatt #define ARM_MVFR1_ASIMD_HPFP_MASK	0x00f00000
13163e3c57fSmatt #define ARM_MVFR1_ASIMD_SPFP_MASK	0x000f0000
13263e3c57fSmatt #define ARM_MVFR1_ASIMD_INT_MASK	0x0000f000
13363e3c57fSmatt #define ARM_MVFR1_ASIMD_LDST_MASK	0x00000f00
13463e3c57fSmatt #define ARM_MVFR1_D_NAN_MASK		0x000000f0
13563e3c57fSmatt #define ARM_MVFR1_FTZ_MASK		0x0000000f
13663e3c57fSmatt 
1371178bf42Sbjh21 /* ARM3-specific coprocessor 15 registers */
1381178bf42Sbjh21 #define ARM3_CP15_FLUSH		1
1391178bf42Sbjh21 #define ARM3_CP15_CONTROL	2
1401178bf42Sbjh21 #define ARM3_CP15_CACHEABLE	3
1411178bf42Sbjh21 #define ARM3_CP15_UPDATEABLE	4
1421178bf42Sbjh21 #define ARM3_CP15_DISRUPTIVE	5
1431178bf42Sbjh21 
1441178bf42Sbjh21 /* ARM3 Control register bits */
1451178bf42Sbjh21 #define ARM3_CTL_CACHE_ON	0x00000001
1461178bf42Sbjh21 #define ARM3_CTL_SHARED		0x00000002
1471178bf42Sbjh21 #define ARM3_CTL_MONITOR	0x00000004
1481178bf42Sbjh21 
1491178bf42Sbjh21 /*
1501178bf42Sbjh21  * Post-ARM3 CP15 registers:
1516d66c469Sthorpej  *
1526d66c469Sthorpej  *	1	Control register
1536d66c469Sthorpej  *
1546d66c469Sthorpej  *	2	Translation Table Base
1556d66c469Sthorpej  *
1566d66c469Sthorpej  *	3	Domain Access Control
1576d66c469Sthorpej  *
1586d66c469Sthorpej  *	4	Reserved
1596d66c469Sthorpej  *
1606d66c469Sthorpej  *	5	Fault Status
1616d66c469Sthorpej  *
1626d66c469Sthorpej  *	6	Fault Address
1636d66c469Sthorpej  *
1646d66c469Sthorpej  *	7	Cache/write-buffer Control
1656d66c469Sthorpej  *
1666d66c469Sthorpej  *	8	TLB Control
1676d66c469Sthorpej  *
1686d66c469Sthorpej  *	9	Cache Lockdown
1696d66c469Sthorpej  *
1706d66c469Sthorpej  *	10	TLB Lockdown
1716d66c469Sthorpej  *
1726d66c469Sthorpej  *	11	Reserved
1736d66c469Sthorpej  *
1746d66c469Sthorpej  *	12	Reserved
1756d66c469Sthorpej  *
1766d66c469Sthorpej  *	13	Process ID (for FCSE)
1776d66c469Sthorpej  *
1786d66c469Sthorpej  *	14	Reserved
1796d66c469Sthorpej  *
1806d66c469Sthorpej  *	15	Implementation Dependent
1811178bf42Sbjh21  */
1826d66c469Sthorpej 
1831178bf42Sbjh21 /* Some of the definitions below need cleaning up for V3/V4 architectures */
1841178bf42Sbjh21 
1851178bf42Sbjh21 /* CPU control register (CP15 register 1) */
1861178bf42Sbjh21 #define CPU_CONTROL_MMU_ENABLE	0x00000001 /* M: MMU/Protection unit enable */
1871178bf42Sbjh21 #define CPU_CONTROL_AFLT_ENABLE	0x00000002 /* A: Alignment fault enable */
1881178bf42Sbjh21 #define CPU_CONTROL_DC_ENABLE	0x00000004 /* C: IDC/DC enable */
1891178bf42Sbjh21 #define CPU_CONTROL_WBUF_ENABLE 0x00000008 /* W: Write buffer enable */
1901178bf42Sbjh21 #define CPU_CONTROL_32BP_ENABLE 0x00000010 /* P: 32-bit exception handlers */
1911178bf42Sbjh21 #define CPU_CONTROL_32BD_ENABLE 0x00000020 /* D: 32-bit addressing */
1921178bf42Sbjh21 #define CPU_CONTROL_LABT_ENABLE 0x00000040 /* L: Late abort enable */
1931178bf42Sbjh21 #define CPU_CONTROL_BEND_ENABLE 0x00000080 /* B: Big-endian mode */
1941178bf42Sbjh21 #define CPU_CONTROL_SYST_ENABLE 0x00000100 /* S: System protection bit */
1951178bf42Sbjh21 #define CPU_CONTROL_ROM_ENABLE	0x00000200 /* R: ROM protection bit */
1961178bf42Sbjh21 #define CPU_CONTROL_CPCLK	0x00000400 /* F: Implementation defined */
197656513acSmatt #define CPU_CONTROL_SWP_ENABLE	0x00000400 /* SW: SWP{B} perform normally. */
1981178bf42Sbjh21 #define CPU_CONTROL_BPRD_ENABLE 0x00000800 /* Z: Branch prediction enable */
1991178bf42Sbjh21 #define CPU_CONTROL_IC_ENABLE   0x00001000 /* I: IC enable */
2001178bf42Sbjh21 #define CPU_CONTROL_VECRELOC	0x00002000 /* V: Vector relocation */
2011178bf42Sbjh21 #define CPU_CONTROL_ROUNDROBIN	0x00004000 /* RR: Predictable replacement */
2021178bf42Sbjh21 #define CPU_CONTROL_V4COMPAT	0x00008000 /* L4: ARMv4 compat LDR R15 etc */
20349daa07bSmatt #define CPU_CONTROL_HA_ENABLE	0x00020000 /* HA: Hardware Access flag enable */
20449daa07bSmatt #define CPU_CONTROL_WXN_ENABLE	0x00080000 /* WXN: Write Execute Never */
20549daa07bSmatt #define CPU_CONTROL_UWXN_ENABLE	0x00100000 /* UWXN: User Write eXecute Never */
2064886aa3dSmatt #define CPU_CONTROL_FI_ENABLE	0x00200000 /* FI: Low interrupt latency */
207a652e1f5Sbsh #define CPU_CONTROL_UNAL_ENABLE	0x00400000 /* U: unaligned data access */
208a652e1f5Sbsh #define CPU_CONTROL_XP_ENABLE	0x00800000 /* XP: extended page table */
209d5f7715cSbsh #define	CPU_CONTROL_V_ENABLE	0x01000000 /* VE: Interrupt vectors enable */
210d5f7715cSbsh #define	CPU_CONTROL_EX_BEND	0x02000000 /* EE: exception endianness */
211d5f7715cSbsh #define	CPU_CONTROL_NMFI	0x08000000 /* NMFI: Non maskable FIQ */
212d5f7715cSbsh #define	CPU_CONTROL_TR_ENABLE	0x10000000 /* TRE: */
213d5f7715cSbsh #define	CPU_CONTROL_AF_ENABLE	0x20000000 /* AFE: Access flag enable */
214d5f7715cSbsh #define	CPU_CONTROL_TE_ENABLE	0x40000000 /* TE: Thumb Exception enable */
2151178bf42Sbjh21 
2161178bf42Sbjh21 #define CPU_CONTROL_IDC_ENABLE	CPU_CONTROL_DC_ENABLE
2171178bf42Sbjh21 
218c872068cSmatt /* ARMv6/ARMv7 Co-Processor Access Control Register (CP15, 0, c1, c0, 2) */
219c872068cSmatt #define	CPACR_V7_ASEDIS		0x80000000 /* Disable Advanced SIMD Ext. */
220c872068cSmatt #define	CPACR_V7_D32DIS		0x40000000 /* Disable VFP regs 15-31 */
221c872068cSmatt #define	CPACR_CPn(n)		(3 << (2*n))
222c872068cSmatt #define	CPACR_NOACCESS		0 /* reset value */
223c872068cSmatt #define	CPACR_PRIVED		1 /* Privileged mode access */
224c872068cSmatt #define	CPACR_RESERVED		2
225c872068cSmatt #define	CPACR_ALL		3 /* Privileged and User mode access */
226c872068cSmatt 
2279fe65634Smatt /* ARMv6/ARMv7 Non-Secure Access Control Register (CP15, 0, c1, c1, 2) */
2289fe65634Smatt #define NSACR_SMP		0x00040000 /* ACTRL.SMP is writeable (!A8) */
2299fe65634Smatt #define NSACR_L2ERR		0x00020000 /* L2ECTRL is writeable (!A8) */
2309fe65634Smatt #define NSACR_ASEDIS		0x00008000 /* Deny Advanced SIMD Ext. */
2319fe65634Smatt #define NSACR_D32DIS		0x00004000 /* Deny VFP regs 15-31 */
2329fe65634Smatt #define NSACR_CPn(n)		(1 << (n)) /* NonSecure access allowed */
2339fe65634Smatt 
234ee03b21dSskrll /* ARM11x6 Auxiliary Control Register (CP15 register 1, opcode2 1) */
235ee03b21dSskrll #define	ARM11X6_AUXCTL_RS	0x00000001 /* return stack */
236ee03b21dSskrll #define	ARM11X6_AUXCTL_DB	0x00000002 /* dynamic branch prediction */
237ee03b21dSskrll #define	ARM11X6_AUXCTL_SB	0x00000004 /* static branch prediction */
238ee03b21dSskrll #define	ARM11X6_AUXCTL_TR	0x00000008 /* MicroTLB replacement strat. */
239ee03b21dSskrll #define	ARM11X6_AUXCTL_EX	0x00000010 /* exclusive L1/L2 cache */
240ee03b21dSskrll #define	ARM11X6_AUXCTL_RA	0x00000020 /* clean entire cache disable */
241ee03b21dSskrll #define	ARM11X6_AUXCTL_RV	0x00000040 /* block transfer cache disable */
242ee03b21dSskrll #define	ARM11X6_AUXCTL_CZ	0x00000080 /* restrict cache size */
243ee03b21dSskrll 
244c263f806Sskrll /* ARM1136 Auxiliary Control Register (CP15 register 1, opcode2 1) */
245c263f806Sskrll #define ARM1136_AUXCTL_PFI	0x80000000 /* PFI: partial FI mode. */
246c263f806Sskrll 					   /* This is an undocumented flag
247c263f806Sskrll 					    * used to work around a cache bug
248c263f806Sskrll 					    * in r0 steppings. See errata
249c263f806Sskrll 					    * 364296.
250c263f806Sskrll 					    */
251ee03b21dSskrll /* ARM1176 Auxiliary Control Register (CP15 register 1, opcode2 1) */
252ee03b21dSskrll #define	ARM1176_AUXCTL_PHD	0x10000000 /* inst. prefetch halting disable */
253ee03b21dSskrll #define	ARM1176_AUXCTL_BFD	0x20000000 /* branch folding disable */
254ee03b21dSskrll #define	ARM1176_AUXCTL_FSD	0x40000000 /* force speculative ops disable */
255ee03b21dSskrll #define	ARM1176_AUXCTL_FIO	0x80000000 /* low intr latency override */
2564886aa3dSmatt 
25748e1ff02Sskrll /* XScale Auxiliary Control Register (CP15 register 1, opcode2 1) */
258bc6522fbSthorpej #define	XSCALE_AUXCTL_K		0x00000001 /* dis. write buffer coalescing */
259bc6522fbSthorpej #define	XSCALE_AUXCTL_P		0x00000002 /* ECC protect page table access */
260bc6522fbSthorpej #define	XSCALE_AUXCTL_MD_WB_RA	0x00000000 /* mini-D$ wb, read-allocate */
261bc6522fbSthorpej #define	XSCALE_AUXCTL_MD_WB_RWA	0x00000010 /* mini-D$ wb, read/write-allocate */
262d533e315Sthorpej #define	XSCALE_AUXCTL_MD_WT	0x00000020 /* mini-D$ wt, read-allocate */
263d533e315Sthorpej #define	XSCALE_AUXCTL_MD_MASK	0x00000030
264bc6522fbSthorpej 
26548e1ff02Sskrll /* ARM11 MPCore Auxiliary Control Register (CP15 register 1, opcode2 1) */
266d5f7715cSbsh #define	MPCORE_AUXCTL_RS	0x00000001 /* return stack */
267d5f7715cSbsh #define	MPCORE_AUXCTL_DB	0x00000002 /* dynamic branch prediction */
268d5f7715cSbsh #define	MPCORE_AUXCTL_SB	0x00000004 /* static branch prediction */
269d5f7715cSbsh #define	MPCORE_AUXCTL_F 	0x00000008 /* instruction folding enable */
270d5f7715cSbsh #define	MPCORE_AUXCTL_EX	0x00000010 /* exclusive L1/L2 cache */
271d5f7715cSbsh #define	MPCORE_AUXCTL_SA	0x00000020 /* SMP/AMP */
272d5f7715cSbsh 
2737ba300a9Sandvar /* Marvell PJ4B Auxiliary Control Register (CP15.0.R1.c0.1) */
274637c81b6Shsuenaga #define PJ4B_AUXCTL_FW		__BIT(0)   /* Cache and TLB updates broadcast */
275637c81b6Shsuenaga #define PJ4B_AUXCTL_SMPNAMP	__BIT(6)   /* 0 = AMP, 1 = SMP */
276637c81b6Shsuenaga #define PJ4B_AUXCTL_L1PARITY	__BIT(9)   /* L1 parity checking */
277637c81b6Shsuenaga 
278637c81b6Shsuenaga /* Marvell PJ4B Auxialiary Function Modes Control 0 (CP15.1.R15.c2.0) */
279637c81b6Shsuenaga #define PJ4B_AUXFMC0_L2EN	__BIT(0)  /* Tightly-Coupled L2 cache enable */
280637c81b6Shsuenaga #define PJ4B_AUXFMC0_SMPNAMP	__BIT(1)  /* 0 = AMP, 1 = SMP */
281637c81b6Shsuenaga #define PJ4B_AUXFMC0_L1PARITY	__BIT(2)  /* alias of PJ4B_AUXCTL_L1PARITY */
282637c81b6Shsuenaga #define PJ4B_AUXFMC0_DCSLFD	__BIT(2)  /* Disable DC Speculative linefill */
283637c81b6Shsuenaga #define PJ4B_AUXFMC0_FW		__BIT(8)  /* alias of PJ4B_AUXCTL_FW*/
284d625d3f3Srkujawa 
285bc1fdbc7Sskrll /* Cortex-A5 Auxiliary Control Register (CP15 register 1, opcode 1) */
286bc1fdbc7Sskrll #define	CORTEXA5_ACTLR_FW	__BIT(0)
287bc1fdbc7Sskrll #define	CORTEXA5_ACTLR_SMP	__BIT(6)  /* Inner Cache Shared is cacheable */
288bc1fdbc7Sskrll #define	CORTEXA5_ACTLR_EXCL	__BIT(7)  /* Exclusive L1/L2 cache control */
289bc1fdbc7Sskrll 
290bc1fdbc7Sskrll /* Cortex-A7 Auxiliary Control Register (CP15 register 1, opcode 1) */
291bc1fdbc7Sskrll #define	CORTEXA7_ACTLR_L1ALIAS	__BIT(0)  /* Enables L1 cache alias checks */
292bc1fdbc7Sskrll #define	CORTEXA7_ACTLR_L2EN	__BIT(1)  /* Enables L2 cache */
293bc1fdbc7Sskrll #define	CORTEXA7_ACTLR_SMP	__BIT(6)  /* SMP */
294bc1fdbc7Sskrll 
295bc1fdbc7Sskrll /* Cortex-A8 Auxiliary Control Register (CP15 register 1, opcode 1) */
296bc1fdbc7Sskrll #define	CORTEXA8_ACTLR_L1ALIAS	__BIT(0)  /* Enables L1 cache alias checks */
297bc1fdbc7Sskrll #define	CORTEXA8_ACTLR_L2EN	__BIT(1)  /* Enables L2 cache */
298bc1fdbc7Sskrll 
299977dafe5Smatt /* Cortex-A9 Auxiliary Control Register (CP15 register 1, opcode 1) */
300977dafe5Smatt #define	CORTEXA9_AUXCTL_FW	0x00000001 /* Cache and TLB updates broadcast */
301ecb438fbSmatt #define	CORTEXA9_AUXCTL_L2PE	0x00000002 /* Prefetch hint enable */
302ecb438fbSmatt #define	CORTEXA9_AUXCTL_L1PE	0x00000004 /* Data prefetch hint enable */
303977dafe5Smatt #define	CORTEXA9_AUXCTL_WR_ZERO	0x00000008 /* Ena. write full line of 0s mode */
304977dafe5Smatt #define	CORTEXA9_AUXCTL_SMP	0x00000040 /* Coherency is active */
305977dafe5Smatt #define	CORTEXA9_AUXCTL_EXCL	0x00000080 /* Exclusive cache bit */
306977dafe5Smatt #define	CORTEXA9_AUXCTL_ONEWAY	0x00000100 /* Allocate in on cache way only */
307977dafe5Smatt #define	CORTEXA9_AUXCTL_PARITY	0x00000200 /* Support parity checking */
308977dafe5Smatt 
30918f77e70Sskrll /* Cortex-A15 Auxiliary Control Register (CP15 register 1, opcode 1) */
31018f77e70Sskrll #define	CORTEXA15_ACTLR_BTB	__BIT(0)  /* Cache and TLB updates broadcast */
31118f77e70Sskrll #define	CORTEXA15_ACTLR_SMP	__BIT(6)  /* SMP */
31214a3507fSskrll #define	CORTEXA15_ACTLR_IOBEU	__BIT(15) /* In order issue in Branch Exec Unit */
313bc1fdbc7Sskrll #define	CORTEXA15_ACTLR_SDEH	__BIT(31) /* snoop-delayed exclusive handling */
31418f77e70Sskrll 
3158a414bd1Sjmcneill /* Cortex-A17 Auxiliary Control Register (CP15 register 1, opcode 1) */
3168a414bd1Sjmcneill #define	CORTEXA17_ACTLR_SMP	__BIT(6)  /* SMP */
3178a414bd1Sjmcneill #define	CORTEXA17_ACTLR_ASSE	__BIT(3)  /* ACE STREX Signaling Enable */
3188a414bd1Sjmcneill #define	CORTEXA17_ACTLR_L2PF	__BIT(2)  /* Enable L2 prefetch */
3198a414bd1Sjmcneill #define	CORTEXA17_ACTLR_L1PF	__BIT(1)  /* Enable L1 prefetch */
3208a414bd1Sjmcneill 
3214f2a5779Skiyohara /* Marvell Feroceon Extra Features Register (CP15 register 1, opcode2 0) */
3224f2a5779Skiyohara #define FC_DCACHE_REPL_LOCK	0x80000000 /* Replace DCache Lock */
3234f2a5779Skiyohara #define FC_DCACHE_STREAM_EN	0x20000000 /* DCache Streaming Switch */
3244f2a5779Skiyohara #define FC_WR_ALLOC_EN		0x10000000 /* Enable Write Allocate */
3254f2a5779Skiyohara #define FC_L2_PREF_DIS		0x01000000 /* L2 Cache Prefetch Disable */
3264f2a5779Skiyohara #define FC_L2_INV_EVICT_LINE	0x00800000 /* L2 Invalidates Uncorrectable Error Line Eviction */
3274f2a5779Skiyohara #define FC_L2CACHE_EN		0x00400000 /* L2 enable */
3284f2a5779Skiyohara #define FC_ICACHE_REPL_LOCK	0x00080000 /* Replace ICache Lock */
3294f2a5779Skiyohara #define FC_GLOB_HIST_REG_EN	0x00040000 /* Branch Global History Register Enable */
3304f2a5779Skiyohara #define FC_BRANCH_TARG_BUF_DIS	0x00020000 /* Branch Target Buffer Disable */
3314f2a5779Skiyohara #define FC_L1_PAR_ERR_EN	0x00010000 /* L1 Parity Error Enable */
3324f2a5779Skiyohara 
33351b80a6cSmatt /* Cache type register definitions 0 */
33451b80a6cSmatt #define	CPU_CT_FORMAT(x)	(((x) >> 29) & 0x7)	/* reg format */
335959181a8Sthorpej #define	CPU_CT_ISIZE(x)		((x) & 0xfff)		/* I$ info */
336959181a8Sthorpej #define	CPU_CT_DSIZE(x)		(((x) >> 12) & 0xfff)	/* D$ info */
337959181a8Sthorpej #define	CPU_CT_S		(1U << 24)		/* split cache */
338959181a8Sthorpej #define	CPU_CT_CTYPE(x)		(((x) >> 25) & 0xf)	/* cache type */
339959181a8Sthorpej 
340959181a8Sthorpej #define	CPU_CT_CTYPE_WT		0	/* write-through */
341959181a8Sthorpej #define	CPU_CT_CTYPE_WB1	1	/* write-back, clean w/ read */
342959181a8Sthorpej #define	CPU_CT_CTYPE_WB2	2	/* w/b, clean w/ cp15,7 */
343959181a8Sthorpej #define	CPU_CT_CTYPE_WB6	6	/* w/b, cp15,7, lockdown fmt A */
344959181a8Sthorpej #define	CPU_CT_CTYPE_WB7	7	/* w/b, cp15,7, lockdown fmt B */
34551b80a6cSmatt #define	CPU_CT_CTYPE_WB14	14	/* w/b, cp15,7, lockdown fmt C */
346959181a8Sthorpej 
347959181a8Sthorpej #define	CPU_CT_xSIZE_LEN(x)	((x) & 0x3)		/* line size */
348959181a8Sthorpej #define	CPU_CT_xSIZE_M		(1U << 2)		/* multiplier */
349959181a8Sthorpej #define	CPU_CT_xSIZE_ASSOC(x)	(((x) >> 3) & 0x7)	/* associativity */
350959181a8Sthorpej #define	CPU_CT_xSIZE_SIZE(x)	(((x) >> 6) & 0x7)	/* size */
351825088edSmatt #define	CPU_CT_xSIZE_P		(1U << 11)		/* need to page-color */
3521178bf42Sbjh21 
35351b80a6cSmatt /* format 4 definitions */
35451b80a6cSmatt #define	CPU_CT4_ILINE(x)	((x) & 0xf)		/* I$ line size */
35551b80a6cSmatt #define	CPU_CT4_DLINE(x)	(((x) >> 16) & 0xf)	/* D$ line size */
35651b80a6cSmatt #define	CPU_CT4_L1IPOLICY(x)	(((x) >> 14) & 0x3)	/* I$ policy */
35703bbd14bSmatt #define	CPU_CT4_L1_AIVIVT	1			/* ASID tagged VIVT */
35851b80a6cSmatt #define	CPU_CT4_L1_VIPT		2			/* VIPT */
35903bbd14bSmatt #define	CPU_CT4_L1_PIPT		3			/* PIPT */
36003bbd14bSmatt #define	CPU_CT4_ERG(x)		(((x) >> 20) & 0xf)	/* Cache WriteBack Granule */
36103bbd14bSmatt #define	CPU_CT4_CWG(x)		(((x) >> 24) & 0xf)	/* Exclusive Resv. Granule */
36251b80a6cSmatt 
36351b80a6cSmatt /* Cache size identifaction register definitions 1, Rd, c0, c0, 0 */
36451b80a6cSmatt #define	CPU_CSID_CTYPE_WT	0x80000000	/* write-through avail */
36551b80a6cSmatt #define	CPU_CSID_CTYPE_WB	0x40000000	/* write-back avail */
36651b80a6cSmatt #define	CPU_CSID_CTYPE_RA	0x20000000	/* read-allocation avail */
36751b80a6cSmatt #define	CPU_CSID_CTYPE_WA	0x10000000	/* write-allocation avail */
3688497a955Smatt #define	CPU_CSID_NUMSETS(x)	(((x) >> 13) & 0x7fff)
36951b80a6cSmatt #define	CPU_CSID_ASSOC(x)	(((x) >> 3) & 0x1ff)
370ce2db8d3Smatt #define	CPU_CSID_LEN(x)		((x) & 0x07)
37151b80a6cSmatt 
37251b80a6cSmatt /* Cache size selection register definitions 2, Rd, c0, c0, 0 */
37351b80a6cSmatt #define	CPU_CSSR_L2		0x00000002
37451b80a6cSmatt #define	CPU_CSSR_L1		0x00000000
37551b80a6cSmatt #define	CPU_CSSR_InD		0x00000001
37651b80a6cSmatt 
3771178bf42Sbjh21 /* Fault status register definitions */
3781178bf42Sbjh21 
3791178bf42Sbjh21 #define FAULT_TYPE_MASK 0x0f
3801178bf42Sbjh21 #define FAULT_USER      0x10
3811178bf42Sbjh21 
3821178bf42Sbjh21 #define FAULT_WRTBUF_0  0x00 /* Vector Exception */
3831178bf42Sbjh21 #define FAULT_WRTBUF_1  0x02 /* Terminal Exception */
3841178bf42Sbjh21 #define FAULT_BUSERR_0  0x04 /* External Abort on Linefetch -- Section */
3851178bf42Sbjh21 #define FAULT_BUSERR_1  0x06 /* External Abort on Linefetch -- Page */
3861178bf42Sbjh21 #define FAULT_BUSERR_2  0x08 /* External Abort on Non-linefetch -- Section */
3871178bf42Sbjh21 #define FAULT_BUSERR_3  0x0a /* External Abort on Non-linefetch -- Page */
3881178bf42Sbjh21 #define FAULT_BUSTRNL1  0x0c /* External abort on Translation -- Level 1 */
3891178bf42Sbjh21 #define FAULT_BUSTRNL2  0x0e /* External abort on Translation -- Level 2 */
3901178bf42Sbjh21 #define FAULT_ALIGN_0   0x01 /* Alignment */
3911178bf42Sbjh21 #define FAULT_ALIGN_1   0x03 /* Alignment */
3921178bf42Sbjh21 #define FAULT_TRANS_S   0x05 /* Translation -- Section */
3931178bf42Sbjh21 #define FAULT_TRANS_P   0x07 /* Translation -- Page */
3941178bf42Sbjh21 #define FAULT_DOMAIN_S  0x09 /* Domain -- Section */
3951178bf42Sbjh21 #define FAULT_DOMAIN_P  0x0b /* Domain -- Page */
3961178bf42Sbjh21 #define FAULT_PERM_S    0x0d /* Permission -- Section */
3971178bf42Sbjh21 #define FAULT_PERM_P    0x0f /* Permission -- Page */
3981178bf42Sbjh21 
3997ff1a6efSmatt #define FAULT_LPAE	0x0200	/* (SW) used long descriptors */
4007ff1a6efSmatt #define FAULT_IMPRECISE	0x0400	/* Imprecise exception (XSCALE) */
4017ff1a6efSmatt #define FAULT_WRITE	0x0800	/* fault was due to write (ARMv6+) */
4027ff1a6efSmatt #define FAULT_EXT	0x1000	/* fault was due to external abort (ARMv6+) */
4037ff1a6efSmatt #define FAULT_CM	0x2000	/* fault was due to cache maintenance (ARMv7+) */
404336806ebSscw 
4051178bf42Sbjh21 /*
406d36a56b0Sthorpej  * Address of the vector page, low and high versions.
407d36a56b0Sthorpej  */
408a6b19137Sthorpej #define	ARM_VECTORS_LOW		0x00000000U
409a6b19137Sthorpej #define	ARM_VECTORS_HIGH	0xffff0000U
410d36a56b0Sthorpej 
411d36a56b0Sthorpej /*
4121178bf42Sbjh21  * ARM Instructions
4131178bf42Sbjh21  *
4141178bf42Sbjh21  *       3 3 2 2 2
4151178bf42Sbjh21  *       1 0 9 8 7                                                     0
4161178bf42Sbjh21  *      +-------+-------------------------------------------------------+
4174cbd24b2Swiz  *      | cond  |              instruction dependent                    |
4181178bf42Sbjh21  *      |c c c c|                                                       |
4191178bf42Sbjh21  *      +-------+-------------------------------------------------------+
4201178bf42Sbjh21  */
4211178bf42Sbjh21 
4221178bf42Sbjh21 #define INSN_SIZE		4		/* Always 4 bytes */
4231178bf42Sbjh21 #define INSN_COND_MASK		0xf0000000	/* Condition mask */
424f50530a0Smatt #define INSN_COND_EQ		0		/* Z == 1 */
425f50530a0Smatt #define INSN_COND_NE		1		/* Z == 0 */
426f50530a0Smatt #define INSN_COND_CS		2		/* C == 1 */
427f50530a0Smatt #define INSN_COND_CC		3		/* C == 0 */
428f50530a0Smatt #define INSN_COND_MI		4		/* N == 1 */
429f50530a0Smatt #define INSN_COND_PL		5		/* N == 0 */
430f50530a0Smatt #define INSN_COND_VS		6		/* V == 1 */
431f50530a0Smatt #define INSN_COND_VC		7		/* V == 0 */
432f50530a0Smatt #define INSN_COND_HI		8		/* C == 1 && Z == 0 */
433f50530a0Smatt #define INSN_COND_LS		9		/* C == 0 || Z == 1 */
434f50530a0Smatt #define INSN_COND_GE		10		/* N == V */
435f50530a0Smatt #define INSN_COND_LT		11		/* N != V */
436f50530a0Smatt #define INSN_COND_GT		12		/* Z == 0 && N == V */
437f50530a0Smatt #define INSN_COND_LE		13		/* Z == 1 || N != V */
438f50530a0Smatt #define INSN_COND_AL		14		/* Always condition */
4391178bf42Sbjh21 
440a64bc9e8Srearnsha #define THUMB_INSN_SIZE		2		/* Some are 4 bytes.  */
441a64bc9e8Srearnsha 
442825088edSmatt /*
443825088edSmatt  * Defines and such for arm11 Performance Monitor Counters (p15, c15, c12, 0)
444825088edSmatt  */
445825088edSmatt #define ARM11_PMCCTL_E		__BIT(0)	/* enable all three counters */
446825088edSmatt #define ARM11_PMCCTL_P		__BIT(1)	/* reset both Count Registers to zero */
447825088edSmatt #define ARM11_PMCCTL_C		__BIT(2)	/* reset the Cycle Counter Register to zero */
448825088edSmatt #define ARM11_PMCCTL_D		__BIT(3)	/* cycle count divide by 64 */
449825088edSmatt #define ARM11_PMCCTL_EC0	__BIT(4)	/* Enable Counter Register 0 interrupt */
450825088edSmatt #define ARM11_PMCCTL_EC1	__BIT(5)	/* Enable Counter Register 1 interrupt */
451825088edSmatt #define ARM11_PMCCTL_ECC	__BIT(6)	/* Enable Cycle Counter interrupt */
452825088edSmatt #define ARM11_PMCCTL_SBZa	__BIT(7)	/* UNP/SBZ */
453825088edSmatt #define ARM11_PMCCTL_CR0	__BIT(8)	/* Count Register 0 overflow flag */
454825088edSmatt #define ARM11_PMCCTL_CR1	__BIT(9)	/* Count Register 1 overflow flag */
455825088edSmatt #define ARM11_PMCCTL_CCR	__BIT(10)	/* Cycle Count Register overflow flag */
456825088edSmatt #define ARM11_PMCCTL_X		__BIT(11)	/* Enable Export of the events to the event bus */
457825088edSmatt #define ARM11_PMCCTL_EVT1	__BITS(19,12)	/* source of events for Count Register 1 */
458825088edSmatt #define ARM11_PMCCTL_EVT0	__BITS(27,20)	/* source of events for Count Register 0 */
459825088edSmatt #define ARM11_PMCCTL_SBZb	__BITS(31,28)	/* UNP/SBZ */
460825088edSmatt #define ARM11_PMCCTL_SBZ	\
461825088edSmatt 		(ARM11_PMCCTL_SBZa | ARM11_PMCCTL_SBZb)
462825088edSmatt 
463825088edSmatt #define	ARM11_PMCEVT_ICACHE_MISS	0	/* Instruction Cache Miss */
464825088edSmatt #define	ARM11_PMCEVT_ISTREAM_STALL	1	/* Instruction Stream Stall */
465825088edSmatt #define	ARM11_PMCEVT_IUTLB_MISS		2	/* Instruction uTLB Miss */
466825088edSmatt #define	ARM11_PMCEVT_DUTLB_MISS		3	/* Data uTLB Miss */
467825088edSmatt #define	ARM11_PMCEVT_BRANCH		4	/* Branch Inst. Executed */
468825088edSmatt #define	ARM11_PMCEVT_BRANCH_MISS	6	/* Branch mispredicted */
469825088edSmatt #define	ARM11_PMCEVT_INST_EXEC		7	/* Instruction Executed */
470825088edSmatt #define	ARM11_PMCEVT_DCACHE_ACCESS0	9	/* Data Cache Access */
471825088edSmatt #define	ARM11_PMCEVT_DCACHE_ACCESS1	10	/* Data Cache Access */
472825088edSmatt #define	ARM11_PMCEVT_DCACHE_MISS	11	/* Data Cache Miss */
473825088edSmatt #define	ARM11_PMCEVT_DCACHE_WRITEBACK	12	/* Data Cache Writeback */
474825088edSmatt #define	ARM11_PMCEVT_PC_CHANGE		13	/* Software PC change */
475825088edSmatt #define	ARM11_PMCEVT_TLB_MISS		15	/* Main TLB Miss */
476825088edSmatt #define	ARM11_PMCEVT_DATA_ACCESS	16	/* non-cached data access */
477825088edSmatt #define	ARM11_PMCEVT_LSU_STALL		17	/* Load/Store Unit stall */
478825088edSmatt #define	ARM11_PMCEVT_WBUF_DRAIN		18	/* Write buffer drained */
479825088edSmatt #define	ARM11_PMCEVT_ETMEXTOUT0		32	/* ETMEXTOUT[0] asserted */
480825088edSmatt #define	ARM11_PMCEVT_ETMEXTOUT1		33	/* ETMEXTOUT[1] asserted */
481825088edSmatt #define	ARM11_PMCEVT_ETMEXTOUT		34	/* ETMEXTOUT[0 & 1] */
482825088edSmatt #define	ARM11_PMCEVT_CALL_EXEC		35	/* Procedure call executed */
483825088edSmatt #define	ARM11_PMCEVT_RETURN_EXEC	36	/* Return executed */
484825088edSmatt #define	ARM11_PMCEVT_RETURN_HIT		37	/* return address predicted */
485825088edSmatt #define	ARM11_PMCEVT_RETURN_MISS	38	/* return addr. mispredicted */
486825088edSmatt #define	ARM11_PMCEVT_CYCLE		255	/* Increment each cycle */
487825088edSmatt 
488*c9219daaSryo /* ARMv7 PMCR, Performance Monitor Control Register */
489*c9219daaSryo #define	PMCR_N			__BITS(15,11)
490*c9219daaSryo #define	PMCR_D			__BIT(3)
491*c9219daaSryo #define	PMCR_E			__BIT(0)
492*c9219daaSryo 
493*c9219daaSryo /* ARMv7 INTEN{SET,CLR}, Performance Monitors Interrupt Enable Set register */
494*c9219daaSryo #define	PMINTEN_C		__BIT(31)
495*c9219daaSryo #define	PMINTEN_P		__BITS(30,0)
496*c9219daaSryo #define	PMCNTEN_C		__BIT(31)
497*c9219daaSryo #define	PMCNTEN_P		__BITS(30,0)
498*c9219daaSryo 
499*c9219daaSryo /* ARMv7 PMOVSR, Performance Monitors Overflow Flag Status Register */
500*c9219daaSryo #define	PMOVS_C			__BIT(31)
501*c9219daaSryo #define	PMOVS_P			__BITS(30,0)
502*c9219daaSryo 
503*c9219daaSryo /* ARMv7 PMXEVTYPER, Performance Monitors Event Type Select Register */
504*c9219daaSryo #define	PMEVTYPER_P		__BIT(31)
505*c9219daaSryo #define	PMEVTYPER_U		__BIT(30)
506*c9219daaSryo #define	PMEVTYPER_EVTCOUNT	__BITS(7,0)
507*c9219daaSryo 
50830ce2039Smatt /* Defines for ARM CORTEX performance counters */
50930ce2039Smatt #define CORTEX_CNTENS_C __BIT(31)	/* Enables the cycle counter */
51030ce2039Smatt #define CORTEX_CNTENC_C __BIT(31)	/* Disables the cycle counter */
51130ce2039Smatt #define CORTEX_CNTOFL_C __BIT(31)	/* Cycle counter overflow flag */
5125ddffda4Sjmcneill 
5137ff1a6efSmatt /* Defines for ARM Cortex A7/A15 L2CTRL */
5147ff1a6efSmatt #define L2CTRL_NUMCPU	__BITS(25,24)	// numcpus - 1
5157ff1a6efSmatt #define L2CTRL_ICPRES	__BIT(23)	// Interrupt Controller is present
5167ff1a6efSmatt 
5176b30782bSskrll /* Translation Table Base Register */
5186b30782bSskrll #define	TTBR_C			__BIT(0)	/* without MPE */
5196b30782bSskrll #define	TTBR_S			__BIT(1)
5206b30782bSskrll #define	TTBR_IMP		__BIT(2)
5216b30782bSskrll #define	TTBR_RGN_MASK		__BITS(4,3)
5226b30782bSskrll #define	 TTBR_RGN_NC		__SHIFTIN(0, TTBR_RGN_MASK)
5236b30782bSskrll #define	 TTBR_RGN_WBWA		__SHIFTIN(1, TTBR_RGN_MASK)
5246b30782bSskrll #define	 TTBR_RGN_WT		__SHIFTIN(2, TTBR_RGN_MASK)
5256b30782bSskrll #define	 TTBR_RGN_WBNWA		__SHIFTIN(3, TTBR_RGN_MASK)
5266b30782bSskrll #define	TTBR_NOS		__BIT(5)
5276b30782bSskrll #define	TTBR_IRGN_MASK		(__BIT(6) | __BIT(0))
5286b30782bSskrll #define	 TTBR_IRGN_NC		0
5296b30782bSskrll #define	 TTBR_IRGN_WBWA		__BIT(6)
5306b30782bSskrll #define	 TTBR_IRGN_WT		__BIT(0)
5316b30782bSskrll #define	 TTBR_IRGN_WBNWA	(__BIT(0) | __BIT(6))
5326b30782bSskrll 
5337d125d00Smatt /* Translate Table Base Control Register */
5347d125d00Smatt #define TTBCR_S_EAE	__BIT(31)	// Extended Address Extension
5357d125d00Smatt #define TTBCR_S_PD1	__BIT(5)	// Don't use TTBR1
5367d125d00Smatt #define TTBCR_S_PD0	__BIT(4)	// Don't use TTBR0
5377d125d00Smatt #define TTBCR_S_N	__BITS(2,0)	// Width of base address in TTB0
5387d125d00Smatt 
5397d125d00Smatt #define TTBCR_L_EAE	__BIT(31)	// Extended Address Extension
5407d125d00Smatt #define TTBCR_L_SH1	__BITS(29,28)	// TTBR1 Shareability
5417d125d00Smatt #define TTBCR_L_ORGN1	__BITS(27,26)	// TTBR1 Outer cacheability
5427d125d00Smatt #define TTBCR_L_IRGN1	__BITS(25,24)	// TTBR1 inner cacheability
5437d125d00Smatt #define TTBCR_L_EPD1	__BIT(23)	// Don't use TTBR1
5447d125d00Smatt #define TTBCR_L_A1	__BIT(22)	// ASID is in TTBR1
5457d125d00Smatt #define TTBCR_L_T1SZ	__BITS(18,16)	// TTBR1 size offset
5467d125d00Smatt #define TTBCR_L_SH0	__BITS(13,12)	// TTBR0 Shareability
5477d125d00Smatt #define TTBCR_L_ORGN0	__BITS(11,10)	// TTBR0 Outer cacheability
5487d125d00Smatt #define TTBCR_L_IRGN0	__BITS(9,8)	// TTBR0 inner cacheability
5497d125d00Smatt #define TTBCR_L_EPD0	__BIT(7)	// Don't use TTBR0
5507d125d00Smatt #define TTBCR_L_T0SZ	__BITS(2,0)	// TTBR0 size offset
5517d125d00Smatt 
552570e2487Sskrll #define NMRR_ORn(n)	__BITS(17+2*(n),16+2*(n)) // Outer Cacheable mappings
553570e2487Sskrll #define NMRR_IRn(n)	__BITS(1+2*(n),0+2*(n)) // Inner Cacheable mappings
554570e2487Sskrll #define NMRR_NC		0		// non-cacheable
555570e2487Sskrll #define NMRR_WBWA	1		// write-back write-allocate
556570e2487Sskrll #define NMRR_WT		2		// write-through
557570e2487Sskrll #define NMRR_WB		3		// write-back
558f2081d52Sskrll #define PRRR_NOSn(n)	__BITS(24+(n))	// Memory region is Inner Shareable only
559ef682d97Smatt #define PRRR_NS1	__BIT(19)	// Normal Shareable S=1 is Shareable
560ef682d97Smatt #define PRRR_NS0	__BIT(18)	// Normal Shareable S=0 is Shareable
561ef682d97Smatt #define PRRR_DS1	__BIT(17)	// Device Shareable S=1 is Shareable
562ef682d97Smatt #define PRRR_DS0	__BIT(16)	// Device Shareable S=0 is Shareable
563ef682d97Smatt #define PRRR_TRn(n)	__BITS(1+2*(n),0+2*(n))
564ef682d97Smatt #define PRRR_TR_STRONG	0		// Strongly Ordered
565ef682d97Smatt #define PRRR_TR_DEVICE	1		// Device
566ef682d97Smatt #define PRRR_TR_NORMAL	2		// Normal Memory
567de0b3201Sskrll 					// 3 is reserved
568ef682d97Smatt 
569637c81b6Shsuenaga /* ARMv7 MPIDR, Multiprocessor Affinity Register generic format  */
570f9faf20aSandvar #define MPIDR_MP		__BIT(31)	/* 1 = Have MP Extension */
571637c81b6Shsuenaga #define MPIDR_U			__BIT(30)	/* 1 = Uni-Processor System */
572637c81b6Shsuenaga #define MPIDR_MT		__BIT(24)	/* 1 = SMT(AFF0 is logical) */
573637c81b6Shsuenaga #define MPIDR_AFF2		__BITS(23,16)	/* Affinity Level 2 */
574637c81b6Shsuenaga #define MPIDR_AFF1		__BITS(15,8)	/* Affinity Level 1 */
575637c81b6Shsuenaga #define MPIDR_AFF0		__BITS(7,0)	/* Affinity Level 0 */
576637c81b6Shsuenaga 
577637c81b6Shsuenaga /* MPIDR implementation of ARM Cortex A9: SMT and AFF2 is not used */
578637c81b6Shsuenaga #define CORTEXA9_MPIDR_MP	MPIDR_MP
579637c81b6Shsuenaga #define CORTEXA9_MPIDR_U	MPIDR_U
580637c81b6Shsuenaga #define	CORTEXA9_MPIDR_CLID	__BITS(11,8)	/* AFF1 = cluster id */
58144bb5643Sskrll #define CORTEXA9_MPIDR_CPUID	__BITS(0,1)	/* AFF0 = physical core id */
582637c81b6Shsuenaga 
583637c81b6Shsuenaga /* MPIDR implementation of Marvell PJ4B-MP: AFF2 is not used */
584637c81b6Shsuenaga #define PJ4B_MPIDR_MP		MPIDR_MP
585637c81b6Shsuenaga #define PJ4B_MPIDR_U		MPIDR_U
586637c81b6Shsuenaga #define PJ4B_MPIDR_MT		MPIDR_MT	/* 1 = SMT(AFF0 is logical) */
587637c81b6Shsuenaga #define PJ4B_MPIDR_CLID		__BITS(11,8)	/* AFF1 = cluster id */
588637c81b6Shsuenaga #define PJ4B_MPIDR_CPUID	__BITS(0,3)	/* AFF0 = core id */
589637c81b6Shsuenaga 
59023b9975cSmatt /* Defines for ARM Generic Timer */
591fe33aa27Sryo #define CNTCTL_ISTATUS		__BIT(2)	// Interrupt is pending
592fe33aa27Sryo #define CNTCTL_IMASK		__BIT(1)	// Mask Interrupt
593fe33aa27Sryo #define CNTCTL_ENABLE		__BIT(0)	// Timer Enabled
59423b9975cSmatt 
595fe33aa27Sryo #define CNTKCTL_PL0PTEN		__BIT(9)	/* PL0 Physical Timer Enable */
596fe33aa27Sryo #define CNTKCTL_PL0VTEN		__BIT(8)	/* PL0 Virtual Timer Enable */
597fe33aa27Sryo #define CNTKCTL_EVNTI		__BITS(7,4)	/* CNTVCT Event Bit Select */
598fe33aa27Sryo #define CNTKCTL_EVNTDIR		__BIT(3)	/* CNTVCT Event Dir (1->0) */
599fe33aa27Sryo #define CNTKCTL_EVNTEN		__BIT(2)	/* CNTVCT Event Enable */
600fe33aa27Sryo #define CNTKCTL_PL0VCTEN	__BIT(1)	/* PL0 Virtual Counter Enable */
601fe33aa27Sryo #define CNTKCTL_PL0PCTEN	__BIT(0)	/* PL0 Physical Counter Enable */
60223b9975cSmatt 
60330571494Sskrll /* CNCHCTL, Timer PL2 Control register, Virtualization Extensions */
604fe33aa27Sryo #define CNTHCTL_EVNTI		__BITS(7,4)
605fe33aa27Sryo #define CNTHCTL_EVNTDIR		__BIT(3)
606fe33aa27Sryo #define CNTHCTL_EVNTEN		__BIT(2)
607fe33aa27Sryo #define CNTHCTL_PL1PCEN		__BIT(1)
608fe33aa27Sryo #define CNTHCTL_PL1PCTEN	__BIT(0)
60923b9975cSmatt 
610c655992eSmatt #define ARM_A5_TLBDATA_DOM		__BITS(62,59)
611c655992eSmatt #define ARM_A5_TLBDATA_AP		__BITS(58,56)
612c655992eSmatt #define ARM_A5_TLBDATA_NS_WALK		__BIT(55)
613c655992eSmatt #define ARM_A5_TLBDATA_NS_PAGE		__BIT(54)
614b889ee88Smatt #define ARM_A5_TLBDATA_XN		__BIT(53)
615c655992eSmatt #define ARM_A5_TLBDATA_TEX		__BITS(52,50)
616c655992eSmatt #define ARM_A5_TLBDATA_B		__BIT(49)
617c655992eSmatt #define ARM_A5_TLBDATA_C		__BIT(48)
618c655992eSmatt #define ARM_A5_TLBDATA_S		__BIT(47)
619b889ee88Smatt #define ARM_A5_TLBDATA_ASID		__BITS(46,39)
620b889ee88Smatt #define ARM_A5_TLBDATA_SIZE		__BITS(38,37)
621c655992eSmatt #define ARM_A5_TLBDATA_SIZE_4KB		0
622c655992eSmatt #define ARM_A5_TLBDATA_SIZE_16KB	1
623c655992eSmatt #define ARM_A5_TLBDATA_SIZE_1MB		2
624c655992eSmatt #define ARM_A5_TLBDATA_SIZE_16MB	3
625b889ee88Smatt #define ARM_A5_TLBDATA_VA		__BITS(36,22)
626b889ee88Smatt #define ARM_A5_TLBDATA_PA		__BITS(21,2)
627c655992eSmatt #define ARM_A5_TLBDATA_nG		__BIT(1)
628c655992eSmatt #define ARM_A5_TLBDATA_VALID		__BIT(0)
629c655992eSmatt 
630c655992eSmatt #define ARM_A7_TLBDATA2_S2_LEVEL	__BITS(85-64,84-64)
631c655992eSmatt #define ARM_A7_TLBDATA2_S1_SIZE		__BITS(83-64,82-64)
632c655992eSmatt #define ARM_A7_TLBDATA2_S1_SIZE_4KB	0
63379bed093Sskrll #define ARM_A7_TLBDATA2_S1_SIZE_64KB	1
63479bed093Sskrll #define ARM_A7_TLBDATA2_S1_SIZE_1MB	2
63579bed093Sskrll #define ARM_A7_TLBDATA2_S1_SIZE_16MB	3
636c655992eSmatt #define ARM_A7_TLBDATA2_DOM		__BITS(81-64,78-64)
637c655992eSmatt #define ARM_A7_TLBDATA2_IS		__BITS(77-64,76-64)
638c655992eSmatt #define ARM_A7_TLBDATA2_IS_NC		0
63979bed093Sskrll #define ARM_A7_TLBDATA2_IS_WB_WA	1
640c655992eSmatt #define ARM_A7_TLBDATA2_IS_WT		2
641c655992eSmatt #define ARM_A7_TLBDATA2_IS_DSO		3
642c655992eSmatt #define ARM_A7_TLBDATA2_S2OVR		__BIT(75-64)
643c655992eSmatt #define ARM_A7_TLBDATA2_SDO_MT		__BITS(74-64,72-64)
644c655992eSmatt #define ARM_A7_TLBDATA2_SDO_MT_D	2
645c655992eSmatt #define ARM_A7_TLBDATA2_SDO_MT_SO	6
646c655992eSmatt #define ARM_A7_TLBDATA2_OS		__BITS(75-64,74-64)
647c655992eSmatt #define ARM_A7_TLBDATA2_OS_NC		0
648c655992eSmatt #define ARM_A7_TLBDATA2_OS_WB_WA	1
649c655992eSmatt #define ARM_A7_TLBDATA2_OS_WT		2
650c655992eSmatt #define ARM_A7_TLBDATA2_OS_WB		3
651c655992eSmatt #define ARM_A7_TLBDATA2_SH		__BITS(73-64,72-64)
652c655992eSmatt #define ARM_A7_TLBDATA2_SH_NONE		0
653c655992eSmatt #define ARM_A7_TLBDATA2_SH_UNUSED	1
654c655992eSmatt #define ARM_A7_TLBDATA2_SH_OS		2
655c655992eSmatt #define ARM_A7_TLBDATA2_SH_IS		3
656c655992eSmatt #define ARM_A7_TLBDATA2_XN2		__BIT(71-64)
657c655992eSmatt #define ARM_A7_TLBDATA2_XN1		__BIT(70-64)
658c655992eSmatt #define ARM_A7_TLBDATA2_PXN		__BIT(69-64)
659c655992eSmatt 
660c655992eSmatt #define ARM_A7_TLBDATA12_PA		__BITS(68-32,41-32)
661c655992eSmatt 
662c655992eSmatt #define ARM_A7_TLBDATA1_NS		__BIT(40-32)
663c655992eSmatt #define ARM_A7_TLBDATA1_HAP		__BITS(39-32,38-32)
664c655992eSmatt #define ARM_A7_TLBDATA1_AP		__BITS(37-32,35-32)
665c655992eSmatt #define ARM_A7_TLBDATA1_nG		__BIT(34-32)
666c655992eSmatt 
667c655992eSmatt #define ARM_A7_TLBDATA01_ASID		__BITS(33,26)
668c655992eSmatt 
669c655992eSmatt #define ARM_A7_TLBDATA0_VMID		__BITS(25,18)
670c655992eSmatt #define ARM_A7_TLBDATA0_VA		__BITS(17,5)
671c655992eSmatt #define ARM_A7_TLBDATA0_NS_WALK		__BIT(4)
672c655992eSmatt #define ARM_A7_TLBDATA0_SIZE		__BITS(3,1)
673c655992eSmatt #define ARM_A7_TLBDATA0_SIZE_V7_4KB	0
674c655992eSmatt #define ARM_A7_TLBDATA0_SIZE_LPAE_4KB	1
675c655992eSmatt #define ARM_A7_TLBDATA0_SIZE_V7_64KB	2
676c655992eSmatt #define ARM_A7_TLBDATA0_SIZE_LPAE_64KB	3
677c655992eSmatt #define ARM_A7_TLBDATA0_SIZE_V7_1MB	4
678c655992eSmatt #define ARM_A7_TLBDATA0_SIZE_LPAE_2MB	5
679c655992eSmatt #define ARM_A7_TLBDATA0_SIZE_V7_16MB	6
680c655992eSmatt #define ARM_A7_TLBDATA0_SIZE_LPAE_1GB	7
681c655992eSmatt 
682c655992eSmatt #define ARM_TLBDATA_VALID		__BIT(0)
683c655992eSmatt 
684c655992eSmatt #define ARM_TLBDATAOP_WAY		__BIT(31)
685c655992eSmatt #define ARM_A5_TLBDATAOP_INDEX		__BITS(5,0)
686c655992eSmatt #define ARM_A7_TLBDATAOP_INDEX		__BITS(6,0)
687c655992eSmatt 
688c81a18bfSmatt #if !defined(__ASSEMBLER__) && defined(_KERNEL)
689f50530a0Smatt static inline bool
arm_cond_ok_p(uint32_t insn,uint32_t psr)690f50530a0Smatt arm_cond_ok_p(uint32_t insn, uint32_t psr)
691f50530a0Smatt {
692f50530a0Smatt 	const uint32_t __cond = __SHIFTOUT(insn, INSN_COND_MASK);
693f50530a0Smatt 
694f50530a0Smatt 	bool __ok;
695f50530a0Smatt 	const bool __z = (psr & PSR_Z_bit);
696f50530a0Smatt 	const bool __n = (psr & PSR_N_bit);
697f50530a0Smatt 	const bool __c = (psr & PSR_C_bit);
698f50530a0Smatt 	const bool __v = (psr & PSR_V_bit);
699f50530a0Smatt 	switch (__cond & ~1) {
700f50530a0Smatt 	case INSN_COND_EQ:	// Z == 1
701f50530a0Smatt 		__ok = __z;
702f50530a0Smatt 		break;
703f50530a0Smatt 	case INSN_COND_CS:	// C == 1
704f50530a0Smatt 		__ok = __c;
705f50530a0Smatt 		break;
706f50530a0Smatt 	case INSN_COND_MI:	// N == 1
707f50530a0Smatt 		__ok = __n;
708f50530a0Smatt 		break;
709f50530a0Smatt 	case INSN_COND_VS:	// V == 1
710f50530a0Smatt 		__ok = __v;
711f50530a0Smatt 		break;
712f50530a0Smatt 	case INSN_COND_HI:	// C == 1 && Z == 0
713f50530a0Smatt 		__ok = __c && !__z;
714f50530a0Smatt 		break;
715f50530a0Smatt 	case INSN_COND_GE:	// N == V
716f50530a0Smatt 		__ok = __n == __v;
717f50530a0Smatt 		break;
718f50530a0Smatt 	case INSN_COND_GT:	// N == V && Z == 0
719f50530a0Smatt 		__ok = __n == __v && !__z;
720f50530a0Smatt 		break;
721b7226711Smatt 	default: /* INSN_COND_AL or unconditional */
722f50530a0Smatt 		return true;
723f50530a0Smatt 	}
724f50530a0Smatt 
725f50530a0Smatt 	return (__cond & 1) ? !__ok : __ok;
726f50530a0Smatt }
727c81a18bfSmatt #endif /* !__ASSEMBLER && _KERNEL */
728f50530a0Smatt 
7293a33e1d7Smatt #if !defined(__ASSEMBLER__) && !defined(_RUMPKERNEL)
730977dafe5Smatt #define	ARMREG_READ_INLINE(name, __insnstring)			\
731977dafe5Smatt static inline uint32_t armreg_##name##_read(void)		\
732977dafe5Smatt {								\
733977dafe5Smatt 	uint32_t __rv;						\
734977dafe5Smatt 	__asm __volatile("mrc " __insnstring : "=r"(__rv));	\
735977dafe5Smatt 	return __rv;						\
736977dafe5Smatt }
737977dafe5Smatt 
738977dafe5Smatt #define	ARMREG_WRITE_INLINE(name, __insnstring)			\
739977dafe5Smatt static inline void armreg_##name##_write(uint32_t __val)	\
740977dafe5Smatt {								\
741977dafe5Smatt 	__asm __volatile("mcr " __insnstring :: "r"(__val));	\
742977dafe5Smatt }
743977dafe5Smatt 
744e1771516Smatt #define	ARMREG_READ_INLINE2(name, __insnstring)			\
745e1771516Smatt static inline uint32_t armreg_##name##_read(void)		\
746e1771516Smatt {								\
747e1771516Smatt 	uint32_t __rv;						\
7480f73a8a0Schristos 	__asm __volatile(".fpu vfp");				\
749e1771516Smatt 	__asm __volatile(__insnstring : "=r"(__rv));		\
750e1771516Smatt 	return __rv;						\
751e1771516Smatt }
752e1771516Smatt 
753e1771516Smatt #define	ARMREG_WRITE_INLINE2(name, __insnstring)		\
754e1771516Smatt static inline void armreg_##name##_write(uint32_t __val)	\
755e1771516Smatt {								\
7560f73a8a0Schristos 	__asm __volatile(".fpu vfp");				\
757e1771516Smatt 	__asm __volatile(__insnstring :: "r"(__val));		\
758e1771516Smatt }
759e1771516Smatt 
76098afdbcbSmatt #define	ARMREG_READ64_INLINE(name, __insnstring)		\
76198afdbcbSmatt static inline uint64_t armreg_##name##_read(void)		\
76298afdbcbSmatt {								\
76398afdbcbSmatt 	uint64_t __rv;						\
76498afdbcbSmatt 	__asm __volatile("mrrc " __insnstring : "=r"(__rv));	\
76598afdbcbSmatt 	return __rv;						\
76698afdbcbSmatt }
76798afdbcbSmatt 
76898afdbcbSmatt #define	ARMREG_WRITE64_INLINE(name, __insnstring)		\
76998afdbcbSmatt static inline void armreg_##name##_write(uint64_t __val)	\
77098afdbcbSmatt {								\
77198afdbcbSmatt 	__asm __volatile("mcrr " __insnstring :: "r"(__val));	\
77298afdbcbSmatt }
77398afdbcbSmatt 
77482b1c4ddSmatt /* cp10 registers */
775b45d78c7Sjoerg ARMREG_READ_INLINE2(fpsid, ".fpu vfp\n vmrs\t%0, fpsid") /* VFP System ID */
776b45d78c7Sjoerg ARMREG_READ_INLINE2(fpscr, ".fpu vfp\n vmrs\t%0, fpscr") /* VFP Status/Control Register */
777b45d78c7Sjoerg ARMREG_WRITE_INLINE2(fpscr, ".fpu vfp\n vmsr\tfpscr, %0") /* VFP Status/Control Register */
778b45d78c7Sjoerg ARMREG_READ_INLINE2(mvfr1, ".fpu vfp\n vmrs\t%0, mvfr1") /* Media and VFP Feature Register 1 */
779b45d78c7Sjoerg ARMREG_READ_INLINE2(mvfr0, ".fpu vfp\n vmrs\t%0, mvfr0") /* Media and VFP Feature Register 0 */
780b45d78c7Sjoerg ARMREG_READ_INLINE2(fpexc, ".fpu vfp\n vmrs\t%0, fpexc") /* VFP Exception Register */
781b45d78c7Sjoerg ARMREG_WRITE_INLINE2(fpexc, ".fpu vfp\n vmsr\tfpexc, %0") /* VFP Exception Register */
782b45d78c7Sjoerg ARMREG_READ_INLINE2(fpinst, ".fpu vfp\n fmrx\t%0, fpinst") /* VFP Exception Instruction */
783b45d78c7Sjoerg ARMREG_WRITE_INLINE2(fpinst, ".fpu vfp\n vmsr\tfpinst, %0") /* VFP Exception Instruction */
784b45d78c7Sjoerg ARMREG_READ_INLINE2(fpinst2, ".fpu vfp\n fmrx\t%0, fpinst2") /* VFP Exception Instruction 2 */
785b45d78c7Sjoerg ARMREG_WRITE_INLINE2(fpinst2, ".fpu vfp\n fmxr\tfpinst2, %0") /* VFP Exception Instruction 2 */
78682b1c4ddSmatt 
78782b1c4ddSmatt /* cp15 c0 registers */
788977dafe5Smatt ARMREG_READ_INLINE(midr, "p15,0,%0,c0,c0,0") /* Main ID Register */
789977dafe5Smatt ARMREG_READ_INLINE(ctr, "p15,0,%0,c0,c0,1") /* Cache Type Register */
790f50530a0Smatt ARMREG_READ_INLINE(tlbtr, "p15,0,%0,c0,c0,3") /* TLB Type Register */
791977dafe5Smatt ARMREG_READ_INLINE(mpidr, "p15,0,%0,c0,c0,5") /* Multiprocess Affinity Register */
792969a0df1Sskrll ARMREG_READ_INLINE(revidr, "p15,0,%0,c0,c0,6") /* Revision ID Register */
793977dafe5Smatt ARMREG_READ_INLINE(pfr0, "p15,0,%0,c0,c1,0") /* Processor Feature Register 0 */
794977dafe5Smatt ARMREG_READ_INLINE(pfr1, "p15,0,%0,c0,c1,1") /* Processor Feature Register 1 */
795977dafe5Smatt ARMREG_READ_INLINE(mmfr0, "p15,0,%0,c0,c1,4") /* Memory Model Feature Register 0 */
796977dafe5Smatt ARMREG_READ_INLINE(mmfr1, "p15,0,%0,c0,c1,5") /* Memory Model Feature Register 1 */
797977dafe5Smatt ARMREG_READ_INLINE(mmfr2, "p15,0,%0,c0,c1,6") /* Memory Model Feature Register 2 */
798977dafe5Smatt ARMREG_READ_INLINE(mmfr3, "p15,0,%0,c0,c1,7") /* Memory Model Feature Register 3 */
799977dafe5Smatt ARMREG_READ_INLINE(isar0, "p15,0,%0,c0,c2,0") /* Instruction Set Attribute Register 0 */
800977dafe5Smatt ARMREG_READ_INLINE(isar1, "p15,0,%0,c0,c2,1") /* Instruction Set Attribute Register 1 */
801977dafe5Smatt ARMREG_READ_INLINE(isar2, "p15,0,%0,c0,c2,2") /* Instruction Set Attribute Register 2 */
802977dafe5Smatt ARMREG_READ_INLINE(isar3, "p15,0,%0,c0,c2,3") /* Instruction Set Attribute Register 3 */
803977dafe5Smatt ARMREG_READ_INLINE(isar4, "p15,0,%0,c0,c2,4") /* Instruction Set Attribute Register 4 */
804977dafe5Smatt ARMREG_READ_INLINE(isar5, "p15,0,%0,c0,c2,5") /* Instruction Set Attribute Register 5 */
805977dafe5Smatt ARMREG_READ_INLINE(ccsidr, "p15,1,%0,c0,c0,0") /* Cache Size ID Register */
806977dafe5Smatt ARMREG_READ_INLINE(clidr, "p15,1,%0,c0,c0,1") /* Cache Level ID Register */
807977dafe5Smatt ARMREG_READ_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */
808977dafe5Smatt ARMREG_WRITE_INLINE(csselr, "p15,2,%0,c0,c0,0") /* Cache Size Selection Register */
80982b1c4ddSmatt /* cp15 c1 registers */
810b34320daSskrll ARMREG_READ_INLINE(sctlr, "p15,0,%0,c1,c0,0") /* System Control Register */
811b34320daSskrll ARMREG_WRITE_INLINE(sctlr, "p15,0,%0,c1,c0,0") /* System Control Register */
812c872068cSmatt ARMREG_READ_INLINE(auxctl, "p15,0,%0,c1,c0,1") /* Auxiliary Control Register */
813c872068cSmatt ARMREG_WRITE_INLINE(auxctl, "p15,0,%0,c1,c0,1") /* Auxiliary Control Register */
814c872068cSmatt ARMREG_READ_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Control Register */
815c872068cSmatt ARMREG_WRITE_INLINE(cpacr, "p15,0,%0,c1,c0,2") /* Co-Processor Access Control Register */
81617dba145Smatt ARMREG_READ_INLINE(scr, "p15,0,%0,c1,c1,0") /* Secure Configuration Register */
8179fe65634Smatt ARMREG_READ_INLINE(nsacr, "p15,0,%0,c1,c1,2") /* Non-Secure Access Control Register */
81882b1c4ddSmatt /* cp15 c2 registers */
81985489630Smatt ARMREG_READ_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */
82085489630Smatt ARMREG_WRITE_INLINE(ttbr, "p15,0,%0,c2,c0,0") /* Translation Table Base Register 0 */
82185489630Smatt ARMREG_READ_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */
82285489630Smatt ARMREG_WRITE_INLINE(ttbr1, "p15,0,%0,c2,c0,1") /* Translation Table Base Register 1 */
82385489630Smatt ARMREG_READ_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */
82485489630Smatt ARMREG_WRITE_INLINE(ttbcr, "p15,0,%0,c2,c0,2") /* Translation Table Base Register */
8257ff1a6efSmatt /* cp15 c3 registers */
8267ff1a6efSmatt ARMREG_READ_INLINE(dacr, "p15,0,%0,c3,c0,0") /* Domain Access Control Register */
8277ff1a6efSmatt ARMREG_WRITE_INLINE(dacr, "p15,0,%0,c3,c0,0") /* Domain Access Control Register */
82882b1c4ddSmatt /* cp15 c5 registers */
829ee6cde04Smatt ARMREG_READ_INLINE(dfsr, "p15,0,%0,c5,c0,0") /* Data Fault Status Register */
830ee6cde04Smatt ARMREG_READ_INLINE(ifsr, "p15,0,%0,c5,c0,1") /* Instruction Fault Status Register */
83182b1c4ddSmatt /* cp15 c6 registers */
832ee6cde04Smatt ARMREG_READ_INLINE(dfar, "p15,0,%0,c6,c0,0") /* Data Fault Address Register */
833ee6cde04Smatt ARMREG_READ_INLINE(ifar, "p15,0,%0,c6,c0,2") /* Instruction Fault Address Register */
83482b1c4ddSmatt /* cp15 c7 registers */
83503bbd14bSmatt ARMREG_WRITE_INLINE(icialluis, "p15,0,%0,c7,c1,0") /* Instruction Inv All (IS) */
8366ca7cdcdSskrll ARMREG_WRITE_INLINE(bpiallis, "p15,0,%0,c7,c1,6") /* Branch Predictor Invalidate All (IS) */
83703bbd14bSmatt ARMREG_READ_INLINE(par, "p15,0,%0,c7,c4,0") /* Physical Address Register */
83803bbd14bSmatt ARMREG_WRITE_INLINE(iciallu, "p15,0,%0,c7,c5,0") /* Instruction Invalidate All */
83903bbd14bSmatt ARMREG_WRITE_INLINE(icimvau, "p15,0,%0,c7,c5,1") /* Instruction Invalidate MVA */
84003bbd14bSmatt ARMREG_WRITE_INLINE(isb, "p15,0,%0,c7,c5,4") /* Instruction Synchronization Barrier */
8416ca7cdcdSskrll ARMREG_WRITE_INLINE(bpiall, "p15,0,%0,c7,c5,6") /* Branch Predictor Invalidate All */
84252d1add0Sskrll ARMREG_WRITE_INLINE(bpimva, "p15,0,%0,c7,c5,7") /* Branch Predictor invalidate by MVA */
84303bbd14bSmatt ARMREG_WRITE_INLINE(dcimvac, "p15,0,%0,c7,c6,1") /* Data Invalidate MVA to PoC */
84403bbd14bSmatt ARMREG_WRITE_INLINE(dcisw, "p15,0,%0,c7,c6,2") /* Data Invalidate Set/Way */
84503bbd14bSmatt ARMREG_WRITE_INLINE(ats1cpr, "p15,0,%0,c7,c8,0") /* AddrTrans CurState PL1 Read */
8467ff1a6efSmatt ARMREG_WRITE_INLINE(ats1cpw, "p15,0,%0,c7,c8,1") /* AddrTrans CurState PL1 Write */
8477ff1a6efSmatt ARMREG_WRITE_INLINE(ats1cur, "p15,0,%0,c7,c8,2") /* AddrTrans CurState PL0 Read */
8487ff1a6efSmatt ARMREG_WRITE_INLINE(ats1cuw, "p15,0,%0,c7,c8,3") /* AddrTrans CurState PL0 Write */
84903bbd14bSmatt ARMREG_WRITE_INLINE(dccmvac, "p15,0,%0,c7,c10,1") /* Data Clean MVA to PoC */
85003bbd14bSmatt ARMREG_WRITE_INLINE(dccsw, "p15,0,%0,c7,c10,2") /* Data Clean Set/Way */
85103bbd14bSmatt ARMREG_WRITE_INLINE(dsb, "p15,0,%0,c7,c10,4") /* Data Synchronization Barrier */
85203bbd14bSmatt ARMREG_WRITE_INLINE(dmb, "p15,0,%0,c7,c10,5") /* Data Memory Barrier */
85352d1add0Sskrll ARMREG_WRITE_INLINE(dccmvau, "p15,0,%0,c7,c11,1") /* Data Clean MVA to PoU */
85403bbd14bSmatt ARMREG_WRITE_INLINE(dccimvac, "p15,0,%0,c7,c14,1") /* Data Clean&Inv MVA to PoC */
85503bbd14bSmatt ARMREG_WRITE_INLINE(dccisw, "p15,0,%0,c7,c14,2") /* Data Clean&Inv Set/Way */
856d025c4bbSmatt /* cp15 c8 registers */
857d025c4bbSmatt ARMREG_WRITE_INLINE(tlbiallis, "p15,0,%0,c8,c3,0") /* Invalidate entire unified TLB, inner shareable */
858d025c4bbSmatt ARMREG_WRITE_INLINE(tlbimvais, "p15,0,%0,c8,c3,1") /* Invalidate unified TLB by MVA, inner shareable */
859d025c4bbSmatt ARMREG_WRITE_INLINE(tlbiasidis, "p15,0,%0,c8,c3,2") /* Invalidate unified TLB by ASID, inner shareable */
860d025c4bbSmatt ARMREG_WRITE_INLINE(tlbimvaais, "p15,0,%0,c8,c3,3") /* Invalidate unified TLB by MVA, all ASID, inner shareable */
861d025c4bbSmatt ARMREG_WRITE_INLINE(itlbiall, "p15,0,%0,c8,c5,0") /* Invalidate entire instruction TLB */
862d025c4bbSmatt ARMREG_WRITE_INLINE(itlbimva, "p15,0,%0,c8,c5,1") /* Invalidate instruction TLB by MVA */
863d025c4bbSmatt ARMREG_WRITE_INLINE(itlbiasid, "p15,0,%0,c8,c5,2") /* Invalidate instruction TLB by ASID */
864d025c4bbSmatt ARMREG_WRITE_INLINE(dtlbiall, "p15,0,%0,c8,c6,0") /* Invalidate entire data TLB */
865d025c4bbSmatt ARMREG_WRITE_INLINE(dtlbimva, "p15,0,%0,c8,c6,1") /* Invalidate data TLB by MVA */
866d025c4bbSmatt ARMREG_WRITE_INLINE(dtlbiasid, "p15,0,%0,c8,c6,2") /* Invalidate data TLB by ASID */
867d025c4bbSmatt ARMREG_WRITE_INLINE(tlbiall, "p15,0,%0,c8,c7,0") /* Invalidate entire unified TLB */
868d025c4bbSmatt ARMREG_WRITE_INLINE(tlbimva, "p15,0,%0,c8,c7,1") /* Invalidate unified TLB by MVA */
869d025c4bbSmatt ARMREG_WRITE_INLINE(tlbiasid, "p15,0,%0,c8,c7,2") /* Invalidate unified TLB by ASID */
870d025c4bbSmatt ARMREG_WRITE_INLINE(tlbimvaa, "p15,0,%0,c8,c7,3") /* Invalidate unified TLB by MVA, all ASID */
87182b1c4ddSmatt /* cp15 c9 registers */
872977dafe5Smatt ARMREG_READ_INLINE(pmcr, "p15,0,%0,c9,c12,0") /* PMC Control Register */
873977dafe5Smatt ARMREG_WRITE_INLINE(pmcr, "p15,0,%0,c9,c12,0") /* PMC Control Register */
874977dafe5Smatt ARMREG_READ_INLINE(pmcntenset, "p15,0,%0,c9,c12,1") /* PMC Count Enable Set */
875977dafe5Smatt ARMREG_WRITE_INLINE(pmcntenset, "p15,0,%0,c9,c12,1") /* PMC Count Enable Set */
876977dafe5Smatt ARMREG_READ_INLINE(pmcntenclr, "p15,0,%0,c9,c12,2") /* PMC Count Enable Clear */
877977dafe5Smatt ARMREG_WRITE_INLINE(pmcntenclr, "p15,0,%0,c9,c12,2") /* PMC Count Enable Clear */
878977dafe5Smatt ARMREG_READ_INLINE(pmovsr, "p15,0,%0,c9,c12,3") /* PMC Overflow Flag Status */
879977dafe5Smatt ARMREG_WRITE_INLINE(pmovsr, "p15,0,%0,c9,c12,3") /* PMC Overflow Flag Status */
880c343fdb6Sjmcneill ARMREG_READ_INLINE(pmselr, "p15,0,%0,c9,c12,5") /* PMC Event Counter Selection */
881c343fdb6Sjmcneill ARMREG_WRITE_INLINE(pmselr, "p15,0,%0,c9,c12,5") /* PMC Event Counter Selection */
882c343fdb6Sjmcneill ARMREG_READ_INLINE(pmceid0, "p15,0,%0,c9,c12,6") /* PMC Event ID 0 */
883c343fdb6Sjmcneill ARMREG_READ_INLINE(pmceid1, "p15,0,%0,c9,c12,7") /* PMC Event ID 1 */
884977dafe5Smatt ARMREG_READ_INLINE(pmccntr, "p15,0,%0,c9,c13,0") /* PMC Cycle Counter */
885977dafe5Smatt ARMREG_WRITE_INLINE(pmccntr, "p15,0,%0,c9,c13,0") /* PMC Cycle Counter */
886c343fdb6Sjmcneill ARMREG_READ_INLINE(pmxevtyper, "p15,0,%0,c9,c13,1") /* PMC Event Type Select */
887c343fdb6Sjmcneill ARMREG_WRITE_INLINE(pmxevtyper, "p15,0,%0,c9,c13,1") /* PMC Event Type Select */
888c343fdb6Sjmcneill ARMREG_READ_INLINE(pmxevcntr, "p15,0,%0,c9,c13,2") /* PMC Event Count */
889c343fdb6Sjmcneill ARMREG_WRITE_INLINE(pmxevcntr, "p15,0,%0,c9,c13,2") /* PMC Event Count */
89098afdbcbSmatt ARMREG_READ_INLINE(pmuserenr, "p15,0,%0,c9,c14,0") /* PMC User Enable */
89198afdbcbSmatt ARMREG_WRITE_INLINE(pmuserenr, "p15,0,%0,c9,c14,0") /* PMC User Enable */
89211cd7766Sskrll ARMREG_READ_INLINE(pmintenset, "p15,0,%0,c9,c14,1") /* PMC Interrupt Enable Set */
89311cd7766Sskrll ARMREG_WRITE_INLINE(pmintenset, "p15,0,%0,c9,c14,1") /* PMC Interrupt Enable Set */
89411cd7766Sskrll ARMREG_READ_INLINE(pmintenclr, "p15,0,%0,c9,c14,2") /* PMC Interrupt Enable Clear */
89511cd7766Sskrll ARMREG_WRITE_INLINE(pmintenclr, "p15,0,%0,c9,c14,2") /* PMC Interrupt Enable Clear */
8967ff1a6efSmatt ARMREG_READ_INLINE(l2ctrl, "p15,1,%0,c9,c0,2") /* A7/A15 L2 Control Register */
897ef682d97Smatt /* cp10 c10 registers */
898ef682d97Smatt ARMREG_READ_INLINE(prrr, "p15,0,%0,c10,c2,0") /* Primary Region Remap Register */
899ef682d97Smatt ARMREG_WRITE_INLINE(prrr, "p15,0,%0,c10,c2,0") /* Primary Region Remap Register */
9008e4f441bSskrll ARMREG_READ_INLINE(nmrr, "p15,0,%0,c10,c2,1") /* Normal Memory Remap Register */
9018e4f441bSskrll ARMREG_WRITE_INLINE(nmrr, "p15,0,%0,c10,c2,1") /* Normal Memory Remap Register */
90282b1c4ddSmatt /* cp15 c13 registers */
90398afdbcbSmatt ARMREG_READ_INLINE(contextidr, "p15,0,%0,c13,c0,1") /* Context ID Register */
90498afdbcbSmatt ARMREG_WRITE_INLINE(contextidr, "p15,0,%0,c13,c0,1") /* Context ID Register */
90510ae3cbfSmatt ARMREG_READ_INLINE(tpidrurw, "p15,0,%0,c13,c0,2") /* User read-write Thread ID Register */
90610ae3cbfSmatt ARMREG_WRITE_INLINE(tpidrurw, "p15,0,%0,c13,c0,2") /* User read-write Thread ID Register */
90710ae3cbfSmatt ARMREG_READ_INLINE(tpidruro, "p15,0,%0,c13,c0,3") /* User read-only Thread ID Register */
90810ae3cbfSmatt ARMREG_WRITE_INLINE(tpidruro, "p15,0,%0,c13,c0,3") /* User read-only Thread ID Register */
909977dafe5Smatt ARMREG_READ_INLINE(tpidrprw, "p15,0,%0,c13,c0,4") /* PL1 only Thread ID Register */
910977dafe5Smatt ARMREG_WRITE_INLINE(tpidrprw, "p15,0,%0,c13,c0,4") /* PL1 only Thread ID Register */
91123b9975cSmatt /* cp14 c12 registers */
9126d97100cSmatt ARMREG_READ_INLINE(vbar, "p15,0,%0,c12,c0,0")	/* Vector Base Address Register */
9136d97100cSmatt ARMREG_WRITE_INLINE(vbar, "p15,0,%0,c12,c0,0")	/* Vector Base Address Register */
91482b1c4ddSmatt /* cp15 c14 registers */
91582b1c4ddSmatt /* cp15 Global Timer Registers */
916a464003fSmatt ARMREG_READ_INLINE(cnt_frq, "p15,0,%0,c14,c0,0") /* Counter Frequency Register */
917a464003fSmatt ARMREG_WRITE_INLINE(cnt_frq, "p15,0,%0,c14,c0,0") /* Counter Frequency Register */
918a464003fSmatt ARMREG_READ_INLINE(cntk_ctl, "p15,0,%0,c14,c1,0") /* Timer PL1 Control Register */
919a464003fSmatt ARMREG_WRITE_INLINE(cntk_ctl, "p15,0,%0,c14,c1,0") /* Timer PL1 Control Register */
92098afdbcbSmatt ARMREG_READ_INLINE(cntp_tval, "p15,0,%0,c14,c2,0") /* PL1 Physical TimerValue Register */
92198afdbcbSmatt ARMREG_WRITE_INLINE(cntp_tval, "p15,0,%0,c14,c2,0") /* PL1 Physical TimerValue Register */
92298afdbcbSmatt ARMREG_READ_INLINE(cntp_ctl, "p15,0,%0,c14,c2,1") /* PL1 Physical Timer Control Register */
92398afdbcbSmatt ARMREG_WRITE_INLINE(cntp_ctl, "p15,0,%0,c14,c2,1") /* PL1 Physical Timer Control Register */
92498afdbcbSmatt ARMREG_READ_INLINE(cntv_tval, "p15,0,%0,c14,c3,0") /* Virtual TimerValue Register */
92598afdbcbSmatt ARMREG_WRITE_INLINE(cntv_tval, "p15,0,%0,c14,c3,0") /* Virtual TimerValue Register */
92698afdbcbSmatt ARMREG_READ_INLINE(cntv_ctl, "p15,0,%0,c14,c3,1") /* Virtual Timer Control Register */
92798afdbcbSmatt ARMREG_WRITE_INLINE(cntv_ctl, "p15,0,%0,c14,c3,1") /* Virtual Timer Control Register */
928a464003fSmatt ARMREG_READ64_INLINE(cntp_ct, "p15,0,%Q0,%R0,c14") /* Physical Count Register */
929a464003fSmatt ARMREG_WRITE64_INLINE(cntp_ct, "p15,0,%Q0,%R0,c14") /* Physical Count Register */
930a464003fSmatt ARMREG_READ64_INLINE(cntv_ct, "p15,1,%Q0,%R0,c14") /* Virtual Count Register */
931a464003fSmatt ARMREG_WRITE64_INLINE(cntv_ct, "p15,1,%Q0,%R0,c14") /* Virtual Count Register */
93298afdbcbSmatt ARMREG_READ64_INLINE(cntp_cval, "p15,2,%Q0,%R0,c14") /* PL1 Physical Timer CompareValue Register */
93398afdbcbSmatt ARMREG_WRITE64_INLINE(cntp_cval, "p15,2,%Q0,%R0,c14") /* PL1 Physical Timer CompareValue Register */
93498afdbcbSmatt ARMREG_READ64_INLINE(cntv_cval, "p15,3,%Q0,%R0,c14") /* PL1 Virtual Timer CompareValue Register */
93598afdbcbSmatt ARMREG_WRITE64_INLINE(cntv_cval, "p15,3,%Q0,%R0,c14") /* PL1 Virtual Timer CompareValue Register */
93611cd7766Sskrll ARMREG_READ64_INLINE(cntvoff, "p15,4,%Q0,%R0,c14") /* Virtual Offset Register */
93711cd7766Sskrll ARMREG_WRITE64_INLINE(cntvoff, "p15,4,%Q0,%R0,c14") /* Virtual Offset Register */
93882b1c4ddSmatt /* cp15 c15 registers */
939c06208b7Sskrll /* Cortex A17 Diagnostic control registers */
940c06208b7Sskrll ARMREG_READ_INLINE(dgnctlr0, "p15,0,%0,c15,c0,0")	/* DGNCTLR0 */
941c06208b7Sskrll ARMREG_WRITE_INLINE(dgnctlr0, "p15,0,%0,c15,c0,0")	/* DGNCTLR0 */
942c06208b7Sskrll ARMREG_READ_INLINE(dgnctlr1, "p15,0,%0,c15,c0,1")	/* DGNCTLR1 */
943c06208b7Sskrll ARMREG_WRITE_INLINE(dgnctlr1, "p15,0,%0,c15,c0,1")	/* DGNCTLR1 */
944c06208b7Sskrll ARMREG_READ_INLINE(dgnctlr2, "p15,0,%0,c15,c0,2")	/* DGNCTLR2 */
945c06208b7Sskrll ARMREG_WRITE_INLINE(dgnctlr2, "p15,0,%0,c15,c0,2")	/* DGNCTLR2 */
946c06208b7Sskrll 
94723b9975cSmatt ARMREG_READ_INLINE(cbar, "p15,4,%0,c15,c0,0")	/* Configuration Base Address Register */
948c06208b7Sskrll 
949977dafe5Smatt ARMREG_READ_INLINE(pmcrv6, "p15,0,%0,c15,c12,0") /* PMC Control Register (armv6) */
950977dafe5Smatt ARMREG_WRITE_INLINE(pmcrv6, "p15,0,%0,c15,c12,0") /* PMC Control Register (armv6) */
951977dafe5Smatt ARMREG_READ_INLINE(pmccntrv6, "p15,0,%0,c15,c12,1") /* PMC Cycle Counter (armv6) */
952977dafe5Smatt ARMREG_WRITE_INLINE(pmccntrv6, "p15,0,%0,c15,c12,1") /* PMC Cycle Counter (armv6) */
953977dafe5Smatt 
954c655992eSmatt ARMREG_READ_INLINE(tlbdata0, "p15,3,%0,c15,c0,0") /* TLB Data Register 0 (cortex) */
955c655992eSmatt ARMREG_READ_INLINE(tlbdata1, "p15,3,%0,c15,c0,1") /* TLB Data Register 1 (cortex) */
956c655992eSmatt ARMREG_READ_INLINE(tlbdata2, "p15,3,%0,c15,c0,2") /* TLB Data Register 2 (cortex) */
957c655992eSmatt ARMREG_WRITE_INLINE(tlbdataop, "p15,3,%0,c15,c4,2") /* TLB Data Read Operation (cortex) */
958c655992eSmatt 
9597550e9f8Smatt ARMREG_READ_INLINE(sheeva_xctrl, "p15,1,%0,c15,c1,0") /* Sheeva eXtra Control register */
9607550e9f8Smatt ARMREG_WRITE_INLINE(sheeva_xctrl, "p15,1,%0,c15,c1,0") /* Sheeva eXtra Control register */
9617550e9f8Smatt 
9621bfb364cSskrll #if defined(_KERNEL)
9631bfb364cSskrll 
9641bfb364cSskrll static inline uint64_t
cpu_mpidr_aff_read(void)9651bfb364cSskrll cpu_mpidr_aff_read(void)
9661bfb364cSskrll {
9671bfb364cSskrll 
9681bfb364cSskrll 	return armreg_mpidr_read() & (MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0);
9691bfb364cSskrll }
9701bfb364cSskrll 
971fe33aa27Sryo /*
972fe33aa27Sryo  * GENERIC TIMER register access
973fe33aa27Sryo  */
974fe33aa27Sryo static inline uint32_t
gtmr_cntfrq_read(void)975fe33aa27Sryo gtmr_cntfrq_read(void)
976fe33aa27Sryo {
977fe33aa27Sryo 
978fe33aa27Sryo 	return armreg_cnt_frq_read();
979fe33aa27Sryo }
980fe33aa27Sryo 
981fe33aa27Sryo static inline uint32_t
gtmr_cntk_ctl_read(void)982fe33aa27Sryo gtmr_cntk_ctl_read(void)
983fe33aa27Sryo {
984fe33aa27Sryo 
985fe33aa27Sryo 	return armreg_cntk_ctl_read();
986fe33aa27Sryo }
987fe33aa27Sryo 
988fe33aa27Sryo static inline void
gtmr_cntk_ctl_write(uint32_t val)989fe33aa27Sryo gtmr_cntk_ctl_write(uint32_t val)
990fe33aa27Sryo {
991fe33aa27Sryo 
992fe33aa27Sryo 	armreg_cntk_ctl_write(val);
993fe33aa27Sryo }
994fe33aa27Sryo 
995fe33aa27Sryo static inline uint64_t
gtmr_cntpct_read(void)996fe33aa27Sryo gtmr_cntpct_read(void)
997fe33aa27Sryo {
998fe33aa27Sryo 
999fe33aa27Sryo 	return armreg_cntp_ct_read();
1000fe33aa27Sryo }
1001fe33aa27Sryo 
1002fe33aa27Sryo /*
1003fe33aa27Sryo  * Counter-timer Virtual Count timer
1004fe33aa27Sryo  */
1005fe33aa27Sryo static inline uint64_t
gtmr_cntvct_read(void)1006fe33aa27Sryo gtmr_cntvct_read(void)
1007fe33aa27Sryo {
1008fe33aa27Sryo 
1009fe33aa27Sryo 	return armreg_cntv_ct_read();
1010fe33aa27Sryo }
1011fe33aa27Sryo 
1012fe33aa27Sryo /*
1013fe33aa27Sryo  * Counter-timer Virtual Timer Control register
1014fe33aa27Sryo  */
1015fe33aa27Sryo static inline uint32_t
gtmr_cntv_ctl_read(void)1016fe33aa27Sryo gtmr_cntv_ctl_read(void)
1017fe33aa27Sryo {
1018fe33aa27Sryo 
1019fe33aa27Sryo 	return armreg_cntv_ctl_read();
1020fe33aa27Sryo }
1021fe33aa27Sryo 
1022fe33aa27Sryo static inline void
gtmr_cntv_ctl_write(uint32_t val)1023fe33aa27Sryo gtmr_cntv_ctl_write(uint32_t val)
1024fe33aa27Sryo {
1025fe33aa27Sryo 
1026fe33aa27Sryo 	armreg_cntv_ctl_write(val);
1027fe33aa27Sryo }
1028fe33aa27Sryo 
102926039c88Sjmcneill 
103026039c88Sjmcneill /*
103126039c88Sjmcneill  * Counter-timer Physical Timer Control register
103226039c88Sjmcneill  */
103326039c88Sjmcneill 
103426039c88Sjmcneill static inline uint32_t
gtmr_cntp_ctl_read(void)103526039c88Sjmcneill gtmr_cntp_ctl_read(void)
103626039c88Sjmcneill {
103726039c88Sjmcneill 
103826039c88Sjmcneill 	return armreg_cntp_ctl_read();
103926039c88Sjmcneill }
104026039c88Sjmcneill 
1041fe33aa27Sryo static inline void
gtmr_cntp_ctl_write(uint32_t val)1042fe33aa27Sryo gtmr_cntp_ctl_write(uint32_t val)
1043fe33aa27Sryo {
1044fe33aa27Sryo 
1045fe33aa27Sryo 	armreg_cntp_ctl_write(val);
1046fe33aa27Sryo }
1047fe33aa27Sryo 
1048fe33aa27Sryo 
1049fe33aa27Sryo /*
105026039c88Sjmcneill  * Counter-timer Physical Timer TimerValue register
105126039c88Sjmcneill  */
105226039c88Sjmcneill static inline uint32_t
gtmr_cntp_tval_read(void)105326039c88Sjmcneill gtmr_cntp_tval_read(void)
105426039c88Sjmcneill {
105526039c88Sjmcneill 
105626039c88Sjmcneill 	return armreg_cntp_tval_read();
105726039c88Sjmcneill }
105826039c88Sjmcneill 
105926039c88Sjmcneill static inline void
gtmr_cntp_tval_write(uint32_t val)106026039c88Sjmcneill gtmr_cntp_tval_write(uint32_t val)
106126039c88Sjmcneill {
106226039c88Sjmcneill 
106326039c88Sjmcneill 	armreg_cntp_tval_write(val);
106426039c88Sjmcneill }
106526039c88Sjmcneill 
106626039c88Sjmcneill 
106726039c88Sjmcneill /*
1068fe33aa27Sryo  * Counter-timer Virtual Timer TimerValue register
1069fe33aa27Sryo  */
1070c6d1ef8aSjoerg static inline uint32_t
gtmr_cntv_tval_read(void)1071c6d1ef8aSjoerg gtmr_cntv_tval_read(void)
1072c6d1ef8aSjoerg {
1073c6d1ef8aSjoerg 
1074c6d1ef8aSjoerg 	return armreg_cntv_tval_read();
1075c6d1ef8aSjoerg }
1076c6d1ef8aSjoerg 
1077fe33aa27Sryo static inline void
gtmr_cntv_tval_write(uint32_t val)1078fe33aa27Sryo gtmr_cntv_tval_write(uint32_t val)
1079fe33aa27Sryo {
1080fe33aa27Sryo 
1081fe33aa27Sryo 	armreg_cntv_tval_write(val);
1082fe33aa27Sryo }
1083fe33aa27Sryo 
1084fe33aa27Sryo 
1085fe33aa27Sryo /*
108626039c88Sjmcneill  * Counter-timer Physical Timer CompareValue register
108726039c88Sjmcneill  */
108826039c88Sjmcneill static inline uint64_t
gtmr_cntp_cval_read(void)108926039c88Sjmcneill gtmr_cntp_cval_read(void)
109026039c88Sjmcneill {
109126039c88Sjmcneill 
109226039c88Sjmcneill 	return armreg_cntp_cval_read();
109326039c88Sjmcneill }
109426039c88Sjmcneill 
109526039c88Sjmcneill static inline void
gtmr_cntp_cval_write(uint64_t val)109626039c88Sjmcneill gtmr_cntp_cval_write(uint64_t val)
109726039c88Sjmcneill {
109826039c88Sjmcneill 
109926039c88Sjmcneill 	armreg_cntp_cval_write(val);
110026039c88Sjmcneill }
110126039c88Sjmcneill 
110226039c88Sjmcneill 
110326039c88Sjmcneill /*
1104fe33aa27Sryo  * Counter-timer Virtual Timer CompareValue register
1105fe33aa27Sryo  */
1106fe33aa27Sryo static inline uint64_t
gtmr_cntv_cval_read(void)1107fe33aa27Sryo gtmr_cntv_cval_read(void)
1108fe33aa27Sryo {
1109fe33aa27Sryo 
1110fe33aa27Sryo 	return armreg_cntv_cval_read();
1111fe33aa27Sryo }
1112fe33aa27Sryo 
1113a5916c5cSjmcneill static inline void
gtmr_cntv_cval_write(uint64_t val)1114a5916c5cSjmcneill gtmr_cntv_cval_write(uint64_t val)
1115a5916c5cSjmcneill {
1116a5916c5cSjmcneill 
1117a5916c5cSjmcneill 	armreg_cntv_cval_write(val);
1118a5916c5cSjmcneill }
1119a5916c5cSjmcneill 
11201bfb364cSskrll #endif /* _KERNEL */
11211bfb364cSskrll #endif /* !__ASSEMBLER && !_RUMPKERNEL */
1122a31d113aSmatt 
1123fe33aa27Sryo #elif defined(__aarch64__)
1124fe33aa27Sryo 
1125fe33aa27Sryo #include <aarch64/armreg.h>
1126fe33aa27Sryo 
1127fe33aa27Sryo #endif /* __arm__/__aarch64__ */
1128fe33aa27Sryo 
1129825088edSmatt #endif	/* _ARM_ARMREG_H */
1130