Home | History | Annotate | Line # | Download | only in include
mcontext.h revision 1.3
      1 /*	$NetBSD: mcontext.h,v 1.3 2003/08/25 09:20:25 drochner Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Klaus Klein.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #ifndef _I386_MCONTEXT_H_
     40 #define _I386_MCONTEXT_H_
     41 
     42 /*
     43  * Layout of mcontext_t according to the System V Application Binary Interface,
     44  * Intel386(tm) Architecture Processor Supplement, Fourth Edition.
     45  */
     46 
     47 /*
     48  * General register state
     49  */
     50 #define _NGREG		19
     51 typedef	int		__greg_t;
     52 typedef	__greg_t	__gregset_t[_NGREG];
     53 
     54 #define _REG_GS		0
     55 #define _REG_FS		1
     56 #define _REG_ES		2
     57 #define _REG_DS		3
     58 #define _REG_EDI	4
     59 #define _REG_ESI	5
     60 #define _REG_EBP	6
     61 #define _REG_ESP	7
     62 #define _REG_EBX	8
     63 #define _REG_EDX	9
     64 #define _REG_ECX	10
     65 #define _REG_EAX	11
     66 #define _REG_TRAPNO	12
     67 #define _REG_ERR	13
     68 #define _REG_EIP	14
     69 #define _REG_CS		15
     70 #define _REG_EFL	16
     71 #define _REG_UESP	17
     72 #define _REG_SS		18
     73 
     74 /*
     75  * Floating point register state
     76  */
     77 typedef struct {
     78 	union {
     79 		struct {
     80 			int	__fp_state[27];	/* Environment and registers */
     81 			int	__fp_status;	/* Software status word */
     82 		} __fpchip_state;
     83 		struct {
     84 			char	__fp_emul[246];
     85 			char	__fp_epad[2];
     86 		} __fp_emul_space;
     87 		struct {
     88 			char	__fp_xmm[512];
     89 		} __fp_xmm_state;
     90 		int	__fp_fpregs[128];
     91 	} __fp_reg_set;
     92 	long	__fp_wregs[33];			/* Weitek? */
     93 } __fpregset_t;
     94 
     95 typedef struct {
     96 	__gregset_t	__gregs;
     97 	__fpregset_t	__fpregs;
     98 } mcontext_t;
     99 
    100 #define _UC_FXSAVE	0x20	/* FP state is in FXSAVE format in XMM space */
    101 
    102 #define _UC_MACHINE_PAD	5	/* Padding appended to ucontext_t */
    103 
    104 #define _UC_UCONTEXT_ALIGN	(~0xf)
    105 
    106 #ifdef _KERNEL
    107 #include "opt_vm86.h"
    108 #ifdef VM86
    109 /*#include <machine/psl.h>*/
    110 #define PSL_VM 0x00020000
    111 #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_UESP] + \
    112 	((uc)->uc_mcontext.__gregs[_REG_EFL] & PSL_VM ? \
    113 	 ((uc)->uc_mcontext.__gregs[_REG_SS] << 4) : 0))
    114 #else
    115 #define _UC_MACHINE_SP(uc)	((uc)->uc_mcontext.__gregs[_REG_UESP])
    116 #endif
    117 #endif
    118 
    119 #endif	/* !_I386_MCONTEXT_H_ */
    120