ucontext.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _SYS_UCONTEXT_H
  15. #define _SYS_UCONTEXT_H 1
  16. #include <features.h>
  17. #include <signal.h>
  18. #include <bits/wordsize.h>
  19. #if __WORDSIZE == 64
  20. #define MC_TSTATE 0
  21. #define MC_PC 1
  22. #define MC_NPC 2
  23. #define MC_Y 3
  24. #define MC_G1 4
  25. #define MC_G2 5
  26. #define MC_G3 6
  27. #define MC_G4 7
  28. #define MC_G5 8
  29. #define MC_G6 9
  30. #define MC_G7 10
  31. #define MC_O0 11
  32. #define MC_O1 12
  33. #define MC_O2 13
  34. #define MC_O3 14
  35. #define MC_O4 15
  36. #define MC_O5 16
  37. #define MC_O6 17
  38. #define MC_O7 18
  39. #define MC_NGREG 19
  40. typedef unsigned long mc_greg_t;
  41. typedef mc_greg_t mc_gregset_t[MC_NGREG];
  42. #define MC_MAXFPQ 16
  43. struct mc_fq {
  44. unsigned long *mcfq_addr;
  45. unsigned int mcfq_insn;
  46. };
  47. struct mc_fpu {
  48. union {
  49. unsigned int sregs[32];
  50. unsigned long dregs[32];
  51. long double qregs[16];
  52. } mcfpu_fregs;
  53. unsigned long mcfpu_fsr;
  54. unsigned long mcfpu_fprs;
  55. unsigned long mcfpu_gsr;
  56. struct mc_fq *mcfpu_fq;
  57. unsigned char mcfpu_qcnt;
  58. unsigned char mcfpu_qentsz;
  59. unsigned char mcfpu_enab;
  60. };
  61. typedef struct mc_fpu mc_fpu_t;
  62. typedef struct {
  63. mc_gregset_t mc_gregs;
  64. mc_greg_t mc_fp;
  65. mc_greg_t mc_i7;
  66. mc_fpu_t mc_fpregs;
  67. } mcontext_t;
  68. typedef struct ucontext {
  69. struct ucontext *uc_link;
  70. unsigned long uc_flags;
  71. unsigned long __uc_sigmask;
  72. mcontext_t uc_mcontext;
  73. stack_t uc_stack;
  74. __sigset_t uc_sigmask;
  75. } ucontext_t;
  76. #endif /* __WORDISIZE == 64 */
  77. /*
  78. * Location of the users' stored registers relative to R0.
  79. * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
  80. */
  81. #define REG_PSR (0)
  82. #define REG_PC (1)
  83. #define REG_nPC (2)
  84. #define REG_Y (3)
  85. #define REG_G1 (4)
  86. #define REG_G2 (5)
  87. #define REG_G3 (6)
  88. #define REG_G4 (7)
  89. #define REG_G5 (8)
  90. #define REG_G6 (9)
  91. #define REG_G7 (10)
  92. #define REG_O0 (11)
  93. #define REG_O1 (12)
  94. #define REG_O2 (13)
  95. #define REG_O3 (14)
  96. #define REG_O4 (15)
  97. #define REG_O5 (16)
  98. #define REG_O6 (17)
  99. #define REG_O7 (18)
  100. /*
  101. * A gregset_t is defined as an array type for compatibility with the reference
  102. * source. This is important due to differences in the way the C language
  103. * treats arrays and structures as parameters.
  104. *
  105. * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
  106. * but that the ABI defines it absolutely to be 21 (resp. 19).
  107. */
  108. #if __WORDSIZE == 64
  109. #define REG_ASI (19)
  110. #define REG_FPRS (20)
  111. #define NGREG 21
  112. typedef long greg_t;
  113. #else /* __WORDSIZE == 32 */
  114. #define NGREG 19
  115. typedef int greg_t;
  116. #endif /* __WORDSIZE == 32 */
  117. typedef greg_t gregset_t[NGREG];
  118. /*
  119. * The following structures define how a register window can appear on the
  120. * stack. This structure is available (when required) through the `gwins'
  121. * field of an mcontext (nested within ucontext). SPARC_MAXWINDOW is the
  122. * maximum number of outstanding regiters window defined in the SPARC
  123. * architecture (*not* implementation).
  124. */
  125. #define SPARC_MAXREGWINDOW 31 /* max windows in SPARC arch. */
  126. struct rwindow
  127. {
  128. greg_t rw_local[8]; /* locals */
  129. greg_t rw_in[8]; /* ins */
  130. };
  131. #define rw_fp rw_in[6] /* frame pointer */
  132. #define rw_rtn rw_in[7] /* return address */
  133. typedef struct gwindows
  134. {
  135. int wbcnt;
  136. int *spbuf[SPARC_MAXREGWINDOW];
  137. struct rwindow wbuf[SPARC_MAXREGWINDOW];
  138. } gwindows_t;
  139. /*
  140. * Floating point definitions.
  141. */
  142. #define MAXFPQ 16 /* max # of fpu queue entries currently supported */
  143. /*
  144. * struct fq defines the minimal format of a floating point instruction queue
  145. * entry. The size of entries in the floating point queue are implementation
  146. * dependent. The union FQu is guarenteed to be the first field in any ABI
  147. * conformant system implementation. Any additional fields provided by an
  148. * implementation should not be used applications designed to be ABI conformant. */
  149. struct fpq
  150. {
  151. unsigned long *fpq_addr; /* address */
  152. unsigned long fpq_instr; /* instruction */
  153. };
  154. struct fq
  155. {
  156. union /* FPU inst/addr queue */
  157. {
  158. double whole;
  159. struct fpq fpq;
  160. } FQu;
  161. };
  162. #define FPU_REGS_TYPE unsigned
  163. #define FPU_DREGS_TYPE unsigned long long
  164. #define V7_FPU_FSR_TYPE unsigned
  165. #define V9_FPU_FSR_TYPE unsigned long long
  166. #define V9_FPU_FPRS_TYPE unsigned
  167. #if __WORDSIZE == 64
  168. typedef struct fpu
  169. {
  170. union { /* FPU floating point regs */
  171. unsigned fpu_regs[32]; /* 32 singles */
  172. double fpu_dregs[16]; /* 32 doubles */
  173. long double fpu_qregs[16]; /* 16 quads */
  174. } fpu_fr;
  175. struct fq *fpu_q; /* ptr to array of FQ entries */
  176. unsigned long fpu_fsr; /* FPU status register */
  177. unsigned char fpu_qcnt; /* # of entries in saved FQ */
  178. unsigned char fpu_q_entrysize; /* # of bytes per FQ entry */
  179. unsigned char fpu_en; /* flag signifying fpu in use */
  180. } fpregset_t;
  181. #else /* __WORDSIZE == 32 */
  182. typedef struct fpu
  183. {
  184. union { /* FPU floating point regs */
  185. unsigned long long fpu_regs[32]; /* 32 singles */
  186. double fpu_dregs[16]; /* 16 doubles */
  187. } fpu_fr;
  188. struct fq *fpu_q; /* ptr to array of FQ entries */
  189. unsigned fpu_fsr; /* FPU status register */
  190. unsigned char fpu_qcnt; /* # of entries in saved FQ */
  191. unsigned char fpu_q_entrysize; /* # of bytes per FQ entry */
  192. unsigned char fpu_en; /* flag signifying fpu in use */
  193. } fpregset_t;
  194. /*
  195. * The following structure is for associating extra register state with
  196. * the ucontext structure and is kept within the uc_mcontext filler area.
  197. *
  198. * If (xrs_id == XRS_ID) then the xrs_ptr field is a valid pointer to
  199. * extra register state. The exact format of the extra register state
  200. * pointed to by xrs_ptr is platform-dependent.
  201. *
  202. * Note: a platform may or may not manage extra register state.
  203. */
  204. typedef struct
  205. {
  206. unsigned int xrs_id; /* indicates xrs_ptr validity */
  207. void * xrs_ptr; /* ptr to extra reg state */
  208. } xrs_t;
  209. #define XRS_ID 0x78727300 /* the string "xrs" */
  210. typedef struct
  211. {
  212. gregset_t gregs; /* general register set */
  213. gwindows_t *gwins; /* POSSIBLE pointer to register windows */
  214. fpregset_t fpregs; /* floating point register set */
  215. xrs_t xrs; /* POSSIBLE extra register state association */
  216. long filler[19];
  217. } mcontext_t;
  218. /* Userlevel context. */
  219. typedef struct ucontext
  220. {
  221. unsigned long uc_flags;
  222. struct ucontext *uc_link;
  223. __sigset_t uc_sigmask;
  224. stack_t uc_stack;
  225. mcontext_t uc_mcontext;
  226. } ucontext_t;
  227. #endif /* __WORDSIZE == 32 */
  228. #endif /* sys/ucontext.h */