ucontext.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* Copyright (C) 1998, 1999, 2002, 2003 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. /* System V/mips ABI compliant context switching support. */
  16. #ifndef _SYS_UCONTEXT_H
  17. #define _SYS_UCONTEXT_H 1
  18. #include <features.h>
  19. #include <signal.h>
  20. /* Type for general register. */
  21. #if _MIPS_SIM == _MIPS_SIM_ABI32
  22. typedef __uint32_t greg_t;
  23. #else
  24. typedef __uint64_t greg_t;
  25. #endif
  26. /* Number of general registers. */
  27. #define NGREG 36
  28. /* Container for all general registers. */
  29. typedef greg_t gregset_t[NGREG];
  30. /* Number of each register is the `gregset_t' array. */
  31. enum
  32. {
  33. CTX_R0 = 0,
  34. #define CTX_R0 CTX_R0
  35. CTX_AT = 1,
  36. #define CTX_AT CTX_AT
  37. CTX_V0 = 2,
  38. #define CTX_V0 CTX_V0
  39. CTX_V1 = 3,
  40. #define CTX_V1 CTX_V1
  41. CTX_A0 = 4,
  42. #define CTX_A0 CTX_A0
  43. CTX_A1 = 5,
  44. #define CTX_A1 CTX_A1
  45. CTX_A2 = 6,
  46. #define CTX_A2 CTX_A2
  47. CTX_A3 = 7,
  48. #define CTX_A3 CTX_A3
  49. CTX_T0 = 8,
  50. #define CTX_T0 CTX_T0
  51. CTX_T1 = 9,
  52. #define CTX_T1 CTX_T1
  53. CTX_T2 = 10,
  54. #define CTX_T2 CTX_T2
  55. CTX_T3 = 11,
  56. #define CTX_T3 CTX_T3
  57. CTX_T4 = 12,
  58. #define CTX_T4 CTX_T4
  59. CTX_T5 = 13,
  60. #define CTX_T5 CTX_T5
  61. CTX_T6 = 14,
  62. #define CTX_T6 CTX_T6
  63. CTX_T7 = 15,
  64. #define CTX_T7 CTX_T7
  65. CTX_S0 = 16,
  66. #define CTX_S0 CTX_S0
  67. CTX_S1 = 17,
  68. #define CTX_S1 CTX_S1
  69. CTX_S2 = 18,
  70. #define CTX_S2 CTX_S2
  71. CTX_S3 = 19,
  72. #define CTX_S3 CTX_S3
  73. CTX_S4 = 20,
  74. #define CTX_S4 CTX_S4
  75. CTX_S5 = 21,
  76. #define CTX_S5 CTX_S5
  77. CTX_S6 = 22,
  78. #define CTX_S6 CTX_S6
  79. CTX_S7 = 23,
  80. #define CTX_S7 CTX_S7
  81. CTX_T8 = 24,
  82. #define CTX_T8 CTX_T8
  83. CTX_T9 = 25,
  84. #define CTX_T9 CTX_T9
  85. CTX_K0 = 26,
  86. #define CTX_K0 CTX_K0
  87. CTX_K1 = 27,
  88. #define CTX_K1 CTX_K1
  89. CTX_GP = 28,
  90. #define CTX_GP CTX_GP
  91. CTX_SP = 29,
  92. #define CTX_SP CTX_SP
  93. CTX_S8 = 30,
  94. #define CTX_S8 CTX_S8
  95. CTX_RA = 31,
  96. #define CTX_RA CTX_RA
  97. CTX_MDLO = 32,
  98. #define CTX_MDLO CTX_MDLO
  99. CTX_MDHI = 33,
  100. #define CTX_MDHI CTX_MDHI
  101. CTX_CAUSE = 34,
  102. #define CTX_CAUSE CTX_CAUSE
  103. CTX_EPC = 35,
  104. #define CTX_EPC CTX_EPC
  105. };
  106. /* Structure to describe FPU registers. */
  107. typedef struct fpregset
  108. {
  109. union
  110. {
  111. #if _MIPS_SIM == _MIPS_SIM_ABI32
  112. double fp_dregs[16];
  113. float fp_fregs[32];
  114. unsigned int fp_regs[32];
  115. #else
  116. double fp_dregs[32];
  117. /* float fp_fregs[32]; */
  118. __uint64_t fp_regs[32];
  119. #endif
  120. } fp_r;
  121. unsigned int fp_csr;
  122. unsigned int fp_pad;
  123. } fpregset_t;
  124. /* Context to describe whole processor state. */
  125. typedef struct
  126. {
  127. gregset_t gpregs;
  128. fpregset_t fpregs;
  129. } mcontext_t;
  130. /* Userlevel context. */
  131. typedef struct ucontext
  132. {
  133. #if _MIPS_SIM == _MIPS_SIM_ABI32
  134. unsigned long int uc_flags;
  135. #else
  136. __uint64_t uc_flags;
  137. #endif
  138. struct ucontext *uc_link;
  139. __sigset_t uc_sigmask;
  140. stack_t uc_stack;
  141. mcontext_t uc_mcontext;
  142. int uc_filler[48];
  143. } ucontext_t;
  144. #endif /* sys/ucontext.h */