/*- * Copyright (c) 2003, by Matthew dillon All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. The name of the developer may NOT be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/simplelock.s,v 1.11.2.2 2003/02/04 20:55:28 jhb Exp $ * $DragonFly: src/sys/platform/pc32/i386/spinlock.s,v 1.1 2003/07/06 21:23:48 dillon Exp $ */ #include /* miscellaneous macros */ #include /* * The spinlock routines may only be used for low level debugging, like * kernel printfs, and when no other option is available such as situations * relating to hardware interrupt masks. Spinlock routines should not be * used in interrupt service routines or in any other situation. * * NOTE: for UP the spinlock routines still disable/restore interrupts */ ENTRY(spin_lock) movl 4(%esp),%edx SPIN_LOCK((%edx)) /* note: %eax, %ecx tromped */ ret ENTRY(spin_unlock) movl 4(%esp),%edx SPIN_UNLOCK((%edx)) /* note: %eax, %ecx tromped */ ret NON_GPROF_ENTRY(spin_lock_np) movl 4(%esp),%edx SPIN_LOCK((%edx)) /* note: %eax, %ecx tromped */ NON_GPROF_RET NON_GPROF_ENTRY(spin_unlock_np) movl 4(%esp), %edx /* get the address of the lock */ SPIN_UNLOCK((%edx)) NON_GPROF_RET /* * Auxillary convenience routines. Note that these functions disable and * restore interrupts as well, on SMP, as performing spin locking functions. */ NON_GPROF_ENTRY(imen_lock) SPIN_LOCK(imen_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(imen_unlock) SPIN_UNLOCK(imen_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(intr_lock) SPIN_LOCK(intr_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(intr_unlock) SPIN_UNLOCK(intr_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(mpintr_lock) SPIN_LOCK(mpintr_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(mpintr_unlock) SPIN_UNLOCK(mpintr_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(clock_lock) SPIN_LOCK(clock_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(clock_unlock) SPIN_UNLOCK(clock_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(com_lock) SPIN_LOCK(com_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(com_unlock) SPIN_UNLOCK(com_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(cons_lock) SPIN_LOCK(cons_spinlock) NON_GPROF_RET NON_GPROF_ENTRY(cons_unlock) SPIN_UNLOCK(cons_spinlock) NON_GPROF_RET