1 /* $OpenBSD: freebsd_machdep.h,v 1.7 2003/06/02 23:27:47 millert Exp $ */ 2 /* $NetBSD: freebsd_machdep.h,v 1.1 1995/10/10 01:22:35 mycroft Exp $ */ 3 4 /* 5 * Copyright (c) 1986, 1989, 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * William Jolitz. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * from: @(#)signal.h 8.1 (Berkeley) 6/11/93 36 * from: Id: signal.h,v 1.4 1994/08/21 04:55:30 paul Exp 37 * 38 * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 39 * from: Id: frame.h,v 1.10 1995/03/16 18:11:42 bde Exp 40 */ 41 #ifndef _FREEBSD_MACHDEP_H 42 #define _FREEBSD_MACHDEP_H 43 44 /* 45 * signal support 46 */ 47 48 struct freebsd_sigcontext { 49 int sc_onstack; /* sigstack state to restore */ 50 int sc_mask; /* signal mask to restore */ 51 int sc_esp; /* machine state */ 52 int sc_ebp; 53 int sc_isp; 54 int sc_eip; 55 int sc_eflags; 56 int sc_es; 57 int sc_ds; 58 int sc_cs; 59 int sc_ss; 60 int sc_edi; 61 int sc_esi; 62 int sc_ebx; 63 int sc_edx; 64 int sc_ecx; 65 int sc_eax; 66 }; 67 68 struct freebsd_sigframe { 69 int sf_signum; 70 int sf_code; 71 struct freebsd_sigcontext *sf_scp; 72 char *sf_addr; 73 sig_t sf_handler; 74 struct freebsd_sigcontext sf_sc; 75 }; 76 77 /* 78 * freebsd_ptrace(2) support 79 */ 80 81 #define FREEBSD_USRSTACK 0xefbfe000 /* USRSTACK */ 82 #define FREEBSD_U_AR0_OFFSET 0x0000045c /* offsetof(struct user, u_ar0) */ 83 #define FREEBSD_U_SAVEFP_OFFSET 0x00000070 84 /* offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_savefpu) */ 85 86 /* Exception/Trap Stack Frame */ 87 struct freebsd_trapframe { 88 int tf_es; 89 int tf_ds; 90 int tf_edi; 91 int tf_esi; 92 int tf_ebp; 93 int tf_isp; 94 int tf_ebx; 95 int tf_edx; 96 int tf_ecx; 97 int tf_eax; 98 int tf_trapno; 99 /* below portion defined in 386 hardware */ 100 int tf_err; 101 int tf_eip; 102 int tf_cs; 103 int tf_eflags; 104 /* below only when transitting rings (e.g. user to kernel) */ 105 int tf_esp; 106 int tf_ss; 107 }; 108 109 /* Environment information of floating point unit */ 110 struct freebsd_env87 { 111 long en_cw; /* control word (16bits) */ 112 long en_sw; /* status word (16bits) */ 113 long en_tw; /* tag word (16bits) */ 114 long en_fip; /* floating point instruction pointer */ 115 u_short en_fcs; /* floating code segment selector */ 116 u_short en_opcode; /* opcode last executed (11 bits ) */ 117 long en_foo; /* floating operand offset */ 118 long en_fos; /* floating operand segment selector */ 119 }; 120 121 /* Contents of each floating point accumulator */ 122 struct freebsd_fpacc87 { 123 #ifdef dontdef /* too unportable */ 124 u_long fp_mantlo; /* mantissa low (31:0) */ 125 u_long fp_manthi; /* mantissa high (63:32) */ 126 int fp_exp:15; /* exponent */ 127 int fp_sgn:1; /* mantissa sign */ 128 #else 129 u_char fp_bytes[10]; 130 #endif 131 }; 132 133 /* Floating point context */ 134 struct freebsd_save87 { 135 struct freebsd_env87 sv_env; /* floating point control/status */ 136 struct freebsd_fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */ 137 u_long sv_ex_sw; /* status word for last exception */ 138 /* 139 * Bogus padding for emulators. Emulators should use their own 140 * struct and arrange to store into this struct (ending here) 141 * before it is inspected for ptracing or for core dumps. Some 142 * emulators overwrite the whole struct. We have no good way of 143 * knowing how much padding to leave. Leave just enough for the 144 * GPL emulator's i387_union (176 bytes total). 145 */ 146 u_char sv_pad[64]; /* padding; used by emulators */ 147 }; 148 149 struct freebsd_ptrace_reg { 150 struct freebsd_trapframe freebsd_ptrace_regs; 151 struct freebsd_save87 freebsd_ptrace_fpregs; 152 }; 153 154 /* sys/i386/include/exec.h */ 155 #define FREEBSD___LDPGSZ 4096 156 157 #ifdef _KERNEL 158 void freebsd_sendsig(sig_t, int, int, u_long, int, union sigval); 159 #endif 160 161 #endif /* _FREEBSD_MACHDEP_H */