ucontext.h revision 118590
1/*-
2 * Copyright (c) 1999 Marcel Moolenaar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer
10 *    in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 *    derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/ia64/include/ucontext.h 118590 2003-08-07 07:52:39Z marcel $
29 */
30
31#ifndef _MACHINE_UCONTEXT_H_
32#define	_MACHINE_UCONTEXT_H_
33
34#include <machine/_regset.h>
35
36/*
37 * The mc_flags field provides the necessary clues when dealing with the gory
38 * details of ia64 specific contexts. A comprehensive explanation is added for
39 * everybody's sanity, including the author's.
40 *
41 * The first and foremost variation in the context is synchronous contexts
42 * (= synctx) versus asynchronous contexts (= asynctx). A synctx is created
43 * synchronously WRT program execution and has the advantage that none of the
44 * scratch registers have to be saved. They are assumed to be clobbered by the
45 * call to the function that creates the context. An asynctx needs to have the
46 * scratch registers preserved because it can describe any point in a thread's
47 * (or process') execution.
48 *
49 * Below a description of the flags and their meaning:
50 *
51 *	_MC_FLAGS_ASYNC_CONTEXT
52 *		If set, indicates that mc_scratch and mc_scratch_fp are both
53 *		valid. IFF not set, _MC_FLAGS_RETURN_VALID indicates if the
54 *		return registers are valid or not.
55 *	_MC_FLAGS_HIGHFP_VALID
56 *		If set, indicates that the high FP registers (f32-f127) are
57 *		valid. This flag is very likely not going to be set for any
58 *		sensible synctx, but is not explicitly disallowed. Any synctx
59 *		that has this flag may or may not have the high FP registers
60 *		restored. In short: don't do it.
61 *	_MC_FLAGS_KSE_SET_MBOX
62 *		This flag is special to setcontext(2) and swapcontext(2). It
63 *		instructs the kernel to write the value in mc_special.isr to
64 *		the memory address pointed to by mc_special.ifa. This allows
65 *		the kernel to switch to a new context in a KSE based threaded
66 *		program. Note that this is a non-srandard extension to the
67 *		otherwise standard system calls and use of this flag should be
68 *		limited to KSE.
69 *	_MC_FLAGS_RETURN_VALID
70 *		If set and _MC_FLAGS_ASYNC_CONTEXT is not set indicates that
71 *		the ABI defined return registers are valid. Both getcontext(2)
72 *		and swapcontext(2) need to save the system call return values.
73 *		Any synctx that does not have this flag may still have the
74 *		return registers restored from the context.
75 *	_MC_FLAGS_SCRATCH_VALID
76 *		If set and _MC_FLAGS_ASYNC_CONTEXT is not set indicates that
77 *		the scratch registers, but not the FP registers are valid.
78 *		This flag is set in contexts passed to signal handlers. This
79 *		flag is a superset of _MC_FLAGS_RETURN_VALID. If both flags
80 *		are set, this flag takes precedence.
81 */
82
83typedef struct __mcontext {
84	unsigned long		mc_flags;
85#define	_MC_FLAGS_ASYNC_CONTEXT		0x0001
86#define	_MC_FLAGS_HIGHFP_VALID		0x0002
87#define	_MC_FLAGS_KSE_SET_MBOX		0x0004
88#define	_MC_FLAGS_RETURN_VALID		0x0008
89#define	_MC_FLAGS_SCRATCH_VALID		0x0010
90	unsigned long		_reserved_;
91	struct _special		mc_special;
92	struct _callee_saved	mc_preserved;
93	struct _callee_saved_fp	mc_preserved_fp;
94	struct _caller_saved	mc_scratch;
95	struct _caller_saved_fp	mc_scratch_fp;
96	struct _high_fp		mc_high_fp;
97} mcontext_t;
98
99#endif /* !_MACHINE_UCONTEXT_H_ */
100