Module: xenomai-head
Branch: master
Commit: e2e02fffcc7bd4df9ed6dea43dd0fe5fe5663639
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=e2e02fffcc7bd4df9ed6dea43dd0fe5fe5663639

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Oct 24 15:47:35 2009 +0200

blackfin: provide atomic set/clear_mask bitops

---

 include/asm-blackfin/atomic.h |   27 ++++++++++++++++---------
 include/asm-blackfin/hal.h    |   13 ++++++++++-
 ksrc/arch/blackfin/Makefile   |    4 +++
 ksrc/arch/blackfin/atomic.S   |   43 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 75 insertions(+), 12 deletions(-)

diff --git a/include/asm-blackfin/atomic.h b/include/asm-blackfin/atomic.h
index a6f03dd..117a36b 100644
--- a/include/asm-blackfin/atomic.h
+++ b/include/asm-blackfin/atomic.h
@@ -22,6 +22,7 @@
 
 #ifdef __KERNEL__
 
+#include <linux/version.h>
 #include <linux/bitops.h>
 #include <asm/atomic.h>
 #include <asm/system.h>
@@ -29,15 +30,21 @@
 #define xnarch_atomic_xchg(ptr,v)   xchg(ptr,v)
 #define xnarch_memory_barrier()     smp_mb()
 
-#define xnarch_atomic_set(pcounter,i)          atomic_set(pcounter,i)
-#define xnarch_atomic_get(pcounter)            atomic_read(pcounter)
-#define xnarch_atomic_inc(pcounter)            atomic_inc(pcounter)
-#define xnarch_atomic_dec(pcounter)            atomic_dec(pcounter)
-#define xnarch_atomic_inc_and_test(pcounter)   atomic_inc_and_test(pcounter)
-#define xnarch_atomic_dec_and_test(pcounter)   atomic_dec_and_test(pcounter)
-#define xnarch_atomic_set_mask(pflags,mask)    
atomic_set_mask(mask,(atomic_t*)pflags)
-#define xnarch_atomic_clear_mask(pflags,mask)  
atomic_clear_mask(mask,(atomic_t*)pflags)
-#define xnarch_atomic_cmpxchg(pcounter,old,new) 
atomic_cmpxchg((pcounter),(old),(new))
+#define xnarch_atomic_set(pcounter,i)           atomic_set(pcounter,i)
+#define xnarch_atomic_get(pcounter)             atomic_read(pcounter)
+#define xnarch_atomic_inc(pcounter)             atomic_inc(pcounter)
+#define xnarch_atomic_dec(pcounter)             atomic_dec(pcounter)
+#define xnarch_atomic_inc_and_test(pcounter)    atomic_inc_and_test(pcounter)
+#define xnarch_atomic_dec_and_test(pcounter)    atomic_dec_and_test(pcounter)
+
+#define xnarch_atomic_set_mask(pflags, mask)   \
+       rthal_atomic_set_mask((pflags), (mask))
+
+#define xnarch_atomic_clear_mask(pflags, mask) \
+       rthal_atomic_clear_mask((pflags), (mask))
+
+#define xnarch_atomic_cmpxchg(pcounter, old, new) \
+       atomic_cmpxchg((pcounter), (old), (new))
 
 typedef atomic_t atomic_counter_t;
 typedef atomic_t xnarch_atomic_t;
@@ -47,7 +54,7 @@ typedef atomic_t xnarch_atomic_t;
 #include <asm/xenomai/features.h>
 #include <asm/xenomai/syscall.h>
 
-typedef struct { int counter;} xnarch_atomic_t;
+typedef struct { int counter; } xnarch_atomic_t;
 
 #define xnarch_atomic_get(v)           ((v)->counter)
 #define xnarch_atomic_set(v, i)        (((v)->counter) = i)
diff --git a/include/asm-blackfin/hal.h b/include/asm-blackfin/hal.h
index 42b23a4..893a283 100644
--- a/include/asm-blackfin/hal.h
+++ b/include/asm-blackfin/hal.h
@@ -83,13 +83,22 @@ extern int rthal_periodic_p;
 #define rthal_periodic_p  0
 #endif /* CONFIG_XENO_OPT_TIMING_PERIODIC */
 
-asmlinkage struct task_struct *rthal_thread_switch(struct thread_struct *prev,
-                                                  struct thread_struct *next);
+asmlinkage struct task_struct *
+rthal_thread_switch(struct thread_struct *prev,
+                   struct thread_struct *next);
 
 asmlinkage void rthal_thread_trampoline(void);
 
 asmlinkage int rthal_defer_switch_p(void);
 
+#ifndef CONFIG_SMP
+asmlinkage void rthal_atomic_set_mask(unsigned long *addr,
+                                     unsigned long mask);
+
+asmlinkage void rthal_atomic_clear_mask(unsigned long *addr,
+                                       unsigned long mask);
+#endif
+
 static const char *const rthal_fault_labels[] = {
        [1] = "Single step",
        [4] = "TAS",
diff --git a/ksrc/arch/blackfin/Makefile b/ksrc/arch/blackfin/Makefile
index 3ff23d8..302a0f4 100644
--- a/ksrc/arch/blackfin/Makefile
+++ b/ksrc/arch/blackfin/Makefile
@@ -3,6 +3,10 @@ obj-$(CONFIG_XENOMAI) += xeno_hal.o
 
 xeno_hal-y := hal.o switch.o
 
+ifndef CONFIG_SMP
+xeno_hal-y += atomic.o
+endif
+
 xeno_hal-$(CONFIG_XENO_HW_NMI_DEBUG_LATENCY) += nmi.o
 
 EXTRA_CFLAGS += -D__IN_XENOMAI__ -Iinclude/xenomai
diff --git a/ksrc/arch/blackfin/atomic.S b/ksrc/arch/blackfin/atomic.S
new file mode 100644
index 0000000..32d6bf1
--- /dev/null
+++ b/ksrc/arch/blackfin/atomic.S
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2009 Philippe Gerum.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
+ * USA; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <linux/linkage.h>
+#include <asm/blackfin.h>
+#include <asm/entry.h>
+
+ENTRY(_rthal_atomic_set_mask)
+       p0 = r0;
+       cli r0
+       r2 = [p0];
+       r2 = r2 | r1;
+       [p0] = r2;
+       sti r0
+       rts;
+ENDPROC(_rthal_atomic_set_mask)
+
+ENTRY(_rthal_atomic_clear_mask)
+       p0 = r0;
+       r1 = ~r1
+       cli r0
+       r2 = [p0];
+       r2 = r2 & r1;
+       [p0] = r2;
+       sti r0
+       rts;
+ENDPROC(_rthal_atomic_clear_mask)


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to