xref: /onnv-gate/usr/src/cmd/fps/fptest/cbbcopy.c (revision 6491:448e02e63395)
16429Svs195195 /*
26429Svs195195  * CDDL HEADER START
36429Svs195195  *
46429Svs195195  * The contents of this file are subject to the terms of the
56429Svs195195  * Common Development and Distribution License (the "License").
66429Svs195195  * You may not use this file except in compliance with the License.
76429Svs195195  *
86429Svs195195  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96429Svs195195  * or http://www.opensolaris.org/os/licensing.
106429Svs195195  * See the License for the specific language governing permissions
116429Svs195195  * and limitations under the License.
126429Svs195195  *
136429Svs195195  * When distributing Covered Code, include this CDDL HEADER in each
146429Svs195195  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156429Svs195195  * If applicable, add the following below this CDDL HEADER, with the
166429Svs195195  * fields enclosed by brackets "[]" replaced with your own identifying
176429Svs195195  * information: Portions Copyright [yyyy] [name of copyright owner]
186429Svs195195  *
196429Svs195195  * CDDL HEADER END
206429Svs195195  */
216429Svs195195 
226429Svs195195 /*
23*6491Sia112686  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
246429Svs195195  * Use is subject to license terms.
256429Svs195195  */
266429Svs195195 
276429Svs195195 #pragma ident	"%Z%%M%	%I%	%E% SMI"
286429Svs195195 
296429Svs195195 #include <stdio.h>
306429Svs195195 #include <stdlib.h>
316429Svs195195 #include <fp.h>
326429Svs195195 #include <fps_ereport.h>
336429Svs195195 
346429Svs195195 #pragma align 64(datain1, datain2, dataout)
356429Svs195195 
366429Svs195195 int cbbcopy(struct fps_test_ereport *report);
376429Svs195195 static void	asi_bcopy_f0(uint32_t *out, uint32_t *in);
386429Svs195195 static void	asi_bcopy_f16(uint32_t *out, uint32_t *in);
396429Svs195195 static void	ax_bcopy(uint32_t *out, uint32_t *in);
406429Svs195195 
416429Svs195195 static uint32_t dataout[64];
426429Svs195195 
436429Svs195195 static uint32_t datain1[64] = {
446429Svs195195 0x55555500, 0x55555501, 0xaaaaaa02, 0xaaaaaa03,
456429Svs195195 0x55555504, 0x55555505, 0xaaaaaa06, 0xaaaaaa07,
466429Svs195195 0x55555508, 0x55555509, 0xaaaaaa0a, 0xaaaaaa0b,
476429Svs195195 0x5555550c, 0x5555550d, 0xaaaaaa0e, 0xaaaaaa0f,
486429Svs195195 0x55555510, 0x55555511, 0xaaaaaa12, 0xaaaaaa13,
496429Svs195195 0x55555514, 0x55555515, 0xaaaaaa16, 0xaaaaaa17,
506429Svs195195 0x55555518, 0x55555519, 0xaaaaaa1a, 0xaaaaaa1b,
516429Svs195195 0x5555551c, 0x5555551d, 0xaaaaaa1e, 0xaaaaaa1f,
526429Svs195195 0x55555520, 0x55555521, 0xaaaaaa22, 0xaaaaaa23,
536429Svs195195 0x55555524, 0x55555525, 0xaaaaaa26, 0xaaaaaa27,
546429Svs195195 0x55555528, 0x55555529, 0xaaaaaa2a, 0xaaaaaa2b,
556429Svs195195 0x5555552c, 0x5555552d, 0xaaaaaa2e, 0xaaaaaa2f,
566429Svs195195 0x55555530, 0x55555531, 0xaaaaaa32, 0xaaaaaa33,
576429Svs195195 0x55555534, 0x55555535, 0xaaaaaa36, 0xaaaaaa37,
586429Svs195195 0x55555538, 0x55555539, 0xaaaaaa3a, 0xaaaaaa3b,
596429Svs195195 0x5555553c, 0x5555553d, 0xaaaaaa3e, 0xaaaaaa3f
606429Svs195195 };
616429Svs195195 
626429Svs195195 static uint32_t datain2[64] = {
636429Svs195195 0xaaaaaaff, 0xaaaaaafe, 0x555555fd, 0x555555fc,
646429Svs195195 0xaaaaaafb, 0xaaaaaafa, 0x555555f9, 0x555555f8,
656429Svs195195 0xaaaaaaf7, 0xaaaaaaf6, 0x555555f5, 0x555555f4,
666429Svs195195 0xaaaaaaf3, 0xaaaaaaf2, 0x555555f1, 0x555555f0,
676429Svs195195 0xaaaaaaef, 0xaaaaaaee, 0x555555ed, 0x555555ec,
686429Svs195195 0xaaaaaaeb, 0xaaaaaaea, 0x555555e9, 0x555555e8,
696429Svs195195 0xaaaaaae7, 0xaaaaaae6, 0x555555e5, 0x555555e4,
706429Svs195195 0xaaaaaae3, 0xaaaaaae2, 0x555555e1, 0x555555e0,
716429Svs195195 0xaaaaaadf, 0xaaaaaade, 0x555555dd, 0x555555dc,
726429Svs195195 0xaaaaaadb, 0xaaaaaada, 0x555555d9, 0x555555d8,
736429Svs195195 0xaaaaaad7, 0xaaaaaad6, 0x555555d5, 0x555555d4,
746429Svs195195 0xaaaaaad3, 0xaaaaaad2, 0x555555d1, 0x555555d0,
756429Svs195195 0xaaaaaacf, 0xaaaaaace, 0x555555cd, 0x555555cc,
766429Svs195195 0xaaaaaacb, 0xaaaaaaca, 0x555555c9, 0x555555c8,
776429Svs195195 0xaaaaaac7, 0xaaaaaac6, 0x555555c5, 0x555555c4,
786429Svs195195 0xaaaaaac3, 0xaaaaaac2, 0x555555c1, 0x555555c0
796429Svs195195 };
806429Svs195195 
816429Svs195195 /*
826429Svs195195  * cbbcopy(int unit, struct fps_test_ereport *report)
836429Svs195195  * exercises block load and store path thru floating point
846429Svs195195  * registers. Returns whether load/store was successful.
856429Svs195195  * If an error, all relevant data is stored in report.
866429Svs195195  * Purpose: FRF integraty check thru both block ld/st and P$
876429Svs195195  * ax/ms pipe for health check online check utility. The utility is intented
886429Svs195195  * to detect simple stuck at fault not timing related faults.
896429Svs195195  */
906429Svs195195 int
cbbcopy(struct fps_test_ereport * report)916429Svs195195 cbbcopy(struct fps_test_ereport *report)
926429Svs195195 {
936429Svs195195 	int i;
946429Svs195195 	uint64_t expect;
956429Svs195195 	uint64_t observe;
966429Svs195195 
976429Svs195195 	ax_bcopy(dataout, datain1);
986429Svs195195 	asi_bcopy_f0(dataout, dataout);
996429Svs195195 
1006429Svs195195 	for (i = 0; i < 64; i++) {
1016429Svs195195 		if (dataout[i] != datain1[i]) {
1026429Svs195195 			expect = (uint64_t)datain1[i];
1036429Svs195195 			observe = (uint64_t)dataout[i];
1046429Svs195195 			setup_fps_test_struct(NO_EREPORT_INFO, report,
1056429Svs195195 			    6337, &observe, &expect, 1, 1);
1066429Svs195195 
1076429Svs195195 			return (FPU_FOROFFLINE);
1086429Svs195195 		}
1096429Svs195195 	}
1106429Svs195195 
1116429Svs195195 	ax_bcopy(dataout, datain2);
1126429Svs195195 	asi_bcopy_f16(dataout, dataout);
1136429Svs195195 
1146429Svs195195 	for (i = 0; i < 64; i++) {
1156429Svs195195 		if (dataout[i] != datain2[i]) {
1166429Svs195195 			expect = (uint64_t)datain2[i];
1176429Svs195195 			observe = (uint64_t)dataout[i];
1186429Svs195195 			setup_fps_test_struct(NO_EREPORT_INFO, report,
1196429Svs195195 			    6338, &observe, &expect, 1, 1);
1206429Svs195195 
1216429Svs195195 			return (FPU_FOROFFLINE);
1226429Svs195195 		}
1236429Svs195195 	}
1246429Svs195195 
1256429Svs195195 	return (FPU_OK);
1266429Svs195195 }
1276429Svs195195 
1286429Svs195195 /*
1296429Svs195195  * asi_bcopy_f0(uint32_t *out, uint32_t *in)
1306429Svs195195  * does the assembly load/store of in to out
1316429Svs195195  */
1326429Svs195195 /* ARGSUSED */
1336429Svs195195 static void
asi_bcopy_f0(uint32_t * out,uint32_t * in)1346429Svs195195 asi_bcopy_f0(uint32_t *out, uint32_t *in)
1356429Svs195195 {
1366429Svs195195 	asm("ldda	[%i1]0xf8,%f0");
1376429Svs195195 	asm("membar	#Sync");
1386429Svs195195 	asm("stda	%f0,[%i0]0xf0");
1396429Svs195195 	asm("membar	#Sync");
1406429Svs195195 }
1416429Svs195195 
1426429Svs195195 /*
1436429Svs195195  * asi_bcopy_f16(uint32_t *out, uint32_t *in)
1446429Svs195195  * does the assembly load/store of in to out
1456429Svs195195  */
1466429Svs195195 /* ARGSUSED */
1476429Svs195195 static void
asi_bcopy_f16(uint32_t * out,uint32_t * in)1486429Svs195195 asi_bcopy_f16(uint32_t *out, uint32_t *in)
1496429Svs195195 {
1506429Svs195195 	asm("ldda	[%i1]0xf0,%f16");
1516429Svs195195 	asm("membar	#Sync");
1526429Svs195195 	asm("stda	%f16,[%i0]0xf8");
1536429Svs195195 	asm("membar	#Sync");
1546429Svs195195 }
1556429Svs195195 
1566429Svs195195 /*
1576429Svs195195  * ax_bcopy(uint32_t *out, uint32_t *in)
1586429Svs195195  * does the assembly load/store of in to out
1596429Svs195195  */
1606429Svs195195 /* ARGSUSED */
1616429Svs195195 static void
ax_bcopy(uint32_t * out,uint32_t * in)1626429Svs195195 ax_bcopy(uint32_t *out, uint32_t *in)
1636429Svs195195 {
1646429Svs195195 	asm("prefetch	[%i1],21");
1656429Svs195195 	asm("prefetch	[%i1+0x40],21");
1666429Svs195195 	asm("ldd	[%i1],%f16");
1676429Svs195195 	asm("ldd	[%i1+8],%f18");
1686429Svs195195 	asm("ldd	[%i1+0x10],%f20");
1696429Svs195195 	asm("ldd	[%i1+0x18],%f22");
1706429Svs195195 	asm("ldd	[%i1+0x20],%f24");
1716429Svs195195 	asm("ldd	[%i1+0x28],%f26");
1726429Svs195195 	asm("ldd	[%i1+0x30],%f28");
1736429Svs195195 	asm("ldd	[%i1+0x38],%f30");
1746429Svs195195 	asm("ldd	[%i1+0x40],%f32");
1756429Svs195195 
1766429Svs195195 	asm("prefetch	[%i1+0x80],21");
1776429Svs195195 	asm("ldd	[%i1+0x48],%f34");
1786429Svs195195 	asm("ldd	[%i1+0x50],%f36");
1796429Svs195195 	asm("ldd	[%i1+0x58],%f38");
1806429Svs195195 	asm("ldd	[%i1+0x60],%f40");
1816429Svs195195 	asm("ldd	[%i1+0x68],%f42");
1826429Svs195195 	asm("ldd	[%i1+0x70],%f44");
1836429Svs195195 	asm("ldd	[%i1+0x78],%f46");
1846429Svs195195 
1856429Svs195195 	asm("prefetch	[%i1+0xc0],21");
1866429Svs195195 	asm("ldd	[%i1+0x80],%f0");
1876429Svs195195 	asm("ldd	[%i1+0x88],%f2");
1886429Svs195195 	asm("ldd	[%i1+0x90],%f4");
1896429Svs195195 	asm("ldd	[%i1+0x98],%f6");
1906429Svs195195 	asm("ldd	[%i1+0xa0],%f8");
1916429Svs195195 	asm("ldd	[%i1+0xa8],%f10");
1926429Svs195195 	asm("ldd	[%i1+0xb0],%f12");
1936429Svs195195 	asm("ldd	[%i1+0xb8],%f14");
1946429Svs195195 
1956429Svs195195 	asm("ldd	[%i1+0xc0],%f48");
1966429Svs195195 	asm("ldd	[%i1+0xc8],%f50");
1976429Svs195195 	asm("ldd	[%i1+0xd0],%f52");
1986429Svs195195 	asm("ldd	[%i1+0xd8],%f54");
1996429Svs195195 	asm("ldd	[%i1+0xe0],%f56");
2006429Svs195195 	asm("ldd	[%i1+0xe8],%f58");
2016429Svs195195 	asm("ldd	[%i1+0xf0],%f60");
2026429Svs195195 	asm("ldd	[%i1+0xf8],%f62");
2036429Svs195195 
2046429Svs195195 	asm("membar	#Sync");
2056429Svs195195 	asm("stda	%f16,[%i0]0xf8");
2066429Svs195195 	asm("add	%i0,0x40,%i0");
2076429Svs195195 	asm("stda	%f32,[%i0]0xf0");
2086429Svs195195 	asm("add	%i0,0x40,%i0");
2096429Svs195195 	asm("stda	%f0,[%i0]0xf0");
2106429Svs195195 	asm("add	%i0,0x40,%i0");
2116429Svs195195 	asm("stda	%f48,[%i0]0xf0");
2126429Svs195195 	asm("membar	#Sync");
2136429Svs195195 }
214