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