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/linkage.h>
17 #include <asm/rwlock.h>
18 #include <asm/alternative-asm.h>
19 #include <asm/frame.h>
20 #include <asm/dwarf2.h>
23 * The semaphore operations have a special calling sequence that
24 * allow us to do a simpler in-line version of them. These routines
25 * need to convert that sequence back into the C sequence when
26 * there is contention on the semaphore.
28 * %eax contains the semaphore pointer on entry. Save the C-clobbered
29 * registers (%eax, %edx and %ecx) except %eax whish is either a return
30 * value or just clobbered..
32 .section .sched.text, "ax"
37 CFI_ADJUST_CFA_OFFSET 4
40 CFI_ADJUST_CFA_OFFSET 4
44 CFI_ADJUST_CFA_OFFSET -4
47 CFI_ADJUST_CFA_OFFSET -4
52 ENDPROC(__down_failed)
54 ENTRY(__down_failed_interruptible)
58 CFI_ADJUST_CFA_OFFSET 4
61 CFI_ADJUST_CFA_OFFSET 4
63 call __down_interruptible
65 CFI_ADJUST_CFA_OFFSET -4
68 CFI_ADJUST_CFA_OFFSET -4
73 ENDPROC(__down_failed_interruptible)
75 ENTRY(__down_failed_trylock)
79 CFI_ADJUST_CFA_OFFSET 4
82 CFI_ADJUST_CFA_OFFSET 4
86 CFI_ADJUST_CFA_OFFSET -4
89 CFI_ADJUST_CFA_OFFSET -4
94 ENDPROC(__down_failed_trylock)
100 CFI_ADJUST_CFA_OFFSET 4
103 CFI_ADJUST_CFA_OFFSET 4
107 CFI_ADJUST_CFA_OFFSET -4
110 CFI_ADJUST_CFA_OFFSET -4
118 * rw spinlock fallbacks
121 ENTRY(__write_lock_failed)
125 addl $ RW_LOCK_BIAS,(%eax)
127 cmpl $ RW_LOCK_BIAS,(%eax)
130 subl $ RW_LOCK_BIAS,(%eax)
135 ENDPROC(__write_lock_failed)
137 ENTRY(__read_lock_failed)
151 ENDPROC(__read_lock_failed)
155 #ifdef CONFIG_RWSEM_XCHGADD_ALGORITHM
157 /* Fix up special calling conventions */
158 ENTRY(call_rwsem_down_read_failed)
161 CFI_ADJUST_CFA_OFFSET 4
164 CFI_ADJUST_CFA_OFFSET 4
166 call rwsem_down_read_failed
168 CFI_ADJUST_CFA_OFFSET -4
170 CFI_ADJUST_CFA_OFFSET -4
173 ENDPROC(call_rwsem_down_read_failed)
175 ENTRY(call_rwsem_down_write_failed)
178 CFI_ADJUST_CFA_OFFSET 4
180 calll rwsem_down_write_failed
182 CFI_ADJUST_CFA_OFFSET -4
185 ENDPROC(call_rwsem_down_write_failed)
187 ENTRY(call_rwsem_wake)
189 decw %dx /* do nothing if still outstanding active readers */
192 CFI_ADJUST_CFA_OFFSET 4
196 CFI_ADJUST_CFA_OFFSET -4
199 ENDPROC(call_rwsem_wake)
201 /* Fix up special calling conventions */
202 ENTRY(call_rwsem_downgrade_wake)
205 CFI_ADJUST_CFA_OFFSET 4
208 CFI_ADJUST_CFA_OFFSET 4
210 call rwsem_downgrade_wake
212 CFI_ADJUST_CFA_OFFSET -4
214 CFI_ADJUST_CFA_OFFSET -4
217 ENDPROC(call_rwsem_downgrade_wake)