1*92a20430Srin /* $NetBSD: pthread_md.h,v 1.9 2020/04/11 09:15:23 rin Exp $ */
2c62a74e6Sthorpej
3c62a74e6Sthorpej /*
4c62a74e6Sthorpej * Copyright (c) 2001 Wasabi Systems, Inc.
5c62a74e6Sthorpej * All rights reserved.
6c62a74e6Sthorpej *
7c62a74e6Sthorpej * Written by Allen Briggs for Wasabi Systems, Inc.
8c62a74e6Sthorpej *
9c62a74e6Sthorpej * Redistribution and use in source and binary forms, with or without
10c62a74e6Sthorpej * modification, are permitted provided that the following conditions
11c62a74e6Sthorpej * are met:
12c62a74e6Sthorpej * 1. Redistributions of source code must retain the above copyright
13c62a74e6Sthorpej * notice, this list of conditions and the following disclaimer.
14c62a74e6Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
15c62a74e6Sthorpej * notice, this list of conditions and the following disclaimer in the
16c62a74e6Sthorpej * documentation and/or other materials provided with the distribution.
17c62a74e6Sthorpej * 3. All advertising materials mentioning features or use of this software
18c62a74e6Sthorpej * must display the following acknowledgement:
19c62a74e6Sthorpej * This product includes software developed for the NetBSD Project by
20c62a74e6Sthorpej * Wasabi Systems, Inc.
21c62a74e6Sthorpej * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22c62a74e6Sthorpej * or promote products derived from this software without specific prior
23c62a74e6Sthorpej * written permission.
24c62a74e6Sthorpej *
25c62a74e6Sthorpej * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26c62a74e6Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27c62a74e6Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28c62a74e6Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29c62a74e6Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30c62a74e6Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31c62a74e6Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32c62a74e6Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33c62a74e6Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34c62a74e6Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35c62a74e6Sthorpej * POSSIBILITY OF SUCH DAMAGE.
36c62a74e6Sthorpej */
37c62a74e6Sthorpej
38c62a74e6Sthorpej #ifndef _LIB_PTHREAD_POWERPC_MD_H
39c62a74e6Sthorpej #define _LIB_PTHREAD_POWERPC_MD_H
40c62a74e6Sthorpej
41c5d359beSchristos static inline unsigned long
pthread__sp(void)42c62a74e6Sthorpej pthread__sp(void)
43c62a74e6Sthorpej {
44c5d359beSchristos unsigned long ret;
45c62a74e6Sthorpej
46c62a74e6Sthorpej __asm("mr %0,1" : "=r" (ret));
47c62a74e6Sthorpej
48c62a74e6Sthorpej return ret;
49c62a74e6Sthorpej }
50c62a74e6Sthorpej
51c62a74e6Sthorpej #define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[1])
52c62a74e6Sthorpej
53c62a74e6Sthorpej /*
54c62a74e6Sthorpej * Set initial, sane values for registers whose values aren't just
55c62a74e6Sthorpej * "don't care".
56*92a20430Srin * 0xd032 is PSL_USERSET from arch/powerpc/include/psl.h
57c62a74e6Sthorpej */
58c62a74e6Sthorpej #define _INITCONTEXT_U_MD(ucp) \
59fb891b41Smatt (ucp)->uc_mcontext.__gregs[_REG_MSR] = 0xd032;
60c62a74e6Sthorpej
61c62a74e6Sthorpej #endif /* _LIB_PTHREAD_POWERPC_MD_H */
62