xref: /openbsd-src/sys/arch/powerpc/include/mplock.h (revision 9593dc34da13a12012033a17061c846c208061c2)
1*9593dc34Smglocker /*	$OpenBSD: mplock.h,v 1.7 2024/09/04 07:54:51 mglocker Exp $	*/
24be6edc1Sdlg 
34be6edc1Sdlg /*
44be6edc1Sdlg  * Copyright (c) 2004 Niklas Hallqvist.  All rights reserved.
54be6edc1Sdlg  *
64be6edc1Sdlg  * Redistribution and use in source and binary forms, with or without
74be6edc1Sdlg  * modification, are permitted provided that the following conditions
84be6edc1Sdlg  * are met:
94be6edc1Sdlg  * 1. Redistributions of source code must retain the above copyright
104be6edc1Sdlg  *    notice, this list of conditions and the following disclaimer.
114be6edc1Sdlg  * 2. Redistributions in binary form must reproduce the above copyright
124be6edc1Sdlg  *    notice, this list of conditions and the following disclaimer in the
134be6edc1Sdlg  *    documentation and/or other materials provided with the distribution.
144be6edc1Sdlg  *
154be6edc1Sdlg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
164be6edc1Sdlg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
174be6edc1Sdlg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
184be6edc1Sdlg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
194be6edc1Sdlg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
204be6edc1Sdlg  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
214be6edc1Sdlg  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
224be6edc1Sdlg  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
234be6edc1Sdlg  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
244be6edc1Sdlg  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
254be6edc1Sdlg  */
264be6edc1Sdlg 
279cfef117Sdlg #ifndef _POWERPC_MPLOCK_H_
289cfef117Sdlg #define _POWERPC_MPLOCK_H_
294be6edc1Sdlg 
30bb9163a1Smpi #define __USE_MI_MPLOCK
31bb9163a1Smpi 
324be6edc1Sdlg /*
3368ea07c5Sgkoehler  * __ppc_lock exists because pte_spill_r() can't use __mp_lock.
344be6edc1Sdlg  * Really simple spinlock implementation with recursive capabilities.
35*9593dc34Smglocker  * Correctness is paramount, no fanciness allowed.
364be6edc1Sdlg  */
374be6edc1Sdlg 
38bb9163a1Smpi struct __ppc_lock {
3968ea07c5Sgkoehler 	struct cpu_info *volatile	mpl_cpu;
4068ea07c5Sgkoehler 	long				mpl_count;
414be6edc1Sdlg };
424be6edc1Sdlg 
434be6edc1Sdlg #ifndef _LOCORE
444be6edc1Sdlg 
451c6319c4Sgkoehler #define PPC_LOCK_INITIALIZER	{ NULL, 0 }
461c6319c4Sgkoehler 
47bb9163a1Smpi void __ppc_lock(struct __ppc_lock *);
48bb9163a1Smpi void __ppc_unlock(struct __ppc_lock *);
494be6edc1Sdlg 
504be6edc1Sdlg #endif
514be6edc1Sdlg 
529cfef117Sdlg #endif /* !_POWERPC_MPLOCK_H */
53