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>
15 #include <asm/semaphore.h>
18 * The semaphore operations have a special calling sequence that
19 * allow us to do a simpler in-line version of them. These routines
20 * need to convert that sequence back into the C sequence when
21 * there is contention on the semaphore.
23 * %eax contains the semaphore pointer on entry. Save the C-clobbered
24 * registers (%eax, %edx and %ecx) except %eax whish is either a return
25 * value or just clobbered..
28 ".section .sched.text\n"
30 ".globl __down_failed\n"
32 #if defined(CONFIG_FRAME_POINTER)
41 #if defined(CONFIG_FRAME_POINTER)
49 ".section .sched.text\n"
51 ".globl __down_failed_interruptible\n"
52 "__down_failed_interruptible:\n\t"
53 #if defined(CONFIG_FRAME_POINTER)
59 "call __down_interruptible\n\t"
62 #if defined(CONFIG_FRAME_POINTER)
70 ".section .sched.text\n"
72 ".globl __down_failed_trylock\n"
73 "__down_failed_trylock:\n\t"
74 #if defined(CONFIG_FRAME_POINTER)
80 "call __down_trylock\n\t"
83 #if defined(CONFIG_FRAME_POINTER)
91 ".section .sched.text\n"
93 ".globl __up_wakeup\n"
104 * rw spinlock fallbacks
106 #if defined(CONFIG_SMP)
108 ".section .sched.text\n"
110 ".globl __write_lock_failed\n"
111 "__write_lock_failed:\n\t"
112 LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ",(%eax)\n"
114 "cmpl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
116 LOCK_PREFIX "subl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
117 "jnz __write_lock_failed\n\t"
122 ".section .sched.text\n"
124 ".globl __read_lock_failed\n"
125 "__read_lock_failed:\n\t"
126 LOCK_PREFIX "incl (%eax)\n"
130 LOCK_PREFIX "decl (%eax)\n\t"
131 "js __read_lock_failed\n\t"