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)
78 CFI_ADJUST_CFA_OFFSET 4
81 CFI_ADJUST_CFA_OFFSET 4
83 call rwsem_down_read_failed
85 CFI_ADJUST_CFA_OFFSET -4
87 CFI_ADJUST_CFA_OFFSET -4
90 ENDPROC(call_rwsem_down_read_failed)
92 ENTRY(call_rwsem_down_write_failed)
95 CFI_ADJUST_CFA_OFFSET 4
97 calll rwsem_down_write_failed
99 CFI_ADJUST_CFA_OFFSET -4
102 ENDPROC(call_rwsem_down_write_failed)
104 ENTRY(call_rwsem_wake)
106 decw %dx /* do nothing if still outstanding active readers */
109 CFI_ADJUST_CFA_OFFSET 4
113 CFI_ADJUST_CFA_OFFSET -4
116 ENDPROC(call_rwsem_wake)
118 /* Fix up special calling conventions */
119 ENTRY(call_rwsem_downgrade_wake)
122 CFI_ADJUST_CFA_OFFSET 4
125 CFI_ADJUST_CFA_OFFSET 4
127 call rwsem_downgrade_wake
129 CFI_ADJUST_CFA_OFFSET -4
131 CFI_ADJUST_CFA_OFFSET -4
134 ENDPROC(call_rwsem_downgrade_wake)