2 * Copyright 2014, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
6 #ifndef _SELFTESTS_POWERPC_PMU_EBB_EBB_H
7 #define _SELFTESTS_POWERPC_PMU_EBB_EBB_H
14 #define PMC_INDEX(pmc) ((pmc)-1)
16 #define NUM_PMC_VALUES 128
22 volatile int ebb_count;
29 struct trace_buffer *trace;
32 extern struct ebb_state ebb_state;
34 #define COUNTER_OVERFLOW 0x80000000ull
36 static inline uint32_t pmc_sample_period(uint32_t value)
38 return COUNTER_OVERFLOW - value;
41 static inline void ebb_enable_pmc_counting(int pmc)
43 ebb_state.pmc_enable[PMC_INDEX(pmc)] = true;
46 bool ebb_check_count(int pmc, u64 sample_period, int fudge);
47 void event_leader_ebb_init(struct event *e);
48 void event_ebb_init(struct event *e);
49 void event_bhrb_init(struct event *e, unsigned ifm);
50 void setup_ebb_handler(void (*callee)(void));
51 void standard_ebb_callee(void);
52 int ebb_event_enable(struct event *e);
53 void ebb_global_enable(void);
54 void ebb_global_disable(void);
55 void ebb_freeze_pmcs(void);
56 void ebb_unfreeze_pmcs(void);
57 void event_ebb_init(struct event *e);
58 void event_leader_ebb_init(struct event *e);
59 int count_pmc(int pmc, uint32_t sample_period);
60 void dump_ebb_state(void);
61 void dump_summary_ebb_state(void);
62 void dump_ebb_hw_state(void);
63 void clear_ebb_stats(void);
64 void write_pmc(int pmc, u64 value);
65 u64 read_pmc(int pmc);
66 void reset_ebb_with_clear_mask(unsigned long mmcr0_clear_mask);
68 int ebb_check_mmcr0(void);
70 extern u64 sample_period;
72 int core_busy_loop(void);
73 int ebb_child(union pipe read_pipe, union pipe write_pipe);
74 int catch_sigill(void (*func)(void));
75 void write_pmc1(void);
77 #endif /* _SELFTESTS_POWERPC_PMU_EBB_EBB_H */