aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/powerpc/pmu/ebb/ebb_lmr_regs.c
blob: aff4241fd88ac6d5dc2ad001656821165eb27283 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright 2016, Jack Miller, IBM Corp.
 * Licensed under GPLv2.
 */

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

#include "ebb.h"
#include "ebb_lmr.h"

#define CHECKS 10000

int ebb_lmr_regs(void)
{
	int i;

	SKIP_IF(!lmr_is_supported());

	ebb_global_enable();

	for (i = 0; i < CHECKS; i++) {
		mtspr(SPRN_LMRR, i << 25);	// skip size and rsvd bits
		mtspr(SPRN_LMSER, i);

		FAIL_IF(mfspr(SPRN_LMRR) != (i << 25));
		FAIL_IF(mfspr(SPRN_LMSER) != i);
	}

	return 0;
}

int main(void)
{
	return test_harness(ebb_lmr_regs, "ebb_lmr_regs");
}