ucontext.h 7.2 KB

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