Home | History | Annotate | Download | only in ptrace
      1 /*
      2  * Copyright (C) 2015 Anshuman Khandual, IBM Corporation.
      3  *
      4  * This program is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU General Public License
      6  * as published by the Free Software Foundation; either version
      7  * 2 of the License, or (at your option) any later version.
      8  */
      9 #define VEC_MAX 128
     10 #define VSX_MAX 32
     11 #define VMX_MAX 32
     12 
     13 /*
     14  * unsigned long vsx[32]
     15  * unsigned long load[128]
     16  */
     17 int validate_vsx(unsigned long *vsx, unsigned long *load)
     18 {
     19 	int i;
     20 
     21 	for (i = 0; i < VSX_MAX; i++) {
     22 		if (vsx[i] != load[2 * i + 1]) {
     23 			printf("vsx[%d]: %lx load[%d] %lx\n",
     24 					i, vsx[i], 2 * i + 1, load[2 * i + 1]);
     25 			return TEST_FAIL;
     26 		}
     27 	}
     28 	return TEST_PASS;
     29 }
     30 
     31 /*
     32  * unsigned long vmx[32][2]
     33  * unsigned long load[128]
     34  */
     35 int validate_vmx(unsigned long vmx[][2], unsigned long *load)
     36 {
     37 	int i;
     38 
     39 	for (i = 0; i < VMX_MAX; i++) {
     40 		#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
     41 		if ((vmx[i][0] != load[64 + 2 * i]) ||
     42 				(vmx[i][1] != load[65 + 2 * i])) {
     43 			printf("vmx[%d][0]: %lx load[%d] %lx\n",
     44 					i, vmx[i][0], 64 + 2 * i,
     45 					load[64 + 2 * i]);
     46 			printf("vmx[%d][1]: %lx load[%d] %lx\n",
     47 					i, vmx[i][1], 65 + 2 * i,
     48 					load[65 + 2 * i]);
     49 			return TEST_FAIL;
     50 		}
     51 		#else  /*
     52 			* In LE each value pair is stored in an
     53 			* alternate manner.
     54 			*/
     55 		if ((vmx[i][0] != load[65 + 2 * i]) ||
     56 				(vmx[i][1] != load[64 + 2 * i])) {
     57 			printf("vmx[%d][0]: %lx load[%d] %lx\n",
     58 					i, vmx[i][0], 65 + 2 * i,
     59 					load[65 + 2 * i]);
     60 			printf("vmx[%d][1]: %lx load[%d] %lx\n",
     61 					i, vmx[i][1], 64 + 2 * i,
     62 					load[64 + 2 * i]);
     63 			return TEST_FAIL;
     64 		}
     65 		#endif
     66 	}
     67 	return TEST_PASS;
     68 }
     69 
     70 /*
     71  * unsigned long store[128]
     72  * unsigned long load[128]
     73  */
     74 int compare_vsx_vmx(unsigned long *store, unsigned long *load)
     75 {
     76 	int i;
     77 
     78 	for (i = 0; i < VSX_MAX; i++) {
     79 		if (store[1 + 2 * i] != load[1 + 2 * i]) {
     80 			printf("store[%d]: %lx load[%d] %lx\n",
     81 					1 + 2 * i, store[i],
     82 					1 + 2 * i, load[i]);
     83 			return TEST_FAIL;
     84 		}
     85 	}
     86 
     87 	#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
     88 	for (i = 64; i < VEC_MAX; i++) {
     89 		if (store[i] != load[i]) {
     90 			printf("store[%d]: %lx load[%d] %lx\n",
     91 					i, store[i], i, load[i]);
     92 			return TEST_FAIL;
     93 		}
     94 	}
     95 	#else	/* In LE each value pair is stored in an alternate manner */
     96 	for (i = 64; i < VEC_MAX; i++) {
     97 		if (!(i % 2) && (store[i] != load[i+1])) {
     98 			printf("store[%d]: %lx load[%d] %lx\n",
     99 					i, store[i], i+1, load[i+1]);
    100 			return TEST_FAIL;
    101 		}
    102 		if ((i % 2) && (store[i] != load[i-1])) {
    103 			printf("here store[%d]: %lx load[%d] %lx\n",
    104 					i, store[i], i-1, load[i-1]);
    105 			return TEST_FAIL;
    106 		}
    107 	}
    108 	#endif
    109 	return TEST_PASS;
    110 }
    111 
    112 void load_vsx_vmx(unsigned long *load, unsigned long *vsx,
    113 		unsigned long vmx[][2])
    114 {
    115 	int i;
    116 
    117 	for (i = 0; i < VSX_MAX; i++)
    118 		vsx[i] = load[1 + 2 * i];
    119 
    120 	for (i = 0; i < VMX_MAX; i++) {
    121 		vmx[i][0] = load[64 + 2 * i];
    122 		vmx[i][1] = load[65 + 2 * i];
    123 	}
    124 }
    125 
    126 void loadvsx(void *p, int tmp);
    127 void storevsx(void *p, int tmp);
    128