More sparc related fixes
authorROS Developer <ros-dev@core0.(none)>
Tue, 29 Sep 2009 03:52:59 +0000 (05:52 +0200)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 1 Oct 2009 20:09:52 +0000 (22:09 +0200)
kern/arch/i386/bitmask.h [new file with mode: 0644]
kern/arch/i386/smp.c
kern/arch/i386/smp_boot.c
kern/arch/sparc/atomic.h
kern/arch/sparc/bitmask.h [new file with mode: 0644]
kern/include/ros/common.h
kern/src/atomic.c
kern/src/testing.c

diff --git a/kern/arch/i386/bitmask.h b/kern/arch/i386/bitmask.h
new file mode 100644 (file)
index 0000000..ffe4855
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef ROS_ARCH_BITMASK_H
+#define ROS_ARCH_BITMASK_H
+
+#ifndef __IVY__
+#include <ros/noivy.h>
+#endif
+
+#include <string.h>
+#include <sys/types.h>
+#include <atomic.h>
+#include <stdio.h>
+
+#define BYTES_FOR_BITMASK(size) (((size) - 1) / 8 + 1)
+#define BYTES_FOR_BITMASK_WITH_CHECK(size) ((size) ? ((size) - (1)) / (8) + (1) : (0))
+#define DECL_BITMASK(name, size) uint8_t (name)[BYTES_FOR_BITMASK((size))]
+
+#define GET_BITMASK_BIT(name, bit) (((name)[(bit)/8] & (1 << ((bit) % 8))) ? 1 : 0)
+#define SET_BITMASK_BIT(name, bit) ((name)[(bit)/8] |= (1 << ((bit) % 8)))
+#define CLR_BITMASK_BIT(name, bit) ((name)[(bit)/8] &= ~(1 << ((bit) % 8)))
+#define SET_BITMASK_BIT_ATOMIC(name, bit) (atomic_orb(&(name)[(bit)/8], (1 << ((bit) % 8))))
+#define CLR_BITMASK_BIT_ATOMIC(name, bit) (atomic_andb(&(name)[(bit)/8], ~(1 << ((bit) % 8))))
+
+#define CLR_BITMASK(name, size) \
+({ \
+       {TRUSTEDBLOCK \
+       memset((void*)((uintptr_t)(name)), 0, BYTES_FOR_BITMASK((size))); \
+       } \
+})
+
+#define FILL_BITMASK(name, size) \
+({ \
+       {TRUSTEDBLOCK \
+       memset((void*)((uintptr_t)(name)), 255, BYTES_FOR_BITMASK((size))); \
+       } \
+       (name)[BYTES_FOR_BITMASK((size))-1] >>= (((size) % 8) ? (8 - ((size) % 8)) : 0 ); \
+}) 
+
+#define COPY_BITMASK(newmask, oldmask, size) \
+({ \
+       {TRUSTEDBLOCK \
+       memcpy((void*)((uintptr_t)(newmask)), \
+           (void*)((uintptr_t)(oldmask)), \
+           BYTES_FOR_BITMASK((size))); \
+       } \
+})
+
+// this checks the entire last byte, so keep it 0 in the other macros
+#define BITMASK_IS_CLEAR(name, size) ({ \
+       uint32_t __n = BYTES_FOR_BITMASK((size)); \
+       bool clear = 1; \
+       while (__n-- > 0) { \
+               if ((name)[__n]) { \
+                       clear = 0; \
+                       break;\
+               }\
+       } \
+       clear; })
+
+#define PRINT_BITMASK(name, size) { \
+       int i;  \
+       for (i = 0; i < BYTES_FOR_BITMASK(size); i++) { \
+               int j;  \
+               for (j = 0; j < 8; j++) \
+                       printk("%x", ((name)[i] >> j) & 1);     \
+       } \
+       printk("\n"); \
+}
+
+#endif /* ROS_ARCH_BITMASK_H */
index aed6af9..84a1d35 100644 (file)
@@ -9,6 +9,7 @@
 #endif
 
 #include <arch/arch.h>
+#include <arch/bitmask.h>
 #include <smp.h>
 
 #include <atomic.h>
index 8b94de7..29fb9f3 100644 (file)
@@ -14,6 +14,7 @@
 #include <smp.h>
 #include <arch/console.h>
 #include <arch/apic.h>
+#include <arch/bitmask.h>
 #include <timing.h>
 
 #include <atomic.h>
index b0886f3..90be16c 100644 (file)
@@ -21,7 +21,6 @@ static inline void atomic_set(atomic_t* number, int32_t val);
 static inline void atomic_add(atomic_t* number, int32_t inc);
 static inline void atomic_inc(atomic_t* number);
 static inline void atomic_dec(atomic_t* number);
-static inline void atomic_andb(volatile uint8_t RACY* number, uint8_t mask);
 static inline uint32_t spin_trylock(spinlock_t*SAFE lock);
 static inline void spin_lock(spinlock_t*SAFE lock);
 static inline void spin_unlock(spinlock_t*SAFE lock);
@@ -71,13 +70,6 @@ static inline void atomic_dec(atomic_t* number)
        atomic_add(number,-1);
 }
 
-static inline void atomic_andb(volatile uint8_t RACY*number, uint8_t mask)
-{
-       // asm volatile("lock andb %1,%0" : "=m"(*number) : "r"(mask) : "cc");
-      // SARAH TODO: change to sparc
-}
-
-
 static inline uint32_t spin_trylock(spinlock_t*SAFE lock)
 {
        uint32_t reg;
diff --git a/kern/arch/sparc/bitmask.h b/kern/arch/sparc/bitmask.h
new file mode 100644 (file)
index 0000000..745d485
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef ROS_ARCH_BITMASK_H
+#define ROS_ARCH_BITMASK_H
+
+#ifndef __IVY__
+#include <ros/noivy.h>
+#endif
+
+#include <string.h>
+#include <sys/types.h>
+#include <atomic.h>
+#include <stdio.h>
+
+#define BYTES_FOR_BITMASK(size) (size)
+#define BYTES_FOR_BITMASK_WITH_CHECK(size) (size)
+#define DECL_BITMASK(name, size) uint8_t (name)[BYTES_FOR_BITMASK((size))]
+
+#define GET_BITMASK_BIT(name, bit) ((name)[(bit)])
+#define SET_BITMASK_BIT(name, bit) ((name)[(bit)] = 1)
+#define CLR_BITMASK_BIT(name, bit) ((name)[(bit)] = 0)
+#define SET_BITMASK_BIT_ATOMIC SET_BITMASK_BIT
+#define CLR_BITMASK_BIT_ATOMIC CLR_BITMASK_BIT
+
+#define CLR_BITMASK(name, size) \
+({ \
+       {TRUSTEDBLOCK \
+       memset((void*)((uintptr_t)(name)), 0, BYTES_FOR_BITMASK((size))); \
+       } \
+})
+
+#define FILL_BITMASK(name, size) \
+({ \
+       {TRUSTEDBLOCK \
+       memset((void*)((uintptr_t)(name)), 1, BYTES_FOR_BITMASK((size))); \
+       } \
+}) 
+
+#define COPY_BITMASK(newmask, oldmask, size) \
+({ \
+       {TRUSTEDBLOCK \
+       memcpy((void*)((uintptr_t)(newmask)), \
+           (void*)((uintptr_t)(oldmask)), \
+           BYTES_FOR_BITMASK((size))); \
+       } \
+})
+
+// this checks the entire last byte, so keep it 0 in the other macros
+#define BITMASK_IS_CLEAR(name, size) ({ \
+       uint32_t __n = BYTES_FOR_BITMASK((size)); \
+       bool clear = 1; \
+       while (__n-- > 0) { \
+               if ((name)[__n]) { \
+                       clear = 0; \
+                       break;\
+               }\
+       } \
+       clear; })
+
+#define PRINT_BITMASK(name, size) { \
+       int i;  \
+       for (i = 0; i < BYTES_FOR_BITMASK(size); i++) { \
+               printk("%x", (name)[i] );       \
+       } \
+       printk("\n"); \
+}
+
+#endif /* ROS_ARCH_BITMASK_H */
index 331a14f..4f25030 100644 (file)
@@ -89,62 +89,4 @@ static inline uint32_t LOG2(uint32_t value)
 // a uint64_t programatically
 #define UINT64(upper, lower) ( (((uint64_t)(upper)) << 32) | (lower) )
 
-
-/*********************** Bitmask stuff **********************/
-#define BYTES_FOR_BITMASK(size) (((size) - 1) / 8 + 1)
-#define BYTES_FOR_BITMASK_WITH_CHECK(size) ((size) ? ((size) - (1)) / (8) + (1) : (0))
-#define DECL_BITMASK(name, size) uint8_t (name)[BYTES_FOR_BITMASK((size))]
-
-#define GET_BITMASK_BIT(name, bit) (((name)[(bit)/8] & (1 << ((bit) % 8))) ? 1 : 0)
-#define SET_BITMASK_BIT(name, bit) ((name)[(bit)/8] |= (1 << ((bit) % 8)))
-#define CLR_BITMASK_BIT(name, bit) ((name)[(bit)/8] &= ~(1 << ((bit) % 8)))
-#define SET_BITMASK_BIT_ATOMIC(name, bit) (atomic_orb(&(name)[(bit)/8], (1 << ((bit) % 8))))
-#define CLR_BITMASK_BIT_ATOMIC(name, bit) (atomic_andb(&(name)[(bit)/8], ~(1 << ((bit) % 8))))
-
-#define CLR_BITMASK(name, size) \
-({ \
-       {TRUSTEDBLOCK \
-       memset((void*)((uintptr_t)(name)), 0, BYTES_FOR_BITMASK((size))); \
-       } \
-})
-
-#define FILL_BITMASK(name, size) \
-({ \
-       {TRUSTEDBLOCK \
-       memset((void*)((uintptr_t)(name)), 255, BYTES_FOR_BITMASK((size))); \
-       } \
-       (name)[BYTES_FOR_BITMASK((size))-1] >>= (((size) % 8) ? (8 - ((size) % 8)) : 0 ); \
-}) 
-
-#define COPY_BITMASK(newmask, oldmask, size) \
-({ \
-       {TRUSTEDBLOCK \
-       memcpy((void*)((uintptr_t)(newmask)), \
-           (void*)((uintptr_t)(oldmask)), \
-           BYTES_FOR_BITMASK((size))); \
-       } \
-})
-
-// this checks the entire last byte, so keep it 0 in the other macros
-#define BITMASK_IS_CLEAR(name, size) ({ \
-       uint32_t __n = BYTES_FOR_BITMASK((size)); \
-       bool clear = 1; \
-       while (__n-- > 0) { \
-               if ((name)[__n]) { \
-                       clear = 0; \
-                       break;\
-               }\
-       } \
-       clear; })
-
-#define PRINT_BITMASK(name, size) { \
-       int i;  \
-       for (i = 0; i < BYTES_FOR_BITMASK(size); i++) { \
-               int j;  \
-               for (j = 0; j < 8; j++) \
-                       printk("%x", ((name)[i] >> j) & 1);     \
-       } \
-       printk("\n"); \
-}
-/**************************************************************/
 #endif /* ROS_COMMON_H */
index a88b7ba..09a0d86 100644 (file)
@@ -3,6 +3,7 @@
 #endif
 
 #include <arch/arch.h>
+#include <arch/bitmask.h>
 
 #include <atomic.h>
 #include <ros/error.h>
index 7325101..6ef113b 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <arch/mmu.h>
 #include <arch/arch.h>
+#include <arch/bitmask.h>
 #include <smp.h>
 
 #include <ros/memlayout.h>