ptrace.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include <uapi/asm/ptrace.h>
  15. #ifndef __ASSEMBLY__
  16. #define user_mode(regs) \
  17. (processor_mode(regs) == USER_MODE)
  18. #define processor_mode(regs) \
  19. ((regs)->UCreg_asr & MODE_MASK)
  20. #define interrupts_enabled(regs) \
  21. (!((regs)->UCreg_asr & PSR_I_BIT))
  22. #define fast_interrupts_enabled(regs) \
  23. (!((regs)->UCreg_asr & PSR_R_BIT))
  24. /* Are the current registers suitable for user mode?
  25. * (used to maintain security in signal handlers)
  26. */
  27. static inline int valid_user_regs(struct pt_regs *regs)
  28. {
  29. unsigned long mode = regs->UCreg_asr & MODE_MASK;
  30. /*
  31. * Always clear the R (REAL) bits
  32. */
  33. regs->UCreg_asr &= ~(PSR_R_BIT);
  34. if ((regs->UCreg_asr & PSR_I_BIT) == 0) {
  35. if (mode == USER_MODE)
  36. return 1;
  37. }
  38. /*
  39. * Force ASR to something logical...
  40. */
  41. regs->UCreg_asr &= PSR_f | USER_MODE;
  42. return 0;
  43. }
  44. #define instruction_pointer(regs) ((regs)->UCreg_pc)
  45. #define user_stack_pointer(regs) ((regs)->UCreg_sp)
  46. #define profile_pc(regs) instruction_pointer(regs)
  47. #endif /* __ASSEMBLY__ */
  48. #endif