1819833afSPeter Tyser /* 2819833afSPeter Tyser * linux/include/asm-arm/proc-armv/ptrace.h 3819833afSPeter Tyser * 4819833afSPeter Tyser * Copyright (C) 1996-1999 Russell King 5819833afSPeter Tyser * 6819833afSPeter Tyser * This program is free software; you can redistribute it and/or modify 7819833afSPeter Tyser * it under the terms of the GNU General Public License version 2 as 8819833afSPeter Tyser * published by the Free Software Foundation. 9819833afSPeter Tyser */ 10819833afSPeter Tyser #ifndef __ASM_PROC_PTRACE_H 11819833afSPeter Tyser #define __ASM_PROC_PTRACE_H 12819833afSPeter Tyser 130ae76531SDavid Feng #ifdef CONFIG_ARM64 140ae76531SDavid Feng 150ae76531SDavid Feng #define PCMASK 0 160ae76531SDavid Feng 170ae76531SDavid Feng #ifndef __ASSEMBLY__ 180ae76531SDavid Feng 190ae76531SDavid Feng /* 200ae76531SDavid Feng * This struct defines the way the registers are stored 210ae76531SDavid Feng * on the stack during an exception. 220ae76531SDavid Feng */ 230ae76531SDavid Feng struct pt_regs { 240ae76531SDavid Feng unsigned long elr; 250ae76531SDavid Feng unsigned long regs[31]; 260ae76531SDavid Feng }; 270ae76531SDavid Feng 280ae76531SDavid Feng #endif /* __ASSEMBLY__ */ 290ae76531SDavid Feng 300ae76531SDavid Feng #else /* CONFIG_ARM64 */ 310ae76531SDavid Feng 32819833afSPeter Tyser #define USR26_MODE 0x00 33819833afSPeter Tyser #define FIQ26_MODE 0x01 34819833afSPeter Tyser #define IRQ26_MODE 0x02 35819833afSPeter Tyser #define SVC26_MODE 0x03 36819833afSPeter Tyser #define USR_MODE 0x10 37819833afSPeter Tyser #define FIQ_MODE 0x11 38819833afSPeter Tyser #define IRQ_MODE 0x12 39819833afSPeter Tyser #define SVC_MODE 0x13 40*3e3b2b47SStephen Warren #define MON_MODE 0x16 41819833afSPeter Tyser #define ABT_MODE 0x17 42b726d22dSMarc Zyngier #define HYP_MODE 0x1a 43819833afSPeter Tyser #define UND_MODE 0x1b 44819833afSPeter Tyser #define SYSTEM_MODE 0x1f 45819833afSPeter Tyser #define MODE_MASK 0x1f 46819833afSPeter Tyser #define T_BIT 0x20 47819833afSPeter Tyser #define F_BIT 0x40 48819833afSPeter Tyser #define I_BIT 0x80 49b726d22dSMarc Zyngier #define A_BIT 0x100 50819833afSPeter Tyser #define CC_V_BIT (1 << 28) 51819833afSPeter Tyser #define CC_C_BIT (1 << 29) 52819833afSPeter Tyser #define CC_Z_BIT (1 << 30) 53819833afSPeter Tyser #define CC_N_BIT (1 << 31) 54819833afSPeter Tyser #define PCMASK 0 55819833afSPeter Tyser 56819833afSPeter Tyser #ifndef __ASSEMBLY__ 57819833afSPeter Tyser 58819833afSPeter Tyser /* this struct defines the way the registers are stored on the 59819833afSPeter Tyser stack during a system call. */ 60819833afSPeter Tyser 61819833afSPeter Tyser struct pt_regs { 62819833afSPeter Tyser long uregs[18]; 63819833afSPeter Tyser }; 64819833afSPeter Tyser 65819833afSPeter Tyser #define ARM_cpsr uregs[16] 66819833afSPeter Tyser #define ARM_pc uregs[15] 67819833afSPeter Tyser #define ARM_lr uregs[14] 68819833afSPeter Tyser #define ARM_sp uregs[13] 69819833afSPeter Tyser #define ARM_ip uregs[12] 70819833afSPeter Tyser #define ARM_fp uregs[11] 71819833afSPeter Tyser #define ARM_r10 uregs[10] 72819833afSPeter Tyser #define ARM_r9 uregs[9] 73819833afSPeter Tyser #define ARM_r8 uregs[8] 74819833afSPeter Tyser #define ARM_r7 uregs[7] 75819833afSPeter Tyser #define ARM_r6 uregs[6] 76819833afSPeter Tyser #define ARM_r5 uregs[5] 77819833afSPeter Tyser #define ARM_r4 uregs[4] 78819833afSPeter Tyser #define ARM_r3 uregs[3] 79819833afSPeter Tyser #define ARM_r2 uregs[2] 80819833afSPeter Tyser #define ARM_r1 uregs[1] 81819833afSPeter Tyser #define ARM_r0 uregs[0] 82819833afSPeter Tyser #define ARM_ORIG_r0 uregs[17] 83819833afSPeter Tyser 84819833afSPeter Tyser #ifdef __KERNEL__ 85819833afSPeter Tyser 86819833afSPeter Tyser #define user_mode(regs) \ 87819833afSPeter Tyser (((regs)->ARM_cpsr & 0xf) == 0) 88819833afSPeter Tyser 89819833afSPeter Tyser #ifdef CONFIG_ARM_THUMB 90819833afSPeter Tyser #define thumb_mode(regs) \ 91819833afSPeter Tyser (((regs)->ARM_cpsr & T_BIT)) 92819833afSPeter Tyser #else 93819833afSPeter Tyser #define thumb_mode(regs) (0) 94819833afSPeter Tyser #endif 95819833afSPeter Tyser 96819833afSPeter Tyser #define processor_mode(regs) \ 97819833afSPeter Tyser ((regs)->ARM_cpsr & MODE_MASK) 98819833afSPeter Tyser 99819833afSPeter Tyser #define interrupts_enabled(regs) \ 100819833afSPeter Tyser (!((regs)->ARM_cpsr & I_BIT)) 101819833afSPeter Tyser 102819833afSPeter Tyser #define fast_interrupts_enabled(regs) \ 103819833afSPeter Tyser (!((regs)->ARM_cpsr & F_BIT)) 104819833afSPeter Tyser 105819833afSPeter Tyser #define condition_codes(regs) \ 106819833afSPeter Tyser ((regs)->ARM_cpsr & (CC_V_BIT|CC_C_BIT|CC_Z_BIT|CC_N_BIT)) 107819833afSPeter Tyser 108819833afSPeter Tyser /* Are the current registers suitable for user mode? 109819833afSPeter Tyser * (used to maintain security in signal handlers) 110819833afSPeter Tyser */ valid_user_regs(struct pt_regs * regs)111819833afSPeter Tyserstatic inline int valid_user_regs(struct pt_regs *regs) 112819833afSPeter Tyser { 113819833afSPeter Tyser if ((regs->ARM_cpsr & 0xf) == 0 && 114819833afSPeter Tyser (regs->ARM_cpsr & (F_BIT|I_BIT)) == 0) 115819833afSPeter Tyser return 1; 116819833afSPeter Tyser 117819833afSPeter Tyser /* 118819833afSPeter Tyser * Force CPSR to something logical... 119819833afSPeter Tyser */ 120819833afSPeter Tyser regs->ARM_cpsr &= (CC_V_BIT|CC_C_BIT|CC_Z_BIT|CC_N_BIT|0x10); 121819833afSPeter Tyser 122819833afSPeter Tyser return 0; 123819833afSPeter Tyser } 124819833afSPeter Tyser 125819833afSPeter Tyser #endif /* __KERNEL__ */ 126819833afSPeter Tyser 127819833afSPeter Tyser #endif /* __ASSEMBLY__ */ 128819833afSPeter Tyser 1290ae76531SDavid Feng #endif /* CONFIG_ARM64 */ 1300ae76531SDavid Feng 131819833afSPeter Tyser #endif 132