ptrace.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * include/asm-xtensa/ptrace.h
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2001 - 2005 Tensilica Inc.
  9. */
  10. #ifndef _XTENSA_PTRACE_H
  11. #define _XTENSA_PTRACE_H
  12. #include <uapi/asm/ptrace.h>
  13. /*
  14. * Kernel stack
  15. *
  16. * +-----------------------+ -------- STACK_SIZE
  17. * | register file | |
  18. * +-----------------------+ |
  19. * | struct pt_regs | |
  20. * +-----------------------+ | ------ PT_REGS_OFFSET
  21. * double : 16 bytes spill area : | ^
  22. * excetion :- - - - - - - - - - - -: | |
  23. * frame : struct pt_regs : | |
  24. * :- - - - - - - - - - - -: | |
  25. * | | | |
  26. * | memory stack | | |
  27. * | | | |
  28. * ~ ~ ~ ~
  29. * ~ ~ ~ ~
  30. * | | | |
  31. * | | | |
  32. * +-----------------------+ | | --- STACK_BIAS
  33. * | struct task_struct | | | ^
  34. * current --> +-----------------------+ | | |
  35. * | struct thread_info | | | |
  36. * +-----------------------+ --------
  37. */
  38. #define KERNEL_STACK_SIZE (2 * PAGE_SIZE)
  39. /* Offsets for exception_handlers[] (3 x 64-entries x 4-byte tables). */
  40. #define EXC_TABLE_KSTK 0x004 /* Kernel Stack */
  41. #define EXC_TABLE_DOUBLE_SAVE 0x008 /* Double exception save area for a0 */
  42. #define EXC_TABLE_FIXUP 0x00c /* Fixup handler */
  43. #define EXC_TABLE_PARAM 0x010 /* For passing a parameter to fixup */
  44. #define EXC_TABLE_SYSCALL_SAVE 0x014 /* For fast syscall handler */
  45. #define EXC_TABLE_FAST_USER 0x100 /* Fast user exception handler */
  46. #define EXC_TABLE_FAST_KERNEL 0x200 /* Fast kernel exception handler */
  47. #define EXC_TABLE_DEFAULT 0x300 /* Default C-Handler */
  48. #define EXC_TABLE_SIZE 0x400
  49. #ifndef __ASSEMBLY__
  50. #include <asm/coprocessor.h>
  51. /*
  52. * This struct defines the way the registers are stored on the
  53. * kernel stack during a system call or other kernel entry.
  54. */
  55. struct pt_regs {
  56. unsigned long pc; /* 4 */
  57. unsigned long ps; /* 8 */
  58. unsigned long depc; /* 12 */
  59. unsigned long exccause; /* 16 */
  60. unsigned long excvaddr; /* 20 */
  61. unsigned long debugcause; /* 24 */
  62. unsigned long wmask; /* 28 */
  63. unsigned long lbeg; /* 32 */
  64. unsigned long lend; /* 36 */
  65. unsigned long lcount; /* 40 */
  66. unsigned long sar; /* 44 */
  67. unsigned long windowbase; /* 48 */
  68. unsigned long windowstart; /* 52 */
  69. unsigned long syscall; /* 56 */
  70. unsigned long icountlevel; /* 60 */
  71. unsigned long scompare1; /* 64 */
  72. unsigned long threadptr; /* 68 */
  73. /* Additional configurable registers that are used by the compiler. */
  74. xtregs_opt_t xtregs_opt;
  75. /* Make sure the areg field is 16 bytes aligned. */
  76. int align[0] __attribute__ ((aligned(16)));
  77. /* current register frame.
  78. * Note: The ESF for kernel exceptions ends after 16 registers!
  79. */
  80. unsigned long areg[16];
  81. };
  82. #include <variant/core.h>
  83. # define arch_has_single_step() (1)
  84. # define task_pt_regs(tsk) ((struct pt_regs*) \
  85. (task_stack_page(tsk) + KERNEL_STACK_SIZE - (XCHAL_NUM_AREGS-16)*4) - 1)
  86. # define user_mode(regs) (((regs)->ps & 0x00000020)!=0)
  87. # define instruction_pointer(regs) ((regs)->pc)
  88. # define return_pointer(regs) (MAKE_PC_FROM_RA((regs)->areg[0], \
  89. (regs)->areg[1]))
  90. # ifndef CONFIG_SMP
  91. # define profile_pc(regs) instruction_pointer(regs)
  92. # else
  93. # define profile_pc(regs) \
  94. ({ \
  95. in_lock_functions(instruction_pointer(regs)) ? \
  96. return_pointer(regs) : instruction_pointer(regs); \
  97. })
  98. # endif
  99. #define user_stack_pointer(regs) ((regs)->areg[1])
  100. #else /* __ASSEMBLY__ */
  101. # include <asm/asm-offsets.h>
  102. #define PT_REGS_OFFSET (KERNEL_STACK_SIZE - PT_USER_SIZE)
  103. #endif /* !__ASSEMBLY__ */
  104. #endif /* _XTENSA_PTRACE_H */