ucontext.h 5.2 KB

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