2 * Copyright 2015, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
6 #ifndef _SELFTESTS_POWERPC_TM_TM_H
7 #define _SELFTESTS_POWERPC_TM_TM_H
10 #include <asm/cputable.h>
15 static inline bool have_htm(void)
17 #ifdef PPC_FEATURE2_HTM
18 return have_hwcap2(PPC_FEATURE2_HTM);
20 printf("PPC_FEATURE2_HTM not defined, can't check AT_HWCAP2\n");
25 static inline bool have_htm_nosc(void)
27 #ifdef PPC_FEATURE2_HTM_NOSC
28 return have_hwcap2(PPC_FEATURE2_HTM_NOSC);
30 printf("PPC_FEATURE2_HTM_NOSC not defined, can't check AT_HWCAP2\n");
35 static inline long failure_code(void)
37 return __builtin_get_texasru() >> 24;
40 static inline bool failure_is_persistent(void)
42 return (failure_code() & TM_CAUSE_PERSISTENT) == TM_CAUSE_PERSISTENT;
45 static inline bool failure_is_syscall(void)
47 return (failure_code() & TM_CAUSE_SYSCALL) == TM_CAUSE_SYSCALL;
50 static inline bool failure_is_unavailable(void)
52 return (failure_code() & TM_CAUSE_FAC_UNAV) == TM_CAUSE_FAC_UNAV;
55 static inline bool failure_is_reschedule(void)
57 if ((failure_code() & TM_CAUSE_RESCHED) == TM_CAUSE_RESCHED ||
58 (failure_code() & TM_CAUSE_KVM_RESCHED) == TM_CAUSE_KVM_RESCHED)
64 static inline bool failure_is_nesting(void)
66 return (__builtin_get_texasru() & 0x400000);
69 static inline int tcheck(void)
72 asm volatile ("tcheck 0" : "=r"(cr) : : "cr0");
73 return (cr >> 28) & 4;
76 static inline bool tcheck_doomed(void)
81 static inline bool tcheck_active(void)
86 static inline bool tcheck_suspended(void)
91 static inline bool tcheck_transactional(void)
96 #endif /* _SELFTESTS_POWERPC_TM_TM_H */