1*ea1d1255Sthorpej /* $NetBSD: mcontext.h,v 1.11 2021/05/24 21:00:12 thorpej Exp $ */
223bc2503Sthorpej
323bc2503Sthorpej /*-
423bc2503Sthorpej * Copyright (c) 2001 The NetBSD Foundation, Inc.
523bc2503Sthorpej * All rights reserved.
623bc2503Sthorpej *
723bc2503Sthorpej * This code is derived from software contributed to The NetBSD Foundation
823bc2503Sthorpej * by Klaus Klein.
923bc2503Sthorpej *
1023bc2503Sthorpej * Redistribution and use in source and binary forms, with or without
1123bc2503Sthorpej * modification, are permitted provided that the following conditions
1223bc2503Sthorpej * are met:
1323bc2503Sthorpej * 1. Redistributions of source code must retain the above copyright
1423bc2503Sthorpej * notice, this list of conditions and the following disclaimer.
1523bc2503Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
1623bc2503Sthorpej * notice, this list of conditions and the following disclaimer in the
1723bc2503Sthorpej * documentation and/or other materials provided with the distribution.
1823bc2503Sthorpej *
1923bc2503Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2023bc2503Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2123bc2503Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2223bc2503Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2323bc2503Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2423bc2503Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2523bc2503Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2623bc2503Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2723bc2503Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2823bc2503Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2923bc2503Sthorpej * POSSIBILITY OF SUCH DAMAGE.
3023bc2503Sthorpej */
3123bc2503Sthorpej
3223bc2503Sthorpej #ifndef _ALPHA_MCONTEXT_H_
3323bc2503Sthorpej #define _ALPHA_MCONTEXT_H_
3423bc2503Sthorpej
3523bc2503Sthorpej /*
3623bc2503Sthorpej * General register state (important: 0-31 maps to `struct reg')
3723bc2503Sthorpej */
3823bc2503Sthorpej #define _NGREG 34 /* 0-31, PC, PS */
3923bc2503Sthorpej typedef unsigned long __greg_t;
4023bc2503Sthorpej typedef __greg_t __gregset_t[_NGREG];
4123bc2503Sthorpej
4223bc2503Sthorpej /* Convenience synonyms */
4323bc2503Sthorpej #define _REG_V0 0
4423bc2503Sthorpej #define _REG_T0 1
4523bc2503Sthorpej #define _REG_T1 2
4623bc2503Sthorpej #define _REG_T2 3
4723bc2503Sthorpej #define _REG_T3 4
4823bc2503Sthorpej #define _REG_T4 5
4923bc2503Sthorpej #define _REG_T5 6
5023bc2503Sthorpej #define _REG_T6 7
5123bc2503Sthorpej #define _REG_T7 8
5223bc2503Sthorpej #define _REG_S0 9
5323bc2503Sthorpej #define _REG_S1 10
5423bc2503Sthorpej #define _REG_S2 11
5523bc2503Sthorpej #define _REG_S3 12
5623bc2503Sthorpej #define _REG_S4 13
5723bc2503Sthorpej #define _REG_S5 14
5823bc2503Sthorpej #define _REG_S6 15
5923bc2503Sthorpej #define _REG_A0 16
6023bc2503Sthorpej #define _REG_A1 17
6123bc2503Sthorpej #define _REG_A2 18
6223bc2503Sthorpej #define _REG_A3 19
6323bc2503Sthorpej #define _REG_A4 20
6423bc2503Sthorpej #define _REG_A5 21
6523bc2503Sthorpej #define _REG_T8 22
6623bc2503Sthorpej #define _REG_T9 23
6723bc2503Sthorpej #define _REG_T10 24
6823bc2503Sthorpej #define _REG_T11 25
6923bc2503Sthorpej #define _REG_RA 26
7023bc2503Sthorpej #define _REG_T12 27
7123bc2503Sthorpej #define _REG_PV 27
7223bc2503Sthorpej #define _REG_AT 28
7323bc2503Sthorpej #define _REG_GP 29
7423bc2503Sthorpej #define _REG_SP 30
7523bc2503Sthorpej #define _REG_UNIQUE 31
7623bc2503Sthorpej #define _REG_PC 32
7723bc2503Sthorpej #define _REG_PS 33
7823bc2503Sthorpej
7923bc2503Sthorpej /*
8023bc2503Sthorpej * Floating point register state (important: maps to `struct fpreg')
8123bc2503Sthorpej */
8223bc2503Sthorpej typedef struct {
8323bc2503Sthorpej union {
8423bc2503Sthorpej unsigned long __fp_regs[32];
8523bc2503Sthorpej double __fp_dregs[32];
8623bc2503Sthorpej } __fp_fr;
8723bc2503Sthorpej unsigned long __fp_fpcr;
8823bc2503Sthorpej } __fpregset_t;
8923bc2503Sthorpej
9023bc2503Sthorpej typedef struct {
9123bc2503Sthorpej __gregset_t __gregs;
9223bc2503Sthorpej __fpregset_t __fpregs;
9323bc2503Sthorpej } mcontext_t;
9423bc2503Sthorpej
9523bc2503Sthorpej /* Machine-dependent uc_flags */
962332652fSmanu #define _UC_TLSBASE 0x20 /* valid process-unique value in _REG_UNIQUE */
97*ea1d1255Sthorpej #define _UC_SETSTACK 0x00010000
98*ea1d1255Sthorpej #define _UC_CLRSTACK 0x00020000
9923bc2503Sthorpej
10023bc2503Sthorpej #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
101ad82f011Skamil #define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S6])
102901da40cSthorpej #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
103901da40cSthorpej #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_V0])
104901da40cSthorpej
105901da40cSthorpej #define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
10623bc2503Sthorpej
107d1b17eebSkamil #if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
108d1b17eebSkamil defined(__LIBPTHREAD_SOURCE__)
109d1b17eebSkamil #include <sys/tls.h>
110d1b17eebSkamil
111d1b17eebSkamil __BEGIN_DECLS
112285592a1Sjoerg static __inline void *
__lwp_getprivate_fast(void)1134c92f569Sjoerg __lwp_getprivate_fast(void)
1144c92f569Sjoerg {
1154c92f569Sjoerg register void *__tmp __asm("$0");
1164c92f569Sjoerg
1174c92f569Sjoerg __asm volatile("call_pal %1 # PAL_rdunique"
1184c92f569Sjoerg : "=r" (__tmp)
1194c92f569Sjoerg : "i" (0x009e /* PAL_rdunique */));
1204c92f569Sjoerg
1214c92f569Sjoerg return __tmp;
1224c92f569Sjoerg }
123d1b17eebSkamil __END_DECLS
124d1b17eebSkamil
125d1b17eebSkamil #endif
1264c92f569Sjoerg
12723bc2503Sthorpej #endif /* !_ALPHA_MCONTEXT_H_ */
128