1 /* 2 * linux/include/asm-arm/proc-armo/ptrace.h 3 * 4 * Copyright (C) 1996-2001 Russell King 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. 9 */ 10 #ifndef __ASM_PROC_PTRACE_H 11 #define __ASM_PROC_PTRACE_H 12 13 #define USR26_MODE 0x00 14 #define FIQ26_MODE 0x01 15 #define IRQ26_MODE 0x02 16 #define SVC26_MODE 0x03 17 #define USR_MODE USR26_MODE 18 #define FIQ_MODE FIQ26_MODE 19 #define IRQ_MODE IRQ26_MODE 20 #define SVC_MODE SVC26_MODE 21 #define MODE_MASK 0x03 22 #define F_BIT (1 << 26) 23 #define I_BIT (1 << 27) 24 #define CC_V_BIT (1 << 28) 25 #define CC_C_BIT (1 << 29) 26 #define CC_Z_BIT (1 << 30) 27 #define CC_N_BIT (1 << 31) 28 #define PCMASK 0xfc000003 29 30 #ifndef __ASSEMBLY__ 31 32 /* this struct defines the way the registers are stored on the 33 stack during a system call. */ 34 35 struct pt_regs { 36 long uregs[17]; 37 }; 38 39 #define ARM_pc uregs[15] 40 #define ARM_lr uregs[14] 41 #define ARM_sp uregs[13] 42 #define ARM_ip uregs[12] 43 #define ARM_fp uregs[11] 44 #define ARM_r10 uregs[10] 45 #define ARM_r9 uregs[9] 46 #define ARM_r8 uregs[8] 47 #define ARM_r7 uregs[7] 48 #define ARM_r6 uregs[6] 49 #define ARM_r5 uregs[5] 50 #define ARM_r4 uregs[4] 51 #define ARM_r3 uregs[3] 52 #define ARM_r2 uregs[2] 53 #define ARM_r1 uregs[1] 54 #define ARM_r0 uregs[0] 55 #define ARM_ORIG_r0 uregs[16] 56 57 #ifdef __KERNEL__ 58 59 #define processor_mode(regs) \ 60 ((regs)->ARM_pc & MODE_MASK) 61 62 #define user_mode(regs) \ 63 (processor_mode(regs) == USR26_MODE) 64 65 #define thumb_mode(regs) (0) 66 67 #define interrupts_enabled(regs) \ 68 (!((regs)->ARM_pc & I_BIT)) 69 70 #define fast_interrupts_enabled(regs) \ 71 (!((regs)->ARM_pc & F_BIT)) 72 73 #define condition_codes(regs) \ 74 ((regs)->ARM_pc & (CC_V_BIT|CC_C_BIT|CC_Z_BIT|CC_N_BIT)) 75 76 /* Are the current registers suitable for user mode? 77 * (used to maintain security in signal handlers) 78 */ valid_user_regs(struct pt_regs * regs)79static inline int valid_user_regs(struct pt_regs *regs) 80 { 81 if (user_mode(regs) && 82 (regs->ARM_pc & (F_BIT | I_BIT)) == 0) 83 return 1; 84 85 /* 86 * force it to be something sensible 87 */ 88 regs->ARM_pc &= ~(MODE_MASK | F_BIT | I_BIT); 89 90 return 0; 91 } 92 93 #endif /* __KERNEL__ */ 94 95 #endif /* __ASSEMBLY__ */ 96 97 #endif 98 99