Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / ucontext.h @ 13

History | View | Annotate | Download (4.36 KB)

1
/*        $NetBSD: ucontext.h,v 1.18 2013/03/06 18:16:58 pooka Exp $        */
2

    
3
/*-
4
 * Copyright (c) 1999, 2003 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, and by Jason R. Thorpe.
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
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
 * POSSIBILITY OF SUCH DAMAGE.
30
 */
31

    
32
#ifndef _SYS_UCONTEXT_H_
33
#define _SYS_UCONTEXT_H_
34

    
35
#include <sys/sigtypes.h>
36
#include <machine/mcontext.h>
37

    
38
typedef struct __ucontext        ucontext_t;
39

    
40
struct __ucontext {
41
        unsigned int        uc_flags;        /* properties */
42
        ucontext_t *         uc_link;        /* context to resume */
43
        sigset_t        uc_sigmask;        /* signals blocked in this context */
44
        stack_t                uc_stack;        /* the stack used by this context */
45
        mcontext_t        uc_mcontext;        /* machine state */
46
#if defined(_UC_MACHINE_PAD)
47
        long                __uc_pad[_UC_MACHINE_PAD];
48
#endif
49
};
50

    
51
#ifndef _UC_UCONTEXT_ALIGN
52
#define _UC_UCONTEXT_ALIGN (~0)
53
#endif
54

    
55
/* uc_flags */
56
#define _UC_SIGMASK        0x01                /* valid uc_sigmask */
57
#define _UC_STACK        0x02                /* valid uc_stack */
58
#define _UC_CPU                0x04                /* valid GPR context in uc_mcontext */
59
#define _UC_FPU                0x08                /* valid FPU context in uc_mcontext */
60
#if defined(__minix)
61
#define        _UC_SWAPPED        0x10000
62
#define _UC_IGNFPU      0x20000
63
#define _UC_IGNSIGM     0x40000
64
#endif /* defined(__minix) */
65
#define        _UC_MD                0x400f0020        /* MD bits.  see below */
66

    
67
/*
68
 * if your port needs more MD bits, please try to choose bits from _UC_MD
69
 * first, rather than picking random unused bits.
70
 *
71
 * _UC_MD details
72
 *
73
 *         _UC_TLSBASE        Context contains valid pthread private pointer 
74
 *                        All ports must define this MD flag
75
 *                         0x00040000        hppa, mips
76
 *                         0x00000020        alpha
77
 *                        0x00080000        all other ports
78
 *
79
 *        _UC_SETSTACK        Context uses signal stack
80
 *                        0x00020000        arm
81
 *                        [undefined]        alpha, powerpc and vax
82
 *                        0x00010000        other ports
83
 *
84
 *        _UC_CLRSTACK        Context does not use signal stack
85
 *                        0x00040000        arm
86
 *                        [undefined]        alpha, powerpc and vax
87
 *                        0x00020000        other ports
88
 *
89
 *        _UC_POWERPC_VEC Context does not use signal stack
90
 *                        0x00010000        powerpc only
91
 *
92
 *        _UC_POWERPC_SPE        Context contains valid SPE context
93
 *                        0x00020000        powerpc only
94
 *
95
 *        _UC_M68K_UC_USER Used by m68k machdep code, but undocumented
96
 *                        0x40000000        m68k only
97
 *
98
 *        _UC_ARM_VFP        Unused
99
 *                        0x00010000        arm only
100
 *
101
 *        _UC_VM                Context contains valid virtual 8086 context
102
 *                        0x00040000        i386, amd64 only
103
 *
104
 *        _UC_FXSAVE        Context contains FPU context in that 
105
 *                        is in FXSAVE format in XMM space 
106
 *                        0x00000020        i386, amd64 only
107
 */
108

    
109
#ifdef _KERNEL
110
struct lwp;
111

    
112
void        getucontext(struct lwp *, ucontext_t *);
113
int        setucontext(struct lwp *, const ucontext_t *);
114
void        cpu_getmcontext(struct lwp *, mcontext_t *, unsigned int *);
115
int        cpu_setmcontext(struct lwp *, const mcontext_t *, unsigned int);
116
int        cpu_mcontext_validate(struct lwp *, const mcontext_t *);
117

    
118
#ifdef __UCONTEXT_SIZE
119
__CTASSERT(sizeof(ucontext_t) == __UCONTEXT_SIZE);
120
#endif
121
#endif /* _KERNEL */
122

    
123
#if defined(__minix)
124
__BEGIN_DECLS
125
void resumecontext(ucontext_t *ucp);
126
 
127
/* These functions get and set ucontext structure through PM/kernel. They don't
128
 * manipulate the stack. */
129
int getuctx(ucontext_t *ucp);
130
int setuctx(const ucontext_t *ucp);
131
__END_DECLS
132
#endif /* defined(__minix) */
133

    
134
#endif /* !_SYS_UCONTEXT_H_ */