ptrace.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
  9. */
  10. #ifndef __ASM_ARC_PTRACE_H
  11. #define __ASM_ARC_PTRACE_H
  12. #include <uapi/asm/ptrace.h>
  13. #ifndef __ASSEMBLY__
  14. /* THE pt_regs: Defines how regs are saved during entry into kernel */
  15. #ifdef CONFIG_ISA_ARCOMPACT
  16. struct pt_regs {
  17. /* Real registers */
  18. unsigned long bta; /* bta_l1, bta_l2, erbta */
  19. unsigned long lp_start, lp_end, lp_count;
  20. unsigned long status32; /* status32_l1, status32_l2, erstatus */
  21. unsigned long ret; /* ilink1, ilink2 or eret */
  22. unsigned long blink;
  23. unsigned long fp;
  24. unsigned long r26; /* gp */
  25. unsigned long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
  26. unsigned long sp; /* User/Kernel depending on where we came from */
  27. unsigned long orig_r0;
  28. /*
  29. * To distinguish bet excp, syscall, irq
  30. * For traps and exceptions, Exception Cause Register.
  31. * ECR: <00> <VV> <CC> <PP>
  32. * Last word used by Linux for extra state mgmt (syscall-restart)
  33. * For interrupts, use artificial ECR values to note current prio-level
  34. */
  35. union {
  36. struct {
  37. #ifdef CONFIG_CPU_BIG_ENDIAN
  38. unsigned long state:8, ecr_vec:8,
  39. ecr_cause:8, ecr_param:8;
  40. #else
  41. unsigned long ecr_param:8, ecr_cause:8,
  42. ecr_vec:8, state:8;
  43. #endif
  44. };
  45. unsigned long event;
  46. };
  47. unsigned long user_r25;
  48. };
  49. #else
  50. struct pt_regs {
  51. unsigned long orig_r0;
  52. union {
  53. struct {
  54. #ifdef CONFIG_CPU_BIG_ENDIAN
  55. unsigned long state:8, ecr_vec:8,
  56. ecr_cause:8, ecr_param:8;
  57. #else
  58. unsigned long ecr_param:8, ecr_cause:8,
  59. ecr_vec:8, state:8;
  60. #endif
  61. };
  62. unsigned long event;
  63. };
  64. unsigned long bta; /* bta_l1, bta_l2, erbta */
  65. unsigned long user_r25;
  66. unsigned long r26; /* gp */
  67. unsigned long fp;
  68. unsigned long sp; /* user/kernel sp depending on where we came from */
  69. unsigned long r12, r30;
  70. /*------- Below list auto saved by h/w -----------*/
  71. unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11;
  72. unsigned long blink;
  73. unsigned long lp_end, lp_start, lp_count;
  74. unsigned long ei, ldi, jli;
  75. unsigned long ret;
  76. unsigned long status32;
  77. };
  78. #endif
  79. /* Callee saved registers - need to be saved only when you are scheduled out */
  80. struct callee_regs {
  81. unsigned long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
  82. };
  83. #define instruction_pointer(regs) ((regs)->ret)
  84. #define profile_pc(regs) instruction_pointer(regs)
  85. /* return 1 if user mode or 0 if kernel mode */
  86. #define user_mode(regs) (regs->status32 & STATUS_U_MASK)
  87. #define user_stack_pointer(regs)\
  88. ({ unsigned int sp; \
  89. if (user_mode(regs)) \
  90. sp = (regs)->sp;\
  91. else \
  92. sp = -1; \
  93. sp; \
  94. })
  95. /* return 1 if PC in delay slot */
  96. #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
  97. #define in_syscall(regs) ((regs->ecr_vec == ECR_V_TRAP) && !regs->ecr_param)
  98. #define in_brkpt_trap(regs) ((regs->ecr_vec == ECR_V_TRAP) && regs->ecr_param)
  99. #define STATE_SCALL_RESTARTED 0x01
  100. #define syscall_wont_restart(reg) (reg->state |= STATE_SCALL_RESTARTED)
  101. #define syscall_restartable(reg) !(reg->state & STATE_SCALL_RESTARTED)
  102. #define current_pt_regs() \
  103. ({ \
  104. /* open-coded current_thread_info() */ \
  105. register unsigned long sp asm ("sp"); \
  106. unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \
  107. (struct pt_regs *)(pg_start + THREAD_SIZE) - 1; \
  108. })
  109. static inline long regs_return_value(struct pt_regs *regs)
  110. {
  111. return (long)regs->r0;
  112. }
  113. #endif /* !__ASSEMBLY__ */
  114. #endif /* __ASM_PTRACE_H */