ptrace.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * include/asm-v850/ptrace.h -- Access to CPU registers
  3. *
  4. * Copyright (C) 2001,02,03 NEC Electronics Corporation
  5. * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General
  8. * Public License. See the file COPYING in the main directory of this
  9. * archive for more details.
  10. *
  11. * Written by Miles Bader <miles@gnu.org>
  12. */
  13. #ifndef __V850_PTRACE_H__
  14. #define __V850_PTRACE_H__
  15. /* v850 general purpose registers with special meanings. */
  16. #define GPR_ZERO 0 /* constant zero */
  17. #define GPR_ASM 1 /* reserved for assembler */
  18. #define GPR_SP 3 /* stack pointer */
  19. #define GPR_GP 4 /* global data pointer */
  20. #define GPR_TP 5 /* `text pointer' */
  21. #define GPR_EP 30 /* `element pointer' */
  22. #define GPR_LP 31 /* link pointer (current return address) */
  23. /* These aren't official names, but they make some code more descriptive. */
  24. #define GPR_ARG0 6
  25. #define GPR_ARG1 7
  26. #define GPR_ARG2 8
  27. #define GPR_ARG3 9
  28. #define GPR_RVAL0 10
  29. #define GPR_RVAL1 11
  30. #define GPR_RVAL GPR_RVAL0
  31. #define NUM_GPRS 32
  32. /* v850 `system' registers. */
  33. #define SR_EIPC 0
  34. #define SR_EIPSW 1
  35. #define SR_FEPC 2
  36. #define SR_FEPSW 3
  37. #define SR_ECR 4
  38. #define SR_PSW 5
  39. #define SR_CTPC 16
  40. #define SR_CTPSW 17
  41. #define SR_DBPC 18
  42. #define SR_DBPSW 19
  43. #define SR_CTBP 20
  44. #define SR_DIR 21
  45. #define SR_ASID 23
  46. #ifndef __ASSEMBLY__
  47. typedef unsigned long v850_reg_t;
  48. /* How processor state is stored on the stack during a syscall/signal.
  49. If you change this structure, change the associated assembly-language
  50. macros below too (PT_*)! */
  51. struct pt_regs
  52. {
  53. /* General purpose registers. */
  54. v850_reg_t gpr[NUM_GPRS];
  55. v850_reg_t pc; /* program counter */
  56. v850_reg_t psw; /* program status word */
  57. /* Registers used by `callt' instruction: */
  58. v850_reg_t ctpc; /* saved program counter */
  59. v850_reg_t ctpsw; /* saved psw */
  60. v850_reg_t ctbp; /* base pointer for callt table */
  61. char kernel_mode; /* 1 if in `kernel mode', 0 if user mode */
  62. };
  63. #define instruction_pointer(regs) ((regs)->pc)
  64. #define profile_pc(regs) instruction_pointer(regs)
  65. #define user_mode(regs) (!(regs)->kernel_mode)
  66. /* When a struct pt_regs is used to save user state for a system call in
  67. the kernel, the system call is stored in the space for R0 (since it's
  68. never used otherwise, R0 being a constant 0). Non-system-calls
  69. simply store 0 there. */
  70. #define PT_REGS_SYSCALL(regs) (regs)->gpr[0]
  71. #define PT_REGS_SET_SYSCALL(regs, val) ((regs)->gpr[0] = (val))
  72. #endif /* !__ASSEMBLY__ */
  73. /* The number of bytes used to store each register. */
  74. #define _PT_REG_SIZE 4
  75. /* Offset of a general purpose register in a struct pt_regs. */
  76. #define PT_GPR(num) ((num) * _PT_REG_SIZE)
  77. /* Offsets of various special registers & fields in a struct pt_regs. */
  78. #define PT_PC ((NUM_GPRS + 0) * _PT_REG_SIZE)
  79. #define PT_PSW ((NUM_GPRS + 1) * _PT_REG_SIZE)
  80. #define PT_CTPC ((NUM_GPRS + 2) * _PT_REG_SIZE)
  81. #define PT_CTPSW ((NUM_GPRS + 3) * _PT_REG_SIZE)
  82. #define PT_CTBP ((NUM_GPRS + 4) * _PT_REG_SIZE)
  83. #define PT_KERNEL_MODE ((NUM_GPRS + 5) * _PT_REG_SIZE)
  84. /* Where the current syscall number is stashed; obviously only valid in
  85. the kernel! */
  86. #define PT_CUR_SYSCALL PT_GPR(0)
  87. /* Size of struct pt_regs, including alignment. */
  88. #define PT_SIZE ((NUM_GPRS + 6) * _PT_REG_SIZE)
  89. /* These are `magic' values for PTRACE_PEEKUSR that return info about where
  90. a process is located in memory. */
  91. #define PT_TEXT_ADDR (PT_SIZE + 1)
  92. #define PT_TEXT_LEN (PT_SIZE + 2)
  93. #define PT_DATA_ADDR (PT_SIZE + 3)
  94. #endif /* __V850_PTRACE_H__ */