ucontext.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. /*
  19. * Location of the users' stored registers relative to R0.
  20. * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
  21. */
  22. #define REG_PSR (0)
  23. #define REG_PC (1)
  24. #define REG_nPC (2)
  25. #define REG_Y (3)
  26. #define REG_G1 (4)
  27. #define REG_G2 (5)
  28. #define REG_G3 (6)
  29. #define REG_G4 (7)
  30. #define REG_G5 (8)
  31. #define REG_G6 (9)
  32. #define REG_G7 (10)
  33. #define REG_O0 (11)
  34. #define REG_O1 (12)
  35. #define REG_O2 (13)
  36. #define REG_O3 (14)
  37. #define REG_O4 (15)
  38. #define REG_O5 (16)
  39. #define REG_O6 (17)
  40. #define REG_O7 (18)
  41. /*
  42. * A gregset_t is defined as an array type for compatibility with the reference
  43. * source. This is important due to differences in the way the C language
  44. * treats arrays and structures as parameters.
  45. *
  46. * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
  47. * but that the ABI defines it absolutely to be 21 (resp. 19).
  48. */
  49. #define NGREG 19
  50. typedef int greg_t;
  51. typedef greg_t gregset_t[NGREG];
  52. /*
  53. * The following structures define how a register window can appear on the
  54. * stack. This structure is available (when required) through the `gwins'
  55. * field of an mcontext (nested within ucontext). SPARC_MAXWINDOW is the
  56. * maximum number of outstanding regiters window defined in the SPARC
  57. * architecture (*not* implementation).
  58. */
  59. #define SPARC_MAXREGWINDOW 31 /* max windows in SPARC arch. */
  60. struct rwindow
  61. {
  62. greg_t rw_local[8]; /* locals */
  63. greg_t rw_in[8]; /* ins */
  64. };
  65. #define rw_fp rw_in[6] /* frame pointer */
  66. #define rw_rtn rw_in[7] /* return address */
  67. typedef struct gwindows
  68. {
  69. int wbcnt;
  70. int *spbuf[SPARC_MAXREGWINDOW];
  71. struct rwindow wbuf[SPARC_MAXREGWINDOW];
  72. } gwindows_t;
  73. /*
  74. * Floating point definitions.
  75. */
  76. #define MAXFPQ 16 /* max # of fpu queue entries currently supported */
  77. /*
  78. * struct fq defines the minimal format of a floating point instruction queue
  79. * entry. The size of entries in the floating point queue are implementation
  80. * dependent. The union FQu is guarenteed to be the first field in any ABI
  81. * conformant system implementation. Any additional fields provided by an
  82. * implementation should not be used applications designed to be ABI conformant. */
  83. struct fpq
  84. {
  85. unsigned long *fpq_addr; /* address */
  86. unsigned long fpq_instr; /* instruction */
  87. };
  88. struct fq
  89. {
  90. union /* FPU inst/addr queue */
  91. {
  92. double whole;
  93. struct fpq fpq;
  94. } FQu;
  95. };
  96. #define FPU_REGS_TYPE unsigned
  97. #define FPU_DREGS_TYPE unsigned long long
  98. #define V7_FPU_FSR_TYPE unsigned
  99. #define V9_FPU_FSR_TYPE unsigned long long
  100. #define V9_FPU_FPRS_TYPE unsigned
  101. typedef struct fpu
  102. {
  103. union { /* FPU floating point regs */
  104. unsigned long long fpu_regs[32]; /* 32 singles */
  105. double fpu_dregs[16]; /* 16 doubles */
  106. } fpu_fr;
  107. struct fq *fpu_q; /* ptr to array of FQ entries */
  108. unsigned fpu_fsr; /* FPU status register */
  109. unsigned char fpu_qcnt; /* # of entries in saved FQ */
  110. unsigned char fpu_q_entrysize; /* # of bytes per FQ entry */
  111. unsigned char fpu_en; /* flag signifying fpu in use */
  112. } fpregset_t;
  113. /*
  114. * The following structure is for associating extra register state with
  115. * the ucontext structure and is kept within the uc_mcontext filler area.
  116. *
  117. * If (xrs_id == XRS_ID) then the xrs_ptr field is a valid pointer to
  118. * extra register state. The exact format of the extra register state
  119. * pointed to by xrs_ptr is platform-dependent.
  120. *
  121. * Note: a platform may or may not manage extra register state.
  122. */
  123. typedef struct
  124. {
  125. unsigned int xrs_id; /* indicates xrs_ptr validity */
  126. void * xrs_ptr; /* ptr to extra reg state */
  127. } xrs_t;
  128. #define XRS_ID 0x78727300 /* the string "xrs" */
  129. typedef struct
  130. {
  131. gregset_t gregs; /* general register set */
  132. gwindows_t *gwins; /* POSSIBLE pointer to register windows */
  133. fpregset_t fpregs; /* floating point register set */
  134. xrs_t xrs; /* POSSIBLE extra register state association */
  135. long filler[19];
  136. } mcontext_t;
  137. /* Userlevel context. */
  138. typedef struct ucontext
  139. {
  140. unsigned long uc_flags;
  141. struct ucontext *uc_link;
  142. __sigset_t uc_sigmask;
  143. stack_t uc_stack;
  144. mcontext_t uc_mcontext;
  145. } ucontext_t;
  146. #endif /* sys/ucontext.h */