18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2015 Anshuman Khandual, IBM Corporation. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci#define GPR_1 1 68c2ecf20Sopenharmony_ci#define GPR_2 2 78c2ecf20Sopenharmony_ci#define GPR_3 3 88c2ecf20Sopenharmony_ci#define GPR_4 4 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define FPR_1 0.001 118c2ecf20Sopenharmony_ci#define FPR_2 0.002 128c2ecf20Sopenharmony_ci#define FPR_3 0.003 138c2ecf20Sopenharmony_ci#define FPR_4 0.004 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define FPR_1_REP 0x3f50624de0000000 168c2ecf20Sopenharmony_ci#define FPR_2_REP 0x3f60624de0000000 178c2ecf20Sopenharmony_ci#define FPR_3_REP 0x3f689374c0000000 188c2ecf20Sopenharmony_ci#define FPR_4_REP 0x3f70624de0000000 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* Buffer must have 18 elements */ 218c2ecf20Sopenharmony_ciint validate_gpr(unsigned long *gpr, unsigned long val) 228c2ecf20Sopenharmony_ci{ 238c2ecf20Sopenharmony_ci int i, found = 1; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci for (i = 0; i < 18; i++) { 268c2ecf20Sopenharmony_ci if (gpr[i] != val) { 278c2ecf20Sopenharmony_ci printf("GPR[%d]: %lx Expected: %lx\n", 288c2ecf20Sopenharmony_ci i+14, gpr[i], val); 298c2ecf20Sopenharmony_ci found = 0; 308c2ecf20Sopenharmony_ci } 318c2ecf20Sopenharmony_ci } 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci if (!found) 348c2ecf20Sopenharmony_ci return TEST_FAIL; 358c2ecf20Sopenharmony_ci return TEST_PASS; 368c2ecf20Sopenharmony_ci} 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* Buffer must have 32 elements */ 398c2ecf20Sopenharmony_ciint validate_fpr(unsigned long *fpr, unsigned long val) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci int i, found = 1; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci for (i = 0; i < 32; i++) { 448c2ecf20Sopenharmony_ci if (fpr[i] != val) { 458c2ecf20Sopenharmony_ci printf("FPR[%d]: %lx Expected: %lx\n", i, fpr[i], val); 468c2ecf20Sopenharmony_ci found = 0; 478c2ecf20Sopenharmony_ci } 488c2ecf20Sopenharmony_ci } 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci if (!found) 518c2ecf20Sopenharmony_ci return TEST_FAIL; 528c2ecf20Sopenharmony_ci return TEST_PASS; 538c2ecf20Sopenharmony_ci} 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci/* Buffer must have 32 elements */ 568c2ecf20Sopenharmony_ciint validate_fpr_float(float *fpr, float val) 578c2ecf20Sopenharmony_ci{ 588c2ecf20Sopenharmony_ci int i, found = 1; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci for (i = 0; i < 32; i++) { 618c2ecf20Sopenharmony_ci if (fpr[i] != val) { 628c2ecf20Sopenharmony_ci printf("FPR[%d]: %f Expected: %f\n", i, fpr[i], val); 638c2ecf20Sopenharmony_ci found = 0; 648c2ecf20Sopenharmony_ci } 658c2ecf20Sopenharmony_ci } 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci if (!found) 688c2ecf20Sopenharmony_ci return TEST_FAIL; 698c2ecf20Sopenharmony_ci return TEST_PASS; 708c2ecf20Sopenharmony_ci} 71