2 * linux/include/asm-arm/semaphore.h
4 #ifndef __ASM_PROC_SEMAPHORE_H
5 #define __ASM_PROC_SEMAPHORE_H
8 * This is ugly, but we want the default case to fall through.
9 * "__down" is the actual routine that waits...
11 extern inline void down(struct semaphore
* sem
)
13 unsigned int cpsr
, temp
;
15 __asm__
__volatile__ ("
16 @ atomic down operation
18 orr %1, %0, #128 @ disable IRQs
21 bic %0, %0, #0x80000000 @ clear N
24 orrmi %0, %0, #0x80000000 @ set N
27 blmi " SYMBOL_NAME_STR(__down_failed
)
28 : "=&r" (cpsr
), "=&r" (temp
)
34 * This is ugly, but we want the default case to fall through.
35 * "__down_interruptible" is the actual routine that waits...
37 extern inline int down_interruptible (struct semaphore
* sem
)
39 unsigned int cpsr
, temp
;
41 __asm__
__volatile__ ("
42 @ atomic down interruptible operation
44 orr %1, %0, #128 @ disable IRQs
47 bic %0, %0, #0x80000000 @ clear N
50 orrmi %0, %0, #0x80000000 @ set N
54 blmi " SYMBOL_NAME_STR(__down_interruptible_failed
) "
56 : "=&r" (cpsr
), "=&r" (temp
)
63 extern inline int down_trylock(struct semaphore
*sem
)
65 unsigned int cpsr
, temp
;
67 __asm__
__volatile__ ("
68 @ atomic down try lock operation
70 orr %1, %0, #128 @ disable IRQs
73 bic %0, %0, #0x80000000 @ clear N
76 orrmi %0, %0, #0x80000000 @ set N
80 blmi " SYMBOL_NAME_STR(__down_trylock_failed
) "
82 : "=&r" (cpsr
), "=&r" (temp
)
90 * Note! This is subtle. We jump to wake people up only if
91 * the semaphore was negative (== somebody was waiting on it).
92 * The default case (no contention) will result in NO
93 * jumps for both down() and up().
95 extern inline void up(struct semaphore
* sem
)
97 unsigned int cpsr
, temp
;
99 __asm__
__volatile__ ("
100 @ atomic up operation
102 orr %1, %0, #128 @ disable IRQs
105 bic %0, %0, #0x80000000 @ clear N
108 orrle %0, %0, #0x80000000 @ set N
111 blmi " SYMBOL_NAME_STR(__up_wakeup
)
112 : "=&r" (cpsr
), "=&r" (temp
)