]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - tools/testing/selftests/powerpc/pmu/ebb/reg_access_test.c
selftests/powerpc: Run EBB tests only on POWER8
[karo-tx-linux.git] / tools / testing / selftests / powerpc / pmu / ebb / reg_access_test.c
1 /*
2  * Copyright 2014, Michael Ellerman, IBM Corp.
3  * Licensed under GPLv2.
4  */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 #include "ebb.h"
10 #include "reg.h"
11
12
13 /*
14  * Test basic access to the EBB regs, they should be user accessible with no
15  * kernel interaction required.
16  */
17 int reg_access(void)
18 {
19         uint64_t val, expected;
20
21         SKIP_IF(!ebb_is_supported());
22
23         expected = 0x8000000100000000ull;
24         mtspr(SPRN_BESCR, expected);
25         val = mfspr(SPRN_BESCR);
26
27         FAIL_IF(val != expected);
28
29         expected = 0x0000000001000000ull;
30         mtspr(SPRN_EBBHR, expected);
31         val = mfspr(SPRN_EBBHR);
32
33         FAIL_IF(val != expected);
34
35         return 0;
36 }
37
38 int main(void)
39 {
40         return test_harness(reg_access, "reg_access");
41 }