1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-15 08:26:56 +00:00
Atmosphere/thermosphere/src/sysreg.h

325 lines
13 KiB
C
Raw Normal View History

2019-07-23 03:47:57 +01:00
#pragma once
#include "preprocessor.h"
// Only for most EL1 regs, etc.
#define __BITL(n) (1ull << (n))
#define TUP_OSDTRRX_EL1 (2, 0, 0, 0, 2)
#define TUP_MDCCINT_EL1 (2, 0, 0, 2, 0)
#define TUP_MDSCR_EL1 (2, 0, 0, 2, 2)
#define TUP_OSDTRTX_EL1 (2, 0, 0, 3, 2)
#define TUP_OSECCR_EL1 (2, 0, 0, 6, 2)
#define TUP_DBGBVRn_EL1(n) (2, 0, 0, n, 4)
#define TUP_DBGBCRn_EL1(n) (2, 0, 0, n, 5)
#define TUP_DBGWVRn_EL1(n) (2, 0, 0, n, 6)
#define TUP_DBGWCRn_EL1(n) (2, 0, 0, n, 7)
#define TUP_MDRAR_EL1 (2, 0, 1, 0, 0)
#define TUP_OSLAR_EL1 (2, 0, 1, 0, 4)
#define TUP_OSLSR_EL1 (2, 0, 1, 1, 4)
#define TUP_OSDLR_EL1 (2, 0, 1, 3, 4)
#define TUP_DBGPRCR_EL1 (2, 0, 1, 4, 4)
#define TUP_DBGCLAIMSET_EL1 (2, 0, 7, 8, 6)
#define TUP_DBGCLAIMCLR_EL1 (2, 0, 7, 9, 6)
#define TUP_DBGAUTHSTATUS_EL1 (2, 0, 7, 14, 6)
#define TUP_MDCCSR_EL0 (2, 3, 0, 1, 0)
#define TUP_DBGDTR_EL0 (2, 3, 0, 4, 0)
#define TUP_DBGDTRRX_EL0 (2, 3, 0, 5, 0)
#define TUP_DBGDTRTX_EL0 (2, 3, 0, 5, 0)
#define TUP_DBGVCR32_EL2 (2, 4, 0, 7, 0)
#define TUP_MIDR_EL1 (3, 0, 0, 0, 0)
#define TUP_MPIDR_EL1 (3, 0, 0, 0, 5)
#define TUP_REVIDR_EL1 (3, 0, 0, 0, 6)
#define TUP_ID_PFR0_EL1 (3, 0, 0, 1, 0)
#define TUP_ID_PFR1_EL1 (3, 0, 0, 1, 1)
#define TUP_ID_DFR0_EL1 (3, 0, 0, 1, 2)
#define TUP_ID_AFR0_EL1 (3, 0, 0, 1, 3)
#define TUP_ID_MMFR0_EL1 (3, 0, 0, 1, 4)
#define TUP_ID_MMFR1_EL1 (3, 0, 0, 1, 5)
#define TUP_ID_MMFR2_EL1 (3, 0, 0, 1, 6)
#define TUP_ID_MMFR3_EL1 (3, 0, 0, 1, 7)
#define TUP_ID_ISAR0_EL1 (3, 0, 0, 2, 0)
#define TUP_ID_ISAR1_EL1 (3, 0, 0, 2, 1)
#define TUP_ID_ISAR2_EL1 (3, 0, 0, 2, 2)
#define TUP_ID_ISAR3_EL1 (3, 0, 0, 2, 3)
#define TUP_ID_ISAR4_EL1 (3, 0, 0, 2, 4)
#define TUP_ID_ISAR5_EL1 (3, 0, 0, 2, 5)
#define TUP_ID_MMFR4_EL1 (3, 0, 0, 2, 6)
#define TUP_MVFR0_EL1 (3, 0, 0, 3, 0)
#define TUP_MVFR1_EL1 (3, 0, 0, 3, 1)
#define TUP_MVFR2_EL1 (3, 0, 0, 3, 2)
#define TUP_ID_AA64PFR0_EL1 (3, 0, 0, 4, 0)
#define TUP_ID_AA64PFR1_EL1 (3, 0, 0, 4, 1)
#define TUP_ID_AA64ZFR0_EL1 (3, 0, 0, 4, 4)
#define TUP_ID_AA64DFR0_EL1 (3, 0, 0, 5, 0)
#define TUP_ID_AA64DFR1_EL1 (3, 0, 0, 5, 1)
#define TUP_ID_AA64AFR0_EL1 (3, 0, 0, 5, 4)
#define TUP_ID_AA64AFR1_EL1 (3, 0, 0, 5, 5)
#define TUP_ID_AA64ISAR0_EL1 (3, 0, 0, 6, 0)
#define TUP_ID_AA64ISAR1_EL1 (3, 0, 0, 6, 1)
#define TUP_ID_AA64MMFR0_EL1 (3, 0, 0, 7, 0)
#define TUP_ID_AA64MMFR1_EL1 (3, 0, 0, 7, 1)
#define TUP_ID_AA64MMFR2_EL1 (3, 0, 0, 7, 2)
#define TUP_SCTLR_EL1 (3, 0, 1, 0, 0)
#define TUP_ACTLR_EL1 (3, 0, 1, 0, 1)
#define TUP_CPACR_EL1 (3, 0, 1, 0, 2)
#define TUP_ZCR_EL1 (3, 0, 1, 2, 0)
#define TUP_TTBR0_EL1 (3, 0, 2, 0, 0)
#define TUP_TTBR1_EL1 (3, 0, 2, 0, 1)
#define TUP_TCR_EL1 (3, 0, 2, 0, 2)
#define TUP_APIAKEYLO_EL1 (3, 0, 2, 1, 0)
#define TUP_APIAKEYHI_EL1 (3, 0, 2, 1, 1)
#define TUP_APIBKEYLO_EL1 (3, 0, 2, 1, 2)
#define TUP_APIBKEYHI_EL1 (3, 0, 2, 1, 3)
#define TUP_APDAKEYLO_EL1 (3, 0, 2, 2, 0)
#define TUP_APDAKEYHI_EL1 (3, 0, 2, 2, 1)
#define TUP_APDBKEYLO_EL1 (3, 0, 2, 2, 2)
#define TUP_APDBKEYHI_EL1 (3, 0, 2, 2, 3)
#define TUP_APGAKEYLO_EL1 (3, 0, 2, 3, 0)
#define TUP_APGAKEYHI_EL1 (3, 0, 2, 3, 1)
#define TUP_ICC_PMR_EL1 (3, 0, 4, 6, 0)
#define TUP_AFSR0_EL1 (3, 0, 5, 1, 0)
#define TUP_AFSR1_EL1 (3, 0, 5, 1, 1)
#define TUP_ESR_EL1 (3, 0, 5, 2, 0)
#define TUP_ERRIDR_EL1 (3, 0, 5, 3, 0)
#define TUP_ERRSELR_EL1 (3, 0, 5, 3, 1)
#define TUP_ERXFR_EL1 (3, 0, 5, 4, 0)
#define TUP_ERXCTLR_EL1 (3, 0, 5, 4, 1)
#define TUP_ERXSTATUS_EL1 (3, 0, 5, 4, 2)
#define TUP_ERXADDR_EL1 (3, 0, 5, 4, 3)
#define TUP_ERXMISC0_EL1 (3, 0, 5, 5, 0)
#define TUP_ERXMISC1_EL1 (3, 0, 5, 5, 1)
#define TUP_FAR_EL1 (3, 0, 6, 0, 0)
#define TUP_PAR_EL1 (3, 0, 7, 4, 0)
#define TUP_PMSIDR_EL1 (3, 0, 9, 9, 7)
#define TUP_PMBIDR_EL1 (3, 0, 9, 10, 7)
#define TUP_PMSCR_EL1 (3, 0, 9, 9, 0)
#define TUP_PMSCR_EL2 (3, 4, 9, 9, 0)
#define TUP_PMSICR_EL1 (3, 0, 9, 9, 2)
#define TUP_PMSIRR_EL1 (3, 0, 9, 9, 3)
#define TUP_PMSFCR_EL1 (3, 0, 9, 9, 4)
#define TUP_PMSEVFR_EL1 (3, 0, 9, 9, 5)
#define TUP_PMSLATFR_EL1 (3, 0, 9, 9, 6)
#define TUP_PMBLIMITR_EL1 (3, 0, 9, 10, 0)
#define TUP_PMBPTR_EL1 (3, 0, 9, 10, 1)
#define TUP_PMBSR_EL1 (3, 0, 9, 10, 3)
#define TUP_PMINTENSET_EL1 (3, 0, 9, 14, 1)
#define TUP_PMINTENCLR_EL1 (3, 0, 9, 14, 2)
#define TUP_MAIR_EL1 (3, 0, 10, 2, 0)
#define TUP_AMAIR_EL1 (3, 0, 10, 3, 0)
#define TUP_LORSA_EL1 (3, 0, 10, 4, 0)
#define TUP_LOREA_EL1 (3, 0, 10, 4, 1)
#define TUP_LORN_EL1 (3, 0, 10, 4, 2)
#define TUP_LORC_EL1 (3, 0, 10, 4, 3)
#define TUP_LORID_EL1 (3, 0, 10, 4, 7)
#define TUP_VBAR_EL1 (3, 0, 12, 0, 0)
#define TUP_DISR_EL1 (3, 0, 12, 1, 1)
#define TUP_ICC_IAR0_EL1 (3, 0, 12, 8, 0)
#define TUP_ICC_EOIR0_EL1 (3, 0, 12, 8, 1)
#define TUP_ICC_HPPIR0_EL1 (3, 0, 12, 8, 2)
#define TUP_ICC_BPR0_EL1 (3, 0, 12, 8, 3)
#define TUP_ICC_AP0Rn_EL1(n) (3, 0, 12, 8, 4 | n)
#define TUP_ICC_AP0R0_EL1 TUP_ICC_AP0Rn_EL1(0)
#define TUP_ICC_AP0R1_EL1 TUP_ICC_AP0Rn_EL1(1)
#define TUP_ICC_AP0R2_EL1 TUP_ICC_AP0Rn_EL1(2)
#define TUP_ICC_AP0R3_EL1 TUP_ICC_AP0Rn_EL1(3)
#define TUP_ICC_AP1Rn_EL1(n) (3, 0, 12, 9, n)
#define TUP_ICC_AP1R0_EL1 TUP_ICC_AP1Rn_EL1(0)
#define TUP_ICC_AP1R1_EL1 TUP_ICC_AP1Rn_EL1(1)
#define TUP_ICC_AP1R2_EL1 TUP_ICC_AP1Rn_EL1(2)
#define TUP_ICC_AP1R3_EL1 TUP_ICC_AP1Rn_EL1(3)
#define TUP_ICC_DIR_EL1 (3, 0, 12, 11, 1)
#define TUP_ICC_RPR_EL1 (3, 0, 12, 11, 3)
#define TUP_ICC_SGI1R_EL1 (3, 0, 12, 11, 5)
#define TUP_ICC_ASGI1R_EL1 (3, 0, 12, 11, 6)
#define TUP_ICC_SGI0R_EL1 (3, 0, 12, 11, 7)
#define TUP_ICC_IAR1_EL1 (3, 0, 12, 12, 0)
#define TUP_ICC_EOIR1_EL1 (3, 0, 12, 12, 1)
#define TUP_ICC_HPPIR1_EL1 (3, 0, 12, 12, 2)
#define TUP_ICC_BPR1_EL1 (3, 0, 12, 12, 3)
#define TUP_ICC_CTLR_EL1 (3, 0, 12, 12, 4)
#define TUP_ICC_SRE_EL1 (3, 0, 12, 12, 5)
#define TUP_ICC_IGRPEN0_EL1 (3, 0, 12, 12, 6)
#define TUP_ICC_IGRPEN1_EL1 (3, 0, 12, 12, 7)
#define TUP_CONTEXTIDR_EL1 (3, 0, 13, 0, 1)
#define TUP_TPIDR_EL1 (3, 0, 13, 0, 4)
#define TUP_CNTKCTL_EL1 (3, 0, 14, 1, 0)
#define TUP_CCSIDR_EL1 (3, 1, 0, 0, 0)
#define TUP_CLIDR_EL1 (3, 1, 0, 0, 1)
#define TUP_AIDR_EL1 (3, 1, 0, 0, 7)
#define TUP_CSSELR_EL1 (3, 2, 0, 0, 0)
#define TUP_CTR_EL0 (3, 3, 0, 0, 1)
#define TUP_DCZID_EL0 (3, 3, 0, 0, 7)
#define TUP_PMCR_EL0 (3, 3, 9, 12, 0)
#define TUP_PMCNTENSET_EL0 (3, 3, 9, 12, 1)
#define TUP_PMCNTENCLR_EL0 (3, 3, 9, 12, 2)
#define TUP_PMOVSCLR_EL0 (3, 3, 9, 12, 3)
#define TUP_PMSWINC_EL0 (3, 3, 9, 12, 4)
#define TUP_PMSELR_EL0 (3, 3, 9, 12, 5)
#define TUP_PMCEID0_EL0 (3, 3, 9, 12, 6)
#define TUP_PMCEID1_EL0 (3, 3, 9, 12, 7)
#define TUP_PMCCNTR_EL0 (3, 3, 9, 13, 0)
#define TUP_PMXEVTYPER_EL0 (3, 3, 9, 13, 1)
#define TUP_PMXEVCNTR_EL0 (3, 3, 9, 13, 2)
#define TUP_PMUSERENR_EL0 (3, 3, 9, 14, 0)
#define TUP_PMOVSSET_EL0 (3, 3, 9, 14, 3)
#define TUP_TPIDR_EL0 (3, 3, 13, 0, 2)
#define TUP_TPIDRRO_EL0 (3, 3, 13, 0, 3)
#define TUP_CNTFRQ_EL0 (3, 3, 14, 0, 0)
#define TUP_CNTP_TVAL_EL0 (3, 3, 14, 2, 0)
#define TUP_CNTP_CTL_EL0 (3, 3, 14, 2, 1)
#define TUP_CNTP_CVAL_EL0 (3, 3, 14, 2, 2)
#define TUP_AARCH32_CNTP_TVAL (0, 0, 14, 2, 0)
#define TUP_AARCH32_CNTP_CTL (0, 0, 14, 2, 1)
#define TUP_AARCH32_CNTP_CVAL (0, 2, 0, 14, 0)
#define __field_PMEV_op2(n) ((n) & 0x7)
#define __field__CNTR_CRm(n) (0x8 | (((n) >> 3) & 0x3))
#define __field__TYPER_CRm(n) (0xC | (((n) >> 3) & 0x3))
#define TUP_PMEVCNTRn_EL0(n) (3, 3, 14, __field_CNTR_CRm(n), __field_PMEV_op2(n))
#define TUP_PMEVTYPERn_EL0(n) (3, 3, 14, __field_TYPER_CRm(n), __field_PMEV_op2(n))
#define TUP_PMCCFILTR_EL0 (3, 3, 14, 15, 7)
#define TUP_ZCR_EL2 (3, 4, 1, 2, 0)
#define TUP_DACR32_EL2 (3, 4, 3, 0, 0)
#define TUP_IFSR32_EL2 (3, 4, 5, 0, 1)
#define TUP_VSESR_EL2 (3, 4, 5, 2, 3)
#define TUP_FPEXC32_EL2 (3, 4, 5, 3, 0)
#define TUP_VDISR_EL2 (3, 4, 12, 1, 1)
#define TUP_ICH_AP0Rn_EL2(n) (3, 4, 12, 8, n)
#define TUP_ICH_AP0R0_EL2 TUP_ICH_AP0Rn_EL2(0)
#define TUP_ICH_AP0R1_EL2 TUP_ICH_AP0Rn_EL2(1)
#define TUP_ICH_AP0R2_EL2 TUP_ICH_AP0Rn_EL2(2)
#define TUP_ICH_AP0R3_EL2 TUP_ICH_AP0Rn_EL2(3)
#define TUP_AP1Rx_EL2(n) (3, 4, 12, 9, n)
#define TUP_ICH_AP1R0_EL2 TUP_ICH_AP1Rn_EL2(0)
#define TUP_ICH_AP1R1_EL2 TUP_ICH_AP1Rn_EL2(1)
#define TUP_ICH_AP1R2_EL2 TUP_ICH_AP1Rn_EL2(2)
#define TUP_ICH_AP1R3_EL2 TUP_ICH_AP1Rn_EL2(3)
#define TUP_ICH_VSEIR_EL2 (3, 4, 12, 9, 4)
#define TUP_ICC_SRE_EL2 (3, 4, 12, 9, 5)
#define TUP_ICH_HCR_EL2 (3, 4, 12, 11, 0)
#define TUP_ICH_VTR_EL2 (3, 4, 12, 11, 1)
#define TUP_ICH_MISR_EL2 (3, 4, 12, 11, 2)
#define TUP_ICH_EISR_EL2 (3, 4, 12, 11, 3)
#define TUP_ICH_ELRSR_EL2 (3, 4, 12, 11, 5)
#define TUP_ICH_VMCR_EL2 (3, 4, 12, 11, 7)
#define TUP_ICH_LRn_EL2(n) (3, 4, 12, 12 + (n)/8, n)
#define TUP_ICH_LR0_EL2 TUP_ICH_LRn_EL2(0)
#define TUP_ICH_LR1_EL2 TUP_ICH_LRn_EL2(1)
#define TUP_ICH_LR2_EL2 TUP_ICH_LRn_EL2(2)
#define TUP_ICH_LR3_EL2 TUP_ICH_LRn_EL2(3)
#define TUP_ICH_LR4_EL2 TUP_ICH_LRn_EL2(4)
#define TUP_ICH_LR5_EL2 TUP_ICH_LRn_EL2(5)
#define TUP_ICH_LR6_EL2 TUP_ICH_LRn_EL2(6)
#define TUP_ICH_LR7_EL2 TUP_ICH_LRn_EL2(7)
#define TUP_ICH_LR8_EL2 TUP_ICH_LRn_EL2(8)
#define TUP_ICH_LR9_EL2 TUP_ICH_LRn_EL2(9)
#define TUP_ICH_LR10_EL2 TUP_ICH_LRn_EL2(10)
#define TUP_ICH_LR11_EL2 TUP_ICH_LRn_EL2(11)
#define TUP_ICH_LR12_EL2 TUP_ICH_LRn_EL2(12)
#define TUP_ICH_LR13_EL2 TUP_ICH_LRn_EL2(13)
#define TUP_ICH_LR14_EL2 TUP_ICH_LRn_EL2(14)
#define TUP_ICH_LR15_EL2 TUP_ICH_LRn_EL2(15)
#define TUP_ZCR_EL12 (3, 5, 1, 2, 0)
#define SCTLR_ELx_DSSBS __BITL(44)
#define SCTLR_ELx_ENIA __BITL(31)
#define SCTLR_ELx_ENIB __BITL(30)
#define SCTLR_ELx_ENDA __BITL(27)
#define SCTLR_ELx_EE __BITL(25)
#define SCTLR_ELx_IESB __BITL(21)
#define SCTLR_ELx_WXN __BITL(19)
#define SCTLR_ELx_ENDB __BITL(13)
#define SCTLR_ELx_I __BITL(12)
#define SCTLR_ELx_SA __BITL(3)
#define SCTLR_ELx_C __BITL(2)
#define SCTLR_ELx_A __BITL(1)
#define SCTLR_ELx_M __BITL(0)
#define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | SCTLR_ELx_SA | SCTLR_ELx_I | SCTLR_ELx_IESB)
#define SCTLR_EL2_RES1 (__BITL(4) | __BITL(5) | __BITL(11) | __BITL(16) | \
__BITL(18) | __BITL(22) | __BITL(23) | __BITL(28) | \
__BITL(29))
#define SCTLR_EL2_RES0 (__BITL(6) | __BITL(7) | __BITL(8) | __BITL(9) | \
__BITL(10) | __BITL(13) | __BITL(14) | __BITL(15) | \
__BITL(17) | __BITL(20) | __BITL(24) | __BITL(26) | \
__BITL(27) | __BITL(30) | __BITL(31) | \
(0xFFFFEFFFull << 32))
#define SCTLR_EL1_UCI __BITL(26)
#define SCTLR_EL1_E0E __BITL(24)
#define SCTLR_EL1_SPAN __BITL(23)
#define SCTLR_EL1_NTWE __BITL(18)
#define SCTLR_EL1_NTWI __BITL(16)
#define SCTLR_EL1_UCT __BITL(15)
#define SCTLR_EL1_DZE __BITL(14)
#define SCTLR_EL1_UMA __BITL(9)
#define SCTLR_EL1_SED __BITL(8)
#define SCTLR_EL1_ITD __BITL(7)
#define SCTLR_EL1_CP15BEN __BITL(5)
#define SCTLR_EL1_SA0 __BITL(4)
#define SCTLR_EL1_RES1 (__BITL(11) | __BITL(20) | __BITL(22) | __BITL(28) | __BITL(29))
#define SCTLR_EL1_RES0 (__BITL(6) | __BITL(10) | __BITL(13) | __BITL(17) | __BITL(27) | __BITL(30) | __BITL(31) | (0xFFFFEFFFull << 32))
#undef __BITL
#define ENCODE_SYSREG_FIELDS_MOV(op0, op1, crn, crm, op2) (((op0) << 19) | ((op1) << 16) | ((crn) << 12) | ((crm) << 8) | ((op2) << 5))
#define ENCODE_SYSREG_MOV(name) EVAL(ENCODE_SYSREG_FIELDS_MOV CAT(TUP_, name))
#define MAKE_MSR(name, Rt) (0xD5000000 | ENCODE_SYSREG_MOV(name) | ((Rt) & 0x1F))
#define MAKE_MRS(name, Rt) (0xD5200000 | ENCODE_SYSREG_MOV(name) | ((Rt) & 0x1F))
#define ENCODE_SYSREG_FIELDS_ISS(op0, op1, crn, crm, op2) (((op0) << 20) | ((op2) << 17) | ((op1) << 14) | ((crn) << 10) | ((crm) << 1))
#define ENCODE_SYSREG_ISS(name) EVAL(ENCODE_SYSREG_FIELDS_ISS CAT(TUP_, name))