mcontext.h revision 1.1
1/* $NetBSD: mcontext.h,v 1.1 2006/04/07 14:21:18 cherry 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 _IA64_MCONTEXT_H_ 40#define _IA64_MCONTEXT_H_ 41 42#include <machine/_regset.h> 43 44/* 45 * The mc_flags field provides the necessary clues when dealing with the gory 46 * details of ia64 specific contexts. A comprehensive explanation is added for 47 * everybody's sanity, including the author's. 48 * 49 * The first and foremost variation in the context is synchronous contexts 50 * (= synctx) versus asynchronous contexts (= asynctx). A synctx is created 51 * synchronously WRT program execution and has the advantage that none of the 52 * scratch registers have to be saved. They are assumed to be clobbered by the 53 * call to the function that creates the context. An asynctx needs to have the 54 * scratch registers preserved because it can describe any point in a thread's 55 * (or process') execution. 56 * The second variation is for synchronous contexts. When the kernel creates 57 * a synchronous context if needs to preserve the scratch registers, because 58 * the syscall argument and return values are stored there in the trapframe 59 * and they need to be preserved in order to restart a syscall or return the 60 * proper return values. Also, the IIP and CFM fields need to be preserved 61 * as they point to the syscall stub, which the kernel saves as a favor to 62 * userland (it keeps the stubs small and simple). 63 * 64 * Below a description of the flags and their meaning: 65 * 66 * _MC_FLAGS_ASYNC_CONTEXT 67 * If set, indicates that mc_scratch and mc_scratch_fp are both 68 * valid. IFF not set, _MC_FLAGS_SYSCALL_CONTEXT indicates if the 69 * synchronous context is one corresponding to a syscall or not. 70 * Only the kernel is expected to create such a context and it's 71 * probably wise to let the kernel restore it. 72 * _MC_FLAGS_HIGHFP_VALID 73 * If set, indicates that the high FP registers (f32-f127) are 74 * valid. This flag is very likely not going to be set for any 75 * sensible synctx, but is not explicitly disallowed. Any synctx 76 * that has this flag may or may not have the high FP registers 77 * restored. In short: don't do it. 78 * _MC_FLAGS_SYSCALL_CONTEXT 79 * If set (hence _MC_FLAGS_ASYNC_CONTEXT is not set) indicates 80 * that the scratch registers contain syscall arguments and 81 * return values and that additionally IIP and CFM are valid. 82 * Only the kernel is expected to create such a context. It's 83 * probably wise to let the kernel restore it. 84 */ 85 86typedef struct __mcontext { 87 unsigned long mc_flags; 88#define _MC_FLAGS_ASYNC_CONTEXT 0x0001 89#define _MC_FLAGS_HIGHFP_VALID 0x0002 90#define _MC_FLAGS_KSE_SET_MBOX 0x0004 /* Undocumented. Has to go. */ 91#define _MC_FLAGS_SYSCALL_CONTEXT 0x0008 92 unsigned long _reserved_; 93 struct _special mc_special; 94 struct _callee_saved mc_preserved; 95 struct _callee_saved_fp mc_preserved_fp; 96 struct _caller_saved mc_scratch; 97 struct _caller_saved_fp mc_scratch_fp; 98 struct _high_fp mc_high_fp; 99} mcontext_t; 100 101#ifndef _UC_MACHINE_SP 102#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.mc_special.sp) 103#endif 104 105#endif /* !_IA64_MCONTEXT_H_ */ 106