Home | History | Annotate | Line # | Download | only in include
mcontext.h revision 1.2
      1 /*	$NetBSD: mcontext.h,v 1.2 2003/10/06 22:53:48 fvdl 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 _AMD64_MCONTEXT_H_
     40 #define _AMD64_MCONTEXT_H_
     41 
     42 /*
     43  * General register state
     44  */
     45 #define _NGREG		26
     46 typedef	long		__greg_t;
     47 typedef	__greg_t	__gregset_t[_NGREG];
     48 
     49 /*
     50  * This is laid out to match trapframe and intrframe (see <machine/frame.h>).
     51  * Hence, memcpy between gregs and a trapframe is possible.
     52  */
     53 #define _REG_RDI	0
     54 #define _REG_RSI	1
     55 #define _REG_RDX	2
     56 #define _REG_RCX	3
     57 #define _REG_R8		4
     58 #define _REG_R9		5
     59 #define _REG_R10	6
     60 #define _REG_R11	7
     61 #define _REG_R12	8
     62 #define _REG_R13	9
     63 #define _REG_R14	10
     64 #define _REG_R15	11
     65 #define _REG_RBP	12
     66 #define _REG_RBX	13
     67 #define _REG_RAX	14
     68 #define _REG_GS		15
     69 #define _REG_FS		16
     70 #define _REG_ES		17
     71 #define _REG_DS		18
     72 #define _REG_TRAPNO	19
     73 #define _REG_ERR	20
     74 #define _REG_RIP	21
     75 #define _REG_CS		22
     76 #define _REG_RFL	23
     77 #define _REG_URSP	24
     78 #define _REG_SS		25
     79 
     80 /*
     81  * Floating point register state
     82  */
     83 typedef char __fpregset_t[512];
     84 
     85 /*
     86  * The padding below is to make __fpregs have a 16-byte aligned offset
     87  * within ucontext_t.
     88  */
     89 
     90 typedef struct {
     91 	__gregset_t	__gregs;
     92 	long 		__pad;
     93 	__fpregset_t	__fpregs;
     94 } mcontext_t;
     95 
     96 #define _UC_UCONTEXT_ALIGN	(~0xf)
     97 
     98 #ifdef _KERNEL
     99 #define _UC_MACHINE_SP(uc)	((uc)->uc_mcontext.__gregs[_REG_URSP])
    100 #endif
    101 
    102 /*
    103  * mcontext extensions to handle signal delivery.
    104  */
    105 #define _UC_SETSTACK	0x00010000
    106 #define _UC_CLRSTACK	0x00020000
    107 
    108 #endif	/* !_AMD64_MCONTEXT_H_ */
    109