]> git.openfabrics.org - ~ardavis/dapl.git/commitdiff
r3687: Add PPC64 support for udapl
authorTodd Bowman <twbowman@gmail.com>
Thu, 6 Oct 2005 21:13:32 +0000 (21:13 +0000)
committerJames Lentini <jlentini@netapp.com>
Thu, 6 Oct 2005 21:13:32 +0000 (21:13 +0000)
Signed-off-by: Todd Bowman <twbowman@gmail.com>
Signed-off-by: James Lentini <jlentini@netapp.com>
dapl/udapl/linux/dapl_osd.h
test/dapltest/mdep/linux/dapl_mdep_user.c
test/dapltest/mdep/linux/dapl_mdep_user.h

index 97d0a72b98bd0c4544ab942890dc2607e5e5b1da..822686a8fb4f12e5d6dee749bea3b32787c7decd 100644 (file)
@@ -49,7 +49,7 @@
 #error UNDEFINED OS TYPE
 #endif /* __linux__ */
 
-#if !defined (__i386__) && !defined (__ia64__) && !defined(__x86_64__)
+#if !defined (__i386__) && !defined (__ia64__) && !defined(__x86_64__) && !defined(__PPC64__)
 #error UNDEFINED ARCH
 #endif
 
@@ -78,7 +78,7 @@
 #include <sys/socket.h>
 #include <ctype.h>
 
-#ifdef __ia64__
+#if defined(__ia64__) || defined(__PPC64__)
 #include <asm/atomic.h>
 #include <asm/system.h>
 #endif
@@ -161,6 +161,8 @@ dapl_os_atomic_inc (
        IA64_FETCHADD(old_value,v,1,4);
 #   endif
 
+#elif defined(__PPC64__)
+   atomic_inc((atomic_t *) v);
 #else  /* !__ia64__ */
     __asm__ __volatile__ (
        "lock;" "incl %0"
@@ -189,6 +191,9 @@ dapl_os_atomic_dec (
        IA64_FETCHADD(old_value,v,-1,4);
 #   endif
 
+#elif defined (__PPC64__)
+   atomic_dec((atomic_t *)v);
+
 #else  /* !__ia64__ */
     __asm__ __volatile__ (
        "lock;" "decl %0"
@@ -230,7 +235,21 @@ dapl_os_atomic_assign (
     current_value = ia64_cmpxchg("acq",v,match_value,new_value,4);
 #else
     current_value = ia64_cmpxchg(acq,v,match_value,new_value,4);
-#endif
+#endif /* __ia64__ */
+#elif defined(__PPC64__)
+        __asm__ __volatile__ (
+        EIEIO_ON_SMP
+"1:     lwarx   %0,0,%2         # __cmpxchg_u64\n\
+        cmpd    0,%0,%3\n\
+        bne-    2f\n\
+        stwcx.  %4,0,%2\n\
+        bne-    1b"
+        ISYNC_ON_SMP
+        "\n\
+2:"
+        : "=&r" (current_value), "=m" (*v)
+        : "r" (v), "r" (match_value), "r" (new_value), "m" (*v)
+        : "cc", "memory");
 #else
     __asm__ __volatile__ (
         "lock; cmpxchgl %1, %2"
index 433c8b6a2b21d3fe66965f3eb86351f0287ad794..18fc06fe2b18fabe944c7bb50e7ec08e7710552d 100644 (file)
@@ -186,7 +186,11 @@ DT_Mdep_GetCpuMhz (
     void )
 {
 #define DT_CPU_MHZ_BUFFER_SIZE         128
+#if defined (__PPC64__)
+#define DT_CPU_MHZ_MHZ          "clock"
+#else
 #define DT_CPU_MHZ_MHZ                 "cpu MHz"
+#endif
 #define DT_CPU_MHZ_DELIMITER   ":"
 
     FILE *fp;
index ac371ddb6df42411fad47632467462790a90e5c2..981783dbe498b5a7b5b07f53434773c34fc2feff 100644 (file)
@@ -129,7 +129,17 @@ DT_Mdep_GetTimeStamp ( void )
     x = get_cycles ();
     return x;
 #else
-#error "Non-Pentium Linux - unimplemented"
+#if defined(__PPC64__)
+    unsigned int tbl, tbu0, tbu1;
+    do {
+         __asm__ __volatile__ ("mftbu %0" : "=r"(tbu0));
+         __asm__ __volatile__ ("mftb %0" : "=r"(tbl));
+         __asm__ __volatile__ ("mftbu %0" : "=r"(tbu1));
+    } while (tbu0 != tbu1);
+    return (((unsigned long long)tbu0) << 32) | tbl;
+#else
+#error "Non-Pentium and Non-PPC Linux - unimplemented"
+#endif
 #endif
 #endif
 }