1*6c8f7fc3SBen Gras /* $NetBSD: frame.h,v 1.35 2012/02/19 21:06:11 rmind Exp $ */ 2*6c8f7fc3SBen Gras 3*6c8f7fc3SBen Gras /*- 4*6c8f7fc3SBen Gras * Copyright (c) 1998 The NetBSD Foundation, Inc. 5*6c8f7fc3SBen Gras * All rights reserved. 6*6c8f7fc3SBen Gras * 7*6c8f7fc3SBen Gras * This code is derived from software contributed to The NetBSD Foundation 8*6c8f7fc3SBen Gras * by Charles M. Hannum. 9*6c8f7fc3SBen Gras * 10*6c8f7fc3SBen Gras * Redistribution and use in source and binary forms, with or without 11*6c8f7fc3SBen Gras * modification, are permitted provided that the following conditions 12*6c8f7fc3SBen Gras * are met: 13*6c8f7fc3SBen Gras * 1. Redistributions of source code must retain the above copyright 14*6c8f7fc3SBen Gras * notice, this list of conditions and the following disclaimer. 15*6c8f7fc3SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 16*6c8f7fc3SBen Gras * notice, this list of conditions and the following disclaimer in the 17*6c8f7fc3SBen Gras * documentation and/or other materials provided with the distribution. 18*6c8f7fc3SBen Gras * 19*6c8f7fc3SBen Gras * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20*6c8f7fc3SBen Gras * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21*6c8f7fc3SBen Gras * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22*6c8f7fc3SBen Gras * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23*6c8f7fc3SBen Gras * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24*6c8f7fc3SBen Gras * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25*6c8f7fc3SBen Gras * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26*6c8f7fc3SBen Gras * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27*6c8f7fc3SBen Gras * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28*6c8f7fc3SBen Gras * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29*6c8f7fc3SBen Gras * POSSIBILITY OF SUCH DAMAGE. 30*6c8f7fc3SBen Gras */ 31*6c8f7fc3SBen Gras 32*6c8f7fc3SBen Gras /*- 33*6c8f7fc3SBen Gras * Copyright (c) 1990 The Regents of the University of California. 34*6c8f7fc3SBen Gras * All rights reserved. 35*6c8f7fc3SBen Gras * 36*6c8f7fc3SBen Gras * This code is derived from software contributed to Berkeley by 37*6c8f7fc3SBen Gras * William Jolitz. 38*6c8f7fc3SBen Gras * 39*6c8f7fc3SBen Gras * Redistribution and use in source and binary forms, with or without 40*6c8f7fc3SBen Gras * modification, are permitted provided that the following conditions 41*6c8f7fc3SBen Gras * are met: 42*6c8f7fc3SBen Gras * 1. Redistributions of source code must retain the above copyright 43*6c8f7fc3SBen Gras * notice, this list of conditions and the following disclaimer. 44*6c8f7fc3SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 45*6c8f7fc3SBen Gras * notice, this list of conditions and the following disclaimer in the 46*6c8f7fc3SBen Gras * documentation and/or other materials provided with the distribution. 47*6c8f7fc3SBen Gras * 3. Neither the name of the University nor the names of its contributors 48*6c8f7fc3SBen Gras * may be used to endorse or promote products derived from this software 49*6c8f7fc3SBen Gras * without specific prior written permission. 50*6c8f7fc3SBen Gras * 51*6c8f7fc3SBen Gras * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 52*6c8f7fc3SBen Gras * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 53*6c8f7fc3SBen Gras * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 54*6c8f7fc3SBen Gras * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 55*6c8f7fc3SBen Gras * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 56*6c8f7fc3SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 57*6c8f7fc3SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 58*6c8f7fc3SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 59*6c8f7fc3SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 60*6c8f7fc3SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 61*6c8f7fc3SBen Gras * SUCH DAMAGE. 62*6c8f7fc3SBen Gras * 63*6c8f7fc3SBen Gras * @(#)frame.h 5.2 (Berkeley) 1/18/91 64*6c8f7fc3SBen Gras */ 65*6c8f7fc3SBen Gras 66*6c8f7fc3SBen Gras #ifndef _I386_FRAME_H_ 67*6c8f7fc3SBen Gras #define _I386_FRAME_H_ 68*6c8f7fc3SBen Gras 69*6c8f7fc3SBen Gras #include <sys/signal.h> 70*6c8f7fc3SBen Gras 71*6c8f7fc3SBen Gras /* 72*6c8f7fc3SBen Gras * System stack frames. 73*6c8f7fc3SBen Gras */ 74*6c8f7fc3SBen Gras 75*6c8f7fc3SBen Gras /* 76*6c8f7fc3SBen Gras * Exception/Trap Stack Frame 77*6c8f7fc3SBen Gras */ 78*6c8f7fc3SBen Gras struct trapframe { 79*6c8f7fc3SBen Gras uint16_t tf_gs; 80*6c8f7fc3SBen Gras uint16_t tf_gs_pad; 81*6c8f7fc3SBen Gras uint16_t tf_fs; 82*6c8f7fc3SBen Gras uint16_t tf_fs_pad; 83*6c8f7fc3SBen Gras uint16_t tf_es; 84*6c8f7fc3SBen Gras uint16_t tf_es_pad; 85*6c8f7fc3SBen Gras uint16_t tf_ds; 86*6c8f7fc3SBen Gras uint16_t tf_ds_pad; 87*6c8f7fc3SBen Gras int tf_edi; 88*6c8f7fc3SBen Gras int tf_esi; 89*6c8f7fc3SBen Gras int tf_ebp; 90*6c8f7fc3SBen Gras int tf_ebx; 91*6c8f7fc3SBen Gras int tf_edx; 92*6c8f7fc3SBen Gras int tf_ecx; 93*6c8f7fc3SBen Gras int tf_eax; 94*6c8f7fc3SBen Gras int tf_trapno; 95*6c8f7fc3SBen Gras /* below portion defined in 386 hardware */ 96*6c8f7fc3SBen Gras int tf_err; 97*6c8f7fc3SBen Gras int tf_eip; 98*6c8f7fc3SBen Gras int tf_cs; 99*6c8f7fc3SBen Gras int tf_eflags; 100*6c8f7fc3SBen Gras /* below used when transitting rings (e.g. user to kernel) */ 101*6c8f7fc3SBen Gras int tf_esp; 102*6c8f7fc3SBen Gras int tf_ss; 103*6c8f7fc3SBen Gras /* below used when switching out of VM86 mode */ 104*6c8f7fc3SBen Gras int tf_vm86_es; 105*6c8f7fc3SBen Gras int tf_vm86_ds; 106*6c8f7fc3SBen Gras int tf_vm86_fs; 107*6c8f7fc3SBen Gras int tf_vm86_gs; 108*6c8f7fc3SBen Gras }; 109*6c8f7fc3SBen Gras 110*6c8f7fc3SBen Gras /* 111*6c8f7fc3SBen Gras * Interrupt stack frame 112*6c8f7fc3SBen Gras */ 113*6c8f7fc3SBen Gras struct intrframe { 114*6c8f7fc3SBen Gras int if_ppl; 115*6c8f7fc3SBen Gras int if_gs; 116*6c8f7fc3SBen Gras int if_fs; 117*6c8f7fc3SBen Gras int if_es; 118*6c8f7fc3SBen Gras int if_ds; 119*6c8f7fc3SBen Gras int if_edi; 120*6c8f7fc3SBen Gras int if_esi; 121*6c8f7fc3SBen Gras int if_ebp; 122*6c8f7fc3SBen Gras int if_ebx; 123*6c8f7fc3SBen Gras int if_edx; 124*6c8f7fc3SBen Gras int if_ecx; 125*6c8f7fc3SBen Gras int if_eax; 126*6c8f7fc3SBen Gras uint32_t __if_trapno; /* for compat with trap frame - trapno */ 127*6c8f7fc3SBen Gras uint32_t __if_err; /* for compat with trap frame - err */ 128*6c8f7fc3SBen Gras /* below portion defined in 386 hardware */ 129*6c8f7fc3SBen Gras int if_eip; 130*6c8f7fc3SBen Gras int if_cs; 131*6c8f7fc3SBen Gras int if_eflags; 132*6c8f7fc3SBen Gras /* below only when transitting rings (e.g. user to kernel) */ 133*6c8f7fc3SBen Gras int if_esp; 134*6c8f7fc3SBen Gras int if_ss; 135*6c8f7fc3SBen Gras }; 136*6c8f7fc3SBen Gras 137*6c8f7fc3SBen Gras /* 138*6c8f7fc3SBen Gras * Stack frame inside cpu_switchto() 139*6c8f7fc3SBen Gras */ 140*6c8f7fc3SBen Gras struct switchframe { 141*6c8f7fc3SBen Gras int sf_edi; 142*6c8f7fc3SBen Gras int sf_esi; 143*6c8f7fc3SBen Gras int sf_ebx; 144*6c8f7fc3SBen Gras int sf_eip; 145*6c8f7fc3SBen Gras }; 146*6c8f7fc3SBen Gras 147*6c8f7fc3SBen Gras #ifdef _KERNEL 148*6c8f7fc3SBen Gras /* 149*6c8f7fc3SBen Gras * Old-style signal frame 150*6c8f7fc3SBen Gras */ 151*6c8f7fc3SBen Gras struct sigframe_sigcontext { 152*6c8f7fc3SBen Gras int sf_ra; /* return address for handler */ 153*6c8f7fc3SBen Gras int sf_signum; /* "signum" argument for handler */ 154*6c8f7fc3SBen Gras int sf_code; /* "code" argument for handler */ 155*6c8f7fc3SBen Gras struct sigcontext *sf_scp; /* "scp" argument for handler */ 156*6c8f7fc3SBen Gras struct sigcontext sf_sc; /* actual saved context */ 157*6c8f7fc3SBen Gras }; 158*6c8f7fc3SBen Gras #endif 159*6c8f7fc3SBen Gras 160*6c8f7fc3SBen Gras /* 161*6c8f7fc3SBen Gras * New-style signal frame 162*6c8f7fc3SBen Gras */ 163*6c8f7fc3SBen Gras struct sigframe_siginfo { 164*6c8f7fc3SBen Gras int sf_ra; /* return address for handler */ 165*6c8f7fc3SBen Gras int sf_signum; /* "signum" argument for handler */ 166*6c8f7fc3SBen Gras siginfo_t *sf_sip; /* "sip" argument for handler */ 167*6c8f7fc3SBen Gras ucontext_t *sf_ucp; /* "ucp" argument for handler */ 168*6c8f7fc3SBen Gras siginfo_t sf_si; /* actual saved siginfo */ 169*6c8f7fc3SBen Gras ucontext_t sf_uc; /* actual saved ucontext */ 170*6c8f7fc3SBen Gras }; 171*6c8f7fc3SBen Gras 172*6c8f7fc3SBen Gras #ifdef _KERNEL 173*6c8f7fc3SBen Gras void *getframe(struct lwp *, int, int *); 174*6c8f7fc3SBen Gras void buildcontext(struct lwp *, int, void *, void *); 175*6c8f7fc3SBen Gras void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *); 176*6c8f7fc3SBen Gras #endif 177*6c8f7fc3SBen Gras 178*6c8f7fc3SBen Gras #endif /* _I386_FRAME_H_ */ 179