0001
0002
0003
0004
0005
0006 #include <stdio.h>
0007 #include <stdlib.h>
0008
0009 #include "ebb.h"
0010
0011
0012
0013
0014
0015 int cycles(void)
0016 {
0017 struct event event;
0018
0019 SKIP_IF(!ebb_is_supported());
0020
0021 event_init_named(&event, 0x1001e, "cycles");
0022 event_leader_ebb_init(&event);
0023
0024 event.attr.exclude_kernel = 1;
0025 event.attr.exclude_hv = 1;
0026 event.attr.exclude_idle = 1;
0027
0028 FAIL_IF(event_open(&event));
0029
0030 ebb_enable_pmc_counting(1);
0031 setup_ebb_handler(standard_ebb_callee);
0032 ebb_global_enable();
0033 FAIL_IF(ebb_event_enable(&event));
0034
0035 mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
0036
0037 while (ebb_state.stats.ebb_count < 10) {
0038 FAIL_IF(core_busy_loop());
0039 FAIL_IF(ebb_check_mmcr0());
0040 }
0041
0042 ebb_global_disable();
0043 ebb_freeze_pmcs();
0044
0045 dump_ebb_state();
0046
0047 event_close(&event);
0048
0049 FAIL_IF(ebb_state.stats.ebb_count == 0);
0050 FAIL_IF(!ebb_check_count(1, sample_period, 100));
0051
0052 return 0;
0053 }
0054
0055 int main(void)
0056 {
0057 return test_harness(cycles, "cycles");
0058 }