xref: /onnv-gate/usr/src/cmd/fps/fptest/cbbcopy.c (revision 6429:a90bb8316257)
1*6429Svs195195 /*
2*6429Svs195195  * CDDL HEADER START
3*6429Svs195195  *
4*6429Svs195195  * The contents of this file are subject to the terms of the
5*6429Svs195195  * Common Development and Distribution License (the "License").
6*6429Svs195195  * You may not use this file except in compliance with the License.
7*6429Svs195195  *
8*6429Svs195195  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*6429Svs195195  * or http://www.opensolaris.org/os/licensing.
10*6429Svs195195  * See the License for the specific language governing permissions
11*6429Svs195195  * and limitations under the License.
12*6429Svs195195  *
13*6429Svs195195  * When distributing Covered Code, include this CDDL HEADER in each
14*6429Svs195195  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*6429Svs195195  * If applicable, add the following below this CDDL HEADER, with the
16*6429Svs195195  * fields enclosed by brackets "[]" replaced with your own identifying
17*6429Svs195195  * information: Portions Copyright [yyyy] [name of copyright owner]
18*6429Svs195195  *
19*6429Svs195195  * CDDL HEADER END
20*6429Svs195195  */
21*6429Svs195195 
22*6429Svs195195 /*
23*6429Svs195195  * Copyright 2008 Sun Microsystems, Inc.
24*6429Svs195195  * All rights reserved.
25*6429Svs195195  * Use is subject to license terms.
26*6429Svs195195  */
27*6429Svs195195 
28*6429Svs195195 #pragma ident	"%Z%%M%	%I%	%E% SMI"
29*6429Svs195195 
30*6429Svs195195 #include <stdio.h>
31*6429Svs195195 #include <stdlib.h>
32*6429Svs195195 #include <fp.h>
33*6429Svs195195 #include <fps_ereport.h>
34*6429Svs195195 
35*6429Svs195195 #pragma align 64(datain1, datain2, dataout)
36*6429Svs195195 
37*6429Svs195195 int cbbcopy(struct fps_test_ereport *report);
38*6429Svs195195 static void	asi_bcopy_f0(uint32_t *out, uint32_t *in);
39*6429Svs195195 static void	asi_bcopy_f16(uint32_t *out, uint32_t *in);
40*6429Svs195195 static void	ax_bcopy(uint32_t *out, uint32_t *in);
41*6429Svs195195 
42*6429Svs195195 static uint32_t dataout[64];
43*6429Svs195195 
44*6429Svs195195 static uint32_t datain1[64] = {
45*6429Svs195195 0x55555500, 0x55555501, 0xaaaaaa02, 0xaaaaaa03,
46*6429Svs195195 0x55555504, 0x55555505, 0xaaaaaa06, 0xaaaaaa07,
47*6429Svs195195 0x55555508, 0x55555509, 0xaaaaaa0a, 0xaaaaaa0b,
48*6429Svs195195 0x5555550c, 0x5555550d, 0xaaaaaa0e, 0xaaaaaa0f,
49*6429Svs195195 0x55555510, 0x55555511, 0xaaaaaa12, 0xaaaaaa13,
50*6429Svs195195 0x55555514, 0x55555515, 0xaaaaaa16, 0xaaaaaa17,
51*6429Svs195195 0x55555518, 0x55555519, 0xaaaaaa1a, 0xaaaaaa1b,
52*6429Svs195195 0x5555551c, 0x5555551d, 0xaaaaaa1e, 0xaaaaaa1f,
53*6429Svs195195 0x55555520, 0x55555521, 0xaaaaaa22, 0xaaaaaa23,
54*6429Svs195195 0x55555524, 0x55555525, 0xaaaaaa26, 0xaaaaaa27,
55*6429Svs195195 0x55555528, 0x55555529, 0xaaaaaa2a, 0xaaaaaa2b,
56*6429Svs195195 0x5555552c, 0x5555552d, 0xaaaaaa2e, 0xaaaaaa2f,
57*6429Svs195195 0x55555530, 0x55555531, 0xaaaaaa32, 0xaaaaaa33,
58*6429Svs195195 0x55555534, 0x55555535, 0xaaaaaa36, 0xaaaaaa37,
59*6429Svs195195 0x55555538, 0x55555539, 0xaaaaaa3a, 0xaaaaaa3b,
60*6429Svs195195 0x5555553c, 0x5555553d, 0xaaaaaa3e, 0xaaaaaa3f
61*6429Svs195195 };
62*6429Svs195195 
63*6429Svs195195 static uint32_t datain2[64] = {
64*6429Svs195195 0xaaaaaaff, 0xaaaaaafe, 0x555555fd, 0x555555fc,
65*6429Svs195195 0xaaaaaafb, 0xaaaaaafa, 0x555555f9, 0x555555f8,
66*6429Svs195195 0xaaaaaaf7, 0xaaaaaaf6, 0x555555f5, 0x555555f4,
67*6429Svs195195 0xaaaaaaf3, 0xaaaaaaf2, 0x555555f1, 0x555555f0,
68*6429Svs195195 0xaaaaaaef, 0xaaaaaaee, 0x555555ed, 0x555555ec,
69*6429Svs195195 0xaaaaaaeb, 0xaaaaaaea, 0x555555e9, 0x555555e8,
70*6429Svs195195 0xaaaaaae7, 0xaaaaaae6, 0x555555e5, 0x555555e4,
71*6429Svs195195 0xaaaaaae3, 0xaaaaaae2, 0x555555e1, 0x555555e0,
72*6429Svs195195 0xaaaaaadf, 0xaaaaaade, 0x555555dd, 0x555555dc,
73*6429Svs195195 0xaaaaaadb, 0xaaaaaada, 0x555555d9, 0x555555d8,
74*6429Svs195195 0xaaaaaad7, 0xaaaaaad6, 0x555555d5, 0x555555d4,
75*6429Svs195195 0xaaaaaad3, 0xaaaaaad2, 0x555555d1, 0x555555d0,
76*6429Svs195195 0xaaaaaacf, 0xaaaaaace, 0x555555cd, 0x555555cc,
77*6429Svs195195 0xaaaaaacb, 0xaaaaaaca, 0x555555c9, 0x555555c8,
78*6429Svs195195 0xaaaaaac7, 0xaaaaaac6, 0x555555c5, 0x555555c4,
79*6429Svs195195 0xaaaaaac3, 0xaaaaaac2, 0x555555c1, 0x555555c0
80*6429Svs195195 };
81*6429Svs195195 
82*6429Svs195195 /*
83*6429Svs195195  * cbbcopy(int unit, struct fps_test_ereport *report)
84*6429Svs195195  * exercises block load and store path thru floating point
85*6429Svs195195  * registers. Returns whether load/store was successful.
86*6429Svs195195  * If an error, all relevant data is stored in report.
87*6429Svs195195  * Purpose: FRF integraty check thru both block ld/st and P$
88*6429Svs195195  * ax/ms pipe for health check online check utility. The utility is intented
89*6429Svs195195  * to detect simple stuck at fault not timing related faults.
90*6429Svs195195  */
91*6429Svs195195 int
92*6429Svs195195 cbbcopy(struct fps_test_ereport *report)
93*6429Svs195195 {
94*6429Svs195195 	int i;
95*6429Svs195195 	uint64_t expect;
96*6429Svs195195 	uint64_t observe;
97*6429Svs195195 
98*6429Svs195195 	ax_bcopy(dataout, datain1);
99*6429Svs195195 	asi_bcopy_f0(dataout, dataout);
100*6429Svs195195 
101*6429Svs195195 	for (i = 0; i < 64; i++) {
102*6429Svs195195 		if (dataout[i] != datain1[i]) {
103*6429Svs195195 			expect = (uint64_t)datain1[i];
104*6429Svs195195 			observe = (uint64_t)dataout[i];
105*6429Svs195195 			setup_fps_test_struct(NO_EREPORT_INFO, report,
106*6429Svs195195 			    6337, &observe, &expect, 1, 1);
107*6429Svs195195 
108*6429Svs195195 			return (FPU_FOROFFLINE);
109*6429Svs195195 		}
110*6429Svs195195 	}
111*6429Svs195195 
112*6429Svs195195 	ax_bcopy(dataout, datain2);
113*6429Svs195195 	asi_bcopy_f16(dataout, dataout);
114*6429Svs195195 
115*6429Svs195195 	for (i = 0; i < 64; i++) {
116*6429Svs195195 		if (dataout[i] != datain2[i]) {
117*6429Svs195195 			expect = (uint64_t)datain2[i];
118*6429Svs195195 			observe = (uint64_t)dataout[i];
119*6429Svs195195 			setup_fps_test_struct(NO_EREPORT_INFO, report,
120*6429Svs195195 			    6338, &observe, &expect, 1, 1);
121*6429Svs195195 
122*6429Svs195195 			return (FPU_FOROFFLINE);
123*6429Svs195195 		}
124*6429Svs195195 	}
125*6429Svs195195 
126*6429Svs195195 	return (FPU_OK);
127*6429Svs195195 }
128*6429Svs195195 
129*6429Svs195195 /*
130*6429Svs195195  * asi_bcopy_f0(uint32_t *out, uint32_t *in)
131*6429Svs195195  * does the assembly load/store of in to out
132*6429Svs195195  */
133*6429Svs195195 /* ARGSUSED */
134*6429Svs195195 static void
135*6429Svs195195 asi_bcopy_f0(uint32_t *out, uint32_t *in)
136*6429Svs195195 {
137*6429Svs195195 	asm("ldda	[%i1]0xf8,%f0");
138*6429Svs195195 	asm("membar	#Sync");
139*6429Svs195195 	asm("stda	%f0,[%i0]0xf0");
140*6429Svs195195 	asm("membar	#Sync");
141*6429Svs195195 }
142*6429Svs195195 
143*6429Svs195195 /*
144*6429Svs195195  * asi_bcopy_f16(uint32_t *out, uint32_t *in)
145*6429Svs195195  * does the assembly load/store of in to out
146*6429Svs195195  */
147*6429Svs195195 /* ARGSUSED */
148*6429Svs195195 static void
149*6429Svs195195 asi_bcopy_f16(uint32_t *out, uint32_t *in)
150*6429Svs195195 {
151*6429Svs195195 	asm("ldda	[%i1]0xf0,%f16");
152*6429Svs195195 	asm("membar	#Sync");
153*6429Svs195195 	asm("stda	%f16,[%i0]0xf8");
154*6429Svs195195 	asm("membar	#Sync");
155*6429Svs195195 }
156*6429Svs195195 
157*6429Svs195195 /*
158*6429Svs195195  * ax_bcopy(uint32_t *out, uint32_t *in)
159*6429Svs195195  * does the assembly load/store of in to out
160*6429Svs195195  */
161*6429Svs195195 /* ARGSUSED */
162*6429Svs195195 static void
163*6429Svs195195 ax_bcopy(uint32_t *out, uint32_t *in)
164*6429Svs195195 {
165*6429Svs195195 	asm("prefetch	[%i1],21");
166*6429Svs195195 	asm("prefetch	[%i1+0x40],21");
167*6429Svs195195 	asm("ldd	[%i1],%f16");
168*6429Svs195195 	asm("ldd	[%i1+8],%f18");
169*6429Svs195195 	asm("ldd	[%i1+0x10],%f20");
170*6429Svs195195 	asm("ldd	[%i1+0x18],%f22");
171*6429Svs195195 	asm("ldd	[%i1+0x20],%f24");
172*6429Svs195195 	asm("ldd	[%i1+0x28],%f26");
173*6429Svs195195 	asm("ldd	[%i1+0x30],%f28");
174*6429Svs195195 	asm("ldd	[%i1+0x38],%f30");
175*6429Svs195195 	asm("ldd	[%i1+0x40],%f32");
176*6429Svs195195 
177*6429Svs195195 	asm("prefetch	[%i1+0x80],21");
178*6429Svs195195 	asm("ldd	[%i1+0x48],%f34");
179*6429Svs195195 	asm("ldd	[%i1+0x50],%f36");
180*6429Svs195195 	asm("ldd	[%i1+0x58],%f38");
181*6429Svs195195 	asm("ldd	[%i1+0x60],%f40");
182*6429Svs195195 	asm("ldd	[%i1+0x68],%f42");
183*6429Svs195195 	asm("ldd	[%i1+0x70],%f44");
184*6429Svs195195 	asm("ldd	[%i1+0x78],%f46");
185*6429Svs195195 
186*6429Svs195195 	asm("prefetch	[%i1+0xc0],21");
187*6429Svs195195 	asm("ldd	[%i1+0x80],%f0");
188*6429Svs195195 	asm("ldd	[%i1+0x88],%f2");
189*6429Svs195195 	asm("ldd	[%i1+0x90],%f4");
190*6429Svs195195 	asm("ldd	[%i1+0x98],%f6");
191*6429Svs195195 	asm("ldd	[%i1+0xa0],%f8");
192*6429Svs195195 	asm("ldd	[%i1+0xa8],%f10");
193*6429Svs195195 	asm("ldd	[%i1+0xb0],%f12");
194*6429Svs195195 	asm("ldd	[%i1+0xb8],%f14");
195*6429Svs195195 
196*6429Svs195195 	asm("ldd	[%i1+0xc0],%f48");
197*6429Svs195195 	asm("ldd	[%i1+0xc8],%f50");
198*6429Svs195195 	asm("ldd	[%i1+0xd0],%f52");
199*6429Svs195195 	asm("ldd	[%i1+0xd8],%f54");
200*6429Svs195195 	asm("ldd	[%i1+0xe0],%f56");
201*6429Svs195195 	asm("ldd	[%i1+0xe8],%f58");
202*6429Svs195195 	asm("ldd	[%i1+0xf0],%f60");
203*6429Svs195195 	asm("ldd	[%i1+0xf8],%f62");
204*6429Svs195195 
205*6429Svs195195 	asm("membar	#Sync");
206*6429Svs195195 	asm("stda	%f16,[%i0]0xf8");
207*6429Svs195195 	asm("add	%i0,0x40,%i0");
208*6429Svs195195 	asm("stda	%f32,[%i0]0xf0");
209*6429Svs195195 	asm("add	%i0,0x40,%i0");
210*6429Svs195195 	asm("stda	%f0,[%i0]0xf0");
211*6429Svs195195 	asm("add	%i0,0x40,%i0");
212*6429Svs195195 	asm("stda	%f48,[%i0]0xf0");
213*6429Svs195195 	asm("membar	#Sync");
214*6429Svs195195 }
215