166458Sdfr/*- 2122368Smarcel * Copyright (c) 1999, 2003 Marcel Moolenaar 366458Sdfr * All rights reserved. 466458Sdfr * 566458Sdfr * Redistribution and use in source and binary forms, with or without 666458Sdfr * modification, are permitted provided that the following conditions 766458Sdfr * are met: 866458Sdfr * 1. Redistributions of source code must retain the above copyright 966458Sdfr * notice, this list of conditions and the following disclaimer 1066458Sdfr * in this position and unchanged. 1166458Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1266458Sdfr * notice, this list of conditions and the following disclaimer in the 1366458Sdfr * documentation and/or other materials provided with the distribution. 1466458Sdfr * 3. The name of the author may not be used to endorse or promote products 1566458Sdfr * derived from this software without specific prior written permission. 1666458Sdfr * 1766458Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1866458Sdfr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1966458Sdfr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2066458Sdfr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2166458Sdfr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2266458Sdfr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2366458Sdfr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2466458Sdfr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2566458Sdfr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2666458Sdfr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2766458Sdfr * 2866458Sdfr * $FreeBSD$ 2966458Sdfr */ 3066458Sdfr 3166458Sdfr#ifndef _MACHINE_UCONTEXT_H_ 3266458Sdfr#define _MACHINE_UCONTEXT_H_ 3366458Sdfr 34115084Smarcel#include <machine/_regset.h> 3566458Sdfr 36118590Smarcel/* 37118590Smarcel * The mc_flags field provides the necessary clues when dealing with the gory 38118590Smarcel * details of ia64 specific contexts. A comprehensive explanation is added for 39118590Smarcel * everybody's sanity, including the author's. 40118590Smarcel * 41118590Smarcel * The first and foremost variation in the context is synchronous contexts 42118590Smarcel * (= synctx) versus asynchronous contexts (= asynctx). A synctx is created 43118590Smarcel * synchronously WRT program execution and has the advantage that none of the 44118590Smarcel * scratch registers have to be saved. They are assumed to be clobbered by the 45118590Smarcel * call to the function that creates the context. An asynctx needs to have the 46118590Smarcel * scratch registers preserved because it can describe any point in a thread's 47118590Smarcel * (or process') execution. 48123255Smarcel * The second variation is for synchronous contexts. When the kernel creates 49123255Smarcel * a synchronous context if needs to preserve the scratch registers, because 50123255Smarcel * the syscall argument and return values are stored there in the trapframe 51123255Smarcel * and they need to be preserved in order to restart a syscall or return the 52123255Smarcel * proper return values. Also, the IIP and CFM fields need to be preserved 53123255Smarcel * as they point to the syscall stub, which the kernel saves as a favor to 54123255Smarcel * userland (it keeps the stubs small and simple). 55118590Smarcel * 56118590Smarcel * Below a description of the flags and their meaning: 57118590Smarcel * 58118590Smarcel * _MC_FLAGS_ASYNC_CONTEXT 59118590Smarcel * If set, indicates that mc_scratch and mc_scratch_fp are both 60123255Smarcel * valid. IFF not set, _MC_FLAGS_SYSCALL_CONTEXT indicates if the 61123255Smarcel * synchronous context is one corresponding to a syscall or not. 62123255Smarcel * Only the kernel is expected to create such a context and it's 63123255Smarcel * probably wise to let the kernel restore it. 64118590Smarcel * _MC_FLAGS_HIGHFP_VALID 65118590Smarcel * If set, indicates that the high FP registers (f32-f127) are 66118590Smarcel * valid. This flag is very likely not going to be set for any 67118590Smarcel * sensible synctx, but is not explicitly disallowed. Any synctx 68118590Smarcel * that has this flag may or may not have the high FP registers 69118590Smarcel * restored. In short: don't do it. 70123255Smarcel * _MC_FLAGS_SYSCALL_CONTEXT 71123255Smarcel * If set (hence _MC_FLAGS_ASYNC_CONTEXT is not set) indicates 72123255Smarcel * that the scratch registers contain syscall arguments and 73123255Smarcel * return values and that additionally IIP and CFM are valid. 74123255Smarcel * Only the kernel is expected to create such a context. It's 75123255Smarcel * probably wise to let the kernel restore it. 76118590Smarcel */ 77118590Smarcel 7866458Sdfrtypedef struct __mcontext { 79118333Smarcel unsigned long mc_flags; 80118590Smarcel#define _MC_FLAGS_ASYNC_CONTEXT 0x0001 81118590Smarcel#define _MC_FLAGS_HIGHFP_VALID 0x0002 82123255Smarcel#define _MC_FLAGS_SYSCALL_CONTEXT 0x0008 83118333Smarcel unsigned long _reserved_; 84115084Smarcel struct _special mc_special; 85115084Smarcel struct _callee_saved mc_preserved; 86115084Smarcel struct _callee_saved_fp mc_preserved_fp; 87115084Smarcel struct _caller_saved mc_scratch; 88115084Smarcel struct _caller_saved_fp mc_scratch_fp; 89115084Smarcel struct _high_fp mc_high_fp; 9066458Sdfr} mcontext_t; 9166458Sdfr 9266458Sdfr#endif /* !_MACHINE_UCONTEXT_H_ */ 93