2 * i386 semaphore implementation.
4 * (C) Copyright 1999 Linus Torvalds
6 * Portions Copyright 1999 Red Hat, Inc.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
13 * rw semaphores implemented November 1999 by Benjamin LaHaise <bcrl@kvack.org>
16 #include <linux/config.h>
17 #include <linux/linkage.h>
18 #include <asm/rwlock.h>
19 #include <asm/alternative-asm.i>
20 #include <asm/frame.i>
21 #include <asm/dwarf2.h>
24 * The semaphore operations have a special calling sequence that
25 * allow us to do a simpler in-line version of them. These routines
26 * need to convert that sequence back into the C sequence when
27 * there is contention on the semaphore.
29 * %eax contains the semaphore pointer on entry. Save the C-clobbered
30 * registers (%eax, %edx and %ecx) except %eax whish is either a return
31 * value or just clobbered..
38 CFI_ADJUST_CFA_OFFSET 4
41 CFI_ADJUST_CFA_OFFSET 4
45 CFI_ADJUST_CFA_OFFSET -4
48 CFI_ADJUST_CFA_OFFSET -4
55 ENTRY(__down_failed_interruptible)
59 CFI_ADJUST_CFA_OFFSET 4
62 CFI_ADJUST_CFA_OFFSET 4
64 call __down_interruptible
66 CFI_ADJUST_CFA_OFFSET -4
69 CFI_ADJUST_CFA_OFFSET -4
74 END(__down_failed_interruptible)
76 ENTRY(__down_failed_trylock)
80 CFI_ADJUST_CFA_OFFSET 4
83 CFI_ADJUST_CFA_OFFSET 4
87 CFI_ADJUST_CFA_OFFSET -4
90 CFI_ADJUST_CFA_OFFSET -4
95 END(__down_failed_trylock)
101 CFI_ADJUST_CFA_OFFSET 4
104 CFI_ADJUST_CFA_OFFSET 4
108 CFI_ADJUST_CFA_OFFSET -4
111 CFI_ADJUST_CFA_OFFSET -4
119 * rw spinlock fallbacks
122 ENTRY(__write_lock_failed)
126 addl $ RW_LOCK_BIAS,(%eax)
128 cmpl $ RW_LOCK_BIAS,(%eax)
131 subl $ RW_LOCK_BIAS,(%eax)
136 END(__write_lock_failed)
138 ENTRY(__read_lock_failed)
152 END(__read_lock_failed)
156 /* Fix up special calling conventions */
157 ENTRY(call_rwsem_down_read_failed)
160 CFI_ADJUST_CFA_OFFSET 4
163 CFI_ADJUST_CFA_OFFSET 4
165 call rwsem_down_read_failed
167 CFI_ADJUST_CFA_OFFSET -4
169 CFI_ADJUST_CFA_OFFSET -4
172 END(call_rwsem_down_read_failed)
174 ENTRY(call_rwsem_down_write_failed)
177 CFI_ADJUST_CFA_OFFSET 4
179 calll rwsem_down_write_failed
181 CFI_ADJUST_CFA_OFFSET -4
184 END(call_rwsem_down_write_failed)
186 ENTRY(call_rwsem_wake)
188 decw %dx /* do nothing if still outstanding active readers */
191 CFI_ADJUST_CFA_OFFSET 4
195 CFI_ADJUST_CFA_OFFSET -4
200 /* Fix up special calling conventions */
201 ENTRY(call_rwsem_downgrade_wake)
204 CFI_ADJUST_CFA_OFFSET 4
207 CFI_ADJUST_CFA_OFFSET 4
209 call rwsem_downgrade_wake
211 CFI_ADJUST_CFA_OFFSET -4
213 CFI_ADJUST_CFA_OFFSET -4
216 END(call_rwsem_downgrade_wake)