0001
0002
0003
0004
0005
0006 #include <stdio.h>
0007 #include <stdlib.h>
0008
0009 #include "../event.h"
0010 #include "misc.h"
0011 #include "utils.h"
0012
0013 extern void thirty_two_instruction_loop(int loops);
0014
0015
0016 #define EventCode 0x500fa
0017
0018
0019 #define IFM_COND_BRANCH 0x3
0020
0021
0022
0023
0024
0025 static int mmcra_bhrb_cond_test(void)
0026 {
0027 struct event event;
0028 u64 *intr_regs;
0029
0030
0031
0032
0033
0034 SKIP_IF(check_pvr_for_sampling_tests());
0035 SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
0036
0037
0038 event_init_sampling(&event, EventCode);
0039 event.attr.sample_regs_intr = platform_extended_mask;
0040 event.attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
0041 event.attr.branch_sample_type = PERF_SAMPLE_BRANCH_COND;
0042 event.attr.exclude_kernel = 1;
0043
0044 FAIL_IF(event_open(&event));
0045 event.mmap_buffer = event_sample_buf_mmap(event.fd, 1);
0046
0047 FAIL_IF(event_enable(&event));
0048
0049
0050 thirty_two_instruction_loop(10000);
0051
0052 FAIL_IF(event_disable(&event));
0053
0054 intr_regs = get_intr_regs(&event, event.mmap_buffer);
0055
0056
0057 FAIL_IF(!intr_regs);
0058
0059
0060 FAIL_IF(get_mmcra_ifm(get_reg_value(intr_regs, "MMCRA"), 5) != IFM_COND_BRANCH);
0061
0062 event_close(&event);
0063 return 0;
0064 }
0065
0066 int main(void)
0067 {
0068 return test_harness(mmcra_bhrb_cond_test, "mmcra_bhrb_cond_test");
0069 }