ucontext.h revision 123255
1/*- 2 * Copyright (c) 1999, 2003 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 123255 2003-12-07 20:47:33Z 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 * The second variation is for synchronous contexts. When the kernel creates 49 * a synchronous context if needs to preserve the scratch registers, because 50 * the syscall argument and return values are stored there in the trapframe 51 * and they need to be preserved in order to restart a syscall or return the 52 * proper return values. Also, the IIP and CFM fields need to be preserved 53 * as they point to the syscall stub, which the kernel saves as a favor to 54 * userland (it keeps the stubs small and simple). 55 * 56 * Below a description of the flags and their meaning: 57 * 58 * _MC_FLAGS_ASYNC_CONTEXT 59 * If set, indicates that mc_scratch and mc_scratch_fp are both 60 * valid. IFF not set, _MC_FLAGS_SYSCALL_CONTEXT indicates if the 61 * synchronous context is one corresponding to a syscall or not. 62 * Only the kernel is expected to create such a context and it's 63 * probably wise to let the kernel restore it. 64 * _MC_FLAGS_HIGHFP_VALID 65 * If set, indicates that the high FP registers (f32-f127) are 66 * valid. This flag is very likely not going to be set for any 67 * sensible synctx, but is not explicitly disallowed. Any synctx 68 * that has this flag may or may not have the high FP registers 69 * restored. In short: don't do it. 70 * _MC_FLAGS_SYSCALL_CONTEXT 71 * If set (hence _MC_FLAGS_ASYNC_CONTEXT is not set) indicates 72 * that the scratch registers contain syscall arguments and 73 * return values and that additionally IIP and CFM are valid. 74 * Only the kernel is expected to create such a context. It's 75 * probably wise to let the kernel restore it. 76 */ 77 78typedef struct __mcontext { 79 unsigned long mc_flags; 80#define _MC_FLAGS_ASYNC_CONTEXT 0x0001 81#define _MC_FLAGS_HIGHFP_VALID 0x0002 82#define _MC_FLAGS_KSE_SET_MBOX 0x0004 /* Undocumented. Has to go. */ 83#define _MC_FLAGS_SYSCALL_CONTEXT 0x0008 84 unsigned long _reserved_; 85 struct _special mc_special; 86 struct _callee_saved mc_preserved; 87 struct _callee_saved_fp mc_preserved_fp; 88 struct _caller_saved mc_scratch; 89 struct _caller_saved_fp mc_scratch_fp; 90 struct _high_fp mc_high_fp; 91} mcontext_t; 92 93#endif /* !_MACHINE_UCONTEXT_H_ */ 94