xref: /minix3/sys/arch/i386/include/frame.h (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
16c8f7fc3SBen Gras /*	$NetBSD: frame.h,v 1.35 2012/02/19 21:06:11 rmind Exp $	*/
26c8f7fc3SBen Gras 
36c8f7fc3SBen Gras /*-
46c8f7fc3SBen Gras  * Copyright (c) 1998 The NetBSD Foundation, Inc.
56c8f7fc3SBen Gras  * All rights reserved.
66c8f7fc3SBen Gras  *
76c8f7fc3SBen Gras  * This code is derived from software contributed to The NetBSD Foundation
86c8f7fc3SBen Gras  * by Charles M. Hannum.
96c8f7fc3SBen Gras  *
106c8f7fc3SBen Gras  * Redistribution and use in source and binary forms, with or without
116c8f7fc3SBen Gras  * modification, are permitted provided that the following conditions
126c8f7fc3SBen Gras  * are met:
136c8f7fc3SBen Gras  * 1. Redistributions of source code must retain the above copyright
146c8f7fc3SBen Gras  *    notice, this list of conditions and the following disclaimer.
156c8f7fc3SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
166c8f7fc3SBen Gras  *    notice, this list of conditions and the following disclaimer in the
176c8f7fc3SBen Gras  *    documentation and/or other materials provided with the distribution.
186c8f7fc3SBen Gras  *
196c8f7fc3SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
206c8f7fc3SBen Gras  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
216c8f7fc3SBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
226c8f7fc3SBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
236c8f7fc3SBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
246c8f7fc3SBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
256c8f7fc3SBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
266c8f7fc3SBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
276c8f7fc3SBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
286c8f7fc3SBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
296c8f7fc3SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
306c8f7fc3SBen Gras  */
316c8f7fc3SBen Gras 
326c8f7fc3SBen Gras /*-
336c8f7fc3SBen Gras  * Copyright (c) 1990 The Regents of the University of California.
346c8f7fc3SBen Gras  * All rights reserved.
356c8f7fc3SBen Gras  *
366c8f7fc3SBen Gras  * This code is derived from software contributed to Berkeley by
376c8f7fc3SBen Gras  * William Jolitz.
386c8f7fc3SBen Gras  *
396c8f7fc3SBen Gras  * Redistribution and use in source and binary forms, with or without
406c8f7fc3SBen Gras  * modification, are permitted provided that the following conditions
416c8f7fc3SBen Gras  * are met:
426c8f7fc3SBen Gras  * 1. Redistributions of source code must retain the above copyright
436c8f7fc3SBen Gras  *    notice, this list of conditions and the following disclaimer.
446c8f7fc3SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
456c8f7fc3SBen Gras  *    notice, this list of conditions and the following disclaimer in the
466c8f7fc3SBen Gras  *    documentation and/or other materials provided with the distribution.
476c8f7fc3SBen Gras  * 3. Neither the name of the University nor the names of its contributors
486c8f7fc3SBen Gras  *    may be used to endorse or promote products derived from this software
496c8f7fc3SBen Gras  *    without specific prior written permission.
506c8f7fc3SBen Gras  *
516c8f7fc3SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
526c8f7fc3SBen Gras  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
536c8f7fc3SBen Gras  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
546c8f7fc3SBen Gras  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
556c8f7fc3SBen Gras  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
566c8f7fc3SBen Gras  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
576c8f7fc3SBen Gras  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
586c8f7fc3SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
596c8f7fc3SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
606c8f7fc3SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
616c8f7fc3SBen Gras  * SUCH DAMAGE.
626c8f7fc3SBen Gras  *
636c8f7fc3SBen Gras  *	@(#)frame.h	5.2 (Berkeley) 1/18/91
646c8f7fc3SBen Gras  */
656c8f7fc3SBen Gras 
666c8f7fc3SBen Gras #ifndef _I386_FRAME_H_
676c8f7fc3SBen Gras #define _I386_FRAME_H_
686c8f7fc3SBen Gras 
696c8f7fc3SBen Gras #include <sys/signal.h>
706c8f7fc3SBen Gras 
716c8f7fc3SBen Gras /*
726c8f7fc3SBen Gras  * System stack frames.
736c8f7fc3SBen Gras  */
746c8f7fc3SBen Gras 
756c8f7fc3SBen Gras /*
766c8f7fc3SBen Gras  * Exception/Trap Stack Frame
776c8f7fc3SBen Gras  */
786c8f7fc3SBen Gras struct trapframe {
796c8f7fc3SBen Gras 	uint16_t	tf_gs;
806c8f7fc3SBen Gras 	uint16_t	tf_gs_pad;
816c8f7fc3SBen Gras 	uint16_t	tf_fs;
826c8f7fc3SBen Gras 	uint16_t	tf_fs_pad;
836c8f7fc3SBen Gras 	uint16_t	tf_es;
846c8f7fc3SBen Gras 	uint16_t	tf_es_pad;
856c8f7fc3SBen Gras 	uint16_t	tf_ds;
866c8f7fc3SBen Gras 	uint16_t	tf_ds_pad;
876c8f7fc3SBen Gras 	int	tf_edi;
886c8f7fc3SBen Gras 	int	tf_esi;
896c8f7fc3SBen Gras 	int	tf_ebp;
906c8f7fc3SBen Gras 	int	tf_ebx;
916c8f7fc3SBen Gras 	int	tf_edx;
926c8f7fc3SBen Gras 	int	tf_ecx;
936c8f7fc3SBen Gras 	int	tf_eax;
946c8f7fc3SBen Gras 	int	tf_trapno;
956c8f7fc3SBen Gras 	/* below portion defined in 386 hardware */
966c8f7fc3SBen Gras 	int	tf_err;
976c8f7fc3SBen Gras 	int	tf_eip;
986c8f7fc3SBen Gras 	int	tf_cs;
996c8f7fc3SBen Gras 	int	tf_eflags;
1006c8f7fc3SBen Gras 	/* below used when transitting rings (e.g. user to kernel) */
1016c8f7fc3SBen Gras 	int	tf_esp;
1026c8f7fc3SBen Gras 	int	tf_ss;
1036c8f7fc3SBen Gras 	/* below used when switching out of VM86 mode */
1046c8f7fc3SBen Gras 	int	tf_vm86_es;
1056c8f7fc3SBen Gras 	int	tf_vm86_ds;
1066c8f7fc3SBen Gras 	int	tf_vm86_fs;
1076c8f7fc3SBen Gras 	int	tf_vm86_gs;
1086c8f7fc3SBen Gras };
1096c8f7fc3SBen Gras 
1106c8f7fc3SBen Gras /*
1116c8f7fc3SBen Gras  * Interrupt stack frame
1126c8f7fc3SBen Gras  */
1136c8f7fc3SBen Gras struct intrframe {
1146c8f7fc3SBen Gras 	int	if_ppl;
1156c8f7fc3SBen Gras 	int	if_gs;
1166c8f7fc3SBen Gras 	int	if_fs;
1176c8f7fc3SBen Gras 	int	if_es;
1186c8f7fc3SBen Gras 	int	if_ds;
1196c8f7fc3SBen Gras 	int	if_edi;
1206c8f7fc3SBen Gras 	int	if_esi;
1216c8f7fc3SBen Gras 	int	if_ebp;
1226c8f7fc3SBen Gras 	int	if_ebx;
1236c8f7fc3SBen Gras 	int	if_edx;
1246c8f7fc3SBen Gras 	int	if_ecx;
1256c8f7fc3SBen Gras 	int	if_eax;
1266c8f7fc3SBen Gras 	uint32_t __if_trapno;	/* for compat with trap frame - trapno */
1276c8f7fc3SBen Gras 	uint32_t __if_err;	/* for compat with trap frame - err */
1286c8f7fc3SBen Gras 	/* below portion defined in 386 hardware */
1296c8f7fc3SBen Gras 	int	if_eip;
1306c8f7fc3SBen Gras 	int	if_cs;
1316c8f7fc3SBen Gras 	int	if_eflags;
1326c8f7fc3SBen Gras 	/* below only when transitting rings (e.g. user to kernel) */
1336c8f7fc3SBen Gras 	int	if_esp;
1346c8f7fc3SBen Gras 	int	if_ss;
1356c8f7fc3SBen Gras };
1366c8f7fc3SBen Gras 
1376c8f7fc3SBen Gras /*
1386c8f7fc3SBen Gras  * Stack frame inside cpu_switchto()
1396c8f7fc3SBen Gras  */
1406c8f7fc3SBen Gras struct switchframe {
1416c8f7fc3SBen Gras 	int	sf_edi;
1426c8f7fc3SBen Gras 	int	sf_esi;
1436c8f7fc3SBen Gras 	int	sf_ebx;
1446c8f7fc3SBen Gras 	int	sf_eip;
1456c8f7fc3SBen Gras };
1466c8f7fc3SBen Gras 
1477597f4a8SBen Gras #if defined(_KERNEL) || defined(__minix)
1486c8f7fc3SBen Gras /*
1496c8f7fc3SBen Gras  * Old-style signal frame
1506c8f7fc3SBen Gras  */
1516c8f7fc3SBen Gras struct sigframe_sigcontext {
152*84d9c625SLionel Sambuc #if defined(__minix)
1537597f4a8SBen Gras 	/* ret addr + stackframe for handler */
1547597f4a8SBen Gras 	int	sf_ra_sigreturn;	/* first return to sigreturn */
1557597f4a8SBen Gras #else
1566c8f7fc3SBen Gras 	int	sf_ra;			/* return address for handler */
157*84d9c625SLionel Sambuc #endif /* defined(__minix) */
1586c8f7fc3SBen Gras 	int	sf_signum;		/* "signum" argument for handler */
1596c8f7fc3SBen Gras 	int	sf_code;		/* "code" argument for handler */
1606c8f7fc3SBen Gras 	struct	sigcontext *sf_scp;	/* "scp" argument for handler */
161*84d9c625SLionel Sambuc #if defined(__minix)
1627597f4a8SBen Gras 	/* ret addr + stackframe for sigreturn */
1637597f4a8SBen Gras 	uint32_t sf_fp;			/* saved FP */
1647597f4a8SBen Gras 	int	sf_ra;			/* actual return address for handler */
1657597f4a8SBen Gras 	struct	sigcontext *sf_scpcopy;	/* minix scp copy */
166*84d9c625SLionel Sambuc #endif /* defined(__minix) */
1676c8f7fc3SBen Gras 	struct	sigcontext sf_sc;	/* actual saved context */
1686c8f7fc3SBen Gras };
1696c8f7fc3SBen Gras #endif
1706c8f7fc3SBen Gras 
1716c8f7fc3SBen Gras /*
1726c8f7fc3SBen Gras  * New-style signal frame
1736c8f7fc3SBen Gras  */
1746c8f7fc3SBen Gras struct sigframe_siginfo {
1756c8f7fc3SBen Gras 	int		sf_ra;		/* return address for handler */
1766c8f7fc3SBen Gras 	int		sf_signum;	/* "signum" argument for handler */
1776c8f7fc3SBen Gras 	siginfo_t	*sf_sip;	/* "sip" argument for handler */
1786c8f7fc3SBen Gras 	ucontext_t	*sf_ucp;	/* "ucp" argument for handler */
1796c8f7fc3SBen Gras 	siginfo_t	sf_si;		/* actual saved siginfo */
1806c8f7fc3SBen Gras 	ucontext_t	sf_uc;		/* actual saved ucontext */
1816c8f7fc3SBen Gras };
1826c8f7fc3SBen Gras 
1836c8f7fc3SBen Gras #ifdef _KERNEL
1846c8f7fc3SBen Gras void *getframe(struct lwp *, int, int *);
1856c8f7fc3SBen Gras void buildcontext(struct lwp *, int, void *, void *);
1866c8f7fc3SBen Gras void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *);
1876c8f7fc3SBen Gras #endif
1886c8f7fc3SBen Gras 
1896c8f7fc3SBen Gras #endif  /* _I386_FRAME_H_ */
190