ptrace.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. struct pt_regs {
  16. /* Real registers */
  17. long bta; /* bta_l1, bta_l2, erbta */
  18. long lp_start, lp_end, lp_count;
  19. long status32; /* status32_l1, status32_l2, erstatus */
  20. long ret; /* ilink1, ilink2 or eret */
  21. long blink;
  22. long fp;
  23. long r26; /* gp */
  24. long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
  25. long sp; /* user/kernel sp depending on where we came from */
  26. long orig_r0;
  27. /*
  28. * To distinguish bet excp, syscall, irq
  29. * For traps and exceptions, Exception Cause Register.
  30. * ECR: <00> <VV> <CC> <PP>
  31. * Last word used by Linux for extra state mgmt (syscall-restart)
  32. * For interrupts, use artificial ECR values to note current prio-level
  33. */
  34. union {
  35. struct {
  36. #ifdef CONFIG_CPU_BIG_ENDIAN
  37. unsigned long state:8, ecr_vec:8,
  38. ecr_cause:8, ecr_param:8;
  39. #else
  40. unsigned long ecr_param:8, ecr_cause:8,
  41. ecr_vec:8, state:8;
  42. #endif
  43. };
  44. unsigned long event;
  45. };
  46. long user_r25;
  47. };
  48. /* Callee saved registers - need to be saved only when you are scheduled out */
  49. struct callee_regs {
  50. long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
  51. };
  52. #define instruction_pointer(regs) ((regs)->ret)
  53. #define profile_pc(regs) instruction_pointer(regs)
  54. /* return 1 if user mode or 0 if kernel mode */
  55. #define user_mode(regs) (regs->status32 & STATUS_U_MASK)
  56. #define user_stack_pointer(regs)\
  57. ({ unsigned int sp; \
  58. if (user_mode(regs)) \
  59. sp = (regs)->sp;\
  60. else \
  61. sp = -1; \
  62. sp; \
  63. })
  64. /* return 1 if PC in delay slot */
  65. #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
  66. #define in_syscall(regs) ((regs->ecr_vec == ECR_V_TRAP) && !regs->ecr_param)
  67. #define in_brkpt_trap(regs) ((regs->ecr_vec == ECR_V_TRAP) && regs->ecr_param)
  68. #define STATE_SCALL_RESTARTED 0x01
  69. #define syscall_wont_restart(reg) (reg->state |= STATE_SCALL_RESTARTED)
  70. #define syscall_restartable(reg) !(reg->state & STATE_SCALL_RESTARTED)
  71. #define current_pt_regs() \
  72. ({ \
  73. /* open-coded current_thread_info() */ \
  74. register unsigned long sp asm ("sp"); \
  75. unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \
  76. (struct pt_regs *)(pg_start + THREAD_SIZE) - 1; \
  77. })
  78. static inline long regs_return_value(struct pt_regs *regs)
  79. {
  80. return regs->r0;
  81. }
  82. #endif /* !__ASSEMBLY__ */
  83. #endif /* __ASM_PTRACE_H */