ptrace.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * OpenRISC Linux
  3. *
  4. * Linux architectural port borrowing liberally from similar works of
  5. * others. All original copyrights apply as per the original source
  6. * declaration.
  7. *
  8. * OpenRISC implementation:
  9. * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
  10. * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
  11. * et al.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. */
  18. #ifndef __ASM_OPENRISC_PTRACE_H
  19. #define __ASM_OPENRISC_PTRACE_H
  20. #include <asm/spr-defs.h>
  21. #ifndef __ASSEMBLY__
  22. /*
  23. * This is the layout of the regset returned by the GETREGSET ptrace call
  24. */
  25. struct user_regs_struct {
  26. /* GPR R0-R31... */
  27. unsigned long gpr[32];
  28. unsigned long pc;
  29. unsigned long sr;
  30. unsigned long pad1;
  31. unsigned long pad2;
  32. };
  33. #endif
  34. #ifdef __KERNEL__
  35. /*
  36. * Make kernel PTrace/register structures opaque to userspace... userspace can
  37. * access thread state via the regset mechanism. This allows us a bit of
  38. * flexibility in how we order the registers on the stack, permitting some
  39. * optimizations like packing call-clobbered registers together so that
  40. * they share a cacheline (not done yet, though... future optimization).
  41. */
  42. #ifndef __ASSEMBLY__
  43. /*
  44. * This struct describes how the registers are laid out on the kernel stack
  45. * during a syscall or other kernel entry.
  46. *
  47. * This structure should always be cacheline aligned on the stack.
  48. * FIXME: I don't think that's the case right now. The alignment is
  49. * taken care of elsewhere... head.S, process.c, etc.
  50. */
  51. struct pt_regs {
  52. union {
  53. struct {
  54. /* Named registers */
  55. long sr; /* Stored in place of r0 */
  56. long sp; /* r1 */
  57. };
  58. struct {
  59. /* Old style */
  60. long offset[2];
  61. long gprs[30];
  62. };
  63. struct {
  64. /* New style */
  65. long gpr[32];
  66. };
  67. };
  68. long pc;
  69. long orig_gpr11; /* For restarting system calls */
  70. long syscallno; /* Syscall number (used by strace) */
  71. long dummy; /* Cheap alignment fix */
  72. };
  73. #endif /* __ASSEMBLY__ */
  74. /* TODO: Rename this to REDZONE because that's what it is */
  75. #define STACK_FRAME_OVERHEAD 128 /* size of minimum stack frame */
  76. #define instruction_pointer(regs) ((regs)->pc)
  77. #define user_mode(regs) (((regs)->sr & SPR_SR_SM) == 0)
  78. #define user_stack_pointer(regs) ((unsigned long)(regs)->sp)
  79. #define profile_pc(regs) instruction_pointer(regs)
  80. /*
  81. * Offsets used by 'ptrace' system call interface.
  82. */
  83. #define PT_SR 0
  84. #define PT_SP 4
  85. #define PT_GPR2 8
  86. #define PT_GPR3 12
  87. #define PT_GPR4 16
  88. #define PT_GPR5 20
  89. #define PT_GPR6 24
  90. #define PT_GPR7 28
  91. #define PT_GPR8 32
  92. #define PT_GPR9 36
  93. #define PT_GPR10 40
  94. #define PT_GPR11 44
  95. #define PT_GPR12 48
  96. #define PT_GPR13 52
  97. #define PT_GPR14 56
  98. #define PT_GPR15 60
  99. #define PT_GPR16 64
  100. #define PT_GPR17 68
  101. #define PT_GPR18 72
  102. #define PT_GPR19 76
  103. #define PT_GPR20 80
  104. #define PT_GPR21 84
  105. #define PT_GPR22 88
  106. #define PT_GPR23 92
  107. #define PT_GPR24 96
  108. #define PT_GPR25 100
  109. #define PT_GPR26 104
  110. #define PT_GPR27 108
  111. #define PT_GPR28 112
  112. #define PT_GPR29 116
  113. #define PT_GPR30 120
  114. #define PT_GPR31 124
  115. #define PT_PC 128
  116. #define PT_ORIG_GPR11 132
  117. #define PT_SYSCALLNO 136
  118. #endif /* __KERNEL__ */
  119. #endif /* __ASM_OPENRISC_PTRACE_H */