1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2015 Anshuman Khandual, IBM Corporation.
4  */
5 #define GPR_1	1
6 #define GPR_2	2
7 #define GPR_3	3
8 #define GPR_4	4
9 
10 #define FPR_1	0.001
11 #define FPR_2	0.002
12 #define FPR_3	0.003
13 #define FPR_4	0.004
14 
15 #define FPR_1_REP 0x3f50624dd2f1a9fcull
16 #define FPR_2_REP 0x3f60624dd2f1a9fcull
17 #define FPR_3_REP 0x3f689374bc6a7efaull
18 #define FPR_4_REP 0x3f70624dd2f1a9fcull
19 
20 /* Buffer must have 18 elements */
validate_gpr(unsigned long * gpr,unsigned long val)21 int validate_gpr(unsigned long *gpr, unsigned long val)
22 {
23 	int i, found = 1;
24 
25 	for (i = 0; i < 18; i++) {
26 		if (gpr[i] != val) {
27 			printf("GPR[%d]: %lx Expected: %lx\n",
28 				i+14, gpr[i], val);
29 			found = 0;
30 		}
31 	}
32 
33 	if (!found)
34 		return TEST_FAIL;
35 	return TEST_PASS;
36 }
37 
38 /* Buffer must have 32 elements */
validate_fpr(__u64 * fpr,__u64 val)39 int validate_fpr(__u64 *fpr, __u64 val)
40 {
41 	int i, found = 1;
42 
43 	for (i = 0; i < 32; i++) {
44 		if (fpr[i] != val) {
45 			printf("FPR[%d]: %llx Expected: %llx\n", i, fpr[i], val);
46 			found = 0;
47 		}
48 	}
49 
50 	if (!found)
51 		return TEST_FAIL;
52 	return TEST_PASS;
53 }
54 
55 /* Buffer must have 32 elements */
validate_fpr_double(double * fpr,double val)56 int validate_fpr_double(double *fpr, double val)
57 {
58 	int i, found = 1;
59 
60 	for (i = 0; i < 32; i++) {
61 		if (fpr[i] != val) {
62 			printf("FPR[%d]: %f Expected: %f\n", i, fpr[i], val);
63 			found = 0;
64 		}
65 	}
66 
67 	if (!found)
68 		return TEST_FAIL;
69 	return TEST_PASS;
70 }
71