xref: /netbsd-src/sys/arch/sparc64/include/mutex.h (revision a88454562984bb90edf6581e332f43e4b38e23a1)
1*a8845456Sriastradh /*	$NetBSD: mutex.h,v 1.10 2023/07/12 12:50:13 riastradh Exp $	*/
2b07ec3fcSad 
3b07ec3fcSad /*-
4b07ec3fcSad  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
5b07ec3fcSad  * All rights reserved.
6b07ec3fcSad  *
7b07ec3fcSad  * This code is derived from software contributed to The NetBSD Foundation
8b07ec3fcSad  * by Jason R. Thorpe and Andrew Doran.
9b07ec3fcSad  *
10b07ec3fcSad  * Redistribution and use in source and binary forms, with or without
11b07ec3fcSad  * modification, are permitted provided that the following conditions
12b07ec3fcSad  * are met:
13b07ec3fcSad  * 1. Redistributions of source code must retain the above copyright
14b07ec3fcSad  *    notice, this list of conditions and the following disclaimer.
15b07ec3fcSad  * 2. Redistributions in binary form must reproduce the above copyright
16b07ec3fcSad  *    notice, this list of conditions and the following disclaimer in the
17b07ec3fcSad  *    documentation and/or other materials provided with the distribution.
18b07ec3fcSad  *
19b07ec3fcSad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20b07ec3fcSad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21b07ec3fcSad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22b07ec3fcSad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23b07ec3fcSad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24b07ec3fcSad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25b07ec3fcSad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26b07ec3fcSad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27b07ec3fcSad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28b07ec3fcSad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29b07ec3fcSad  * POSSIBILITY OF SUCH DAMAGE.
30b07ec3fcSad  */
31b07ec3fcSad 
32b07ec3fcSad #ifndef _SPARC64_MUTEX_H_
33b07ec3fcSad #define	_SPARC64_MUTEX_H_
34b07ec3fcSad 
35*a8845456Sriastradh #include <sys/types.h>
36*a8845456Sriastradh 
3778272616Sriastradh #ifdef __MUTEX_PRIVATE
3878272616Sriastradh #include <machine/intr.h>
39d7dc966cSmartin #include <machine/psl.h>
4078272616Sriastradh #endif
4178272616Sriastradh 
42b07ec3fcSad struct kmutex {
43b07ec3fcSad 	union {
44b07ec3fcSad 		volatile uintptr_t	mtxa_owner;
45b07ec3fcSad #ifdef __MUTEX_PRIVATE
46b07ec3fcSad 		struct {
47b07ec3fcSad 			uint8_t			mtxs_unused;
48b07ec3fcSad                         __cpu_simple_lock_t	mtxs_lock;
49b07ec3fcSad 			ipl_cookie_t		mtxs_ipl;
50b07ec3fcSad 			uint8_t			mtxs_dummy;
51b07ec3fcSad 		} s;
52b07ec3fcSad #endif
53b07ec3fcSad 	} u;
54b07ec3fcSad };
55b07ec3fcSad 
56b07ec3fcSad #ifdef __MUTEX_PRIVATE
57b07ec3fcSad 
58b07ec3fcSad #define	mtx_owner 			u.mtxa_owner
59b07ec3fcSad #define	mtx_ipl 			u.s.mtxs_ipl
60b07ec3fcSad #define	mtx_lock			u.s.mtxs_lock
61b07ec3fcSad 
62b07ec3fcSad #define __HAVE_MUTEX_STUBS		1
63b07ec3fcSad #define	__HAVE_SIMPLE_MUTEXES		1
64b07ec3fcSad 
65b07ec3fcSad #endif	/* __MUTEX_PRIVATE */
66b07ec3fcSad 
67b07ec3fcSad #endif /* _SPARC64_MUTEX_H_ */
68