GuanXuetao | 6dea1ba | 2011-01-15 18:21:56 +0800 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/unicore32/include/asm/ptrace.h |
| 3 | * |
| 4 | * Code specific to PKUnity SoC and UniCore ISA |
| 5 | * |
| 6 | * Copyright (C) 2001-2010 GUAN Xue-tao |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | #ifndef __UNICORE_PTRACE_H__ |
| 13 | #define __UNICORE_PTRACE_H__ |
| 14 | |
David Howells | e8ce15a | 2012-10-09 09:47:48 +0100 | [diff] [blame] | 15 | #include <uapi/asm/ptrace.h> |
GuanXuetao | 6dea1ba | 2011-01-15 18:21:56 +0800 | [diff] [blame] | 16 | |
| 17 | #ifndef __ASSEMBLY__ |
| 18 | |
GuanXuetao | 6dea1ba | 2011-01-15 18:21:56 +0800 | [diff] [blame] | 19 | #define user_mode(regs) \ |
| 20 | (processor_mode(regs) == USER_MODE) |
| 21 | |
| 22 | #define processor_mode(regs) \ |
| 23 | ((regs)->UCreg_asr & MODE_MASK) |
| 24 | |
| 25 | #define interrupts_enabled(regs) \ |
| 26 | (!((regs)->UCreg_asr & PSR_I_BIT)) |
| 27 | |
| 28 | #define fast_interrupts_enabled(regs) \ |
| 29 | (!((regs)->UCreg_asr & PSR_R_BIT)) |
| 30 | |
| 31 | /* Are the current registers suitable for user mode? |
| 32 | * (used to maintain security in signal handlers) |
| 33 | */ |
| 34 | static inline int valid_user_regs(struct pt_regs *regs) |
| 35 | { |
| 36 | unsigned long mode = regs->UCreg_asr & MODE_MASK; |
| 37 | |
| 38 | /* |
| 39 | * Always clear the R (REAL) bits |
| 40 | */ |
| 41 | regs->UCreg_asr &= ~(PSR_R_BIT); |
| 42 | |
| 43 | if ((regs->UCreg_asr & PSR_I_BIT) == 0) { |
| 44 | if (mode == USER_MODE) |
| 45 | return 1; |
| 46 | } |
| 47 | |
| 48 | /* |
| 49 | * Force ASR to something logical... |
| 50 | */ |
| 51 | regs->UCreg_asr &= PSR_f | USER_MODE; |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | #define instruction_pointer(regs) ((regs)->UCreg_pc) |
Al Viro | 5208ba2 | 2012-12-14 01:50:19 -0500 | [diff] [blame] | 57 | #define user_stack_pointer(regs) ((regs)->UCreg_sp) |
Chen Gang | 1febf61 | 2014-03-24 20:54:11 +0800 | [diff] [blame] | 58 | #define profile_pc(regs) instruction_pointer(regs) |
GuanXuetao | 6dea1ba | 2011-01-15 18:21:56 +0800 | [diff] [blame] | 59 | |
GuanXuetao | 6dea1ba | 2011-01-15 18:21:56 +0800 | [diff] [blame] | 60 | #endif /* __ASSEMBLY__ */ |
GuanXuetao | 6dea1ba | 2011-01-15 18:21:56 +0800 | [diff] [blame] | 61 | #endif |