1
2
3
4
5
6#ifndef _SELFTESTS_POWERPC_UTILS_H
7#define _SELFTESTS_POWERPC_UTILS_H
8
9#define __cacheline_aligned __attribute__((aligned(128)))
10
11#include <stdint.h>
12#include <stdbool.h>
13#include <linux/auxvec.h>
14#include "reg.h"
15
16
17typedef unsigned long long u64;
18typedef signed long long s64;
19
20
21typedef uint32_t u32;
22typedef uint16_t u16;
23typedef uint8_t u8;
24
25void test_harness_set_timeout(uint64_t time);
26int test_harness(int (test_function)(void), char *name);
27extern void *get_auxv_entry(int type);
28int pick_online_cpu(void);
29
30static inline bool have_hwcap(unsigned long ftr)
31{
32 return ((unsigned long)get_auxv_entry(AT_HWCAP) & ftr) == ftr;
33}
34
35#ifdef AT_HWCAP2
36static inline bool have_hwcap2(unsigned long ftr2)
37{
38 return ((unsigned long)get_auxv_entry(AT_HWCAP2) & ftr2) == ftr2;
39}
40#else
41static inline bool have_hwcap2(unsigned long ftr2)
42{
43 return false;
44}
45#endif
46
47
48#define FAIL_IF(x) \
49do { \
50 if ((x)) { \
51 fprintf(stderr, \
52 "[FAIL] Test FAILED on line %d\n", __LINE__); \
53 return 1; \
54 } \
55} while (0)
56
57
58#define MAGIC_SKIP_RETURN_VALUE 99
59
60#define SKIP_IF(x) \
61do { \
62 if ((x)) { \
63 fprintf(stderr, \
64 "[SKIP] Test skipped on line %d\n", __LINE__); \
65 return MAGIC_SKIP_RETURN_VALUE; \
66 } \
67} while (0)
68
69#define _str(s) #s
70#define str(s) _str(s)
71
72
73#ifndef PPC_FEATURE2_ARCH_3_00
74#define PPC_FEATURE2_ARCH_3_00 0x00800000
75#endif
76
77#endif
78