stack.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* SPARC stack layout Macros and structures,
  2. * mainly taken from BCC (the Bare C compiler for
  3. * SPARC LEON2/3) sources.
  4. *
  5. * (C) Copyright 2007
  6. * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. *
  23. */
  24. #ifndef __SPARC_STACK_H__
  25. #define __SPARC_STACK_H__
  26. #include <asm/ptrace.h>
  27. #ifndef __ASSEMBLER__
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #define PT_REGS_SZ sizeof(struct pt_regs)
  32. /* A Sparc stack frame */
  33. struct sparc_stackframe_regs {
  34. unsigned long sf_locals[8];
  35. unsigned long sf_ins[6];
  36. struct sparc_stackframe_regs *sf_fp;
  37. unsigned long sf_callers_pc;
  38. char *sf_structptr;
  39. unsigned long sf_xargs[6];
  40. unsigned long sf_xxargs[1];
  41. };
  42. #define SF_REGS_SZ sizeof(struct sparc_stackframe_regs)
  43. /* A register window */
  44. struct sparc_regwindow_regs {
  45. unsigned long locals[8];
  46. unsigned long ins[8];
  47. };
  48. #define RW_REGS_SZ sizeof(struct sparc_regwindow_regs)
  49. /* A fpu window */
  50. struct sparc_fpuwindow_regs {
  51. unsigned long locals[32];
  52. unsigned long fsr;
  53. unsigned long lastctx;
  54. };
  55. #define FW_REGS_SZ sizeof(struct sparc_fpuwindow_regs)
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #else
  60. #define PT_REGS_SZ 0x50 /* 20*4 */
  61. #define SF_REGS_SZ 0x60 /* 24*4 */
  62. #define RW_REGS_SZ 0x20 /* 16*4 */
  63. #define FW_REGS_SZ 0x88 /* 34*4 */
  64. #endif /* !ASM */
  65. /* These are for pt_regs. */
  66. #define PT_PSR 0x0
  67. #define PT_PC 0x4
  68. #define PT_NPC 0x8
  69. #define PT_Y 0xc
  70. #define PT_G0 0x10
  71. #define PT_WIM PT_G0
  72. #define PT_G1 0x14
  73. #define PT_G2 0x18
  74. #define PT_G3 0x1c
  75. #define PT_G4 0x20
  76. #define PT_G5 0x24
  77. #define PT_G6 0x28
  78. #define PT_G7 0x2c
  79. #define PT_I0 0x30
  80. #define PT_I1 0x34
  81. #define PT_I2 0x38
  82. #define PT_I3 0x3c
  83. #define PT_I4 0x40
  84. #define PT_I5 0x44
  85. #define PT_I6 0x48
  86. #define PT_FP PT_I6
  87. #define PT_I7 0x4c
  88. /* Stack_frame offsets */
  89. #define SF_L0 0x00
  90. #define SF_L1 0x04
  91. #define SF_L2 0x08
  92. #define SF_L3 0x0c
  93. #define SF_L4 0x10
  94. #define SF_L5 0x14
  95. #define SF_L6 0x18
  96. #define SF_L7 0x1c
  97. #define SF_I0 0x20
  98. #define SF_I1 0x24
  99. #define SF_I2 0x28
  100. #define SF_I3 0x2c
  101. #define SF_I4 0x30
  102. #define SF_I5 0x34
  103. #define SF_FP 0x38
  104. #define SF_PC 0x3c
  105. #define SF_RETP 0x40
  106. #define SF_XARG0 0x44
  107. #define SF_XARG1 0x48
  108. #define SF_XARG2 0x4c
  109. #define SF_XARG3 0x50
  110. #define SF_XARG4 0x54
  111. #define SF_XARG5 0x58
  112. #define SF_XXARG 0x5c
  113. /* Reg_window offsets */
  114. #define RW_L0 0x00
  115. #define RW_L1 0x04
  116. #define RW_L2 0x08
  117. #define RW_L3 0x0c
  118. #define RW_L4 0x10
  119. #define RW_L5 0x14
  120. #define RW_L6 0x18
  121. #define RW_L7 0x1c
  122. #define RW_I0 0x20
  123. #define RW_I1 0x24
  124. #define RW_I2 0x28
  125. #define RW_I3 0x2c
  126. #define RW_I4 0x30
  127. #define RW_I5 0x34
  128. #define RW_I6 0x38
  129. #define RW_I7 0x3c
  130. /* Fpu_window offsets */
  131. #define FW_F0 0x00
  132. #define FW_F2 0x08
  133. #define FW_F4 0x10
  134. #define FW_F6 0x18
  135. #define FW_F8 0x20
  136. #define FW_F10 0x28
  137. #define FW_F12 0x30
  138. #define FW_F14 0x38
  139. #define FW_F16 0x40
  140. #define FW_F18 0x48
  141. #define FW_F20 0x50
  142. #define FW_F22 0x58
  143. #define FW_F24 0x60
  144. #define FW_F26 0x68
  145. #define FW_F28 0x70
  146. #define FW_F30 0x78
  147. #define FW_FSR 0x80
  148. #endif