summaryrefslogtreecommitdiffstats
path: root/include/asm-arm/proc-armo/semaphore.h
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1998-03-17 22:05:47 +0000
committerRalf Baechle <ralf@linux-mips.org>1998-03-17 22:05:47 +0000
commit27cfca1ec98e91261b1a5355d10a8996464b63af (patch)
tree8e895a53e372fa682b4c0a585b9377d67ed70d0e /include/asm-arm/proc-armo/semaphore.h
parent6a76fb7214c477ccf6582bd79c5b4ccc4f9c41b1 (diff)
Look Ma' what I found on my harddisk ...
o New faster syscalls for 2.1.x, too o Upgrade to 2.1.89. Don't try to run this. It's flaky as hell. But feel free to debug ...
Diffstat (limited to 'include/asm-arm/proc-armo/semaphore.h')
-rw-r--r--include/asm-arm/proc-armo/semaphore.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/include/asm-arm/proc-armo/semaphore.h b/include/asm-arm/proc-armo/semaphore.h
new file mode 100644
index 000000000..483803217
--- /dev/null
+++ b/include/asm-arm/proc-armo/semaphore.h
@@ -0,0 +1,83 @@
+/*
+ * linux/include/asm-arm/proc-armo/semaphore.h
+ */
+#ifndef __ASM_PROC_SEMAPHORE_H
+#define __ASM_PROC_SEMAPHORE_H
+
+/*
+ * This is ugly, but we want the default case to fall through.
+ * "__down" is the actual routine that waits...
+ */
+extern inline void down(struct semaphore * sem)
+{
+ __asm__ __volatile__ ("
+ @ atomic down operation
+ mov r0, pc
+ orr r1, r0, #0x08000000
+ and r0, r0, #0x0c000003
+ teqp r1, #0
+ ldr r1, [%0]
+ subs r1, r1, #1
+ str r1, [%0]
+ mov r1, pc, lsr #28
+ teqp r0, r1, lsl #28
+ movmi r0, %0
+ blmi " SYMBOL_NAME_STR(__down)
+ : : "r" (sem) : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
+}
+
+/*
+ * This is ugly, but we want the default case to fall through.
+ * "__down_interruptible" is the actual routine that waits...
+ */
+extern inline int down_interruptible (struct semaphore * sem)
+{
+ int result;
+ __asm__ __volatile__ ("
+ @ atomic down operation
+ mov r0, pc
+ orr r1, r0, #0x08000000
+ and r0, r0, #0x0c000003
+ teqp r1, #0
+ ldr r1, [%1]
+ subs r1, r1, #1
+ str r1, [%1]
+ mov r1, pc, lsr #28
+ orrmi r0, r0, #0x80000000 @ set N
+ teqp r0, r1, lsl #28
+ movmi r0, %1
+ movpl r0, #0
+ blmi " SYMBOL_NAME_STR(__down_interruptible) "
+ mov %0, r0"
+ : "=r" (result)
+ : "r" (sem)
+ : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
+ return result;
+}
+
+/*
+ * Note! This is subtle. We jump to wake people up only if
+ * the semaphore was negative (== somebody was waiting on it).
+ * The default case (no contention) will result in NO
+ * jumps for both down() and up().
+ */
+extern inline void up(struct semaphore * sem)
+{
+ __asm__ __volatile__ ("
+ @ atomic up operation
+ mov r0, pc
+ orr r1, r0, #0x08000000
+ and r0, r0, #0x0c000003
+ teqp r1, #0
+ ldr r1, [%0]
+ adds r1, r1, #1
+ str r1, [%0]
+ mov r1, pc, lsr #28
+ orrls r0, r0, #0x80000000 @ set N
+ teqp r0, r1, lsl #28
+ movmi r0, %0
+ blmi " SYMBOL_NAME_STR(__up)
+ : : "r" (sem) : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
+}
+
+#endif