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