selftests/powerpc: Add TM tcheck helpers in C
authorCyril Bur <cyrilbur@gmail.com>
Fri, 23 Sep 2016 06:18:18 +0000 (16:18 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 4 Oct 2016 09:10:14 +0000 (20:10 +1100)
Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
tools/testing/selftests/powerpc/tm/tm.h

index 60318ba..2c8da74 100644 (file)
@@ -52,4 +52,31 @@ static inline bool failure_is_nesting(void)
        return (__builtin_get_texasru() & 0x400000);
 }
 
+static inline int tcheck(void)
+{
+       long cr;
+       asm volatile ("tcheck 0" : "=r"(cr) : : "cr0");
+       return (cr >> 28) & 4;
+}
+
+static inline bool tcheck_doomed(void)
+{
+       return tcheck() & 8;
+}
+
+static inline bool tcheck_active(void)
+{
+       return tcheck() & 4;
+}
+
+static inline bool tcheck_suspended(void)
+{
+       return tcheck() & 2;
+}
+
+static inline bool tcheck_transactional(void)
+{
+       return tcheck() & 6;
+}
+
 #endif /* _SELFTESTS_POWERPC_TM_TM_H */