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_ANY_BRANCH 0x0
0020
0021
0022
0023
0024
0025 static int mmcra_bhrb_any_test(void)
0026 {
0027 struct event event;
0028 u64 *intr_regs;
0029
0030
0031 SKIP_IF(check_pvr_for_sampling_tests());
0032
0033
0034 event_init_sampling(&event, EventCode);
0035 event.attr.sample_regs_intr = platform_extended_mask;
0036 event.attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
0037 event.attr.branch_sample_type = PERF_SAMPLE_BRANCH_ANY;
0038 event.attr.exclude_kernel = 1;
0039
0040 FAIL_IF(event_open(&event));
0041 event.mmap_buffer = event_sample_buf_mmap(event.fd, 1);
0042
0043 FAIL_IF(event_enable(&event));
0044
0045
0046 thirty_two_instruction_loop(10000);
0047
0048 FAIL_IF(event_disable(&event));
0049
0050 intr_regs = get_intr_regs(&event, event.mmap_buffer);
0051
0052
0053 FAIL_IF(!intr_regs);
0054
0055
0056 FAIL_IF(get_mmcra_ifm(get_reg_value(intr_regs, "MMCRA"), 5) != IFM_ANY_BRANCH);
0057
0058 event_close(&event);
0059 return 0;
0060 }
0061
0062 int main(void)
0063 {
0064 return test_harness(mmcra_bhrb_any_test, "mmcra_bhrb_any_test");
0065 }