ucontext.h revision 331722
1276333Sian/*-
2276333Sian * Copyright (C) 1995, 1996 Wolfgang Solfrank.
3276333Sian * Copyright (C) 1995, 1996 TooLs GmbH.
4276333Sian * All rights reserved.
5276333Sian *
6276333Sian * Redistribution and use in source and binary forms, with or without
7276333Sian * modification, are permitted provided that the following conditions
8276333Sian * are met:
9276333Sian * 1. Redistributions of source code must retain the above copyright
10276333Sian *    notice, this list of conditions and the following disclaimer.
11276333Sian * 2. Redistributions in binary form must reproduce the above copyright
12276333Sian *    notice, this list of conditions and the following disclaimer in the
13276333Sian *    documentation and/or other materials provided with the distribution.
14276333Sian * 3. All advertising materials mentioning features or use of this software
15276333Sian *    must display the following acknowledgement:
16276333Sian *	This product includes software developed by TooLs GmbH.
17276333Sian * 4. The name of TooLs GmbH may not be used to endorse or promote products
18276333Sian *    derived from this software without specific prior written permission.
19276333Sian *
20276333Sian * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
21276333Sian * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22276333Sian * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23276333Sian * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24276333Sian * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25276333Sian * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26276333Sian * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27276333Sian * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28276333Sian * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29276333Sian * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30276333Sian *
31276333Sian * $NetBSD: signal.h,v 1.4 1998/09/14 02:48:34 thorpej Exp $
32276333Sian * $FreeBSD: stable/11/sys/powerpc/include/ucontext.h 331722 2018-03-29 02:50:57Z eadler $
33276333Sian */
34276333Sian
35289602Sian#ifndef	_MACHINE_UCONTEXT_H_
36289602Sian#define	_MACHINE_UCONTEXT_H_
37289602Sian
38289602Siantypedef struct __mcontext {
39289602Sian	int		mc_vers;
40289602Sian	int		mc_flags;
41289602Sian#define _MC_FP_VALID	0x01
42289602Sian#define _MC_AV_VALID	0x02
43289602Sian	int		mc_onstack;	  	/* saved onstack flag */
44289602Sian	int		mc_len;			/* sizeof(__mcontext) */
45289602Sian	__uint64_t	mc_avec[32*2];		/* vector register file */
46289602Sian	__uint32_t	mc_av[2];
47289602Sian	__register_t	mc_frame[42];
48307342Smmel	__uint64_t	mc_fpreg[33];
49307342Smmel	__uint64_t	mc_vsxfpreg[32];	/* low-order half of VSR0-31 */
50307342Smmel} mcontext_t __aligned(16);
51314525Sian
52331988Smmel#if defined(_KERNEL) && defined(__powerpc64__)
53289602Siantypedef struct __mcontext32 {
54307342Smmel	int		mc_vers;
55289602Sian	int		mc_flags;
56289602Sian#define _MC_FP_VALID	0x01
57289602Sian#define _MC_AV_VALID	0x02
58307342Smmel	int		mc_onstack;	  	/* saved onstack flag */
59314525Sian	int		mc_len;			/* sizeof(__mcontext) */
60307342Smmel	uint64_t	mc_avec[32*2];		/* vector register file */
61307342Smmel	uint32_t	mc_av[2];
62276333Sian	uint32_t	mc_frame[42];
63276333Sian	uint64_t	mc_fpreg[33];
64276333Sian	uint64_t	mc_vsxfpreg[32];	/* low-order half of VSR0-31 */
65276333Sian} mcontext32_t __aligned(16);
66276333Sian#endif
67276333Sian
68276333Sian/* GPRs and supervisor-level regs */
69276333Sian#define mc_gpr		mc_frame
70276333Sian#define mc_lr		mc_frame[32]
71276333Sian#define mc_cr		mc_frame[33]
72276333Sian#define mc_xer		mc_frame[34]
73276333Sian#define	mc_ctr		mc_frame[35]
74276333Sian#define mc_srr0		mc_frame[36]
75276333Sian#define mc_srr1		mc_frame[37]
76276333Sian#define mc_exc		mc_frame[38]
77276333Sian#define mc_dar		mc_frame[39]
78276333Sian#define mc_dsisr	mc_frame[40]
79276333Sian
80276333Sian/* floating-point state */
81276333Sian#define mc_fpscr	mc_fpreg[32]
82276333Sian
83276333Sian/* altivec state */
84276333Sian#define mc_vscr		mc_av[0]
85314525Sian#define mc_vrsave	mc_av[1]
86314525Sian
87276333Sian#define _MC_VERSION	0x1
88314525Sian#define _MC_VERSION_KSE 0xee	/* partial ucontext for libpthread */
89276333Sian
90276333Sian#endif	/* !_MACHINE_UCONTEXT_H_ */
91276333Sian