Home | History | Annotate | Line # | Download | only in include
armreg.h revision 1.41
      1  1.41  riastrad /* $NetBSD: armreg.h,v 1.41 2020/05/10 21:40:38 riastradh Exp $ */
      2   1.1      matt 
      3   1.1      matt /*-
      4   1.1      matt  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5   1.1      matt  * All rights reserved.
      6   1.1      matt  *
      7   1.1      matt  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1      matt  * by Matt Thomas of 3am Software Foundry.
      9   1.1      matt  *
     10   1.1      matt  * Redistribution and use in source and binary forms, with or without
     11   1.1      matt  * modification, are permitted provided that the following conditions
     12   1.1      matt  * are met:
     13   1.1      matt  * 1. Redistributions of source code must retain the above copyright
     14   1.1      matt  *    notice, this list of conditions and the following disclaimer.
     15   1.1      matt  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1      matt  *    notice, this list of conditions and the following disclaimer in the
     17   1.1      matt  *    documentation and/or other materials provided with the distribution.
     18   1.1      matt  *
     19   1.1      matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.1      matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.1      matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.1      matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.1      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.1      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.1      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.1      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.1      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.1      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.1      matt  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1      matt  */
     31   1.1      matt 
     32   1.1      matt #ifndef _AARCH64_ARMREG_H_
     33   1.1      matt #define _AARCH64_ARMREG_H_
     34   1.1      matt 
     35   1.8       ryo #include <arm/cputypes.h>
     36   1.1      matt #include <sys/types.h>
     37   1.1      matt 
     38  1.33      maxv #define AARCH64REG_READ_INLINE3(regname, regdesc, fnattrs)	\
     39  1.33      maxv static __inline uint64_t fnattrs				\
     40   1.7     skrll reg_##regname##_read(void)					\
     41   1.7     skrll {								\
     42   1.7     skrll 	uint64_t __rv;						\
     43   1.7     skrll 	__asm __volatile("mrs %0, " #regdesc : "=r"(__rv));	\
     44   1.7     skrll 	return __rv;						\
     45   1.1      matt }
     46   1.1      matt 
     47  1.33      maxv #define AARCH64REG_READ_INLINE2(regname, regdesc)		\
     48  1.33      maxv 	AARCH64REG_READ_INLINE3(regname, regdesc, )
     49  1.33      maxv 
     50  1.33      maxv #define AARCH64REG_WRITE_INLINE3(regname, regdesc, fnattrs)	\
     51  1.33      maxv static __inline void fnattrs					\
     52   1.7     skrll reg_##regname##_write(uint64_t __val)				\
     53   1.7     skrll {								\
     54   1.7     skrll 	__asm __volatile("msr " #regdesc ", %0" :: "r"(__val));	\
     55   1.1      matt }
     56   1.1      matt 
     57  1.33      maxv #define AARCH64REG_WRITE_INLINE2(regname, regdesc)		\
     58  1.33      maxv 	AARCH64REG_WRITE_INLINE3(regname, regdesc, )
     59  1.33      maxv 
     60   1.7     skrll #define AARCH64REG_WRITEIMM_INLINE2(regname, regdesc)		\
     61  1.12  christos static __inline void						\
     62   1.7     skrll reg_##regname##_write(uint64_t __val)				\
     63   1.7     skrll {								\
     64   1.7     skrll 	__asm __volatile("msr " #regdesc ", %0" :: "n"(__val));	\
     65   1.1      matt }
     66   1.1      matt 
     67   1.7     skrll #define AARCH64REG_READ_INLINE(regname)				\
     68   1.1      matt 	AARCH64REG_READ_INLINE2(regname, regname)
     69   1.1      matt 
     70   1.7     skrll #define AARCH64REG_WRITE_INLINE(regname)			\
     71   1.1      matt 	AARCH64REG_WRITE_INLINE2(regname, regname)
     72   1.1      matt 
     73   1.7     skrll #define AARCH64REG_WRITEIMM_INLINE(regname)			\
     74   1.1      matt 	AARCH64REG_WRITEIMM_INLINE2(regname, regname)
     75  1.15  jmcneill 
     76  1.15  jmcneill #define AARCH64REG_READWRITE_INLINE2(regname, regdesc)		\
     77  1.15  jmcneill 	AARCH64REG_READ_INLINE2(regname, regdesc)		\
     78  1.15  jmcneill 	AARCH64REG_WRITE_INLINE2(regname, regdesc)
     79  1.15  jmcneill 
     80  1.24       ryo #define AARCH64REG_ATWRITE_INLINE2(regname, regdesc)		\
     81  1.24       ryo static __inline void						\
     82  1.24       ryo reg_##regname##_write(uint64_t __val)				\
     83  1.24       ryo {								\
     84  1.24       ryo 	__asm __volatile("at " #regdesc ", %0" :: "r"(__val));	\
     85  1.24       ryo }
     86  1.24       ryo 
     87  1.24       ryo #define AARCH64REG_ATWRITE_INLINE(regname)			\
     88  1.24       ryo 	AARCH64REG_ATWRITE_INLINE2(regname, regname)
     89  1.24       ryo 
     90   1.1      matt /*
     91   1.1      matt  * System registers available at EL0 (user)
     92   1.1      matt  */
     93   1.1      matt AARCH64REG_READ_INLINE(ctr_el0)		// Cache Type Register
     94   1.1      matt 
     95  1.13     skrll #define	CTR_EL0_CWG_LINE	__BITS(27,24)	// Cacheback Writeback Granule
     96  1.13     skrll #define	CTR_EL0_ERG_LINE	__BITS(23,20)	// Exclusives Reservation Granule
     97  1.13     skrll #define	CTR_EL0_DMIN_LINE	__BITS(19,16)	// Dcache MIN LINE size (log2 - 2)
     98  1.12  christos #define	CTR_EL0_L1IP_MASK	__BITS(15,14)
     99  1.37       ryo #define	 CTR_EL0_L1IP_VPIPT	0		//  VMID-aware Physical Index, Physical Tag
    100  1.13     skrll #define	 CTR_EL0_L1IP_AIVIVT	1		//  ASID-tagged Virtual Index, Virtual Tag
    101  1.13     skrll #define	 CTR_EL0_L1IP_VIPT	2		//  Virtual Index, Physical Tag
    102  1.13     skrll #define	 CTR_EL0_L1IP_PIPT	3		//  Physical Index, Physical Tag
    103  1.13     skrll #define	CTR_EL0_IMIN_LINE	__BITS(3,0)	// Icache MIN LINE size (log2 - 2)
    104   1.1      matt 
    105  1.14     skrll AARCH64REG_READ_INLINE(dczid_el0)	// Data Cache Zero ID Register
    106   1.1      matt 
    107  1.13     skrll #define	DCZID_DZP		__BIT(4)	// Data Zero Prohibited
    108  1.13     skrll #define	DCZID_BS		__BITS(3,0)	// Block Size (log2 - 2)
    109   1.1      matt 
    110  1.14     skrll AARCH64REG_READ_INLINE(fpcr)		// Floating Point Control Register
    111   1.1      matt AARCH64REG_WRITE_INLINE(fpcr)
    112   1.1      matt 
    113  1.13     skrll #define	FPCR_AHP		__BIT(26)	// Alternative Half Precision
    114  1.13     skrll #define	FPCR_DN			__BIT(25)	// Default Nan Control
    115  1.13     skrll #define	FPCR_FZ			__BIT(24)	// Flush-To-Zero
    116  1.13     skrll #define	FPCR_RMODE		__BITS(23,22)	// Rounding Mode
    117  1.13     skrll #define	 FPCR_RN		0		//  Round Nearest
    118  1.13     skrll #define	 FPCR_RP		1		//  Round towards Plus infinity
    119  1.13     skrll #define	 FPCR_RM		2		//  Round towards Minus infinity
    120  1.13     skrll #define	 FPCR_RZ		3		//  Round towards Zero
    121  1.13     skrll #define	FPCR_STRIDE		__BITS(21,20)
    122  1.20  riastrad #define	FPCR_FZ16		__BIT(19)	// Flush-To-Zero for FP16
    123  1.13     skrll #define	FPCR_LEN		__BITS(18,16)
    124  1.13     skrll #define	FPCR_IDE		__BIT(15)	// Input Denormal Exception enable
    125  1.13     skrll #define	FPCR_IXE		__BIT(12)	// IneXact Exception enable
    126  1.13     skrll #define	FPCR_UFE		__BIT(11)	// UnderFlow Exception enable
    127  1.13     skrll #define	FPCR_OFE		__BIT(10)	// OverFlow Exception enable
    128  1.13     skrll #define	FPCR_DZE		__BIT(9)	// Divide by Zero Exception enable
    129  1.13     skrll #define	FPCR_IOE		__BIT(8)	// Invalid Operation Exception enable
    130  1.13     skrll #define	FPCR_ESUM		0x1F00
    131   1.1      matt 
    132   1.1      matt AARCH64REG_READ_INLINE(fpsr)		// Floating Point Status Register
    133   1.1      matt AARCH64REG_WRITE_INLINE(fpsr)
    134   1.1      matt 
    135  1.13     skrll #define	FPSR_N32		__BIT(31)	// AARCH32 Negative
    136  1.13     skrll #define	FPSR_Z32		__BIT(30)	// AARCH32 Zero
    137  1.13     skrll #define	FPSR_C32		__BIT(29)	// AARCH32 Carry
    138  1.13     skrll #define	FPSR_V32		__BIT(28)	// AARCH32 Overflow
    139  1.13     skrll #define	FPSR_QC			__BIT(27)	// SIMD Saturation
    140  1.13     skrll #define	FPSR_IDC		__BIT(7)	// Input Denormal Cumulative status
    141  1.13     skrll #define	FPSR_IXC		__BIT(4)	// IneXact Cumulative status
    142  1.13     skrll #define	FPSR_UFC		__BIT(3)	// UnderFlow Cumulative status
    143  1.13     skrll #define	FPSR_OFC		__BIT(2)	// OverFlow Cumulative status
    144  1.13     skrll #define	FPSR_DZC		__BIT(1)	// Divide by Zero Cumulative status
    145  1.13     skrll #define	FPSR_IOC		__BIT(0)	// Invalid Operation Cumulative status
    146  1.13     skrll #define	FPSR_CSUM		0x1F
    147   1.1      matt 
    148   1.1      matt AARCH64REG_READ_INLINE(nzcv)		// condition codes
    149   1.1      matt AARCH64REG_WRITE_INLINE(nzcv)
    150   1.1      matt 
    151  1.13     skrll #define	NZCV_N			__BIT(31)	// Negative
    152  1.13     skrll #define	NZCV_Z			__BIT(30)	// Zero
    153  1.13     skrll #define	NZCV_C			__BIT(29)	// Carry
    154  1.13     skrll #define	NZCV_V			__BIT(28)	// Overflow
    155   1.1      matt 
    156   1.1      matt AARCH64REG_READ_INLINE(tpidr_el0)	// Thread Pointer ID Register (RW)
    157   1.1      matt AARCH64REG_WRITE_INLINE(tpidr_el0)
    158   1.1      matt 
    159   1.9       ryo AARCH64REG_READ_INLINE(tpidrro_el0)	// Thread Pointer ID Register (RO)
    160   1.9       ryo 
    161   1.3     skrll /*
    162   1.1      matt  * From here on, these can only be accessed at EL1 (kernel)
    163   1.1      matt  */
    164   1.1      matt 
    165   1.1      matt /*
    166   1.1      matt  * These are readonly registers
    167   1.1      matt  */
    168   1.9       ryo AARCH64REG_READ_INLINE(aidr_el1)
    169   1.9       ryo 
    170  1.14     skrll AARCH64REG_READ_INLINE2(cbar_el1, s3_1_c15_c3_0)	// Cortex-A57
    171   1.1      matt 
    172  1.13     skrll #define	CBAR_PA			__BITS(47,18)
    173   1.1      matt 
    174   1.9       ryo AARCH64REG_READ_INLINE(ccsidr_el1)
    175   1.9       ryo 
    176  1.37       ryo #define	CCSIDR_WT		__BIT(31)	// OBSOLETE: Write-through supported
    177  1.37       ryo #define	CCSIDR_WB		__BIT(30)	// OBSOLETE: Write-back supported
    178  1.37       ryo #define	CCSIDR_RA		__BIT(29)	// OBSOLETE: Read-allocation supported
    179  1.37       ryo #define	CCSIDR_WA		__BIT(28)	// OBSOLETE: Write-allocation supported
    180  1.13     skrll #define	CCSIDR_NUMSET		__BITS(27,13)	// (Number of sets in cache) - 1
    181  1.13     skrll #define	CCSIDR_ASSOC		__BITS(12,3)	// (Associativity of cache) - 1
    182  1.13     skrll #define	CCSIDR_LINESIZE 	__BITS(2,0)	// Number of bytes in cache line
    183   1.9       ryo 
    184   1.1      matt AARCH64REG_READ_INLINE(clidr_el1)
    185   1.9       ryo 
    186  1.37       ryo #define	CLIDR_ICB		__BITS(32,30)	// Inner cache boundary
    187  1.13     skrll #define	CLIDR_LOUU		__BITS(29,27)	// Level of Unification Uniprocessor
    188  1.13     skrll #define	CLIDR_LOC		__BITS(26,24)	// Level of Coherency
    189  1.13     skrll #define	CLIDR_LOUIS		__BITS(23,21)	// Level of Unification InnerShareable*/
    190  1.13     skrll #define	CLIDR_CTYPE7		__BITS(20,18)	// Cache Type field for level7
    191  1.13     skrll #define	CLIDR_CTYPE6		__BITS(17,15)	// Cache Type field for level6
    192  1.13     skrll #define	CLIDR_CTYPE5		__BITS(14,12)	// Cache Type field for level5
    193  1.13     skrll #define	CLIDR_CTYPE4		__BITS(11,9)	// Cache Type field for level4
    194  1.13     skrll #define	CLIDR_CTYPE3		__BITS(8,6)	// Cache Type field for level3
    195  1.13     skrll #define	CLIDR_CTYPE2		__BITS(5,3)	// Cache Type field for level2
    196  1.13     skrll #define	CLIDR_CTYPE1		__BITS(2,0)	// Cache Type field for level1
    197  1.13     skrll #define	 CLIDR_TYPE_NOCACHE	 0		//  No cache
    198  1.13     skrll #define	 CLIDR_TYPE_ICACHE	 1		//  Instruction cache only
    199  1.13     skrll #define	 CLIDR_TYPE_DCACHE	 2		//  Data cache only
    200  1.13     skrll #define	 CLIDR_TYPE_IDCACHE	 3		//  Separate inst and data caches
    201  1.13     skrll #define	 CLIDR_TYPE_UNIFIEDCACHE 4		//  Unified cache
    202   1.9       ryo 
    203   1.9       ryo AARCH64REG_READ_INLINE(currentel)
    204   1.9       ryo AARCH64REG_READ_INLINE(id_aa64afr0_el1)
    205   1.9       ryo AARCH64REG_READ_INLINE(id_aa64afr1_el1)
    206   1.9       ryo AARCH64REG_READ_INLINE(id_aa64dfr0_el1)
    207   1.9       ryo 
    208  1.37       ryo #define	ID_AA64DFR0_EL1_TRACEFILT	__BITS(43,40)
    209  1.37       ryo #define	 ID_AA64DFR0_EL1_TRACEFILT_NONE	 0
    210  1.37       ryo #define	 ID_AA64DFR0_EL1_TRACEFILT_IMPL	 1
    211  1.38       ryo #define	ID_AA64DFR0_EL1_DBLLOCK		__BITS(39,36)
    212  1.37       ryo #define	 ID_AA64DFR0_EL1_DBLLOCK_IMPL	 0
    213  1.37       ryo #define	 ID_AA64DFR0_EL1_DBLLOCK_NONE	 15
    214  1.37       ryo #define	ID_AA64DFR0_EL1_PMSVER		__BITS(35,32)
    215  1.13     skrll #define	ID_AA64DFR0_EL1_CTX_CMPS	__BITS(31,28)
    216  1.13     skrll #define	ID_AA64DFR0_EL1_WRPS		__BITS(20,23)
    217  1.13     skrll #define	ID_AA64DFR0_EL1_BRPS		__BITS(12,15)
    218  1.13     skrll #define	ID_AA64DFR0_EL1_PMUVER		__BITS(8,11)
    219  1.13     skrll #define	 ID_AA64DFR0_EL1_PMUVER_NONE	 0
    220  1.12  christos #define	 ID_AA64DFR0_EL1_PMUVER_V3	 1
    221  1.13     skrll #define	 ID_AA64DFR0_EL1_PMUVER_NOV3	 2
    222  1.13     skrll #define	ID_AA64DFR0_EL1_TRACEVER	__BITS(4,7)
    223  1.13     skrll #define	 ID_AA64DFR0_EL1_TRACEVER_NONE	 0
    224  1.13     skrll #define	 ID_AA64DFR0_EL1_TRACEVER_IMPL	 1
    225  1.13     skrll #define	ID_AA64DFR0_EL1_DEBUGVER	__BITS(0,3)
    226  1.13     skrll #define	 ID_AA64DFR0_EL1_DEBUGVER_V8A	 6
    227   1.9       ryo 
    228   1.9       ryo AARCH64REG_READ_INLINE(id_aa64dfr1_el1)
    229   1.9       ryo 
    230   1.9       ryo AARCH64REG_READ_INLINE(id_aa64isar0_el1)
    231   1.9       ryo 
    232  1.41  riastrad #define	ID_AA64ISAR0_EL1_RNDR		__BITS(63,60)
    233  1.37       ryo #define	 ID_AA64ISAR0_EL1_RNDR_NONE	 0
    234  1.37       ryo #define	 ID_AA64ISAR0_EL1_RNDR_RNDRRS	 1
    235  1.37       ryo #define	ID_AA64ISAR0_EL1_TLB		__BITS(59,56)
    236  1.37       ryo #define	 ID_AA64ISAR0_EL1_TLB_NONE	 0
    237  1.37       ryo #define	 ID_AA64ISAR0_EL1_TLB_OS	 1
    238  1.37       ryo #define	 ID_AA64ISAR0_EL1_TLB_OS_TLB	 2
    239  1.37       ryo #define	ID_AA64ISAR0_EL1_TS		__BITS(55,52)
    240  1.37       ryo #define	 ID_AA64ISAR0_EL1_TS_NONE	 0
    241  1.37       ryo #define	 ID_AA64ISAR0_EL1_TS_CFINV	 1
    242  1.37       ryo #define	 ID_AA64ISAR0_EL1_TS_AXFLAG	 2
    243  1.37       ryo #define	ID_AA64ISAR0_EL1_FHM		__BITS(51,48)
    244  1.37       ryo #define	 ID_AA64ISAR0_EL1_FHM_NONE	 0
    245  1.37       ryo #define	 ID_AA64ISAR0_EL1_FHM_FMLAL	 1
    246  1.37       ryo #define	ID_AA64ISAR0_EL1_DP		__BITS(47,44)
    247  1.37       ryo #define	 ID_AA64ISAR0_EL1_DP_NONE	 0
    248  1.37       ryo #define	 ID_AA64ISAR0_EL1_DP_UDOT	 1
    249  1.37       ryo #define	ID_AA64ISAR0_EL1_SM4		__BITS(43,40)
    250  1.37       ryo #define	 ID_AA64ISAR0_EL1_SM4_NONE	 0
    251  1.37       ryo #define	 ID_AA64ISAR0_EL1_SM4_SM4	 1
    252  1.37       ryo #define	ID_AA64ISAR0_EL1_SM3		__BITS(39,36)
    253  1.37       ryo #define	 ID_AA64ISAR0_EL1_SM3_NONE	 0
    254  1.37       ryo #define	 ID_AA64ISAR0_EL1_SM3_SM3	 1
    255  1.37       ryo #define	ID_AA64ISAR0_EL1_SHA3		__BITS(35,32)
    256  1.37       ryo #define	 ID_AA64ISAR0_EL1_SHA3_NONE	 0
    257  1.37       ryo #define	 ID_AA64ISAR0_EL1_SHA3_EOR3	 1
    258  1.37       ryo #define	ID_AA64ISAR0_EL1_RDM		__BITS(31,28)
    259  1.37       ryo #define	 ID_AA64ISAR0_EL1_RDM_NONE	 0
    260  1.37       ryo #define	 ID_AA64ISAR0_EL1_RDM_SQRDML	 1
    261  1.37       ryo #define	ID_AA64ISAR0_EL1_ATOMIC		__BITS(23,20)
    262  1.37       ryo #define	 ID_AA64ISAR0_EL1_ATOMIC_NONE	 0
    263  1.37       ryo #define	 ID_AA64ISAR0_EL1_ATOMIC_SWP	 1
    264  1.13     skrll #define	ID_AA64ISAR0_EL1_CRC32		__BITS(19,16)
    265  1.13     skrll #define	 ID_AA64ISAR0_EL1_CRC32_NONE	 0
    266  1.13     skrll #define	 ID_AA64ISAR0_EL1_CRC32_CRC32X	 1
    267  1.13     skrll #define	ID_AA64ISAR0_EL1_SHA2		__BITS(15,12)
    268  1.12  christos #define	 ID_AA64ISAR0_EL1_SHA2_NONE	 0
    269  1.12  christos #define	 ID_AA64ISAR0_EL1_SHA2_SHA256HSU 1
    270  1.37       ryo #define	 ID_AA64ISAR0_EL1_SHA2_SHA512HSU 2
    271  1.13     skrll #define	ID_AA64ISAR0_EL1_SHA1		__BITS(11,8)
    272  1.12  christos #define	 ID_AA64ISAR0_EL1_SHA1_NONE	 0
    273  1.12  christos #define	 ID_AA64ISAR0_EL1_SHA1_SHA1CPMHSU 1
    274  1.13     skrll #define	ID_AA64ISAR0_EL1_AES		__BITS(7,4)
    275  1.12  christos #define	 ID_AA64ISAR0_EL1_AES_NONE	 0
    276  1.12  christos #define	 ID_AA64ISAR0_EL1_AES_AES	 1
    277  1.12  christos #define	 ID_AA64ISAR0_EL1_AES_PMUL	 2
    278   1.9       ryo 
    279   1.9       ryo AARCH64REG_READ_INLINE(id_aa64isar1_el1)
    280  1.31      maxv 
    281  1.31      maxv #define	ID_AA64ISAR1_EL1_SPECRES	__BITS(43,40)
    282  1.31      maxv #define	 ID_AA64ISAR1_EL1_SPECRES_NONE	 0
    283  1.31      maxv #define	 ID_AA64ISAR1_EL1_SPECRES_SUPPORTED 1
    284  1.31      maxv #define	ID_AA64ISAR1_EL1_SB		__BITS(39,36)
    285  1.31      maxv #define	 ID_AA64ISAR1_EL1_SB_NONE	 0
    286  1.31      maxv #define	 ID_AA64ISAR1_EL1_SB_SUPPORTED	 1
    287  1.31      maxv #define	ID_AA64ISAR1_EL1_FRINTTS	__BITS(35,32)
    288  1.31      maxv #define	 ID_AA64ISAR1_EL1_FRINTTS_NONE	 0
    289  1.31      maxv #define	 ID_AA64ISAR1_EL1_FRINTTS_SUPPORTED 1
    290  1.31      maxv #define	ID_AA64ISAR1_EL1_GPI		__BITS(31,28)
    291  1.31      maxv #define	 ID_AA64ISAR1_EL1_GPI_NONE	 0
    292  1.31      maxv #define	 ID_AA64ISAR1_EL1_GPI_SUPPORTED	 1
    293  1.31      maxv #define	ID_AA64ISAR1_EL1_GPA		__BITS(27,24)
    294  1.31      maxv #define	 ID_AA64ISAR1_EL1_GPA_NONE	 0
    295  1.31      maxv #define	 ID_AA64ISAR1_EL1_GPA_QARMA	 1
    296  1.31      maxv #define	ID_AA64ISAR1_EL1_LRCPC		__BITS(23,20)
    297  1.31      maxv #define	 ID_AA64ISAR1_EL1_LRCPC_NONE	 0
    298  1.31      maxv #define	 ID_AA64ISAR1_EL1_LRCPC_PR	 1
    299  1.31      maxv #define	 ID_AA64ISAR1_EL1_LRCPC_PR_UR	 2
    300  1.31      maxv #define	ID_AA64ISAR1_EL1_FCMA		__BITS(19,16)
    301  1.31      maxv #define	 ID_AA64ISAR1_EL1_FCMA_NONE	 0
    302  1.31      maxv #define	 ID_AA64ISAR1_EL1_FCMA_SUPPORTED 1
    303  1.31      maxv #define	ID_AA64ISAR1_EL1_JSCVT		__BITS(15,12)
    304  1.31      maxv #define	 ID_AA64ISAR1_EL1_JSCVT_NONE	 0
    305  1.31      maxv #define	 ID_AA64ISAR1_EL1_JSCVT_SUPPORTED 1
    306  1.31      maxv #define	ID_AA64ISAR1_EL1_API		__BITS(11,8)
    307  1.31      maxv #define	 ID_AA64ISAR1_EL1_API_NONE	 0
    308  1.31      maxv #define	 ID_AA64ISAR1_EL1_API_SUPPORTED	 1
    309  1.31      maxv #define	 ID_AA64ISAR1_EL1_API_ENHANCED	 2
    310  1.31      maxv #define	ID_AA64ISAR1_EL1_APA		__BITS(7,4)
    311  1.31      maxv #define	 ID_AA64ISAR1_EL1_APA_NONE	 0
    312  1.31      maxv #define	 ID_AA64ISAR1_EL1_APA_QARMA	 1
    313  1.31      maxv #define	 ID_AA64ISAR1_EL1_APA_QARMA_ENH	 2
    314  1.31      maxv #define	ID_AA64ISAR1_EL1_DPB		__BITS(3,0)
    315  1.31      maxv #define	 ID_AA64ISAR1_EL1_DPB_NONE	 0
    316  1.31      maxv #define	 ID_AA64ISAR1_EL1_DPB_CVAP	 1
    317  1.31      maxv #define	 ID_AA64ISAR1_EL1_DPB_CVAP_CVADP 2
    318  1.31      maxv 
    319   1.9       ryo AARCH64REG_READ_INLINE(id_aa64mmfr0_el1)
    320   1.9       ryo 
    321  1.37       ryo #define	ID_AA64MMFR0_EL1_EXS		__BITS(43,40)
    322  1.13     skrll #define	ID_AA64MMFR0_EL1_TGRAN4		__BITS(31,28)
    323  1.13     skrll #define	 ID_AA64MMFR0_EL1_TGRAN4_4KB	 0
    324  1.13     skrll #define	 ID_AA64MMFR0_EL1_TGRAN4_NONE	 15
    325  1.13     skrll #define	ID_AA64MMFR0_EL1_TGRAN64	__BITS(24,27)
    326  1.13     skrll #define	 ID_AA64MMFR0_EL1_TGRAN64_64KB	 0
    327  1.13     skrll #define	 ID_AA64MMFR0_EL1_TGRAN64_NONE	 15
    328  1.13     skrll #define	ID_AA64MMFR0_EL1_TGRAN16	__BITS(20,23)
    329  1.13     skrll #define	 ID_AA64MMFR0_EL1_TGRAN16_NONE	 0
    330  1.13     skrll #define	 ID_AA64MMFR0_EL1_TGRAN16_16KB	 1
    331  1.13     skrll #define	ID_AA64MMFR0_EL1_BIGENDEL0	__BITS(16,19)
    332  1.12  christos #define	 ID_AA64MMFR0_EL1_BIGENDEL0_NONE 0
    333  1.13     skrll #define	 ID_AA64MMFR0_EL1_BIGENDEL0_MIX	 1
    334  1.13     skrll #define	ID_AA64MMFR0_EL1_SNSMEM		__BITS(12,15)
    335  1.13     skrll #define	 ID_AA64MMFR0_EL1_SNSMEM_NONE	 0
    336  1.13     skrll #define	 ID_AA64MMFR0_EL1_SNSMEM_SNSMEM	 1
    337  1.13     skrll #define	ID_AA64MMFR0_EL1_BIGEND		__BITS(8,11)
    338  1.13     skrll #define	 ID_AA64MMFR0_EL1_BIGEND_NONE	 0
    339  1.13     skrll #define	 ID_AA64MMFR0_EL1_BIGEND_MIX	 1
    340  1.13     skrll #define	ID_AA64MMFR0_EL1_ASIDBITS	__BITS(4,7)
    341  1.13     skrll #define	 ID_AA64MMFR0_EL1_ASIDBITS_8BIT	 0
    342  1.12  christos #define	 ID_AA64MMFR0_EL1_ASIDBITS_16BIT 2
    343  1.13     skrll #define	ID_AA64MMFR0_EL1_PARANGE	__BITS(0,3)
    344  1.13     skrll #define	 ID_AA64MMFR0_EL1_PARANGE_4G	 0
    345  1.13     skrll #define	 ID_AA64MMFR0_EL1_PARANGE_64G	 1
    346  1.13     skrll #define	 ID_AA64MMFR0_EL1_PARANGE_1T	 2
    347  1.13     skrll #define	 ID_AA64MMFR0_EL1_PARANGE_4T	 3
    348  1.13     skrll #define	 ID_AA64MMFR0_EL1_PARANGE_16T	 4
    349  1.13     skrll #define	 ID_AA64MMFR0_EL1_PARANGE_256T	 5
    350  1.37       ryo #define	 ID_AA64MMFR0_EL1_PARANGE_4P	 6
    351   1.9       ryo 
    352   1.9       ryo AARCH64REG_READ_INLINE(id_aa64mmfr1_el1)
    353  1.31      maxv 
    354  1.31      maxv #define	ID_AA64MMFR1_EL1_XNX		__BITS(31,28)
    355  1.31      maxv #define	 ID_AA64MMFR1_EL1_XNX_NONE	 0
    356  1.31      maxv #define	 ID_AA64MMFR1_EL1_XNX_SUPPORTED	 1
    357  1.31      maxv #define	ID_AA64MMFR1_EL1_SPECSEI	__BITS(27,24)
    358  1.31      maxv #define	 ID_AA64MMFR1_EL1_SPECSEI_NONE	 0
    359  1.31      maxv #define	 ID_AA64MMFR1_EL1_SPECSEI_EXTINT 1
    360  1.31      maxv #define	ID_AA64MMFR1_EL1_PAN		__BITS(23,20)
    361  1.31      maxv #define	 ID_AA64MMFR1_EL1_PAN_NONE	 0
    362  1.31      maxv #define	 ID_AA64MMFR1_EL1_PAN_SUPPORTED	 1
    363  1.31      maxv #define	 ID_AA64MMFR1_EL1_PAN_S1E1	 2
    364  1.31      maxv #define	ID_AA64MMFR1_EL1_LO		__BITS(19,16)
    365  1.31      maxv #define	 ID_AA64MMFR1_EL1_LO_NONE	 0
    366  1.31      maxv #define	 ID_AA64MMFR1_EL1_LO_SUPPORTED	 1
    367  1.31      maxv #define	ID_AA64MMFR1_EL1_HPDS		__BITS(15,12)
    368  1.31      maxv #define	 ID_AA64MMFR1_EL1_HPDS_NONE	 0
    369  1.31      maxv #define	 ID_AA64MMFR1_EL1_HPDS_SUPPORTED 1
    370  1.31      maxv #define	 ID_AA64MMFR1_EL1_HPDS_EXTRA_PTD 2
    371  1.31      maxv #define	ID_AA64MMFR1_EL1_VH		__BITS(11,8)
    372  1.31      maxv #define	 ID_AA64MMFR1_EL1_VH_NONE	 0
    373  1.31      maxv #define	 ID_AA64MMFR1_EL1_VH_SUPPORTED	 1
    374  1.31      maxv #define	ID_AA64MMFR1_EL1_VMIDBITS	__BITS(7,4)
    375  1.31      maxv #define	 ID_AA64MMFR1_EL1_VMIDBITS_8BIT	 0
    376  1.31      maxv #define	 ID_AA64MMFR1_EL1_VMIDBITS_16BIT 2
    377  1.31      maxv #define	ID_AA64MMFR1_EL1_HAFDBS		__BITS(3,0)
    378  1.31      maxv #define	 ID_AA64MMFR1_EL1_HAFDBS_NONE	 0
    379  1.31      maxv #define	 ID_AA64MMFR1_EL1_HAFDBS_A	 1
    380  1.31      maxv #define	 ID_AA64MMFR1_EL1_HAFDBS_AD	 2
    381  1.31      maxv 
    382  1.33      maxv AARCH64REG_READ_INLINE3(id_aa64mmfr2_el1, id_aa64mmfr2_el1,
    383  1.33      maxv     __attribute__((target("arch=armv8.2-a"))))
    384  1.31      maxv 
    385  1.31      maxv #define	ID_AA64MMFR2_EL1_E0PD		__BITS(63,60)
    386  1.31      maxv #define	 ID_AA64MMFR2_EL1_E0PD_NONE	 0
    387  1.31      maxv #define	 ID_AA64MMFR2_EL1_E0PD_SUPPORTED 1
    388  1.31      maxv #define	ID_AA64MMFR2_EL1_EVT		__BITS(59,56)
    389  1.31      maxv #define	 ID_AA64MMFR2_EL1_EVT_NONE	 0
    390  1.31      maxv #define	 ID_AA64MMFR2_EL1_EVT_TO_TI	 1
    391  1.31      maxv #define	 ID_AA64MMFR2_EL1_EVT_TO_TI_TTL	 2
    392  1.31      maxv #define	ID_AA64MMFR2_EL1_BBM		__BITS(55,52)
    393  1.31      maxv #define	 ID_AA64MMFR2_EL1_BBM_L0	 0
    394  1.31      maxv #define	 ID_AA64MMFR2_EL1_BBM_L1	 1
    395  1.31      maxv #define	 ID_AA64MMFR2_EL1_BBM_L2	 2
    396  1.31      maxv #define	ID_AA64MMFR2_EL1_TTL		__BITS(51,48)
    397  1.31      maxv #define	 ID_AA64MMFR2_EL1_TTL_NONE	 0
    398  1.31      maxv #define	 ID_AA64MMFR2_EL1_TTL_SUPPORTED	 1
    399  1.31      maxv #define	ID_AA64MMFR2_EL1_FWB		__BITS(43,40)
    400  1.31      maxv #define	 ID_AA64MMFR2_EL1_FWB_NONE	 0
    401  1.31      maxv #define	 ID_AA64MMFR2_EL1_FWB_SUPPORTED	 1
    402  1.31      maxv #define	ID_AA64MMFR2_EL1_IDS		__BITS(39,36)
    403  1.31      maxv #define	 ID_AA64MMFR2_EL1_IDS_0X0	 0
    404  1.31      maxv #define	 ID_AA64MMFR2_EL1_IDS_0X18	 1
    405  1.31      maxv #define	ID_AA64MMFR2_EL1_AT		__BITS(35,32)
    406  1.31      maxv #define	 ID_AA64MMFR2_EL1_AT_NONE	 0
    407  1.31      maxv #define	 ID_AA64MMFR2_EL1_AT_16BIT	 1
    408  1.31      maxv #define	ID_AA64MMFR2_EL1_ST		__BITS(31,28)
    409  1.31      maxv #define	 ID_AA64MMFR2_EL1_ST_39		 0
    410  1.31      maxv #define	 ID_AA64MMFR2_EL1_ST_48		 1
    411  1.31      maxv #define	ID_AA64MMFR2_EL1_NV		__BITS(27,24)
    412  1.31      maxv #define	 ID_AA64MMFR2_EL1_NV_NONE	 0
    413  1.31      maxv #define	 ID_AA64MMFR2_EL1_NV_HCR	 1
    414  1.31      maxv #define	 ID_AA64MMFR2_EL1_NV_HCR_VNCR	 2
    415  1.31      maxv #define	ID_AA64MMFR2_EL1_CCIDX		__BITS(23,20)
    416  1.31      maxv #define	 ID_AA64MMFR2_EL1_CCIDX_32BIT	 0
    417  1.31      maxv #define	 ID_AA64MMFR2_EL1_CCIDX_64BIT	 1
    418  1.31      maxv #define	ID_AA64MMFR2_EL1_VARANGE	__BITS(19,16)
    419  1.31      maxv #define	 ID_AA64MMFR2_EL1_VARANGE_48BIT	 0
    420  1.31      maxv #define	 ID_AA64MMFR2_EL1_VARANGE_52BIT	 1
    421  1.31      maxv #define	ID_AA64MMFR2_EL1_IESB		__BITS(15,12)
    422  1.31      maxv #define	 ID_AA64MMFR2_EL1_IESB_NONE	 0
    423  1.31      maxv #define	 ID_AA64MMFR2_EL1_IESB_SUPPORTED 1
    424  1.31      maxv #define	ID_AA64MMFR2_EL1_LSM		__BITS(11,8)
    425  1.31      maxv #define	 ID_AA64MMFR2_EL1_LSM_NONE	 0
    426  1.31      maxv #define	 ID_AA64MMFR2_EL1_LSM_SUPPORTED	 1
    427  1.31      maxv #define	ID_AA64MMFR2_EL1_UAO		__BITS(7,4)
    428  1.31      maxv #define	 ID_AA64MMFR2_EL1_UAO_NONE	 0
    429  1.31      maxv #define	 ID_AA64MMFR2_EL1_UAO_SUPPORTED	 1
    430  1.31      maxv #define	ID_AA64MMFR2_EL1_CNP		__BITS(3,0)
    431  1.31      maxv #define	 ID_AA64MMFR2_EL1_CNP_NONE	 0
    432  1.31      maxv #define	 ID_AA64MMFR2_EL1_CNP_SUPPORTED	 1
    433  1.31      maxv 
    434  1.31      maxv AARCH64REG_READ_INLINE2(a72_cpuactlr_el1, s3_1_c15_c2_0)
    435   1.9       ryo AARCH64REG_READ_INLINE(id_aa64pfr0_el1)
    436   1.9       ryo AARCH64REG_READ_INLINE(id_aa64pfr1_el1)
    437  1.31      maxv 
    438  1.31      maxv #define	ID_AA64PFR1_EL1_RASFRAC		__BITS(15,12)
    439  1.31      maxv #define	 ID_AA64PFR1_EL1_RASFRAC_NORMAL	 0
    440  1.31      maxv #define	 ID_AA64PFR1_EL1_RASFRAC_EXTRA	 1
    441  1.31      maxv #define	ID_AA64PFR1_EL1_MTE		__BITS(11,8)
    442  1.31      maxv #define	 ID_AA64PFR1_EL1_MTE_NONE	 0
    443  1.31      maxv #define	 ID_AA64PFR1_EL1_MTE_PARTIAL	 1
    444  1.31      maxv #define	 ID_AA64PFR1_EL1_MTE_SUPPORTED	 2
    445  1.31      maxv #define	ID_AA64PFR1_EL1_SSBS		__BITS(7,4)
    446  1.31      maxv #define	 ID_AA64PFR1_EL1_SSBS_NONE	 0
    447  1.31      maxv #define	 ID_AA64PFR1_EL1_SSBS_SUPPORTED	 1
    448  1.31      maxv #define	 ID_AA64PFR1_EL1_SSBS_MSR_MRS	 2
    449  1.31      maxv #define	ID_AA64PFR1_EL1_BT		__BITS(3,0)
    450  1.31      maxv #define	 ID_AA64PFR1_EL1_BT_NONE	 0
    451  1.31      maxv #define	 ID_AA64PFR1_EL1_BT_SUPPORTED	 1
    452  1.31      maxv 
    453  1.21       mrg AARCH64REG_READ_INLINE(id_aa64zfr0_el1)
    454   1.9       ryo AARCH64REG_READ_INLINE(id_pfr1_el1)
    455   1.1      matt AARCH64REG_READ_INLINE(isr_el1)
    456   1.1      matt AARCH64REG_READ_INLINE(midr_el1)
    457   1.1      matt AARCH64REG_READ_INLINE(mpidr_el1)
    458   1.9       ryo 
    459  1.21       mrg #define	MIDR_EL1_IMPL		__BITS(31,24)		// Implementor
    460  1.21       mrg #define	MIDR_EL1_VARIANT	__BITS(23,20)		// CPU Variant
    461  1.21       mrg #define	MIDR_EL1_ARCH		__BITS(19,16)		// Architecture
    462  1.21       mrg #define	MIDR_EL1_PARTNUM	__BITS(15,4)		// PartNum
    463  1.21       mrg #define	MIDR_EL1_REVISION	__BITS(3,0)		// Revision
    464  1.21       mrg 
    465  1.13     skrll #define	MPIDR_AFF3		__BITS(32,39)
    466  1.13     skrll #define	MPIDR_U	 		__BIT(30)		// 1 = Uni-Processor System
    467  1.13     skrll #define	MPIDR_MT		__BIT(24)		// 1 = SMT(AFF0 is logical)
    468  1.13     skrll #define	MPIDR_AFF2		__BITS(16,23)
    469  1.13     skrll #define	MPIDR_AFF1		__BITS(8,15)
    470  1.13     skrll #define	MPIDR_AFF0		__BITS(0,7)
    471   1.9       ryo 
    472   1.1      matt AARCH64REG_READ_INLINE(mvfr0_el1)
    473   1.9       ryo 
    474  1.14     skrll #define	MVFR0_FPROUND		__BITS(31,28)
    475  1.14     skrll #define	 MVFR0_FPROUND_NEAREST	 0
    476  1.12  christos #define	 MVFR0_FPROUND_ALL	 1
    477  1.14     skrll #define	MVFR0_FPSHVEC		__BITS(27,24)
    478  1.12  christos #define	 MVFR0_FPSHVEC_NONE	 0
    479  1.14     skrll #define	 MVFR0_FPSHVEC_SHVEC	 1
    480  1.14     skrll #define	MVFR0_FPSQRT		__BITS(23,20)
    481  1.12  christos #define	 MVFR0_FPSQRT_NONE	 0
    482  1.12  christos #define	 MVFR0_FPSQRT_VSQRT	 1
    483  1.14     skrll #define	MVFR0_FPDIVIDE		__BITS(19,16)
    484  1.14     skrll #define	 MVFR0_FPDIVIDE_NONE	 0
    485  1.14     skrll #define	 MVFR0_FPDIVIDE_VDIV	 1
    486  1.14     skrll #define	MVFR0_FPTRAP		__BITS(15,12)
    487  1.12  christos #define	 MVFR0_FPTRAP_NONE	 0
    488  1.12  christos #define	 MVFR0_FPTRAP_TRAP	 1
    489  1.14     skrll #define	MVFR0_FPDP		__BITS(11,8)
    490  1.12  christos #define	 MVFR0_FPDP_NONE	 0
    491  1.12  christos #define	 MVFR0_FPDP_VFPV2	 1
    492  1.12  christos #define	 MVFR0_FPDP_VFPV3	 2
    493  1.14     skrll #define	MVFR0_FPSP		__BITS(7,4)
    494  1.12  christos #define	 MVFR0_FPSP_NONE	 0
    495  1.12  christos #define	 MVFR0_FPSP_VFPV2	 1
    496  1.12  christos #define	 MVFR0_FPSP_VFPV3	 2
    497  1.14     skrll #define	MVFR0_SIMDREG		__BITS(3,0)
    498  1.12  christos #define	 MVFR0_SIMDREG_NONE	 0
    499  1.14     skrll #define	 MVFR0_SIMDREG_16x64	 1
    500  1.14     skrll #define	 MVFR0_SIMDREG_32x64	 2
    501   1.9       ryo 
    502   1.1      matt AARCH64REG_READ_INLINE(mvfr1_el1)
    503   1.9       ryo 
    504  1.14     skrll #define	MVFR1_SIMDFMAC		__BITS(31,28)
    505  1.14     skrll #define	 MVFR1_SIMDFMAC_NONE	 0
    506  1.14     skrll #define	 MVFR1_SIMDFMAC_FMAC	 1
    507  1.14     skrll #define	MVFR1_FPHP		__BITS(27,24)
    508  1.12  christos #define	 MVFR1_FPHP_NONE	 0
    509  1.14     skrll #define	 MVFR1_FPHP_HALF_SINGLE	 1
    510  1.14     skrll #define	 MVFR1_FPHP_HALF_DOUBLE	 2
    511  1.20  riastrad #define	 MVFR1_FPHP_HALF_ARITH	 3
    512  1.14     skrll #define	MVFR1_SIMDHP		__BITS(23,20)
    513  1.12  christos #define	 MVFR1_SIMDHP_NONE	 0
    514  1.12  christos #define	 MVFR1_SIMDHP_HALF	 1
    515  1.20  riastrad #define	 MVFR1_SIMDHP_HALF_ARITH 3
    516  1.14     skrll #define	MVFR1_SIMDSP		__BITS(19,16)
    517  1.12  christos #define	 MVFR1_SIMDSP_NONE	 0
    518  1.14     skrll #define	 MVFR1_SIMDSP_SINGLE	 1
    519  1.14     skrll #define	MVFR1_SIMDINT		 __BITS(15,12)
    520  1.12  christos #define	 MVFR1_SIMDINT_NONE	 0
    521  1.14     skrll #define	 MVFR1_SIMDINT_INTEGER	 1
    522  1.14     skrll #define	MVFR1_SIMDLS		__BITS(11,8)
    523  1.12  christos #define	 MVFR1_SIMDLS_NONE	 0
    524  1.14     skrll #define	 MVFR1_SIMDLS_LOADSTORE	 1
    525  1.14     skrll #define	MVFR1_FPDNAN		__BITS(7,4)
    526  1.12  christos #define	 MVFR1_FPDNAN_NONE	 0
    527  1.12  christos #define	 MVFR1_FPDNAN_NAN	 1
    528  1.14     skrll #define	MVFR1_FPFTZ		__BITS(3,0)
    529  1.12  christos #define	 MVFR1_FPFTZ_NONE	 0
    530  1.14     skrll #define	 MVFR1_FPFTZ_DENORMAL	 1
    531   1.9       ryo 
    532   1.1      matt AARCH64REG_READ_INLINE(mvfr2_el1)
    533   1.9       ryo 
    534  1.14     skrll #define	MVFR2_FPMISC		__BITS(7,4)
    535  1.12  christos #define	 MVFR2_FPMISC_NONE	 0
    536  1.12  christos #define	 MVFR2_FPMISC_SEL	 1
    537  1.14     skrll #define	 MVFR2_FPMISC_DROUND	 2
    538  1.14     skrll #define	 MVFR2_FPMISC_ROUNDINT	 3
    539  1.14     skrll #define	 MVFR2_FPMISC_MAXMIN	 4
    540  1.14     skrll #define	MVFR2_SIMDMISC		__BITS(3,0)
    541  1.14     skrll #define	 MVFR2_SIMDMISC_NONE	 0
    542  1.14     skrll #define	 MVFR2_SIMDMISC_DROUND	 1
    543  1.12  christos #define	 MVFR2_SIMDMISC_ROUNDINT 2
    544  1.14     skrll #define	 MVFR2_SIMDMISC_MAXMIN	 3
    545   1.9       ryo 
    546   1.1      matt AARCH64REG_READ_INLINE(revidr_el1)
    547   1.1      matt 
    548   1.1      matt /*
    549   1.1      matt  * These are read/write registers
    550   1.1      matt  */
    551   1.1      matt AARCH64REG_READ_INLINE(cpacr_el1)	// Coprocessor Access Control Regiser
    552   1.1      matt AARCH64REG_WRITE_INLINE(cpacr_el1)
    553   1.1      matt 
    554  1.14     skrll #define	CPACR_TTA		__BIT(28)	 // System Register Access Traps
    555  1.14     skrll #define	CPACR_FPEN		__BITS(21,20)
    556  1.14     skrll #define  CPACR_FPEN_NONE	 __SHIFTIN(0, CPACR_FPEN)
    557  1.14     skrll #define	 CPACR_FPEN_EL1		 __SHIFTIN(1, CPACR_FPEN)
    558  1.14     skrll #define	 CPACR_FPEN_NONE_2	 __SHIFTIN(2, CPACR_FPEN)
    559  1.14     skrll #define	 CPACR_FPEN_ALL		 __SHIFTIN(3, CPACR_FPEN)
    560   1.1      matt 
    561   1.9       ryo AARCH64REG_READ_INLINE(csselr_el1)	// Cache Size Selection Register
    562   1.9       ryo AARCH64REG_WRITE_INLINE(csselr_el1)
    563   1.9       ryo 
    564  1.14     skrll #define	CSSELR_LEVEL		__BITS(3,1)	// Cache level of required cache
    565  1.14     skrll #define	CSSELR_IND		__BIT(0)	// Instruction not Data bit
    566   1.9       ryo 
    567   1.9       ryo AARCH64REG_READ_INLINE(daif)		// Debug Async Irq Fiq mask register
    568   1.9       ryo AARCH64REG_WRITE_INLINE(daif)
    569   1.9       ryo AARCH64REG_WRITEIMM_INLINE(daifclr)
    570   1.9       ryo AARCH64REG_WRITEIMM_INLINE(daifset)
    571   1.9       ryo 
    572  1.14     skrll #define	DAIF_D			__BIT(9)	// Debug Exception Mask
    573  1.14     skrll #define	DAIF_A			__BIT(8)	// SError Abort Mask
    574  1.14     skrll #define	DAIF_I			__BIT(7)	// IRQ Mask
    575  1.14     skrll #define	DAIF_F			__BIT(6)	// FIQ Mask
    576  1.14     skrll #define	DAIF_SETCLR_SHIFT	6		// for daifset/daifclr #imm shift
    577   1.9       ryo 
    578   1.1      matt AARCH64REG_READ_INLINE(elr_el1)		// Exception Link Register
    579   1.1      matt AARCH64REG_WRITE_INLINE(elr_el1)
    580   1.1      matt 
    581   1.1      matt AARCH64REG_READ_INLINE(esr_el1)		// Exception Symdrone Register
    582   1.1      matt AARCH64REG_WRITE_INLINE(esr_el1)
    583   1.1      matt 
    584  1.14     skrll #define	ESR_EC			__BITS(31,26) // Exception Cause
    585  1.14     skrll #define	 ESR_EC_UNKNOWN		 0x00	// AXX: Unknown Reason
    586  1.14     skrll #define	 ESR_EC_WFX		 0x01	// AXX: WFI or WFE instruction execution
    587  1.14     skrll #define	 ESR_EC_CP15_RT		 0x03	// A32: MCR/MRC access to CP15 !EC=0
    588  1.14     skrll #define	 ESR_EC_CP15_RRT	 0x04	// A32: MCRR/MRRC access to CP15 !EC=0
    589  1.14     skrll #define	 ESR_EC_CP14_RT		 0x05	// A32: MCR/MRC access to CP14
    590  1.14     skrll #define	 ESR_EC_CP14_DT		 0x06	// A32: LDC/STC access to CP14
    591  1.14     skrll #define	 ESR_EC_FP_ACCESS	 0x07	// AXX: Access to SIMD/FP Registers
    592  1.14     skrll #define	 ESR_EC_FPID		 0x08	// A32: MCR/MRC access to CP10 !EC=7
    593  1.14     skrll #define	 ESR_EC_CP14_RRT	 0x0c	// A32: MRRC access to CP14
    594  1.35      maxv #define	 ESR_EC_BTE_A64		 0x0d	// A64: Branch Target Exception (V8.5)
    595  1.14     skrll #define	 ESR_EC_ILL_STATE	 0x0e	// AXX: Illegal Execution State
    596  1.14     skrll #define	 ESR_EC_SVC_A32		 0x11	// A32: SVC Instruction Execution
    597  1.14     skrll #define	 ESR_EC_HVC_A32		 0x12	// A32: HVC Instruction Execution
    598  1.14     skrll #define	 ESR_EC_SMC_A32		 0x13	// A32: SMC Instruction Execution
    599  1.14     skrll #define	 ESR_EC_SVC_A64		 0x15	// A64: SVC Instruction Execution
    600  1.14     skrll #define	 ESR_EC_HVC_A64		 0x16	// A64: HVC Instruction Execution
    601  1.14     skrll #define	 ESR_EC_SMC_A64		 0x17	// A64: SMC Instruction Execution
    602  1.14     skrll #define	 ESR_EC_SYS_REG		 0x18	// A64: MSR/MRS/SYS instruction (!EC0/1/7)
    603  1.14     skrll #define	 ESR_EC_INSN_ABT_EL0	 0x20	// AXX: Instruction Abort (EL0)
    604  1.14     skrll #define	 ESR_EC_INSN_ABT_EL1	 0x21	// AXX: Instruction Abort (EL1)
    605  1.14     skrll #define	 ESR_EC_PC_ALIGNMENT	 0x22	// AXX: Misaligned PC
    606  1.14     skrll #define	 ESR_EC_DATA_ABT_EL0	 0x24	// AXX: Data Abort (EL0)
    607  1.14     skrll #define	 ESR_EC_DATA_ABT_EL1	 0x25	// AXX: Data Abort (EL1)
    608  1.14     skrll #define	 ESR_EC_SP_ALIGNMENT 	 0x26	// AXX: Misaligned SP
    609  1.14     skrll #define	 ESR_EC_FP_TRAP_A32	 0x28	// A32: FP Exception
    610  1.14     skrll #define	 ESR_EC_FP_TRAP_A64	 0x2c	// A64: FP Exception
    611  1.14     skrll #define	 ESR_EC_SERROR	 	 0x2f	// AXX: SError Interrupt
    612  1.14     skrll #define	 ESR_EC_BRKPNT_EL0	 0x30	// AXX: Breakpoint Exception (EL0)
    613  1.14     skrll #define	 ESR_EC_BRKPNT_EL1	 0x31	// AXX: Breakpoint Exception (EL1)
    614  1.14     skrll #define	 ESR_EC_SW_STEP_EL0	 0x32	// AXX: Software Step (EL0)
    615  1.14     skrll #define	 ESR_EC_SW_STEP_EL1	 0x33	// AXX: Software Step (EL1)
    616  1.14     skrll #define	 ESR_EC_WTCHPNT_EL0	 0x34	// AXX: Watchpoint (EL0)
    617  1.14     skrll #define	 ESR_EC_WTCHPNT_EL1	 0x35	// AXX: Watchpoint (EL1)
    618  1.14     skrll #define	 ESR_EC_BKPT_INSN_A32	 0x38	// A32: BKPT Instruction Execution
    619  1.14     skrll #define	 ESR_EC_VECTOR_CATCH	 0x3a	// A32: Vector Catch Exception
    620  1.14     skrll #define	 ESR_EC_BKPT_INSN_A64	 0x3c	// A64: BKPT Instruction Execution
    621  1.14     skrll #define	ESR_IL			__BIT(25)	// Instruction Length (1=32-bit)
    622  1.14     skrll #define	ESR_ISS			__BITS(24,0)	// Instruction Specific Syndrome
    623  1.12  christos #define	ESR_ISS_CV		__BIT(24)	// common
    624  1.12  christos #define	ESR_ISS_COND		__BITS(23,20)	// common
    625  1.12  christos #define	ESR_ISS_WFX_TRAP_INSN	__BIT(0)	// for ESR_EC_WFX
    626  1.12  christos #define	ESR_ISS_MRC_OPC2	__BITS(19,17)	// for ESR_EC_CP15_RT
    627  1.12  christos #define	ESR_ISS_MRC_OPC1	__BITS(16,14)	// for ESR_EC_CP15_RT
    628  1.12  christos #define	ESR_ISS_MRC_CRN		__BITS(13,10)	// for ESR_EC_CP15_RT
    629  1.12  christos #define	ESR_ISS_MRC_RT		__BITS(9,5)	// for ESR_EC_CP15_RT
    630  1.12  christos #define	ESR_ISS_MRC_CRM		__BITS(4,1)	// for ESR_EC_CP15_RT
    631  1.12  christos #define	ESR_ISS_MRC_DIRECTION	__BIT(0)	// for ESR_EC_CP15_RT
    632  1.12  christos #define	ESR_ISS_MCRR_OPC1	__BITS(19,16)	// for ESR_EC_CP15_RRT
    633  1.12  christos #define	ESR_ISS_MCRR_RT2	__BITS(14,10)	// for ESR_EC_CP15_RRT
    634  1.12  christos #define	ESR_ISS_MCRR_RT		__BITS(9,5)	// for ESR_EC_CP15_RRT
    635  1.12  christos #define	ESR_ISS_MCRR_CRM	__BITS(4,1)	// for ESR_EC_CP15_RRT
    636  1.12  christos #define	ESR_ISS_MCRR_DIRECTION	__BIT(0)	// for ESR_EC_CP15_RRT
    637  1.12  christos #define	ESR_ISS_HVC_IMM16	__BITS(15,0)	// for ESR_EC_{SVC,HVC}
    638  1.12  christos // ...
    639  1.12  christos #define	ESR_ISS_INSNABORT_EA	__BIT(9)	// for ESC_RC_INSN_ABT_EL[01]
    640  1.12  christos #define	ESR_ISS_INSNABORT_S1PTW	__BIT(7)	// for ESC_RC_INSN_ABT_EL[01]
    641  1.12  christos #define	ESR_ISS_INSNABORT_IFSC	__BITS(0,5)	// for ESC_RC_INSN_ABT_EL[01]
    642  1.12  christos #define	ESR_ISS_DATAABORT_ISV	__BIT(24)	// for ESC_RC_DATA_ABT_EL[01]
    643  1.12  christos #define	ESR_ISS_DATAABORT_SAS	__BITS(23,22)	// for ESC_RC_DATA_ABT_EL[01]
    644  1.12  christos #define	ESR_ISS_DATAABORT_SSE	__BIT(21)	// for ESC_RC_DATA_ABT_EL[01]
    645  1.12  christos #define	ESR_ISS_DATAABORT_SRT	__BITS(19,16)	// for ESC_RC_DATA_ABT_EL[01]
    646  1.12  christos #define	ESR_ISS_DATAABORT_SF	__BIT(15)	// for ESC_RC_DATA_ABT_EL[01]
    647  1.12  christos #define	ESR_ISS_DATAABORT_AR	__BIT(14)	// for ESC_RC_DATA_ABT_EL[01]
    648  1.12  christos #define	ESR_ISS_DATAABORT_EA	__BIT(9)	// for ESC_RC_DATA_ABT_EL[01]
    649  1.12  christos #define	ESR_ISS_DATAABORT_CM	__BIT(8)	// for ESC_RC_DATA_ABT_EL[01]
    650  1.12  christos #define	ESR_ISS_DATAABORT_S1PTW	__BIT(7)	// for ESC_RC_DATA_ABT_EL[01]
    651  1.12  christos #define	ESR_ISS_DATAABORT_WnR	__BIT(6)	// for ESC_RC_DATA_ABT_EL[01]
    652  1.12  christos #define	ESR_ISS_DATAABORT_DFSC	__BITS(0,5)	// for ESC_RC_DATA_ABT_EL[01]
    653  1.12  christos 
    654  1.14     skrll #define	ESR_ISS_FSC_ADDRESS_SIZE_FAULT_0		0x00
    655  1.14     skrll #define	ESR_ISS_FSC_ADDRESS_SIZE_FAULT_1		0x01
    656  1.14     skrll #define	ESR_ISS_FSC_ADDRESS_SIZE_FAULT_2		0x02
    657  1.14     skrll #define	ESR_ISS_FSC_ADDRESS_SIZE_FAULT_3		0x03
    658  1.14     skrll #define	ESR_ISS_FSC_TRANSLATION_FAULT_0			0x04
    659  1.14     skrll #define	ESR_ISS_FSC_TRANSLATION_FAULT_1			0x05
    660  1.14     skrll #define	ESR_ISS_FSC_TRANSLATION_FAULT_2			0x06
    661  1.14     skrll #define	ESR_ISS_FSC_TRANSLATION_FAULT_3			0x07
    662  1.14     skrll #define	ESR_ISS_FSC_ACCESS_FAULT_0			0x08
    663  1.14     skrll #define	ESR_ISS_FSC_ACCESS_FAULT_1			0x09
    664  1.14     skrll #define	ESR_ISS_FSC_ACCESS_FAULT_2			0x0a
    665  1.14     skrll #define	ESR_ISS_FSC_ACCESS_FAULT_3			0x0b
    666  1.14     skrll #define	ESR_ISS_FSC_PERM_FAULT_0			0x0c
    667  1.14     skrll #define	ESR_ISS_FSC_PERM_FAULT_1			0x0d
    668  1.14     skrll #define	ESR_ISS_FSC_PERM_FAULT_2			0x0e
    669  1.14     skrll #define	ESR_ISS_FSC_PERM_FAULT_3			0x0f
    670  1.14     skrll #define	ESR_ISS_FSC_SYNC_EXTERNAL_ABORT			0x10
    671  1.14     skrll #define	ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_0	0x14
    672  1.14     skrll #define	ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_1	0x15
    673  1.14     skrll #define	ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_2	0x16
    674  1.14     skrll #define	ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_3	0x17
    675  1.14     skrll #define	ESR_ISS_FSC_SYNC_PARITY_ERROR			0x18
    676  1.14     skrll #define	ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_0	0x1c
    677  1.14     skrll #define	ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_1	0x1d
    678  1.14     skrll #define	ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_2	0x1e
    679  1.14     skrll #define	ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_3	0x1f
    680  1.14     skrll #define	ESR_ISS_FSC_ALIGNMENT_FAULT			0x21
    681  1.14     skrll #define	ESR_ISS_FSC_TLB_CONFLICT_FAULT			0x30
    682  1.14     skrll #define	ESR_ISS_FSC_LOCKDOWN_ABORT			0x34
    683  1.14     skrll #define	ESR_ISS_FSC_UNSUPPORTED_EXCLUSIVE		0x35
    684  1.14     skrll #define	ESR_ISS_FSC_FIRST_LEVEL_DOMAIN_FAULT		0x3d
    685  1.14     skrll #define	ESR_ISS_FSC_SECOND_LEVEL_DOMAIN_FAULT		0x3e
    686   1.1      matt 
    687   1.1      matt 
    688   1.1      matt AARCH64REG_READ_INLINE(far_el1)		// Fault Address Register
    689   1.1      matt AARCH64REG_WRITE_INLINE(far_el1)
    690   1.1      matt 
    691   1.9       ryo AARCH64REG_READ_INLINE2(l2ctlr_el1, s3_1_c11_c0_2)  // Cortex-A53,57,72,73
    692   1.9       ryo AARCH64REG_WRITE_INLINE2(l2ctlr_el1, s3_1_c11_c0_2) // Cortex-A53,57,72,73
    693   1.9       ryo 
    694  1.12  christos #define	L2CTLR_NUMOFCORE	__BITS(25,24)	// Number of cores
    695  1.12  christos #define	L2CTLR_CPUCACHEPROT	__BIT(22)	// CPU Cache Protection
    696  1.12  christos #define	L2CTLR_SCUL2CACHEPROT	__BIT(21)	// SCU-L2 Cache Protection
    697  1.12  christos #define	L2CTLR_L2_INPUT_LATENCY	__BIT(5)	// L2 Data RAM input latency
    698  1.12  christos #define	L2CTLR_L2_OUTPUT_LATENCY __BIT(0)	// L2 Data RAM output latency
    699   1.9       ryo 
    700   1.9       ryo AARCH64REG_READ_INLINE(mair_el1) // Memory Attribute Indirection Register
    701   1.1      matt AARCH64REG_WRITE_INLINE(mair_el1)
    702   1.1      matt 
    703  1.14     skrll #define	MAIR_ATTR0		 __BITS(7,0)
    704  1.14     skrll #define	MAIR_ATTR1		 __BITS(15,8)
    705  1.14     skrll #define	MAIR_ATTR2		 __BITS(23,16)
    706  1.14     skrll #define	MAIR_ATTR3		 __BITS(31,24)
    707  1.14     skrll #define	MAIR_ATTR4		 __BITS(39,32)
    708  1.14     skrll #define	MAIR_ATTR5		 __BITS(47,40)
    709  1.14     skrll #define	MAIR_ATTR6		 __BITS(55,48)
    710  1.14     skrll #define	MAIR_ATTR7		 __BITS(63,56)
    711  1.14     skrll #define	MAIR_DEVICE_nGnRnE	 0x00	// NoGathering,NoReordering,NoEarlyWriteAck.
    712  1.29  jmcneill #define	MAIR_DEVICE_nGnRE	 0x04	// NoGathering,NoReordering,EarlyWriteAck.
    713  1.14     skrll #define	MAIR_NORMAL_NC		 0x44
    714  1.14     skrll #define	MAIR_NORMAL_WT		 0xbb
    715  1.14     skrll #define	MAIR_NORMAL_WB		 0xff
    716   1.9       ryo 
    717   1.1      matt AARCH64REG_READ_INLINE(par_el1)		// Physical Address Register
    718   1.1      matt AARCH64REG_WRITE_INLINE(par_el1)
    719   1.1      matt 
    720  1.14     skrll #define	PAR_ATTR		__BITS(63,56)	// F=0 memory attributes
    721  1.36       ryo #define	PAR_PA			__BITS(51,12)	// F=0 physical address
    722  1.36       ryo #define	PAR_PA_SHIFT		12
    723  1.14     skrll #define	PAR_NS			__BIT(9)	// F=0 non-secure
    724  1.14     skrll #define	PAR_S			__BIT(9)	// F=1 failure stage
    725  1.14     skrll #define	PAR_SHA			__BITS(8,7)	// F=0 shareability attribute
    726  1.14     skrll #define	 PAR_SHA_NONE		 0
    727  1.14     skrll #define	 PAR_SHA_OUTER		 2
    728  1.14     skrll #define	 PAR_SHA_INNER		 3
    729  1.14     skrll #define	PAR_PTW			__BIT(8)	// F=1 partial table walk
    730  1.14     skrll #define	PAR_FST			__BITS(6,1)	// F=1 fault status code
    731  1.14     skrll #define	PAR_F			__BIT(0)	// translation failed
    732   1.1      matt 
    733   1.1      matt AARCH64REG_READ_INLINE(rmr_el1)		// Reset Management Register
    734   1.1      matt AARCH64REG_WRITE_INLINE(rmr_el1)
    735   1.1      matt 
    736   1.1      matt AARCH64REG_READ_INLINE(rvbar_el1)	// Reset Vector Base Address Register
    737   1.1      matt AARCH64REG_WRITE_INLINE(rvbar_el1)
    738   1.1      matt 
    739  1.24       ryo AARCH64REG_ATWRITE_INLINE(s1e0r);	// Address Translate Stages 1
    740  1.24       ryo AARCH64REG_ATWRITE_INLINE(s1e0w);
    741  1.24       ryo AARCH64REG_ATWRITE_INLINE(s1e1r);
    742  1.24       ryo AARCH64REG_ATWRITE_INLINE(s1e1w);
    743  1.24       ryo 
    744   1.2     skrll AARCH64REG_READ_INLINE(sctlr_el1)	// System Control Register
    745   1.2     skrll AARCH64REG_WRITE_INLINE(sctlr_el1)
    746   1.1      matt 
    747  1.14     skrll #define	SCTLR_RES0		0xc8222400	// Reserved ARMv8.0, write 0
    748  1.14     skrll #define	SCTLR_RES1		0x30d00800	// Reserved ARMv8.0, write 1
    749  1.14     skrll #define	SCTLR_M			__BIT(0)
    750  1.14     skrll #define	SCTLR_A			__BIT(1)
    751  1.14     skrll #define	SCTLR_C			__BIT(2)
    752  1.14     skrll #define	SCTLR_SA		__BIT(3)
    753  1.14     skrll #define	SCTLR_SA0		__BIT(4)
    754  1.14     skrll #define	SCTLR_CP15BEN		__BIT(5)
    755  1.32      maxv #define	SCTLR_nAA		__BIT(6)
    756  1.14     skrll #define	SCTLR_ITD		__BIT(7)
    757  1.14     skrll #define	SCTLR_SED		__BIT(8)
    758  1.14     skrll #define	SCTLR_UMA		__BIT(9)
    759  1.34      maxv #define	SCTLR_EnRCTX		__BIT(10)
    760  1.34      maxv #define	SCTLR_EOS		__BIT(11)
    761  1.14     skrll #define	SCTLR_I			__BIT(12)
    762  1.34      maxv #define	SCTLR_EnDB		__BIT(13)
    763  1.14     skrll #define	SCTLR_DZE		__BIT(14)
    764  1.14     skrll #define	SCTLR_UCT		__BIT(15)
    765  1.14     skrll #define	SCTLR_nTWI		__BIT(16)
    766  1.14     skrll #define	SCTLR_nTWE		__BIT(18)
    767  1.14     skrll #define	SCTLR_WXN		__BIT(19)
    768  1.34      maxv #define	SCTLR_TSCXT		__BIT(20)
    769  1.14     skrll #define	SCTLR_IESB		__BIT(21)
    770  1.34      maxv #define	SCTLR_EIS		__BIT(22)
    771  1.14     skrll #define	SCTLR_SPAN		__BIT(23)
    772  1.14     skrll #define	SCTLR_EOE		__BIT(24)
    773  1.14     skrll #define	SCTLR_EE		__BIT(25)
    774  1.14     skrll #define	SCTLR_UCI		__BIT(26)
    775  1.34      maxv #define	SCTLR_EnDA		__BIT(27)
    776  1.14     skrll #define	SCTLR_nTLSMD		__BIT(28)
    777  1.14     skrll #define	SCTLR_LSMAOE		__BIT(29)
    778  1.34      maxv #define	SCTLR_EnIB		__BIT(30)
    779  1.34      maxv #define	SCTLR_EnIA		__BIT(31)
    780  1.34      maxv #define	SCTLR_BT0		__BIT(35)
    781  1.34      maxv #define	SCTLR_BT1		__BIT(36)
    782  1.34      maxv #define	SCTLR_ITFSB		__BIT(37)
    783  1.34      maxv #define	SCTLR_TCF0		__BITS(39,38)
    784  1.34      maxv #define	SCTLR_TCF		__BITS(41,40)
    785  1.34      maxv #define	SCTLR_ATA0		__BIT(42)
    786  1.34      maxv #define	SCTLR_ATA		__BIT(43)
    787  1.34      maxv #define	SCTLR_DSSBS		__BIT(44)
    788   1.9       ryo 
    789  1.40      maxv static __inline void
    790  1.40      maxv reg_APIAKeyLo_EL1_write(uint64_t __val)
    791  1.40      maxv {
    792  1.40      maxv 	__asm __volatile(".arch armv8.3-a+pac\n"
    793  1.40      maxv 	    "msr APIAKeyLo_EL1, %0" :: "r"(__val));
    794  1.40      maxv }
    795  1.40      maxv 
    796  1.40      maxv static __inline void
    797  1.40      maxv reg_APIAKeyHi_EL1_write(uint64_t __val)
    798  1.40      maxv {
    799  1.40      maxv 	__asm __volatile(".arch armv8.3-a+pac\n"
    800  1.40      maxv 	    "msr APIAKeyHi_EL1, %0" :: "r"(__val));
    801  1.40      maxv }
    802  1.40      maxv 
    803  1.40      maxv #define	PTR_VA_RANGE_SELECT	__BIT(55)
    804  1.40      maxv #define	PTR_PAC_MASK		(__BITS(63,56) | __BITS(54, 48))
    805  1.40      maxv 
    806  1.40      maxv static __inline uint64_t
    807  1.40      maxv ptr_strip_pac(uint64_t __val)
    808  1.40      maxv {
    809  1.40      maxv 	if (__val & PTR_VA_RANGE_SELECT)
    810  1.40      maxv 		return __val | PTR_PAC_MASK;
    811  1.40      maxv 	return __val & ~PTR_PAC_MASK;
    812  1.40      maxv }
    813  1.40      maxv 
    814   1.9       ryo // current EL stack pointer
    815  1.12  christos static __inline uint64_t
    816   1.9       ryo reg_sp_read(void)
    817   1.9       ryo {
    818   1.9       ryo 	uint64_t __rv;
    819   1.9       ryo 	__asm __volatile ("mov %0, sp" : "=r"(__rv));
    820   1.9       ryo 	return __rv;
    821   1.9       ryo }
    822   1.9       ryo 
    823   1.9       ryo AARCH64REG_READ_INLINE(sp_el0)		// EL0 Stack Pointer
    824   1.1      matt AARCH64REG_WRITE_INLINE(sp_el0)
    825   1.1      matt 
    826   1.9       ryo AARCH64REG_READ_INLINE(spsel)		// Stack Pointer Select
    827   1.9       ryo AARCH64REG_WRITE_INLINE(spsel)
    828   1.1      matt 
    829  1.14     skrll #define	SPSEL_SP		__BIT(0);	// use SP_EL0 at all exception levels
    830   1.1      matt 
    831   1.1      matt AARCH64REG_READ_INLINE(spsr_el1)	// Saved Program Status Register
    832   1.1      matt AARCH64REG_WRITE_INLINE(spsr_el1)
    833   1.1      matt 
    834  1.14     skrll #define	SPSR_NZCV 		__BITS(31,28)	// mask of N Z C V
    835  1.14     skrll #define	 SPSR_N	 		__BIT(31)	// Negative
    836  1.14     skrll #define	 SPSR_Z	 		__BIT(30)	// Zero
    837  1.14     skrll #define	 SPSR_C	 		__BIT(29)	// Carry
    838  1.14     skrll #define	 SPSR_V	 		__BIT(28)	// oVerflow
    839  1.14     skrll #define	SPSR_A32_Q 		__BIT(27)	// A32: Overflow
    840  1.32      maxv #define	SPSR_A32_IT1 		__BIT(26)	// A32: IT[1]
    841  1.32      maxv #define	SPSR_A32_IT0 		__BIT(25)	// A32: IT[0]
    842  1.14     skrll #define	SPSR_SS	 		__BIT(21)	// Software Step
    843  1.22       ryo #define	SPSR_SS_SHIFT		21
    844  1.14     skrll #define	SPSR_IL	 		__BIT(20)	// Instruction Length
    845  1.14     skrll #define	SPSR_GE	 		__BITS(19,16)	// A32: SIMD GE
    846  1.14     skrll #define	SPSR_IT7 		__BIT(15)	// A32: IT[7]
    847  1.14     skrll #define	SPSR_IT6 		__BIT(14)	// A32: IT[6]
    848  1.14     skrll #define	SPSR_IT5 		__BIT(13)	// A32: IT[5]
    849  1.14     skrll #define	SPSR_IT4 		__BIT(12)	// A32: IT[4]
    850  1.14     skrll #define	SPSR_IT3 		__BIT(11)	// A32: IT[3]
    851  1.14     skrll #define	SPSR_IT2 		__BIT(10)	// A32: IT[2]
    852  1.35      maxv #define	SPSR_A64_BTYPE 		__BIT(11,10)	// A64: BTYPE
    853  1.14     skrll #define	SPSR_A64_D 		__BIT(9)	// A64: Debug Exception Mask
    854  1.14     skrll #define	SPSR_A32_E 		__BIT(9)	// A32: BE Endian Mode
    855  1.14     skrll #define	SPSR_A	 		__BIT(8)	// Async abort (SError) Mask
    856  1.14     skrll #define	SPSR_I	 		__BIT(7)	// IRQ Mask
    857  1.14     skrll #define	SPSR_F	 		__BIT(6)	// FIQ Mask
    858  1.14     skrll #define	SPSR_A32_T 		__BIT(5)	// A32 Thumb Mode
    859  1.19       ryo #define	SPSR_A32		__BIT(4)	// A32 Mode (a part of SPSR_M)
    860  1.14     skrll #define	SPSR_M	 		__BITS(4,0)	// Execution State
    861  1.14     skrll #define	 SPSR_M_EL3H 		 0x0d
    862  1.14     skrll #define	 SPSR_M_EL3T 		 0x0c
    863  1.14     skrll #define	 SPSR_M_EL2H 		 0x09
    864  1.14     skrll #define	 SPSR_M_EL2T 		 0x08
    865  1.14     skrll #define	 SPSR_M_EL1H 		 0x05
    866  1.14     skrll #define	 SPSR_M_EL1T 		 0x04
    867  1.14     skrll #define	 SPSR_M_EL0T 		 0x00
    868  1.14     skrll #define	 SPSR_M_SYS32		 0x1f
    869  1.14     skrll #define	 SPSR_M_UND32		 0x1b
    870  1.14     skrll #define	 SPSR_M_ABT32		 0x17
    871  1.14     skrll #define	 SPSR_M_SVC32		 0x13
    872  1.14     skrll #define	 SPSR_M_IRQ32		 0x12
    873  1.14     skrll #define	 SPSR_M_FIQ32		 0x11
    874  1.14     skrll #define	 SPSR_M_USR32		 0x10
    875   1.1      matt 
    876   1.1      matt AARCH64REG_READ_INLINE(tcr_el1)		// Translation Control Register
    877   1.1      matt AARCH64REG_WRITE_INLINE(tcr_el1)
    878   1.1      matt 
    879  1.27     skrll 
    880  1.27     skrll /* TCR_EL1 - Translation Control Register */
    881  1.27     skrll #define TCR_TBI1		__BIT(38)		/* ignore Top Byte TTBR1_EL1 */
    882  1.27     skrll #define TCR_TBI0		__BIT(37)		/* ignore Top Byte TTBR0_EL1 */
    883  1.27     skrll #define TCR_AS64K		__BIT(36)		/* Use 64K ASIDs */
    884  1.27     skrll #define TCR_IPS			__BITS(34,32)		/* Intermediate PhysAdr Size */
    885  1.27     skrll #define  TCR_IPS_4PB		__SHIFTIN(6,TCR_IPS)	/* 52 bits (  4 PB) */
    886  1.27     skrll #define  TCR_IPS_256TB		__SHIFTIN(5,TCR_IPS)	/* 48 bits (256 TB) */
    887  1.27     skrll #define  TCR_IPS_16TB		__SHIFTIN(4,TCR_IPS)	/* 44 bits  (16 TB) */
    888  1.27     skrll #define  TCR_IPS_4TB		__SHIFTIN(3,TCR_IPS)	/* 42 bits  ( 4 TB) */
    889  1.27     skrll #define  TCR_IPS_1TB		__SHIFTIN(2,TCR_IPS)	/* 40 bits  ( 1 TB) */
    890  1.27     skrll #define  TCR_IPS_64GB		__SHIFTIN(1,TCR_IPS)	/* 36 bits  (64 GB) */
    891  1.27     skrll #define  TCR_IPS_4GB		__SHIFTIN(0,TCR_IPS)	/* 32 bits   (4 GB) */
    892  1.27     skrll #define TCR_TG1			__BITS(31,30)		/* TTBR1 Page Granule Size */
    893  1.27     skrll #define  TCR_TG1_16KB		__SHIFTIN(1,TCR_TG1)	/* 16KB page size */
    894  1.27     skrll #define  TCR_TG1_4KB		__SHIFTIN(2,TCR_TG1)	/* 4KB page size */
    895  1.27     skrll #define  TCR_TG1_64KB		__SHIFTIN(3,TCR_TG1)	/* 64KB page size */
    896  1.27     skrll #define TCR_SH1			__BITS(29,28)
    897  1.27     skrll #define  TCR_SH1_NONE		__SHIFTIN(0,TCR_SH1)
    898  1.27     skrll #define  TCR_SH1_OUTER		__SHIFTIN(2,TCR_SH1)
    899  1.27     skrll #define  TCR_SH1_INNER		__SHIFTIN(3,TCR_SH1)
    900  1.27     skrll #define TCR_ORGN1		__BITS(27,26)		/* TTBR1 Outer cacheability */
    901  1.27     skrll #define  TCR_ORGN1_NC		__SHIFTIN(0,TCR_ORGN1)	/* Non Cacheable */
    902  1.27     skrll #define  TCR_ORGN1_WB_WA	__SHIFTIN(1,TCR_ORGN1)	/* WriteBack WriteAllocate */
    903  1.27     skrll #define  TCR_ORGN1_WT		__SHIFTIN(2,TCR_ORGN1)	/* WriteThrough */
    904  1.27     skrll #define  TCR_ORGN1_WB		__SHIFTIN(3,TCR_ORGN1)	/* WriteBack */
    905  1.27     skrll #define TCR_IRGN1		__BITS(25,24)		/* TTBR1 Inner cacheability */
    906  1.27     skrll #define  TCR_IRGN1_NC		__SHIFTIN(0,TCR_IRGN1)	/* Non Cacheable */
    907  1.27     skrll #define  TCR_IRGN1_WB_WA	__SHIFTIN(1,TCR_IRGN1)	/* WriteBack WriteAllocate */
    908  1.27     skrll #define  TCR_IRGN1_WT		__SHIFTIN(2,TCR_IRGN1)	/* WriteThrough */
    909  1.27     skrll #define  TCR_IRGN1_WB		__SHIFTIN(3,TCR_IRGN1)	/* WriteBack */
    910  1.27     skrll #define TCR_EPD1		__BIT(23)		/* Walk Disable for TTBR1_EL1 */
    911  1.27     skrll #define TCR_A1			__BIT(22)		/* ASID is in TTBR1_EL1 */
    912  1.27     skrll #define TCR_T1SZ		__BITS(21,16)		/* Size offset for TTBR1_EL1 */
    913  1.27     skrll #define TCR_TG0			__BITS(15,14)		/* TTBR0 Page Granule Size */
    914  1.27     skrll #define  TCR_TG0_4KB		__SHIFTIN(0,TCR_TG0)	/* 4KB page size */
    915  1.27     skrll #define  TCR_TG0_64KB		__SHIFTIN(1,TCR_TG0)	/* 64KB page size */
    916  1.27     skrll #define  TCR_TG0_16KB		__SHIFTIN(2,TCR_TG0)	/* 16KB page size */
    917  1.27     skrll #define TCR_SH0			__BITS(13,12)
    918  1.27     skrll #define  TCR_SH0_NONE		__SHIFTIN(0,TCR_SH0)
    919  1.27     skrll #define  TCR_SH0_OUTER		__SHIFTIN(2,TCR_SH0)
    920  1.27     skrll #define  TCR_SH0_INNER		__SHIFTIN(3,TCR_SH0)
    921  1.27     skrll #define TCR_ORGN0		__BITS(11,10)		/* TTBR0 Outer cacheability */
    922  1.27     skrll #define  TCR_ORGN0_NC		__SHIFTIN(0,TCR_ORGN0)	/* Non Cacheable */
    923  1.27     skrll #define  TCR_ORGN0_WB_WA	__SHIFTIN(1,TCR_ORGN0)	/* WriteBack WriteAllocate */
    924  1.27     skrll #define  TCR_ORGN0_WT		__SHIFTIN(2,TCR_ORGN0)	/* WriteThrough */
    925  1.27     skrll #define  TCR_ORGN0_WB		__SHIFTIN(3,TCR_ORGN0)	/* WriteBack */
    926  1.27     skrll #define TCR_IRGN0		__BITS(9,8)		/* TTBR0 Inner cacheability */
    927  1.27     skrll #define  TCR_IRGN0_NC		__SHIFTIN(0,TCR_IRGN0)	/* Non Cacheable */
    928  1.27     skrll #define  TCR_IRGN0_WB_WA	__SHIFTIN(1,TCR_IRGN0)	/* WriteBack WriteAllocate */
    929  1.27     skrll #define  TCR_IRGN0_WT		__SHIFTIN(2,TCR_IRGN0)	/* WriteThrough */
    930  1.27     skrll #define  TCR_IRGN0_WB		__SHIFTIN(3,TCR_IRGN0)	/* WriteBack */
    931  1.27     skrll #define TCR_EPD0		__BIT(7)		/* Walk Disable for TTBR0 */
    932  1.27     skrll #define TCR_T0SZ		__BITS(5,0)		/* Size offset for TTBR0_EL1 */
    933   1.1      matt 
    934   1.1      matt AARCH64REG_READ_INLINE(tpidr_el1)	// Thread ID Register (EL1)
    935   1.1      matt AARCH64REG_WRITE_INLINE(tpidr_el1)
    936   1.1      matt 
    937   1.1      matt AARCH64REG_WRITE_INLINE(tpidrro_el0)	// Thread ID Register (RO for EL0)
    938   1.1      matt 
    939   1.9       ryo AARCH64REG_READ_INLINE(ttbr0_el1) // Translation Table Base Register 0 EL1
    940   1.1      matt AARCH64REG_WRITE_INLINE(ttbr0_el1)
    941   1.1      matt 
    942   1.9       ryo AARCH64REG_READ_INLINE(ttbr1_el1) // Translation Table Base Register 1 EL1
    943   1.1      matt AARCH64REG_WRITE_INLINE(ttbr1_el1)
    944   1.1      matt 
    945  1.27     skrll #define TTBR_ASID		__BITS(63,48)
    946  1.27     skrll #define TTBR_BADDR		__BITS(47,0)
    947  1.27     skrll 
    948   1.1      matt AARCH64REG_READ_INLINE(vbar_el1)	// Vector Base Address Register
    949   1.1      matt AARCH64REG_WRITE_INLINE(vbar_el1)
    950   1.1      matt 
    951   1.9       ryo /*
    952   1.9       ryo  * From here on, these are DEBUG registers
    953   1.9       ryo  */
    954   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr0_el1) // Debug Breakpoint Control Register 0
    955   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr0_el1)
    956   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr1_el1) // Debug Breakpoint Control Register 1
    957   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr1_el1)
    958   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr2_el1) // Debug Breakpoint Control Register 2
    959   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr2_el1)
    960   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr3_el1) // Debug Breakpoint Control Register 3
    961   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr3_el1)
    962   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr4_el1) // Debug Breakpoint Control Register 4
    963   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr4_el1)
    964   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr5_el1) // Debug Breakpoint Control Register 5
    965   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr5_el1)
    966   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr6_el1) // Debug Breakpoint Control Register 6
    967   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr6_el1)
    968   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr7_el1) // Debug Breakpoint Control Register 7
    969   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr7_el1)
    970   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr8_el1) // Debug Breakpoint Control Register 8
    971   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr8_el1)
    972   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr9_el1) // Debug Breakpoint Control Register 9
    973   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr9_el1)
    974   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr10_el1) // Debug Breakpoint Control Register 10
    975   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr10_el1)
    976   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr11_el1) // Debug Breakpoint Control Register 11
    977   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr11_el1)
    978   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr12_el1) // Debug Breakpoint Control Register 12
    979   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr12_el1)
    980   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr13_el1) // Debug Breakpoint Control Register 13
    981   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr13_el1)
    982   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr14_el1) // Debug Breakpoint Control Register 14
    983   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr14_el1)
    984   1.9       ryo AARCH64REG_READ_INLINE(dbgbcr15_el1) // Debug Breakpoint Control Register 15
    985   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbcr15_el1)
    986   1.9       ryo 
    987  1.14     skrll #define	DBGBCR_BT		 __BITS(23,20)
    988  1.14     skrll #define	DBGBCR_LBN		 __BITS(19,16)
    989  1.14     skrll #define	DBGBCR_SSC		 __BITS(15,14)
    990  1.14     skrll #define	DBGBCR_HMC		 __BIT(13)
    991  1.14     skrll #define	DBGBCR_BAS		 __BITS(8,5)
    992  1.14     skrll #define	DBGBCR_PMC		 __BITS(2,1)
    993  1.14     skrll #define	DBGBCR_E		 __BIT(0)
    994   1.9       ryo 
    995   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr0_el1) // Debug Breakpoint Value Register 0
    996   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr0_el1)
    997   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr1_el1) // Debug Breakpoint Value Register 1
    998   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr1_el1)
    999   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr2_el1) // Debug Breakpoint Value Register 2
   1000   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr2_el1)
   1001   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr3_el1) // Debug Breakpoint Value Register 3
   1002   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr3_el1)
   1003   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr4_el1) // Debug Breakpoint Value Register 4
   1004   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr4_el1)
   1005   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr5_el1) // Debug Breakpoint Value Register 5
   1006   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr5_el1)
   1007   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr6_el1) // Debug Breakpoint Value Register 6
   1008   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr6_el1)
   1009   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr7_el1) // Debug Breakpoint Value Register 7
   1010   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr7_el1)
   1011   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr8_el1) // Debug Breakpoint Value Register 8
   1012   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr8_el1)
   1013   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr9_el1) // Debug Breakpoint Value Register 9
   1014   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr9_el1)
   1015   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr10_el1) // Debug Breakpoint Value Register 10
   1016   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr10_el1)
   1017   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr11_el1) // Debug Breakpoint Value Register 11
   1018   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr11_el1)
   1019   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr12_el1) // Debug Breakpoint Value Register 12
   1020   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr12_el1)
   1021   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr13_el1) // Debug Breakpoint Value Register 13
   1022   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr13_el1)
   1023   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr14_el1) // Debug Breakpoint Value Register 14
   1024   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr14_el1)
   1025   1.9       ryo AARCH64REG_READ_INLINE(dbgbvr15_el1) // Debug Breakpoint Value Register 15
   1026   1.9       ryo AARCH64REG_WRITE_INLINE(dbgbvr15_el1)
   1027   1.9       ryo 
   1028   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr0_el1) // Debug Watchpoint Control Register 0
   1029   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr0_el1)
   1030   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr1_el1) // Debug Watchpoint Control Register 1
   1031   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr1_el1)
   1032   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr2_el1) // Debug Watchpoint Control Register 2
   1033   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr2_el1)
   1034   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr3_el1) // Debug Watchpoint Control Register 3
   1035   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr3_el1)
   1036   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr4_el1) // Debug Watchpoint Control Register 4
   1037   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr4_el1)
   1038   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr5_el1) // Debug Watchpoint Control Register 5
   1039   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr5_el1)
   1040   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr6_el1) // Debug Watchpoint Control Register 6
   1041   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr6_el1)
   1042   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr7_el1) // Debug Watchpoint Control Register 7
   1043   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr7_el1)
   1044   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr8_el1) // Debug Watchpoint Control Register 8
   1045   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr8_el1)
   1046   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr9_el1) // Debug Watchpoint Control Register 9
   1047   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr9_el1)
   1048   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr10_el1) // Debug Watchpoint Control Register 10
   1049   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr10_el1)
   1050   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr11_el1) // Debug Watchpoint Control Register 11
   1051   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr11_el1)
   1052   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr12_el1) // Debug Watchpoint Control Register 12
   1053   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr12_el1)
   1054   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr13_el1) // Debug Watchpoint Control Register 13
   1055   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr13_el1)
   1056   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr14_el1) // Debug Watchpoint Control Register 14
   1057   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr14_el1)
   1058   1.9       ryo AARCH64REG_READ_INLINE(dbgwcr15_el1) // Debug Watchpoint Control Register 15
   1059   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwcr15_el1)
   1060   1.9       ryo 
   1061  1.14     skrll #define	DBGWCR_MASK		 __BITS(28,24)
   1062  1.14     skrll #define	DBGWCR_WT		 __BIT(20)
   1063  1.14     skrll #define	DBGWCR_LBN		 __BITS(19,16)
   1064  1.14     skrll #define	DBGWCR_SSC		 __BITS(15,14)
   1065  1.14     skrll #define	DBGWCR_HMC		 __BIT(13)
   1066  1.14     skrll #define	DBGWCR_BAS		 __BITS(12,5)
   1067  1.14     skrll #define	DBGWCR_LSC		 __BITS(4,3)
   1068  1.14     skrll #define	DBGWCR_PAC		 __BITS(2,1)
   1069  1.14     skrll #define	DBGWCR_E		 __BIT(0)
   1070   1.9       ryo 
   1071   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr0_el1) // Debug Watchpoint Value Register 0
   1072   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr0_el1)
   1073   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr1_el1) // Debug Watchpoint Value Register 1
   1074   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr1_el1)
   1075   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr2_el1) // Debug Watchpoint Value Register 2
   1076   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr2_el1)
   1077   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr3_el1) // Debug Watchpoint Value Register 3
   1078   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr3_el1)
   1079   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr4_el1) // Debug Watchpoint Value Register 4
   1080   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr4_el1)
   1081   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr5_el1) // Debug Watchpoint Value Register 5
   1082   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr5_el1)
   1083   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr6_el1) // Debug Watchpoint Value Register 6
   1084   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr6_el1)
   1085   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr7_el1) // Debug Watchpoint Value Register 7
   1086   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr7_el1)
   1087   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr8_el1) // Debug Watchpoint Value Register 8
   1088   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr8_el1)
   1089   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr9_el1) // Debug Watchpoint Value Register 9
   1090   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr9_el1)
   1091   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr10_el1) // Debug Watchpoint Value Register 10
   1092   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr10_el1)
   1093   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr11_el1) // Debug Watchpoint Value Register 11
   1094   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr11_el1)
   1095   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr12_el1) // Debug Watchpoint Value Register 12
   1096   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr12_el1)
   1097   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr13_el1) // Debug Watchpoint Value Register 13
   1098   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr13_el1)
   1099   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr14_el1) // Debug Watchpoint Value Register 14
   1100   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr14_el1)
   1101   1.9       ryo AARCH64REG_READ_INLINE(dbgwvr15_el1) // Debug Watchpoint Value Register 15
   1102   1.9       ryo AARCH64REG_WRITE_INLINE(dbgwvr15_el1)
   1103   1.9       ryo 
   1104  1.14     skrll #define	DBGWVR_MASK		 __BITS(64,3)
   1105   1.9       ryo 
   1106   1.9       ryo 
   1107   1.9       ryo AARCH64REG_READ_INLINE(mdscr_el1) // Monitor Debug System Control Register
   1108   1.9       ryo AARCH64REG_WRITE_INLINE(mdscr_el1)
   1109   1.9       ryo 
   1110  1.22       ryo #define	MDSCR_RXFULL		__BIT(30)	// for EDSCR.RXfull
   1111  1.22       ryo #define	MDSCR_TXFULL		__BIT(29)	// for EDSCR.TXfull
   1112  1.22       ryo #define	MDSCR_RXO		__BIT(27)	// for EDSCR.RXO
   1113  1.22       ryo #define	MDSCR_TXU		__BIT(26)	// for EDSCR.TXU
   1114  1.22       ryo #define	MDSCR_INTDIS		__BITS(32,22)	// for EDSCR.INTdis
   1115  1.22       ryo #define	MDSCR_TDA		__BIT(21)	// for EDSCR.TDA
   1116  1.22       ryo #define	MDSCR_MDE		__BIT(15)	// Monitor debug events
   1117  1.22       ryo #define	MDSCR_HDE		__BIT(14)	// for EDSCR.HDE
   1118  1.22       ryo #define	MDSCR_KDE		__BIT(13)	// Local debug enable
   1119  1.22       ryo #define	MDSCR_TDCC		__BIT(12)	// Trap Debug CommCh access
   1120  1.22       ryo #define	MDSCR_ERR		__BIT(6)	// for EDSCR.ERR
   1121  1.22       ryo #define	MDSCR_SS		__BIT(0)	// Software step
   1122  1.22       ryo 
   1123   1.9       ryo AARCH64REG_WRITE_INLINE(oslar_el1)	// OS Lock Access Register
   1124   1.9       ryo 
   1125   1.9       ryo AARCH64REG_READ_INLINE(oslsr_el1)	// OS Lock Status Register
   1126   1.9       ryo 
   1127   1.9       ryo /*
   1128   1.9       ryo  * From here on, these are PMC registers
   1129   1.9       ryo  */
   1130   1.9       ryo 
   1131   1.1      matt AARCH64REG_READ_INLINE(pmccfiltr_el0)
   1132   1.1      matt AARCH64REG_WRITE_INLINE(pmccfiltr_el0)
   1133   1.1      matt 
   1134  1.14     skrll #define	PMCCFILTR_P		__BIT(31)	// Don't count cycles in EL1
   1135  1.14     skrll #define	PMCCFILTR_U		__BIT(30)	// Don't count cycles in EL0
   1136  1.14     skrll #define	PMCCFILTR_NSK		__BIT(29)	// Don't count cycles in NS EL1
   1137  1.14     skrll #define	PMCCFILTR_NSU 		__BIT(28)	// Don't count cycles in NS EL0
   1138  1.14     skrll #define	PMCCFILTR_NSH 		__BIT(27)	// Don't count cycles in NS EL2
   1139  1.14     skrll #define	PMCCFILTR_M		__BIT(26)	// Don't count cycles in EL3
   1140   1.1      matt 
   1141   1.1      matt AARCH64REG_READ_INLINE(pmccntr_el0)
   1142   1.1      matt 
   1143  1.12  christos AARCH64REG_READ_INLINE(pmceid0_el0)
   1144  1.12  christos AARCH64REG_READ_INLINE(pmceid1_el0)
   1145  1.11  jmcneill 
   1146  1.12  christos AARCH64REG_WRITE_INLINE(pmcntenclr_el0)
   1147  1.12  christos AARCH64REG_WRITE_INLINE(pmcntenset_el0)
   1148  1.11  jmcneill 
   1149  1.39  jmcneill #define	PMCNTEN_C		__BIT(31)	// Enable the cycle counter
   1150  1.39  jmcneill #define	PMCNTEN_P		__BITS(30,0)	// Enable event counter bits
   1151  1.39  jmcneill 
   1152  1.11  jmcneill AARCH64REG_READ_INLINE(pmcr_el0)
   1153  1.11  jmcneill AARCH64REG_WRITE_INLINE(pmcr_el0)
   1154  1.11  jmcneill 
   1155  1.14     skrll #define	PMCR_IMP		__BITS(31,24)	// Implementor code
   1156  1.14     skrll #define	PMCR_IDCODE		__BITS(23,16)	// Identification code
   1157  1.14     skrll #define	PMCR_N			__BITS(15,11)	// Number of event counters
   1158  1.14     skrll #define	PMCR_LC			__BIT(6)	// Long cycle counter enable
   1159  1.14     skrll #define	PMCR_DP			__BIT(5)	// Disable cycle counter when event
   1160  1.14     skrll 						// counting is prohibited
   1161  1.14     skrll #define	PMCR_X			__BIT(4)	// Enable export of events
   1162  1.14     skrll #define	PMCR_D			__BIT(3)	// Clock divider
   1163  1.14     skrll #define	PMCR_C			__BIT(2)	// Cycle counter reset
   1164  1.14     skrll #define	PMCR_P			__BIT(1)	// Event counter reset
   1165  1.14     skrll #define	PMCR_E			__BIT(0)	// Enable
   1166  1.11  jmcneill 
   1167  1.11  jmcneill 
   1168  1.12  christos AARCH64REG_READ_INLINE(pmevcntr1_el0)
   1169  1.12  christos AARCH64REG_WRITE_INLINE(pmevcntr1_el0)
   1170  1.11  jmcneill 
   1171  1.11  jmcneill AARCH64REG_READ_INLINE(pmevtyper1_el0)
   1172  1.11  jmcneill AARCH64REG_WRITE_INLINE(pmevtyper1_el0)
   1173  1.11  jmcneill 
   1174  1.14     skrll #define	PMEVTYPER_P		__BIT(31)	// Don't count events in EL1
   1175  1.14     skrll #define	PMEVTYPER_U		__BIT(30)	// Don't count events in EL0
   1176  1.14     skrll #define	PMEVTYPER_NSK		__BIT(29)	// Don't count events in NS EL1
   1177  1.14     skrll #define	PMEVTYPER_NSU		__BIT(28)	// Don't count events in NS EL0
   1178  1.14     skrll #define	PMEVTYPER_NSH		__BIT(27)	// Count events in NS EL2
   1179  1.14     skrll #define	PMEVTYPER_M		__BIT(26)	// Don't count events in EL3
   1180  1.14     skrll #define	PMEVTYPER_MT		__BIT(25)	// Count events on all CPUs with same
   1181  1.14     skrll 						// aff1 level
   1182  1.14     skrll #define	PMEVTYPER_EVTCOUNT	__BITS(15,0)	// Event to count
   1183  1.11  jmcneill 
   1184  1.12  christos AARCH64REG_WRITE_INLINE(pmintenclr_el1)
   1185  1.12  christos AARCH64REG_WRITE_INLINE(pmintenset_el1)
   1186  1.11  jmcneill 
   1187  1.12  christos AARCH64REG_WRITE_INLINE(pmovsclr_el0)
   1188  1.12  christos AARCH64REG_READ_INLINE(pmovsset_el0)
   1189  1.12  christos AARCH64REG_WRITE_INLINE(pmovsset_el0)
   1190  1.11  jmcneill 
   1191  1.12  christos AARCH64REG_WRITE_INLINE(pmselr_el0)
   1192  1.11  jmcneill 
   1193  1.12  christos AARCH64REG_WRITE_INLINE(pmswinc_el0)
   1194  1.11  jmcneill 
   1195  1.12  christos AARCH64REG_READ_INLINE(pmuserenr_el0)
   1196  1.12  christos AARCH64REG_WRITE_INLINE(pmuserenr_el0)
   1197  1.11  jmcneill 
   1198  1.12  christos AARCH64REG_READ_INLINE(pmxevcntr_el0)
   1199  1.12  christos AARCH64REG_WRITE_INLINE(pmxevcntr_el0)
   1200  1.11  jmcneill 
   1201  1.12  christos AARCH64REG_READ_INLINE(pmxevtyper_el0)
   1202  1.12  christos AARCH64REG_WRITE_INLINE(pmxevtyper_el0)
   1203  1.11  jmcneill 
   1204  1.11  jmcneill /*
   1205  1.11  jmcneill  * Generic timer registers
   1206  1.11  jmcneill  */
   1207  1.11  jmcneill 
   1208   1.1      matt AARCH64REG_READ_INLINE(cntfrq_el0)
   1209   1.1      matt 
   1210   1.9       ryo AARCH64REG_READ_INLINE(cnthctl_el2)
   1211   1.9       ryo AARCH64REG_WRITE_INLINE(cnthctl_el2)
   1212   1.9       ryo 
   1213  1.14     skrll #define	CNTHCTL_EVNTDIR		__BIT(3)
   1214  1.14     skrll #define	CNTHCTL_EVNTEN		__BIT(2)
   1215  1.14     skrll #define	CNTHCTL_EL1PCEN		__BIT(1)
   1216  1.14     skrll #define	CNTHCTL_EL1PCTEN	__BIT(0)
   1217   1.9       ryo 
   1218   1.1      matt AARCH64REG_READ_INLINE(cntkctl_el1)
   1219   1.1      matt AARCH64REG_WRITE_INLINE(cntkctl_el1)
   1220   1.1      matt 
   1221  1.14     skrll #define	CNTKCTL_EL0PTEN		__BIT(9)	// EL0 access for CNTP CVAL/TVAL/CTL
   1222  1.14     skrll #define	CNTKCTL_PL0PTEN		CNTKCTL_EL0PTEN
   1223  1.14     skrll #define	CNTKCTL_EL0VTEN		__BIT(8)	// EL0 access for CNTV CVAL/TVAL/CTL
   1224  1.14     skrll #define	CNTKCTL_PL0VTEN		CNTKCTL_EL0VTEN
   1225  1.14     skrll #define	CNTKCTL_ELNTI		__BITS(7,4)
   1226  1.14     skrll #define	CNTKCTL_EVNTDIR		__BIT(3)
   1227  1.14     skrll #define	CNTKCTL_EVNTEN		__BIT(2)
   1228  1.14     skrll #define	CNTKCTL_EL0VCTEN	__BIT(1)	// EL0 access for CNTVCT and CNTFRQ
   1229  1.14     skrll #define	CNTKCTL_PL0VCTEN	CNTKCTL_EL0VCTEN
   1230  1.14     skrll #define	CNTKCTL_EL0PCTEN	__BIT(0)	// EL0 access for CNTPCT and CNTFRQ
   1231  1.14     skrll #define	CNTKCTL_PL0PCTEN	CNTKCTL_EL0PCTEN
   1232   1.1      matt 
   1233   1.1      matt AARCH64REG_READ_INLINE(cntp_ctl_el0)
   1234   1.1      matt AARCH64REG_WRITE_INLINE(cntp_ctl_el0)
   1235   1.1      matt AARCH64REG_READ_INLINE(cntp_cval_el0)
   1236   1.1      matt AARCH64REG_WRITE_INLINE(cntp_cval_el0)
   1237   1.1      matt AARCH64REG_READ_INLINE(cntp_tval_el0)
   1238   1.1      matt AARCH64REG_WRITE_INLINE(cntp_tval_el0)
   1239   1.1      matt AARCH64REG_READ_INLINE(cntpct_el0)
   1240   1.1      matt AARCH64REG_WRITE_INLINE(cntpct_el0)
   1241   1.1      matt 
   1242   1.1      matt AARCH64REG_READ_INLINE(cntps_ctl_el1)
   1243   1.1      matt AARCH64REG_WRITE_INLINE(cntps_ctl_el1)
   1244   1.1      matt AARCH64REG_READ_INLINE(cntps_cval_el1)
   1245   1.1      matt AARCH64REG_WRITE_INLINE(cntps_cval_el1)
   1246   1.1      matt AARCH64REG_READ_INLINE(cntps_tval_el1)
   1247   1.1      matt AARCH64REG_WRITE_INLINE(cntps_tval_el1)
   1248   1.1      matt 
   1249   1.1      matt AARCH64REG_READ_INLINE(cntv_ctl_el0)
   1250   1.1      matt AARCH64REG_WRITE_INLINE(cntv_ctl_el0)
   1251   1.1      matt AARCH64REG_READ_INLINE(cntv_cval_el0)
   1252   1.1      matt AARCH64REG_WRITE_INLINE(cntv_cval_el0)
   1253   1.1      matt AARCH64REG_READ_INLINE(cntv_tval_el0)
   1254   1.1      matt AARCH64REG_WRITE_INLINE(cntv_tval_el0)
   1255   1.1      matt AARCH64REG_READ_INLINE(cntvct_el0)
   1256   1.1      matt AARCH64REG_WRITE_INLINE(cntvct_el0)
   1257   1.1      matt 
   1258  1.14     skrll #define	CNTCTL_ISTATUS		__BIT(2)	// Interrupt Asserted
   1259  1.14     skrll #define	CNTCTL_IMASK		__BIT(1)	// Timer Interrupt is Masked
   1260  1.14     skrll #define	CNTCTL_ENABLE		__BIT(0)	// Timer Enabled
   1261   1.1      matt 
   1262   1.9       ryo // ID_AA64PFR0_EL1: AArch64 Processor Feature Register 0
   1263  1.37       ryo #define	ID_AA64PFR0_EL1_SVE		__BITS(35,32) // Scalable Vector
   1264  1.37       ryo #define	 ID_AA64PFR0_EL1_SVE_NONE	 0
   1265  1.37       ryo #define	 ID_AA64PFR0_EL1_SVE_IMPL	 1
   1266  1.37       ryo #define	ID_AA64PFR0_EL1_RAS		__BITS(31,28) // RAS Extension
   1267  1.37       ryo #define	 ID_AA64PFR0_EL1_RAS_NONE	 0
   1268  1.37       ryo #define	 ID_AA64PFR0_EL1_RAS_IMPL	 1
   1269  1.37       ryo #define	 ID_AA64PFR0_EL1_RAS_ERX	 2
   1270  1.12  christos #define	ID_AA64PFR0_EL1_GIC		__BITS(24,27) // GIC CPU IF
   1271  1.12  christos #define	ID_AA64PFR0_EL1_GIC_SHIFT	24
   1272  1.14     skrll #define	 ID_AA64PFR0_EL1_GIC_CPUIF_EN	 1
   1273  1.14     skrll #define	 ID_AA64PFR0_EL1_GIC_CPUIF_NONE	 0
   1274  1.12  christos #define	ID_AA64PFR0_EL1_ADVSIMD		__BITS(23,20) // SIMD
   1275  1.14     skrll #define	 ID_AA64PFR0_EL1_ADV_SIMD_IMPL	 0x0
   1276  1.37       ryo #define	 ID_AA64PFR0_EL1_ADV_SIMD_HP	 0x1
   1277  1.14     skrll #define	 ID_AA64PFR0_EL1_ADV_SIMD_NONE	 0xf
   1278  1.12  christos #define	ID_AA64PFR0_EL1_FP		__BITS(19,16) // FP
   1279  1.14     skrll #define	 ID_AA64PFR0_EL1_FP_IMPL	 0x0
   1280  1.37       ryo #define	 ID_AA64PFR0_EL1_FP_HP		 0x1
   1281  1.14     skrll #define	 ID_AA64PFR0_EL1_FP_NONE	 0xf
   1282  1.12  christos #define	ID_AA64PFR0_EL1_EL3		__BITS(15,12) // EL3 handling
   1283  1.14     skrll #define	 ID_AA64PFR0_EL1_EL3_NONE	 0
   1284  1.14     skrll #define	 ID_AA64PFR0_EL1_EL3_64		 1
   1285  1.14     skrll #define	 ID_AA64PFR0_EL1_EL3_64_32	 2
   1286  1.12  christos #define	ID_AA64PFR0_EL1_EL2		__BITS(11,8) // EL2 handling
   1287  1.14     skrll #define	 ID_AA64PFR0_EL1_EL2_NONE	 0
   1288  1.14     skrll #define	 ID_AA64PFR0_EL1_EL2_64	 	 1
   1289  1.14     skrll #define	 ID_AA64PFR0_EL1_EL2_64_32	 2
   1290  1.12  christos #define	ID_AA64PFR0_EL1_EL1		__BITS(7,4) // EL1 handling
   1291  1.14     skrll #define	 ID_AA64PFR0_EL1_EL1_64	 	 1
   1292  1.14     skrll #define	 ID_AA64PFR0_EL1_EL1_64_32	 2
   1293  1.12  christos #define	ID_AA64PFR0_EL1_EL0		__BITS(3,0) // EL0 handling
   1294  1.14     skrll #define	 ID_AA64PFR0_EL1_EL0_64	 	 1
   1295  1.14     skrll #define	 ID_AA64PFR0_EL1_EL0_64_32	 2
   1296   1.9       ryo 
   1297  1.15  jmcneill /*
   1298  1.15  jmcneill  * GICv3 system registers
   1299  1.15  jmcneill  */
   1300  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_sre_el1, s3_0_c12_c12_5)
   1301  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_ctlr_el1, s3_0_c12_c12_4)
   1302  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_pmr_el1, s3_0_c4_c6_0)
   1303  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_bpr0_el1, s3_0_c12_c8_3)
   1304  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_bpr1_el1, s3_0_c12_c12_3)
   1305  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_igrpen0_el1, s3_0_c12_c12_6)
   1306  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_igrpen1_el1, s3_0_c12_c12_7)
   1307  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_eoir0_el1, s3_0_c12_c8_1)
   1308  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_eoir1_el1, s3_0_c12_c12_1)
   1309  1.15  jmcneill AARCH64REG_READWRITE_INLINE2(icc_sgi1r_el1, s3_0_c12_c11_5)
   1310  1.15  jmcneill AARCH64REG_READ_INLINE2(icc_iar1_el1, s3_0_c12_c12_0)
   1311  1.15  jmcneill 
   1312   1.9       ryo // ICC_SRE_EL1: Interrupt Controller System Register Enable register
   1313  1.15  jmcneill #define	ICC_SRE_EL1_DIB		__BIT(2)
   1314  1.15  jmcneill #define	ICC_SRE_EL1_DFB		__BIT(1)
   1315  1.15  jmcneill #define	ICC_SRE_EL1_SRE		__BIT(0)
   1316  1.15  jmcneill 
   1317  1.16  jmcneill // ICC_SRE_EL2: Interrupt Controller System Register Enable register
   1318  1.16  jmcneill #define	ICC_SRE_EL2_EN		__BIT(3)
   1319  1.16  jmcneill #define	ICC_SRE_EL2_DIB		__BIT(2)
   1320  1.16  jmcneill #define	ICC_SRE_EL2_DFB		__BIT(1)
   1321  1.16  jmcneill #define	ICC_SRE_EL2_SRE		__BIT(0)
   1322  1.16  jmcneill 
   1323  1.15  jmcneill // ICC_BPR[01]_EL1: Interrupt Controller Binary Point Register 0/1
   1324  1.15  jmcneill #define	ICC_BPR_EL1_BinaryPoint	__BITS(2,0)
   1325  1.15  jmcneill 
   1326  1.15  jmcneill // ICC_CTLR_EL1: Interrupt Controller Control Register
   1327  1.15  jmcneill #define	ICC_CTLR_EL1_A3V	__BIT(15)
   1328  1.15  jmcneill #define	ICC_CTLR_EL1_SEIS	__BIT(14)
   1329  1.15  jmcneill #define	ICC_CTLR_EL1_IDbits	__BITS(13,11)
   1330  1.15  jmcneill #define	ICC_CTLR_EL1_PRIbits	__BITS(10,8)
   1331  1.15  jmcneill #define	ICC_CTLR_EL1_PMHE	__BIT(6)
   1332  1.15  jmcneill #define	ICC_CTLR_EL1_EOImode	__BIT(1)
   1333  1.15  jmcneill #define	ICC_CTLR_EL1_CBPR	__BIT(0)
   1334  1.15  jmcneill 
   1335  1.15  jmcneill // ICC_IGRPEN[01]_EL1: Interrupt Controller Interrupt Group 0/1 Enable register
   1336  1.15  jmcneill #define	ICC_IGRPEN_EL1_Enable	__BIT(0)
   1337  1.15  jmcneill 
   1338  1.15  jmcneill // ICC_SGI[01]R_EL1: Interrupt Controller Software Generated Interrupt Group 0/1 Register
   1339  1.15  jmcneill #define	ICC_SGIR_EL1_Aff3	__BITS(55,48)
   1340  1.15  jmcneill #define	ICC_SGIR_EL1_IRM	__BIT(40)
   1341  1.15  jmcneill #define	ICC_SGIR_EL1_Aff2	__BITS(39,32)
   1342  1.15  jmcneill #define	ICC_SGIR_EL1_INTID	__BITS(27,24)
   1343  1.15  jmcneill #define	ICC_SGIR_EL1_Aff1	__BITS(23,16)
   1344  1.15  jmcneill #define	ICC_SGIR_EL1_TargetList	__BITS(15,0)
   1345  1.15  jmcneill #define	ICC_SGIR_EL1_Aff	(ICC_SGIR_EL1_Aff3|ICC_SGIR_EL1_Aff2|ICC_SGIR_EL1_Aff1)
   1346  1.15  jmcneill 
   1347  1.15  jmcneill // ICC_IAR[01]_EL1: Interrupt Controller Interrupt Acknowledge Register 0/1
   1348  1.15  jmcneill #define	ICC_IAR_INTID		__BITS(23,0)
   1349  1.15  jmcneill #define	ICC_IAR_INTID_SPURIOUS	1023
   1350  1.15  jmcneill 
   1351  1.15  jmcneill /*
   1352  1.15  jmcneill  * GICv3 REGISTER ACCESS
   1353  1.15  jmcneill  */
   1354   1.9       ryo 
   1355  1.15  jmcneill #define	icc_sre_read		reg_icc_sre_el1_read
   1356  1.15  jmcneill #define	icc_sre_write		reg_icc_sre_el1_write
   1357  1.25     skrll #define	icc_pmr_read		reg_icc_pmr_el1_read
   1358  1.15  jmcneill #define	icc_pmr_write		reg_icc_pmr_el1_write
   1359  1.15  jmcneill #define	icc_bpr0_write		reg_icc_bpr0_el1_write
   1360  1.15  jmcneill #define	icc_bpr1_write		reg_icc_bpr1_el1_write
   1361  1.15  jmcneill #define	icc_ctlr_read		reg_icc_ctlr_el1_read
   1362  1.15  jmcneill #define	icc_ctlr_write		reg_icc_ctlr_el1_write
   1363  1.15  jmcneill #define	icc_igrpen1_write	reg_icc_igrpen1_el1_write
   1364  1.15  jmcneill #define	icc_sgi1r_write		reg_icc_sgi1r_el1_write
   1365  1.15  jmcneill #define	icc_iar1_read		reg_icc_iar1_el1_read
   1366  1.15  jmcneill #define	icc_eoi1r_write		reg_icc_eoir1_el1_write
   1367   1.9       ryo 
   1368  1.18     skrll #if defined(_KERNEL)
   1369  1.18     skrll 
   1370  1.18     skrll /*
   1371  1.18     skrll  * CPU REGISTER ACCESS
   1372  1.18     skrll  */
   1373  1.18     skrll static __inline register_t
   1374  1.18     skrll cpu_mpidr_aff_read(void)
   1375  1.18     skrll {
   1376  1.18     skrll 
   1377  1.18     skrll 	return reg_mpidr_el1_read() &
   1378  1.18     skrll 	    (MPIDR_AFF3|MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0);
   1379  1.18     skrll }
   1380  1.18     skrll 
   1381   1.9       ryo /*
   1382   1.9       ryo  * GENERIC TIMER REGISTER ACCESS
   1383   1.9       ryo  */
   1384  1.12  christos static __inline uint32_t
   1385   1.9       ryo gtmr_cntfrq_read(void)
   1386   1.9       ryo {
   1387   1.9       ryo 
   1388   1.9       ryo 	return reg_cntfrq_el0_read();
   1389   1.9       ryo }
   1390   1.9       ryo 
   1391  1.12  christos static __inline uint32_t
   1392   1.9       ryo gtmr_cntk_ctl_read(void)
   1393   1.9       ryo {
   1394   1.1      matt 
   1395   1.9       ryo 	return reg_cntkctl_el1_read();
   1396   1.9       ryo }
   1397   1.9       ryo 
   1398  1.12  christos static __inline void
   1399   1.9       ryo gtmr_cntk_ctl_write(uint32_t val)
   1400   1.9       ryo {
   1401   1.9       ryo 
   1402   1.9       ryo 	reg_cntkctl_el1_write(val);
   1403   1.9       ryo }
   1404   1.9       ryo 
   1405   1.9       ryo /*
   1406   1.9       ryo  * Counter-timer Virtual Count timer
   1407   1.9       ryo  */
   1408  1.12  christos static __inline uint64_t
   1409   1.9       ryo gtmr_cntpct_read(void)
   1410   1.9       ryo {
   1411   1.9       ryo 
   1412   1.9       ryo 	return reg_cntpct_el0_read();
   1413   1.9       ryo }
   1414   1.9       ryo 
   1415  1.12  christos static __inline uint64_t
   1416   1.9       ryo gtmr_cntvct_read(void)
   1417   1.9       ryo {
   1418   1.9       ryo 
   1419   1.9       ryo 	return reg_cntvct_el0_read();
   1420   1.9       ryo }
   1421   1.9       ryo 
   1422   1.9       ryo /*
   1423   1.9       ryo  * Counter-timer Virtual Timer Control register
   1424   1.9       ryo  */
   1425  1.12  christos static __inline uint32_t
   1426   1.9       ryo gtmr_cntv_ctl_read(void)
   1427   1.9       ryo {
   1428   1.9       ryo 
   1429   1.9       ryo 	return reg_cntv_ctl_el0_read();
   1430   1.9       ryo }
   1431   1.9       ryo 
   1432  1.12  christos static __inline void
   1433   1.9       ryo gtmr_cntv_ctl_write(uint32_t val)
   1434   1.9       ryo {
   1435   1.9       ryo 
   1436   1.9       ryo 	reg_cntv_ctl_el0_write(val);
   1437   1.9       ryo }
   1438   1.9       ryo 
   1439  1.26  jmcneill /*
   1440  1.26  jmcneill  * Counter-timer Physical Timer Control register
   1441  1.26  jmcneill  */
   1442  1.26  jmcneill static __inline uint32_t
   1443  1.26  jmcneill gtmr_cntp_ctl_read(void)
   1444  1.26  jmcneill {
   1445  1.26  jmcneill 
   1446  1.26  jmcneill 	return reg_cntp_ctl_el0_read();
   1447  1.26  jmcneill }
   1448  1.26  jmcneill 
   1449  1.12  christos static __inline void
   1450   1.9       ryo gtmr_cntp_ctl_write(uint32_t val)
   1451   1.9       ryo {
   1452   1.9       ryo 
   1453   1.9       ryo 	reg_cntp_ctl_el0_write(val);
   1454   1.9       ryo }
   1455   1.9       ryo 
   1456   1.9       ryo /*
   1457  1.26  jmcneill  * Counter-timer Physical Timer TimerValue register
   1458  1.26  jmcneill  */
   1459  1.26  jmcneill static __inline uint32_t
   1460  1.26  jmcneill gtmr_cntp_tval_read(void)
   1461  1.26  jmcneill {
   1462  1.26  jmcneill 
   1463  1.26  jmcneill 	return reg_cntp_tval_el0_read();
   1464  1.26  jmcneill }
   1465  1.26  jmcneill 
   1466  1.26  jmcneill static __inline void
   1467  1.26  jmcneill gtmr_cntp_tval_write(uint32_t val)
   1468  1.26  jmcneill {
   1469  1.26  jmcneill 
   1470  1.26  jmcneill 	reg_cntp_tval_el0_write(val);
   1471  1.26  jmcneill }
   1472  1.26  jmcneill 
   1473  1.26  jmcneill /*
   1474   1.9       ryo  * Counter-timer Virtual Timer TimerValue register
   1475   1.9       ryo  */
   1476  1.12  christos static __inline uint32_t
   1477  1.10     joerg gtmr_cntv_tval_read(void)
   1478  1.10     joerg {
   1479  1.10     joerg 
   1480  1.10     joerg 	return reg_cntv_tval_el0_read();
   1481  1.10     joerg }
   1482  1.10     joerg 
   1483  1.12  christos static __inline void
   1484   1.9       ryo gtmr_cntv_tval_write(uint32_t val)
   1485   1.9       ryo {
   1486   1.9       ryo 
   1487   1.9       ryo 	reg_cntv_tval_el0_write(val);
   1488   1.9       ryo }
   1489   1.9       ryo 
   1490  1.26  jmcneill /*
   1491  1.26  jmcneill  * Counter-timer Physical Timer CompareValue register
   1492  1.26  jmcneill  */
   1493  1.26  jmcneill static __inline uint64_t
   1494  1.26  jmcneill gtmr_cntp_cval_read(void)
   1495  1.26  jmcneill {
   1496  1.26  jmcneill 
   1497  1.26  jmcneill 	return reg_cntp_cval_el0_read();
   1498  1.26  jmcneill }
   1499  1.26  jmcneill 
   1500  1.26  jmcneill static __inline void
   1501  1.26  jmcneill gtmr_cntp_cval_write(uint64_t val)
   1502  1.26  jmcneill {
   1503  1.26  jmcneill 
   1504  1.26  jmcneill 	reg_cntp_cval_el0_write(val);
   1505  1.26  jmcneill }
   1506   1.9       ryo 
   1507   1.9       ryo /*
   1508   1.9       ryo  * Counter-timer Virtual Timer CompareValue register
   1509   1.9       ryo  */
   1510  1.12  christos static __inline uint64_t
   1511   1.9       ryo gtmr_cntv_cval_read(void)
   1512   1.9       ryo {
   1513   1.9       ryo 
   1514   1.9       ryo 	return reg_cntv_cval_el0_read();
   1515   1.9       ryo }
   1516  1.23  jmcneill 
   1517  1.23  jmcneill static __inline void
   1518  1.23  jmcneill gtmr_cntv_cval_write(uint64_t val)
   1519  1.23  jmcneill {
   1520  1.23  jmcneill 
   1521  1.23  jmcneill 	reg_cntv_cval_el0_write(val);
   1522  1.23  jmcneill }
   1523  1.18     skrll #endif /* _KERNEL */
   1524   1.1      matt 
   1525  1.21       mrg /*
   1526  1.21       mrg  * Structure attached to machdep.cpuN.cpu_id sysctl node.
   1527  1.21       mrg  * Always add new members to the end, and avoid arrays.
   1528  1.21       mrg  */
   1529  1.21       mrg struct aarch64_sysctl_cpu_id {
   1530  1.21       mrg 	uint64_t ac_midr;	/* Main ID Register */
   1531  1.21       mrg 	uint64_t ac_revidr;	/* Revision ID Register */
   1532  1.21       mrg 	uint64_t ac_mpidr;	/* Multiprocessor Affinity Register */
   1533  1.21       mrg 
   1534  1.21       mrg 	uint64_t ac_aa64dfr0;	/* A64 Debug Feature Register 0 */
   1535  1.21       mrg 	uint64_t ac_aa64dfr1;	/* A64 Debug Feature Register 1 */
   1536  1.21       mrg 
   1537  1.21       mrg 	uint64_t ac_aa64isar0;	/* A64 Instruction Set Attribute Register 0 */
   1538  1.21       mrg 	uint64_t ac_aa64isar1;	/* A64 Instruction Set Attribute Register 1 */
   1539  1.21       mrg 
   1540  1.30       rjs 	uint64_t ac_aa64mmfr0;	/* A64 Memory Model Feature Register 0 */
   1541  1.30       rjs 	uint64_t ac_aa64mmfr1;	/* A64 Memory Model Feature Register 1 */
   1542  1.30       rjs 	uint64_t ac_aa64mmfr2;	/* A64 Memory Model Feature Register 2 */
   1543  1.21       mrg 
   1544  1.21       mrg 	uint64_t ac_aa64pfr0;	/* A64 Processor Feature Register 0 */
   1545  1.21       mrg 	uint64_t ac_aa64pfr1;	/* A64 Processor Feature Register 1 */
   1546  1.21       mrg 
   1547  1.21       mrg 	uint64_t ac_aa64zfr0;	/* A64 SVE Feature ID Register 0 */
   1548  1.21       mrg 
   1549  1.21       mrg 	uint32_t ac_mvfr0;	/* Media and VFP Feature Register 0 */
   1550  1.21       mrg 	uint32_t ac_mvfr1;	/* Media and VFP Feature Register 1 */
   1551  1.21       mrg 	uint32_t ac_mvfr2;	/* Media and VFP Feature Register 2 */
   1552  1.21       mrg };
   1553  1.21       mrg 
   1554   1.1      matt #endif /* _AARCH64_ARMREG_H_ */
   1555