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"
35 * rw spinlock fallbacks
38 ENTRY(__write_lock_failed)
42 addl $ RW_LOCK_BIAS,(%eax)
44 cmpl $ RW_LOCK_BIAS,(%eax)
47 subl $ RW_LOCK_BIAS,(%eax)
52 ENDPROC(__write_lock_failed)
54 ENTRY(__read_lock_failed)
68 ENDPROC(__read_lock_failed)
72 #ifdef CONFIG_RWSEM_XCHGADD_ALGORITHM
74 /* Fix up special calling conventions */
75 ENTRY(call_rwsem_down_read_failed)
81 call rwsem_down_read_failed
86 ENDPROC(call_rwsem_down_read_failed)
88 ENTRY(call_rwsem_down_write_failed)
92 calll rwsem_down_write_failed
96 ENDPROC(call_rwsem_down_write_failed)
98 ENTRY(call_rwsem_wake)
100 decw %dx /* do nothing if still outstanding active readers */
108 ENDPROC(call_rwsem_wake)
110 /* Fix up special calling conventions */
111 ENTRY(call_rwsem_downgrade_wake)
117 call rwsem_downgrade_wake
122 ENDPROC(call_rwsem_downgrade_wake)