1*b2b3ffcdSSimon Schubert/*- 2*b2b3ffcdSSimon Schubert * Copyright (c) 2003 Matthew Dillon. 3*b2b3ffcdSSimon Schubert * Copyright (c) 2008 The DragonFly Project. 4*b2b3ffcdSSimon Schubert * All Rights Reserved. 5*b2b3ffcdSSimon Schubert * 6*b2b3ffcdSSimon Schubert * Redistribution and use in source and binary forms, with or without 7*b2b3ffcdSSimon Schubert * modification, are permitted provided that the following conditions 8*b2b3ffcdSSimon Schubert * are met: 9*b2b3ffcdSSimon Schubert * 1. Redistributions of source code must retain the above copyright 10*b2b3ffcdSSimon Schubert * notice, this list of conditions and the following disclaimer. 11*b2b3ffcdSSimon Schubert * 2. The name of the developer may NOT be used to endorse or promote products 12*b2b3ffcdSSimon Schubert * derived from this software without specific prior written permission. 13*b2b3ffcdSSimon Schubert * 14*b2b3ffcdSSimon Schubert * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*b2b3ffcdSSimon Schubert * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*b2b3ffcdSSimon Schubert * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*b2b3ffcdSSimon Schubert * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*b2b3ffcdSSimon Schubert * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*b2b3ffcdSSimon Schubert * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*b2b3ffcdSSimon Schubert * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*b2b3ffcdSSimon Schubert * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*b2b3ffcdSSimon Schubert * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*b2b3ffcdSSimon Schubert * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*b2b3ffcdSSimon Schubert * SUCH DAMAGE. 25*b2b3ffcdSSimon Schubert * 26*b2b3ffcdSSimon Schubert * $FreeBSD: src/sys/i386/i386/simplelock.s,v 1.11.2.2 2003/02/04 20:55:28 jhb Exp $ 27*b2b3ffcdSSimon Schubert */ 28*b2b3ffcdSSimon Schubert 29*b2b3ffcdSSimon Schubert#include <machine/asmacros.h> /* miscellaneous macros */ 30*b2b3ffcdSSimon Schubert#include <machine/lock.h> 31*b2b3ffcdSSimon Schubert 32*b2b3ffcdSSimon Schubert/* 33*b2b3ffcdSSimon Schubert * The spinlock routines may only be used for low level debugging, like 34*b2b3ffcdSSimon Schubert * kernel printfs, and when no other option is available such as situations 35*b2b3ffcdSSimon Schubert * relating to hardware interrupt masks. Spinlock routines should not be 36*b2b3ffcdSSimon Schubert * used in interrupt service routines or in any other situation. 37*b2b3ffcdSSimon Schubert * 38*b2b3ffcdSSimon Schubert * NOTE: for UP the spinlock routines still disable/restore interrupts 39*b2b3ffcdSSimon Schubert */ 40*b2b3ffcdSSimon SchubertENTRY(spin_lock_deprecated) 41*b2b3ffcdSSimon Schubert movl 4(%esp),%edx 42*b2b3ffcdSSimon Schubert SPIN_LOCK((%edx)) /* note: %eax, %ecx tromped */ 43*b2b3ffcdSSimon Schubert ret 44*b2b3ffcdSSimon Schubert 45*b2b3ffcdSSimon SchubertENTRY(spin_unlock_deprecated) 46*b2b3ffcdSSimon Schubert movl 4(%esp),%edx 47*b2b3ffcdSSimon Schubert SPIN_UNLOCK((%edx)) /* note: %eax, %ecx tromped */ 48*b2b3ffcdSSimon Schubert ret 49*b2b3ffcdSSimon Schubert 50*b2b3ffcdSSimon SchubertNON_GPROF_ENTRY(spin_lock_np) 51*b2b3ffcdSSimon Schubert movl 4(%esp),%edx 52*b2b3ffcdSSimon Schubert SPIN_LOCK((%edx)) /* note: %eax, %ecx tromped */ 53*b2b3ffcdSSimon Schubert NON_GPROF_RET 54*b2b3ffcdSSimon Schubert 55*b2b3ffcdSSimon SchubertNON_GPROF_ENTRY(spin_unlock_np) 56*b2b3ffcdSSimon Schubert movl 4(%esp), %edx /* get the address of the lock */ 57*b2b3ffcdSSimon Schubert SPIN_UNLOCK((%edx)) 58*b2b3ffcdSSimon Schubert NON_GPROF_RET 59*b2b3ffcdSSimon Schubert 60*b2b3ffcdSSimon Schubert/* 61*b2b3ffcdSSimon Schubert * Auxillary convenience routines. Note that these functions disable and 62*b2b3ffcdSSimon Schubert * restore interrupts as well, on SMP, as performing spin locking functions. 63*b2b3ffcdSSimon Schubert */ 64*b2b3ffcdSSimon SchubertNON_GPROF_ENTRY(imen_lock) 65*b2b3ffcdSSimon Schubert SPIN_LOCK(imen_spinlock) 66*b2b3ffcdSSimon Schubert NON_GPROF_RET 67*b2b3ffcdSSimon Schubert 68*b2b3ffcdSSimon SchubertNON_GPROF_ENTRY(imen_unlock) 69*b2b3ffcdSSimon Schubert SPIN_UNLOCK(imen_spinlock) 70*b2b3ffcdSSimon Schubert NON_GPROF_RET 71*b2b3ffcdSSimon Schubert 72*b2b3ffcdSSimon SchubertNON_GPROF_ENTRY(clock_lock) 73*b2b3ffcdSSimon Schubert SPIN_LOCK(clock_spinlock) 74*b2b3ffcdSSimon Schubert NON_GPROF_RET 75*b2b3ffcdSSimon Schubert 76*b2b3ffcdSSimon SchubertNON_GPROF_ENTRY(clock_unlock) 77*b2b3ffcdSSimon Schubert SPIN_UNLOCK(clock_spinlock) 78*b2b3ffcdSSimon Schubert NON_GPROF_RET 79*b2b3ffcdSSimon Schubert 80*b2b3ffcdSSimon SchubertNON_GPROF_ENTRY(com_lock) 81*b2b3ffcdSSimon Schubert SPIN_LOCK(com_spinlock) 82*b2b3ffcdSSimon Schubert NON_GPROF_RET 83*b2b3ffcdSSimon Schubert 84*b2b3ffcdSSimon SchubertNON_GPROF_ENTRY(com_unlock) 85*b2b3ffcdSSimon Schubert SPIN_UNLOCK(com_spinlock) 86*b2b3ffcdSSimon Schubert NON_GPROF_RET 87