Home | History | Annotate | Download | only in fptest
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 
     22 /*
     23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     28 
     29 #include <stdio.h>
     30 #include <unistd.h>
     31 #include <fps_ereport.h>
     32 
     33 extern void	iflush(void);
     34 extern int	g1(unsigned long, unsigned long *, unsigned long *);
     35 extern int	g2(unsigned long, unsigned long *, unsigned long *);
     36 extern int	g3(unsigned long, unsigned long *, unsigned long *);
     37 extern int	g4(unsigned long, unsigned long *, unsigned long *);
     38 extern int	l0(unsigned long, unsigned long *, unsigned long *);
     39 extern int	l1(unsigned long, unsigned long *, unsigned long *);
     40 extern int	l2(unsigned long, unsigned long *, unsigned long *);
     41 extern int	l3(unsigned long, unsigned long *, unsigned long *);
     42 extern int	l4(unsigned long, unsigned long *, unsigned long *);
     43 extern int	l5(unsigned long, unsigned long *, unsigned long *);
     44 extern int	l6(unsigned long, unsigned long *, unsigned long *);
     45 extern int	l7(unsigned long, unsigned long *, unsigned long *);
     46 extern int	o0(unsigned long, unsigned long *, unsigned long *);
     47 extern int	o1(unsigned long, unsigned long *, unsigned long *);
     48 extern int	o2(unsigned long, unsigned long *, unsigned long *);
     49 extern int	o3(unsigned long, unsigned long *, unsigned long *);
     50 extern int	o4(unsigned long, unsigned long *, unsigned long *);
     51 extern int	o5(unsigned long, unsigned long *, unsigned long *);
     52 extern int	o7(unsigned long, unsigned long *, unsigned long *);
     53 
     54 typedef struct {
     55 	char	*reg;
     56 	int	(*test_func) (unsigned long, unsigned long *,\
     57 		unsigned long *);
     58 }reg_info;
     59 
     60 /* Registers to be tested and the functions to be used for it. */
     61 static
     62 reg_info	reg_func[] =
     63 {
     64 	{"g1", g1},
     65 	{"g2", g2},
     66 	{"g3", g3},
     67 	{"g4", g4},
     68 	{"l0", l0},
     69 	{"l1", l1},
     70 	{"l2", l2},
     71 	{"l3", l3},
     72 	{"l4", l4},
     73 	{"l5", l5},
     74 	{"l6", l6},
     75 	{"l7", l7},
     76 	{"o0", o0},
     77 	{"o1", o1},
     78 	{"o2", o2},
     79 	{"o3", o3},
     80 	{"o4", o4},
     81 	{"o5", o5},
     82 	/* %o6 is not tested as it is the %sp */
     83 	{"o7", o7}
     84 };
     85 
     86 #define	N_REGS (sizeof (reg_func)/sizeof (*reg_func))
     87 
     88 /*
     89  * cheetah_sdc_test(int limit, int unit, struct fps_test_ereport *report)
     90  * tests for silent data corruption first unearthed in a 750 Mhz Cheetah
     91  * (Toshiba). Returns if successful or not. If an error, relevant data
     92  * is stored in report. The test calls an assembly routine with
     93  * different target registers but essentially the same code sequence
     94  */
     95 int
     96 cheetah_sdc_test(int limit, struct fps_test_ereport *report)
     97 {
     98 	char err_data[MAX_INFO_SIZE];
     99 	int iter;
    100 	int regs;
    101 	int rval;
    102 	uint64_t expect;
    103 	uint64_t observe;
    104 	unsigned long tmp1 = 0;
    105 	unsigned long tmp2 = 0;
    106 
    107 	unsigned long pattern = 0xDEADDEADDEADDEAD;
    108 
    109 	for (regs = 0; regs < N_REGS; regs++) {
    110 		for (iter = 0; iter < limit; iter++) {
    111 			iflush();
    112 			rval = reg_func[regs].test_func(pattern, &tmp1, &tmp2);
    113 
    114 			if (rval != 0) {
    115 				(void) snprintf(err_data, sizeof (err_data),
    116 				    "Test:%d, reg:%s", iter,
    117 				    reg_func[regs].reg);
    118 				expect = (uint64_t)0;
    119 				observe = (uint64_t)rval;
    120 				setup_fps_test_struct(IS_EREPORT_INFO,
    121 				    report,	6357, &observe,
    122 				    &expect, 1, 1, err_data);
    123 
    124 				return (-1);
    125 			}
    126 		}
    127 	}
    128 
    129 	return (0);
    130 }
    131