ptrace.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Licensed under the GPL
  3. */
  4. #ifndef __SYS_PTRACE_PPC_H
  5. #define __SYS_PTRACE_PPC_H
  6. #include "linux/types.h"
  7. /* the following taken from <asm-ppc/ptrace.h> */
  8. #ifdef CONFIG_PPC64
  9. #define PPC_REG unsigned long /*long*/
  10. #else
  11. #define PPC_REG unsigned long
  12. #endif
  13. struct sys_pt_regs_s {
  14. PPC_REG gpr[32];
  15. PPC_REG nip;
  16. PPC_REG msr;
  17. PPC_REG orig_gpr3; /* Used for restarting system calls */
  18. PPC_REG ctr;
  19. PPC_REG link;
  20. PPC_REG xer;
  21. PPC_REG ccr;
  22. PPC_REG mq; /* 601 only (not used at present) */
  23. /* Used on APUS to hold IPL value. */
  24. PPC_REG trap; /* Reason for being here */
  25. PPC_REG dar; /* Fault registers */
  26. PPC_REG dsisr;
  27. PPC_REG result; /* Result of a system call */
  28. };
  29. #define NUM_REGS (sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG))
  30. struct sys_pt_regs {
  31. PPC_REG regs[sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG)];
  32. };
  33. #define UM_MAX_REG (PT_FPR0)
  34. #define UM_MAX_REG_OFFSET (UM_MAX_REG * sizeof(PPC_REG))
  35. #define EMPTY_REGS { { [ 0 ... NUM_REGS - 1] = 0 } }
  36. #define UM_REG(r, n) ((r)->regs[n])
  37. #define UM_SYSCALL_RET(r) UM_REG(r, PT_R3)
  38. #define UM_SP(r) UM_REG(r, PT_R1)
  39. #define UM_IP(r) UM_REG(r, PT_NIP)
  40. #define UM_ELF_ZERO(r) UM_REG(r, PT_FPSCR)
  41. #define UM_SYSCALL_NR(r) UM_REG(r, PT_R0)
  42. #define UM_SYSCALL_ARG1(r) UM_REG(r, PT_ORIG_R3)
  43. #define UM_SYSCALL_ARG2(r) UM_REG(r, PT_R4)
  44. #define UM_SYSCALL_ARG3(r) UM_REG(r, PT_R5)
  45. #define UM_SYSCALL_ARG4(r) UM_REG(r, PT_R6)
  46. #define UM_SYSCALL_ARG5(r) UM_REG(r, PT_R7)
  47. #define UM_SYSCALL_ARG6(r) UM_REG(r, PT_R8)
  48. #define UM_SYSCALL_NR_OFFSET (PT_R0 * sizeof(PPC_REG))
  49. #define UM_SYSCALL_RET_OFFSET (PT_R3 * sizeof(PPC_REG))
  50. #define UM_SYSCALL_ARG1_OFFSET (PT_R3 * sizeof(PPC_REG))
  51. #define UM_SYSCALL_ARG2_OFFSET (PT_R4 * sizeof(PPC_REG))
  52. #define UM_SYSCALL_ARG3_OFFSET (PT_R5 * sizeof(PPC_REG))
  53. #define UM_SYSCALL_ARG4_OFFSET (PT_R6 * sizeof(PPC_REG))
  54. #define UM_SYSCALL_ARG5_OFFSET (PT_R7 * sizeof(PPC_REG))
  55. #define UM_SYSCALL_ARG6_OFFSET (PT_R8 * sizeof(PPC_REG))
  56. #define UM_SP_OFFSET (PT_R1 * sizeof(PPC_REG))
  57. #define UM_IP_OFFSET (PT_NIP * sizeof(PPC_REG))
  58. #define UM_ELF_ZERO_OFFSET (PT_R3 * sizeof(PPC_REG))
  59. #define UM_SET_SYSCALL_RETURN(_regs, result) \
  60. do { \
  61. if (result < 0) { \
  62. (_regs)->regs[PT_CCR] |= 0x10000000; \
  63. UM_SYSCALL_RET((_regs)) = -result; \
  64. } else { \
  65. UM_SYSCALL_RET((_regs)) = result; \
  66. } \
  67. } while(0)
  68. extern void shove_aux_table(unsigned long sp);
  69. #define UM_FIX_EXEC_STACK(sp) shove_aux_table(sp);
  70. /* These aren't actually defined. The undefs are just to make sure
  71. * everyone's clear on the concept.
  72. */
  73. #undef UML_HAVE_GETREGS
  74. #undef UML_HAVE_GETFPREGS
  75. #undef UML_HAVE_SETREGS
  76. #undef UML_HAVE_SETFPREGS
  77. #endif