ptrace.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * linux/include/asm-arm/proc-armv/ptrace.h
  3. *
  4. * Copyright (C) 1996-1999 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. #ifdef CONFIG_ARM64
  13. #define PCMASK 0
  14. #ifndef __ASSEMBLY__
  15. /*
  16. * This struct defines the way the registers are stored
  17. * on the stack during an exception.
  18. */
  19. struct pt_regs {
  20. unsigned long elr;
  21. unsigned long regs[31];
  22. };
  23. #endif /* __ASSEMBLY__ */
  24. #else /* CONFIG_ARM64 */
  25. #define USR26_MODE 0x00
  26. #define FIQ26_MODE 0x01
  27. #define IRQ26_MODE 0x02
  28. #define SVC26_MODE 0x03
  29. #define USR_MODE 0x10
  30. #define FIQ_MODE 0x11
  31. #define IRQ_MODE 0x12
  32. #define SVC_MODE 0x13
  33. #define ABT_MODE 0x17
  34. #define HYP_MODE 0x1a
  35. #define UND_MODE 0x1b
  36. #define SYSTEM_MODE 0x1f
  37. #define MODE_MASK 0x1f
  38. #define T_BIT 0x20
  39. #define F_BIT 0x40
  40. #define I_BIT 0x80
  41. #define A_BIT 0x100
  42. #define CC_V_BIT (1 << 28)
  43. #define CC_C_BIT (1 << 29)
  44. #define CC_Z_BIT (1 << 30)
  45. #define CC_N_BIT (1 << 31)
  46. #define PCMASK 0
  47. #ifndef __ASSEMBLY__
  48. /* this struct defines the way the registers are stored on the
  49. stack during a system call. */
  50. struct pt_regs {
  51. long uregs[18];
  52. };
  53. #define ARM_cpsr uregs[16]
  54. #define ARM_pc uregs[15]
  55. #define ARM_lr uregs[14]
  56. #define ARM_sp uregs[13]
  57. #define ARM_ip uregs[12]
  58. #define ARM_fp uregs[11]
  59. #define ARM_r10 uregs[10]
  60. #define ARM_r9 uregs[9]
  61. #define ARM_r8 uregs[8]
  62. #define ARM_r7 uregs[7]
  63. #define ARM_r6 uregs[6]
  64. #define ARM_r5 uregs[5]
  65. #define ARM_r4 uregs[4]
  66. #define ARM_r3 uregs[3]
  67. #define ARM_r2 uregs[2]
  68. #define ARM_r1 uregs[1]
  69. #define ARM_r0 uregs[0]
  70. #define ARM_ORIG_r0 uregs[17]
  71. #ifdef __KERNEL__
  72. #define user_mode(regs) \
  73. (((regs)->ARM_cpsr & 0xf) == 0)
  74. #ifdef CONFIG_ARM_THUMB
  75. #define thumb_mode(regs) \
  76. (((regs)->ARM_cpsr & T_BIT))
  77. #else
  78. #define thumb_mode(regs) (0)
  79. #endif
  80. #define processor_mode(regs) \
  81. ((regs)->ARM_cpsr & MODE_MASK)
  82. #define interrupts_enabled(regs) \
  83. (!((regs)->ARM_cpsr & I_BIT))
  84. #define fast_interrupts_enabled(regs) \
  85. (!((regs)->ARM_cpsr & F_BIT))
  86. #define condition_codes(regs) \
  87. ((regs)->ARM_cpsr & (CC_V_BIT|CC_C_BIT|CC_Z_BIT|CC_N_BIT))
  88. /* Are the current registers suitable for user mode?
  89. * (used to maintain security in signal handlers)
  90. */
  91. static inline int valid_user_regs(struct pt_regs *regs)
  92. {
  93. if ((regs->ARM_cpsr & 0xf) == 0 &&
  94. (regs->ARM_cpsr & (F_BIT|I_BIT)) == 0)
  95. return 1;
  96. /*
  97. * Force CPSR to something logical...
  98. */
  99. regs->ARM_cpsr &= (CC_V_BIT|CC_C_BIT|CC_Z_BIT|CC_N_BIT|0x10);
  100. return 0;
  101. }
  102. #endif /* __KERNEL__ */
  103. #endif /* __ASSEMBLY__ */
  104. #endif /* CONFIG_ARM64 */
  105. #endif