ptrace.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __ASM_AVR32_PTRACE_H
  23. #define __ASM_AVR32_PTRACE_H
  24. /*
  25. * Status Register bits
  26. */
  27. #define SR_H 0x40000000
  28. #define SR_R 0x20000000
  29. #define SR_J 0x10000000
  30. #define SR_DM 0x08000000
  31. #define SR_D 0x04000000
  32. #define MODE_NMI 0x01c00000
  33. #define MODE_EXCEPTION 0x01800000
  34. #define MODE_INT3 0x01400000
  35. #define MODE_INT2 0x01000000
  36. #define MODE_INT1 0x00c00000
  37. #define MODE_INT0 0x00800000
  38. #define MODE_SUPERVISOR 0x00400000
  39. #define MODE_USER 0x00000000
  40. #define MODE_MASK 0x01c00000
  41. #define SR_EM 0x00200000
  42. #define SR_I3M 0x00100000
  43. #define SR_I2M 0x00080000
  44. #define SR_I1M 0x00040000
  45. #define SR_I0M 0x00020000
  46. #define SR_GM 0x00010000
  47. #define MODE_SHIFT 22
  48. #define SR_EM_BIT 21
  49. #define SR_I3M_BIT 20
  50. #define SR_I2M_BIT 19
  51. #define SR_I1M_BIT 18
  52. #define SR_I0M_BIT 17
  53. #define SR_GM_BIT 16
  54. /* The user-visible part */
  55. #define SR_Q 0x00000010
  56. #define SR_V 0x00000008
  57. #define SR_N 0x00000004
  58. #define SR_Z 0x00000002
  59. #define SR_C 0x00000001
  60. /*
  61. * The order is defined by the stdsp instruction. r0 is stored first, so it
  62. * gets the highest address.
  63. *
  64. * Registers 0-12 are general-purpose registers (r12 is normally used for
  65. * the function return value).
  66. * Register 13 is the stack pointer
  67. * Register 14 is the link register
  68. * Register 15 is the program counter
  69. */
  70. #define FRAME_SIZE_FULL 72
  71. #define REG_R12_ORIG 68
  72. #define REG_R0 64
  73. #define REG_R1 60
  74. #define REG_R2 56
  75. #define REG_R3 52
  76. #define REG_R4 48
  77. #define REG_R5 44
  78. #define REG_R6 40
  79. #define REG_R7 36
  80. #define REG_R8 32
  81. #define REG_R9 28
  82. #define REG_R10 34
  83. #define REG_R11 20
  84. #define REG_R12 16
  85. #define REG_SP 12
  86. #define REG_LR 8
  87. #define FRAME_SIZE_MIN 8
  88. #define REG_PC 4
  89. #define REG_SR 0
  90. #ifndef __ASSEMBLY__
  91. struct pt_regs {
  92. /* These are always saved */
  93. unsigned long sr;
  94. unsigned long pc;
  95. /* These are sometimes saved */
  96. unsigned long lr;
  97. unsigned long sp;
  98. unsigned long r12;
  99. unsigned long r11;
  100. unsigned long r10;
  101. unsigned long r9;
  102. unsigned long r8;
  103. unsigned long r7;
  104. unsigned long r6;
  105. unsigned long r5;
  106. unsigned long r4;
  107. unsigned long r3;
  108. unsigned long r2;
  109. unsigned long r1;
  110. unsigned long r0;
  111. /* Only saved on system call */
  112. unsigned long r12_orig;
  113. };
  114. #ifdef __KERNEL__
  115. # define user_mode(regs) (((regs)->sr & MODE_MASK) == MODE_USER)
  116. # define instruction_pointer(regs) ((regs)->pc)
  117. extern void show_regs (struct pt_regs *);
  118. static __inline__ int valid_user_regs(struct pt_regs *regs)
  119. {
  120. /*
  121. * Some of the Java bits might be acceptable if/when we
  122. * implement some support for that stuff...
  123. */
  124. if ((regs->sr & 0xffff0000) == 0)
  125. return 1;
  126. /*
  127. * Force status register flags to be sane and report this
  128. * illegal behaviour...
  129. */
  130. regs->sr &= 0x0000ffff;
  131. return 0;
  132. }
  133. #endif
  134. #endif /* ! __ASSEMBLY__ */
  135. #endif /* __ASM_AVR32_PTRACE_H */