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