mcontext.h revision 1.1
11.1Scherry/* $NetBSD: mcontext.h,v 1.1 2006/04/07 14:21:18 cherry Exp $ */ 21.1Scherry 31.1Scherry/*- 41.1Scherry * Copyright (c) 1999 The NetBSD Foundation, Inc. 51.1Scherry * All rights reserved. 61.1Scherry * 71.1Scherry * This code is derived from software contributed to The NetBSD Foundation 81.1Scherry * by Klaus Klein. 91.1Scherry * 101.1Scherry * Redistribution and use in source and binary forms, with or without 111.1Scherry * modification, are permitted provided that the following conditions 121.1Scherry * are met: 131.1Scherry * 1. Redistributions of source code must retain the above copyright 141.1Scherry * notice, this list of conditions and the following disclaimer. 151.1Scherry * 2. Redistributions in binary form must reproduce the above copyright 161.1Scherry * notice, this list of conditions and the following disclaimer in the 171.1Scherry * documentation and/or other materials provided with the distribution. 181.1Scherry * 3. All advertising materials mentioning features or use of this software 191.1Scherry * must display the following acknowledgement: 201.1Scherry * This product includes software developed by the NetBSD 211.1Scherry * Foundation, Inc. and its contributors. 221.1Scherry * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Scherry * contributors may be used to endorse or promote products derived 241.1Scherry * from this software without specific prior written permission. 251.1Scherry * 261.1Scherry * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Scherry * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Scherry * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Scherry * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Scherry * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Scherry * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Scherry * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Scherry * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Scherry * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Scherry * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Scherry * POSSIBILITY OF SUCH DAMAGE. 371.1Scherry */ 381.1Scherry 391.1Scherry#ifndef _IA64_MCONTEXT_H_ 401.1Scherry#define _IA64_MCONTEXT_H_ 411.1Scherry 421.1Scherry#include <machine/_regset.h> 431.1Scherry 441.1Scherry/* 451.1Scherry * The mc_flags field provides the necessary clues when dealing with the gory 461.1Scherry * details of ia64 specific contexts. A comprehensive explanation is added for 471.1Scherry * everybody's sanity, including the author's. 481.1Scherry * 491.1Scherry * The first and foremost variation in the context is synchronous contexts 501.1Scherry * (= synctx) versus asynchronous contexts (= asynctx). A synctx is created 511.1Scherry * synchronously WRT program execution and has the advantage that none of the 521.1Scherry * scratch registers have to be saved. They are assumed to be clobbered by the 531.1Scherry * call to the function that creates the context. An asynctx needs to have the 541.1Scherry * scratch registers preserved because it can describe any point in a thread's 551.1Scherry * (or process') execution. 561.1Scherry * The second variation is for synchronous contexts. When the kernel creates 571.1Scherry * a synchronous context if needs to preserve the scratch registers, because 581.1Scherry * the syscall argument and return values are stored there in the trapframe 591.1Scherry * and they need to be preserved in order to restart a syscall or return the 601.1Scherry * proper return values. Also, the IIP and CFM fields need to be preserved 611.1Scherry * as they point to the syscall stub, which the kernel saves as a favor to 621.1Scherry * userland (it keeps the stubs small and simple). 631.1Scherry * 641.1Scherry * Below a description of the flags and their meaning: 651.1Scherry * 661.1Scherry * _MC_FLAGS_ASYNC_CONTEXT 671.1Scherry * If set, indicates that mc_scratch and mc_scratch_fp are both 681.1Scherry * valid. IFF not set, _MC_FLAGS_SYSCALL_CONTEXT indicates if the 691.1Scherry * synchronous context is one corresponding to a syscall or not. 701.1Scherry * Only the kernel is expected to create such a context and it's 711.1Scherry * probably wise to let the kernel restore it. 721.1Scherry * _MC_FLAGS_HIGHFP_VALID 731.1Scherry * If set, indicates that the high FP registers (f32-f127) are 741.1Scherry * valid. This flag is very likely not going to be set for any 751.1Scherry * sensible synctx, but is not explicitly disallowed. Any synctx 761.1Scherry * that has this flag may or may not have the high FP registers 771.1Scherry * restored. In short: don't do it. 781.1Scherry * _MC_FLAGS_SYSCALL_CONTEXT 791.1Scherry * If set (hence _MC_FLAGS_ASYNC_CONTEXT is not set) indicates 801.1Scherry * that the scratch registers contain syscall arguments and 811.1Scherry * return values and that additionally IIP and CFM are valid. 821.1Scherry * Only the kernel is expected to create such a context. It's 831.1Scherry * probably wise to let the kernel restore it. 841.1Scherry */ 851.1Scherry 861.1Scherrytypedef struct __mcontext { 871.1Scherry unsigned long mc_flags; 881.1Scherry#define _MC_FLAGS_ASYNC_CONTEXT 0x0001 891.1Scherry#define _MC_FLAGS_HIGHFP_VALID 0x0002 901.1Scherry#define _MC_FLAGS_KSE_SET_MBOX 0x0004 /* Undocumented. Has to go. */ 911.1Scherry#define _MC_FLAGS_SYSCALL_CONTEXT 0x0008 921.1Scherry unsigned long _reserved_; 931.1Scherry struct _special mc_special; 941.1Scherry struct _callee_saved mc_preserved; 951.1Scherry struct _callee_saved_fp mc_preserved_fp; 961.1Scherry struct _caller_saved mc_scratch; 971.1Scherry struct _caller_saved_fp mc_scratch_fp; 981.1Scherry struct _high_fp mc_high_fp; 991.1Scherry} mcontext_t; 1001.1Scherry 1011.1Scherry#ifndef _UC_MACHINE_SP 1021.1Scherry#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.mc_special.sp) 1031.1Scherry#endif 1041.1Scherry 1051.1Scherry#endif /* !_IA64_MCONTEXT_H_ */ 106