18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2013 - ARM Ltd 48c2ecf20Sopenharmony_ci * Author: Marc Zyngier <marc.zyngier@arm.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef __ASM_ESR_H 88c2ecf20Sopenharmony_ci#define __ASM_ESR_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <asm/memory.h> 118c2ecf20Sopenharmony_ci#include <asm/sysreg.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define ESR_ELx_EC_UNKNOWN (0x00) 148c2ecf20Sopenharmony_ci#define ESR_ELx_EC_WFx (0x01) 158c2ecf20Sopenharmony_ci/* Unallocated EC: 0x02 */ 168c2ecf20Sopenharmony_ci#define ESR_ELx_EC_CP15_32 (0x03) 178c2ecf20Sopenharmony_ci#define ESR_ELx_EC_CP15_64 (0x04) 188c2ecf20Sopenharmony_ci#define ESR_ELx_EC_CP14_MR (0x05) 198c2ecf20Sopenharmony_ci#define ESR_ELx_EC_CP14_LS (0x06) 208c2ecf20Sopenharmony_ci#define ESR_ELx_EC_FP_ASIMD (0x07) 218c2ecf20Sopenharmony_ci#define ESR_ELx_EC_CP10_ID (0x08) /* EL2 only */ 228c2ecf20Sopenharmony_ci#define ESR_ELx_EC_PAC (0x09) /* EL2 and above */ 238c2ecf20Sopenharmony_ci/* Unallocated EC: 0x0A - 0x0B */ 248c2ecf20Sopenharmony_ci#define ESR_ELx_EC_CP14_64 (0x0C) 258c2ecf20Sopenharmony_ci#define ESR_ELx_EC_BTI (0x0D) 268c2ecf20Sopenharmony_ci#define ESR_ELx_EC_ILL (0x0E) 278c2ecf20Sopenharmony_ci/* Unallocated EC: 0x0F - 0x10 */ 288c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SVC32 (0x11) 298c2ecf20Sopenharmony_ci#define ESR_ELx_EC_HVC32 (0x12) /* EL2 only */ 308c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SMC32 (0x13) /* EL2 and above */ 318c2ecf20Sopenharmony_ci/* Unallocated EC: 0x14 */ 328c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SVC64 (0x15) 338c2ecf20Sopenharmony_ci#define ESR_ELx_EC_HVC64 (0x16) /* EL2 and above */ 348c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SMC64 (0x17) /* EL2 and above */ 358c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SYS64 (0x18) 368c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SVE (0x19) 378c2ecf20Sopenharmony_ci#define ESR_ELx_EC_ERET (0x1a) /* EL2 only */ 388c2ecf20Sopenharmony_ci/* Unallocated EC: 0x1B */ 398c2ecf20Sopenharmony_ci#define ESR_ELx_EC_FPAC (0x1C) /* EL1 and above */ 408c2ecf20Sopenharmony_ci/* Unallocated EC: 0x1D - 0x1E */ 418c2ecf20Sopenharmony_ci#define ESR_ELx_EC_IMP_DEF (0x1f) /* EL3 only */ 428c2ecf20Sopenharmony_ci#define ESR_ELx_EC_IABT_LOW (0x20) 438c2ecf20Sopenharmony_ci#define ESR_ELx_EC_IABT_CUR (0x21) 448c2ecf20Sopenharmony_ci#define ESR_ELx_EC_PC_ALIGN (0x22) 458c2ecf20Sopenharmony_ci/* Unallocated EC: 0x23 */ 468c2ecf20Sopenharmony_ci#define ESR_ELx_EC_DABT_LOW (0x24) 478c2ecf20Sopenharmony_ci#define ESR_ELx_EC_DABT_CUR (0x25) 488c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SP_ALIGN (0x26) 498c2ecf20Sopenharmony_ci/* Unallocated EC: 0x27 */ 508c2ecf20Sopenharmony_ci#define ESR_ELx_EC_FP_EXC32 (0x28) 518c2ecf20Sopenharmony_ci/* Unallocated EC: 0x29 - 0x2B */ 528c2ecf20Sopenharmony_ci#define ESR_ELx_EC_FP_EXC64 (0x2C) 538c2ecf20Sopenharmony_ci/* Unallocated EC: 0x2D - 0x2E */ 548c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SERROR (0x2F) 558c2ecf20Sopenharmony_ci#define ESR_ELx_EC_BREAKPT_LOW (0x30) 568c2ecf20Sopenharmony_ci#define ESR_ELx_EC_BREAKPT_CUR (0x31) 578c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SOFTSTP_LOW (0x32) 588c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SOFTSTP_CUR (0x33) 598c2ecf20Sopenharmony_ci#define ESR_ELx_EC_WATCHPT_LOW (0x34) 608c2ecf20Sopenharmony_ci#define ESR_ELx_EC_WATCHPT_CUR (0x35) 618c2ecf20Sopenharmony_ci/* Unallocated EC: 0x36 - 0x37 */ 628c2ecf20Sopenharmony_ci#define ESR_ELx_EC_BKPT32 (0x38) 638c2ecf20Sopenharmony_ci/* Unallocated EC: 0x39 */ 648c2ecf20Sopenharmony_ci#define ESR_ELx_EC_VECTOR32 (0x3A) /* EL2 only */ 658c2ecf20Sopenharmony_ci/* Unallocated EC: 0x3B */ 668c2ecf20Sopenharmony_ci#define ESR_ELx_EC_BRK64 (0x3C) 678c2ecf20Sopenharmony_ci/* Unallocated EC: 0x3D - 0x3F */ 688c2ecf20Sopenharmony_ci#define ESR_ELx_EC_MAX (0x3F) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define ESR_ELx_EC_SHIFT (26) 718c2ecf20Sopenharmony_ci#define ESR_ELx_EC_WIDTH (6) 728c2ecf20Sopenharmony_ci#define ESR_ELx_EC_MASK (UL(0x3F) << ESR_ELx_EC_SHIFT) 738c2ecf20Sopenharmony_ci#define ESR_ELx_EC(esr) (((esr) & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define ESR_ELx_IL_SHIFT (25) 768c2ecf20Sopenharmony_ci#define ESR_ELx_IL (UL(1) << ESR_ELx_IL_SHIFT) 778c2ecf20Sopenharmony_ci#define ESR_ELx_ISS_MASK (ESR_ELx_IL - 1) 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* ISS field definitions shared by different classes */ 808c2ecf20Sopenharmony_ci#define ESR_ELx_WNR_SHIFT (6) 818c2ecf20Sopenharmony_ci#define ESR_ELx_WNR (UL(1) << ESR_ELx_WNR_SHIFT) 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* Asynchronous Error Type */ 848c2ecf20Sopenharmony_ci#define ESR_ELx_IDS_SHIFT (24) 858c2ecf20Sopenharmony_ci#define ESR_ELx_IDS (UL(1) << ESR_ELx_IDS_SHIFT) 868c2ecf20Sopenharmony_ci#define ESR_ELx_AET_SHIFT (10) 878c2ecf20Sopenharmony_ci#define ESR_ELx_AET (UL(0x7) << ESR_ELx_AET_SHIFT) 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define ESR_ELx_AET_UC (UL(0) << ESR_ELx_AET_SHIFT) 908c2ecf20Sopenharmony_ci#define ESR_ELx_AET_UEU (UL(1) << ESR_ELx_AET_SHIFT) 918c2ecf20Sopenharmony_ci#define ESR_ELx_AET_UEO (UL(2) << ESR_ELx_AET_SHIFT) 928c2ecf20Sopenharmony_ci#define ESR_ELx_AET_UER (UL(3) << ESR_ELx_AET_SHIFT) 938c2ecf20Sopenharmony_ci#define ESR_ELx_AET_CE (UL(6) << ESR_ELx_AET_SHIFT) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* Shared ISS field definitions for Data/Instruction aborts */ 968c2ecf20Sopenharmony_ci#define ESR_ELx_SET_SHIFT (11) 978c2ecf20Sopenharmony_ci#define ESR_ELx_SET_MASK (UL(3) << ESR_ELx_SET_SHIFT) 988c2ecf20Sopenharmony_ci#define ESR_ELx_FnV_SHIFT (10) 998c2ecf20Sopenharmony_ci#define ESR_ELx_FnV (UL(1) << ESR_ELx_FnV_SHIFT) 1008c2ecf20Sopenharmony_ci#define ESR_ELx_EA_SHIFT (9) 1018c2ecf20Sopenharmony_ci#define ESR_ELx_EA (UL(1) << ESR_ELx_EA_SHIFT) 1028c2ecf20Sopenharmony_ci#define ESR_ELx_S1PTW_SHIFT (7) 1038c2ecf20Sopenharmony_ci#define ESR_ELx_S1PTW (UL(1) << ESR_ELx_S1PTW_SHIFT) 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci/* Shared ISS fault status code(IFSC/DFSC) for Data/Instruction aborts */ 1068c2ecf20Sopenharmony_ci#define ESR_ELx_FSC (0x3F) 1078c2ecf20Sopenharmony_ci#define ESR_ELx_FSC_TYPE (0x3C) 1088c2ecf20Sopenharmony_ci#define ESR_ELx_FSC_LEVEL (0x03) 1098c2ecf20Sopenharmony_ci#define ESR_ELx_FSC_EXTABT (0x10) 1108c2ecf20Sopenharmony_ci#define ESR_ELx_FSC_SERROR (0x11) 1118c2ecf20Sopenharmony_ci#define ESR_ELx_FSC_ACCESS (0x08) 1128c2ecf20Sopenharmony_ci#define ESR_ELx_FSC_FAULT (0x04) 1138c2ecf20Sopenharmony_ci#define ESR_ELx_FSC_PERM (0x0C) 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* ISS field definitions for Data Aborts */ 1168c2ecf20Sopenharmony_ci#define ESR_ELx_ISV_SHIFT (24) 1178c2ecf20Sopenharmony_ci#define ESR_ELx_ISV (UL(1) << ESR_ELx_ISV_SHIFT) 1188c2ecf20Sopenharmony_ci#define ESR_ELx_SAS_SHIFT (22) 1198c2ecf20Sopenharmony_ci#define ESR_ELx_SAS (UL(3) << ESR_ELx_SAS_SHIFT) 1208c2ecf20Sopenharmony_ci#define ESR_ELx_SSE_SHIFT (21) 1218c2ecf20Sopenharmony_ci#define ESR_ELx_SSE (UL(1) << ESR_ELx_SSE_SHIFT) 1228c2ecf20Sopenharmony_ci#define ESR_ELx_SRT_SHIFT (16) 1238c2ecf20Sopenharmony_ci#define ESR_ELx_SRT_MASK (UL(0x1F) << ESR_ELx_SRT_SHIFT) 1248c2ecf20Sopenharmony_ci#define ESR_ELx_SF_SHIFT (15) 1258c2ecf20Sopenharmony_ci#define ESR_ELx_SF (UL(1) << ESR_ELx_SF_SHIFT) 1268c2ecf20Sopenharmony_ci#define ESR_ELx_AR_SHIFT (14) 1278c2ecf20Sopenharmony_ci#define ESR_ELx_AR (UL(1) << ESR_ELx_AR_SHIFT) 1288c2ecf20Sopenharmony_ci#define ESR_ELx_CM_SHIFT (8) 1298c2ecf20Sopenharmony_ci#define ESR_ELx_CM (UL(1) << ESR_ELx_CM_SHIFT) 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci/* ISS field definitions for exceptions taken in to Hyp */ 1328c2ecf20Sopenharmony_ci#define ESR_ELx_CV (UL(1) << 24) 1338c2ecf20Sopenharmony_ci#define ESR_ELx_COND_SHIFT (20) 1348c2ecf20Sopenharmony_ci#define ESR_ELx_COND_MASK (UL(0xF) << ESR_ELx_COND_SHIFT) 1358c2ecf20Sopenharmony_ci#define ESR_ELx_WFx_ISS_TI (UL(1) << 0) 1368c2ecf20Sopenharmony_ci#define ESR_ELx_WFx_ISS_WFI (UL(0) << 0) 1378c2ecf20Sopenharmony_ci#define ESR_ELx_WFx_ISS_WFE (UL(1) << 0) 1388c2ecf20Sopenharmony_ci#define ESR_ELx_xVC_IMM_MASK ((1UL << 16) - 1) 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define DISR_EL1_IDS (UL(1) << 24) 1418c2ecf20Sopenharmony_ci/* 1428c2ecf20Sopenharmony_ci * DISR_EL1 and ESR_ELx share the bottom 13 bits, but the RES0 bits may mean 1438c2ecf20Sopenharmony_ci * different things in the future... 1448c2ecf20Sopenharmony_ci */ 1458c2ecf20Sopenharmony_ci#define DISR_EL1_ESR_MASK (ESR_ELx_AET | ESR_ELx_EA | ESR_ELx_FSC) 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci/* ESR value templates for specific events */ 1488c2ecf20Sopenharmony_ci#define ESR_ELx_WFx_MASK (ESR_ELx_EC_MASK | ESR_ELx_WFx_ISS_TI) 1498c2ecf20Sopenharmony_ci#define ESR_ELx_WFx_WFI_VAL ((ESR_ELx_EC_WFx << ESR_ELx_EC_SHIFT) | \ 1508c2ecf20Sopenharmony_ci ESR_ELx_WFx_ISS_WFI) 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci/* BRK instruction trap from AArch64 state */ 1538c2ecf20Sopenharmony_ci#define ESR_ELx_BRK64_ISS_COMMENT_MASK 0xffff 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci/* ISS field definitions for System instruction traps */ 1568c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RES0_SHIFT 22 1578c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RES0_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_RES0_SHIFT) 1588c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_DIR_MASK 0x1 1598c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_DIR_READ 0x1 1608c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_DIR_WRITE 0x0 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RT_SHIFT 5 1638c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_SYS64_ISS_RT_SHIFT) 1648c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_SHIFT 1 1658c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRM_SHIFT) 1668c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRN_SHIFT 10 1678c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRN_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRN_SHIFT) 1688c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP1_SHIFT 14 1698c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP1_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP1_SHIFT) 1708c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP2_SHIFT 17 1718c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP2_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP2_SHIFT) 1728c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP0_SHIFT 20 1738c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_OP0_MASK (UL(0x3) << ESR_ELx_SYS64_ISS_OP0_SHIFT) 1748c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ 1758c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_MASK | \ 1768c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP2_MASK | \ 1778c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_MASK | \ 1788c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_CRM_MASK) 1798c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_VAL(op0, op1, op2, crn, crm) \ 1808c2ecf20Sopenharmony_ci (((op0) << ESR_ELx_SYS64_ISS_OP0_SHIFT) | \ 1818c2ecf20Sopenharmony_ci ((op1) << ESR_ELx_SYS64_ISS_OP1_SHIFT) | \ 1828c2ecf20Sopenharmony_ci ((op2) << ESR_ELx_SYS64_ISS_OP2_SHIFT) | \ 1838c2ecf20Sopenharmony_ci ((crn) << ESR_ELx_SYS64_ISS_CRN_SHIFT) | \ 1848c2ecf20Sopenharmony_ci ((crm) << ESR_ELx_SYS64_ISS_CRM_SHIFT)) 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_OP_MASK (ESR_ELx_SYS64_ISS_SYS_MASK | \ 1878c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_MASK) 1888c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_RT(esr) \ 1898c2ecf20Sopenharmony_ci (((esr) & ESR_ELx_SYS64_ISS_RT_MASK) >> ESR_ELx_SYS64_ISS_RT_SHIFT) 1908c2ecf20Sopenharmony_ci/* 1918c2ecf20Sopenharmony_ci * User space cache operations have the following sysreg encoding 1928c2ecf20Sopenharmony_ci * in System instructions. 1938c2ecf20Sopenharmony_ci * op0=1, op1=3, op2=1, crn=7, crm={ 5, 10, 11, 12, 13, 14 }, WRITE (L=0) 1948c2ecf20Sopenharmony_ci */ 1958c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CIVAC 14 1968c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CVADP 13 1978c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CVAP 12 1988c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CVAU 11 1998c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_DC_CVAC 10 2008c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_CRM_IC_IVAU 5 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ 2038c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_MASK | \ 2048c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP2_MASK | \ 2058c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_MASK | \ 2068c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_MASK) 2078c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_VAL \ 2088c2ecf20Sopenharmony_ci (ESR_ELx_SYS64_ISS_SYS_VAL(1, 3, 1, 7, 0) | \ 2098c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_WRITE) 2108c2ecf20Sopenharmony_ci/* 2118c2ecf20Sopenharmony_ci * User space MRS operations which are supported for emulation 2128c2ecf20Sopenharmony_ci * have the following sysreg encoding in System instructions. 2138c2ecf20Sopenharmony_ci * op0 = 3, op1= 0, crn = 0, {crm = 0, 4-7}, READ (L = 1) 2148c2ecf20Sopenharmony_ci */ 2158c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ 2168c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_MASK | \ 2178c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_MASK | \ 2188c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_MASK) 2198c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_VAL \ 2208c2ecf20Sopenharmony_ci (ESR_ELx_SYS64_ISS_SYS_VAL(3, 0, 0, 0, 0) | \ 2218c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_READ) 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_CTR ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 1, 0, 0) 2248c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_CTR_READ (ESR_ELx_SYS64_ISS_SYS_CTR | \ 2258c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_READ) 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_CNTVCT (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 2, 14, 0) | \ 2288c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_READ) 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci#define ESR_ELx_SYS64_ISS_SYS_CNTFRQ (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 0, 14, 0) | \ 2318c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_DIR_READ) 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci#define esr_sys64_to_sysreg(e) \ 2348c2ecf20Sopenharmony_ci sys_reg((((e) & ESR_ELx_SYS64_ISS_OP0_MASK) >> \ 2358c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP0_SHIFT), \ 2368c2ecf20Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ 2378c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_SHIFT), \ 2388c2ecf20Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ 2398c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_SHIFT), \ 2408c2ecf20Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ 2418c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_CRM_SHIFT), \ 2428c2ecf20Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ 2438c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP2_SHIFT)) 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci#define esr_cp15_to_sysreg(e) \ 2468c2ecf20Sopenharmony_ci sys_reg(3, \ 2478c2ecf20Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ 2488c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP1_SHIFT), \ 2498c2ecf20Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ 2508c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_CRN_SHIFT), \ 2518c2ecf20Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ 2528c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_CRM_SHIFT), \ 2538c2ecf20Sopenharmony_ci (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ 2548c2ecf20Sopenharmony_ci ESR_ELx_SYS64_ISS_OP2_SHIFT)) 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci/* 2578c2ecf20Sopenharmony_ci * ISS field definitions for floating-point exception traps 2588c2ecf20Sopenharmony_ci * (FP_EXC_32/FP_EXC_64). 2598c2ecf20Sopenharmony_ci * 2608c2ecf20Sopenharmony_ci * (The FPEXC_* constants are used instead for common bits.) 2618c2ecf20Sopenharmony_ci */ 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci#define ESR_ELx_FP_EXC_TFV (UL(1) << 23) 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci/* 2668c2ecf20Sopenharmony_ci * ISS field definitions for CP15 accesses 2678c2ecf20Sopenharmony_ci */ 2688c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_DIR_MASK 0x1 2698c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_DIR_READ 0x1 2708c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_DIR_WRITE 0x0 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_RT_SHIFT 5 2738c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_32_ISS_RT_SHIFT) 2748c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_CRM_SHIFT 1 2758c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRM_SHIFT) 2768c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_CRN_SHIFT 10 2778c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_CRN_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) 2788c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_OP1_SHIFT 14 2798c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_OP1_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) 2808c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_OP2_SHIFT 17 2818c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_OP2_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_SYS_MASK (ESR_ELx_CP15_32_ISS_OP1_MASK | \ 2848c2ecf20Sopenharmony_ci ESR_ELx_CP15_32_ISS_OP2_MASK | \ 2858c2ecf20Sopenharmony_ci ESR_ELx_CP15_32_ISS_CRN_MASK | \ 2868c2ecf20Sopenharmony_ci ESR_ELx_CP15_32_ISS_CRM_MASK | \ 2878c2ecf20Sopenharmony_ci ESR_ELx_CP15_32_ISS_DIR_MASK) 2888c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_SYS_VAL(op1, op2, crn, crm) \ 2898c2ecf20Sopenharmony_ci (((op1) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) | \ 2908c2ecf20Sopenharmony_ci ((op2) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) | \ 2918c2ecf20Sopenharmony_ci ((crn) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) | \ 2928c2ecf20Sopenharmony_ci ((crm) << ESR_ELx_CP15_32_ISS_CRM_SHIFT)) 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_DIR_MASK 0x1 2958c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_DIR_READ 0x1 2968c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_DIR_WRITE 0x0 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_RT_SHIFT 5 2998c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT_SHIFT) 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_RT2_SHIFT 10 3028c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_RT2_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT2_SHIFT) 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_OP1_SHIFT 16 3058c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_OP1_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) 3068c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_CRM_SHIFT 1 3078c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_CRM_SHIFT) 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_SYS_VAL(op1, crm) \ 3108c2ecf20Sopenharmony_ci (((op1) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) | \ 3118c2ecf20Sopenharmony_ci ((crm) << ESR_ELx_CP15_64_ISS_CRM_SHIFT)) 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_SYS_MASK (ESR_ELx_CP15_64_ISS_OP1_MASK | \ 3148c2ecf20Sopenharmony_ci ESR_ELx_CP15_64_ISS_CRM_MASK | \ 3158c2ecf20Sopenharmony_ci ESR_ELx_CP15_64_ISS_DIR_MASK) 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_64_ISS_SYS_CNTVCT (ESR_ELx_CP15_64_ISS_SYS_VAL(1, 14) | \ 3188c2ecf20Sopenharmony_ci ESR_ELx_CP15_64_ISS_DIR_READ) 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci#define ESR_ELx_CP15_32_ISS_SYS_CNTFRQ (ESR_ELx_CP15_32_ISS_SYS_VAL(0, 0, 14, 0) |\ 3218c2ecf20Sopenharmony_ci ESR_ELx_CP15_32_ISS_DIR_READ) 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 3248c2ecf20Sopenharmony_ci#include <asm/types.h> 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_cistatic inline bool esr_is_data_abort(u32 esr) 3278c2ecf20Sopenharmony_ci{ 3288c2ecf20Sopenharmony_ci const u32 ec = ESR_ELx_EC(esr); 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci return ec == ESR_ELx_EC_DABT_LOW || ec == ESR_ELx_EC_DABT_CUR; 3318c2ecf20Sopenharmony_ci} 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ciconst char *esr_get_class_string(u32 esr); 3348c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY */ 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci#endif /* __ASM_ESR_H */ 337