]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - tools/testing/selftests/powerpc/include/utils.h
2 * Copyright 2013, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
6 #ifndef _SELFTESTS_POWERPC_UTILS_H
7 #define _SELFTESTS_POWERPC_UTILS_H
9 #define __cacheline_aligned __attribute__((aligned(128)))
13 #include <linux/auxvec.h>
14 #include <linux/perf_event.h>
17 /* Avoid headaches with PRI?64 - just use %ll? always */
18 typedef unsigned long long u64
;
19 typedef signed long long s64
;
21 /* Just for familiarity */
26 void test_harness_set_timeout(uint64_t time
);
27 int test_harness(int (test_function
)(void), char *name
);
29 int read_auxv(char *buf
, ssize_t buf_size
);
30 void *find_auxv_entry(int type
, char *auxv
);
31 void *get_auxv_entry(int type
);
33 int pick_online_cpu(void);
35 int read_debugfs_file(char *debugfs_file
, int *result
);
36 int write_debugfs_file(char *debugfs_file
, int result
);
37 void set_dscr(unsigned long val
);
38 int perf_event_open_counter(unsigned int type
,
39 unsigned long config
, int group_fd
);
40 int perf_event_enable(int fd
);
41 int perf_event_disable(int fd
);
42 int perf_event_reset(int fd
);
44 static inline bool have_hwcap(unsigned long ftr
)
46 return ((unsigned long)get_auxv_entry(AT_HWCAP
) & ftr
) == ftr
;
50 static inline bool have_hwcap2(unsigned long ftr2
)
52 return ((unsigned long)get_auxv_entry(AT_HWCAP2
) & ftr2
) == ftr2
;
55 static inline bool have_hwcap2(unsigned long ftr2
)
61 bool is_ppc64le(void);
63 /* Yes, this is evil */
68 "[FAIL] Test FAILED on line %d\n", __LINE__); \
73 /* The test harness uses this, yes it's gross */
74 #define MAGIC_SKIP_RETURN_VALUE 99
80 "[SKIP] Test skipped on line %d\n", __LINE__); \
81 return MAGIC_SKIP_RETURN_VALUE; \
85 #define SKIP_IF_MSG(x, msg) \
89 "[SKIP] Test skipped on line %d: %s\n", \
91 return MAGIC_SKIP_RETURN_VALUE; \
96 #define str(s) _str(s)
99 #ifndef PPC_FEATURE2_ARCH_3_00
100 #define PPC_FEATURE2_ARCH_3_00 0x00800000
103 #if defined(__powerpc64__)
104 #define UCONTEXT_NIA(UC) (UC)->uc_mcontext.gp_regs[PT_NIP]
105 #define UCONTEXT_MSR(UC) (UC)->uc_mcontext.gp_regs[PT_MSR]
106 #elif defined(__powerpc__)
107 #define UCONTEXT_NIA(UC) (UC)->uc_mcontext.uc_regs->gregs[PT_NIP]
108 #define UCONTEXT_MSR(UC) (UC)->uc_mcontext.uc_regs->gregs[PT_MSR]
110 #error implement UCONTEXT_NIA
113 #endif /* _SELFTESTS_POWERPC_UTILS_H */