# This is a script for diagnostics for hollywood m/cs
report=4
hinv -v

menu {
    /* Display the version of the diagnostic */
echo "///////////////////////////////////////////////////////////////////////////"
    version;
echo ""
echo "                       FUNCTIONAL TEST OPTIONS "
echo "                       -----------------------"
echo "Command   Description"
echo ""
echo "ip26va    IP26/Teton diagnostics with automatic voltage change"
echo ""
echo "gfxva     XZ/Extreme diagnostics with automatic voltage change"
echo ""
echo "a2testva  A2 audio diagnostics with automatic voltage change"
echo ""
echo "                     TECHNICIAN BENCH OPTIONS"
echo "                     ------------------------"
echo "ip26      IP26/Teton diagnostics with no voltage change"
echo "gfx       XZ/Extreme diagnostics with no voltage change"
echo "a2test    A2 audio diagnostics with no voltage change"
echo ""
echo "///////////////////////////////////////////////////////////////////////////"
}

$tmp = 0;
$failed = 0;
$volts = 0;

memory {
	echo "----------------------------------------------------\n"

	$tmp = ecc
	if($tmp){
		echo "Failure detected in ecc test\n"
		$failed=1;
		wait;
	}
	echo "----------------------------------------------------\n"

	# Test local memory ( < 16MB )
	if (lkh_aa) {
		wait;
	}	
	echo "----------------------------------------------------\n"
	
	# Test local memory (16MB and up)
	# Kh test
	$tmp = memtest2 3
	if ($tmp) {
		wait;
	}	
	echo "----------------------------------------------------\n"
	
	# Address Uniqueness test
	$tmp = memtest2 0
	if ($tmp) {
		wait;
	}	
	echo "----------------------------------------------------\n"
	
	# Butterfly test
	$tmp = memtest2 7
	if ($tmp) {
		wait;
	}	
	echo "----------------------------------------------------\n"
	
	# March Y test
	$tmp = memtest2 5
	if ($tmp) {
		wait;
	}	
	echo "----------------------------------------------------\n"
	
#	$tmp=memtest
#	if($tmp) {
#		echo "Failure detected in memtest test\n"
#		$failed=1;
#		wait;
#	}	
#	echo "----------------------------------------------------\n"
}

a2test {
	$loopcount = 0;
	report =4;
	$a2tst0pass = 0;
	$a2tst0fail = 0;
	$a2tst1pass = 0;
	$a2tst1fail = 0;
	$a2tst2pass = 0;
	$a2tst2fail = 0;
	$a2tst3pass = 0;
	$a2tst3fail = 0;
	$a2tst4pass = 0;
	$a2tst4fail = 0;
	$a2tst5pass = 0;
	$a2tst5fail = 0;
	$a2tst6pass = 0;
	$a2tst6fail = 0;
	$a2tst7pass = 0;
	$a2tst7fail = 0;
	while ( $loopcount < 3 ) {
		echo ""
		echo "----------------------------------------------------"
		echo "Starting audio test loop" $loopcount
		echo "----------------------------------------------------\n"

		$a2tst = audio -t0
		if($a2tst) {
			$a2tst0fail = $a2tst0fail + 1;
			$failed = 1;
		}
		else {
			$a2tst0pass = $a2tst0pass + 1;
		}
		a2tst = audio -t1
		if($a2tst) {
			$a2tst1fail = $a2tst1fail + 1;
			$failed = 1;
		}
		else {
			$a2tst1pass = $a2tst1pass + 1;
		}
		a2tst = audio -t2
		if($a2tst) {
			$a2tst2fail = $a2tst2fail + 1;
			$failed = 1;
		}
		else {
			$a2tst2pass = $a2tst2pass + 1;
		}
		a2tst = audio -t3
		if($a2tst) 
			$a2tst3fail = $a2tst3fail + 1;
		else
			$a2tst3pass = $a2tst3pass + 1;
		a2tst = audio -t4
		if($a2tst)
			$a2tst4fail = $a2tst4fail + 1;
		else
			$a2tst4pass = $a2tst4pass + 1;
		a2tst = audio -t5
		if($a2tst) {
			$a2tst5fail = $a2tst5fail + 1;
			$failed = 1;
		}
		else {
			$a2tst5pass = $a2tst5pass + 1;
		}
		a2tst = audio -t6
		if($a2tst) {
			$a2tst6fail = $a2tst6fail + 1;
			$failed = 1;
		}
		else {
			$a2tst6pass = $a2tst6pass + 1;
		}
		a2tst = audio -t7
		if($a2tst) 
			$a2tst7fail = $a2tst7fail + 1;
		else
			$a2tst7pass = $a2tst7pass + 1;

		$loopcount = $loopcount + 1;
	}
	echo "audio test 0: 	Pass =" $a2tst0pass"	fail =" $a2tst0fail
	echo "audio test 1: 	Pass =" $a2tst1pass"	fail =" $a2tst1fail
	echo "audio test 2: 	Pass =" $a2tst2pass"	fail =" $a2tst2fail
	echo "audio test 3: 	Pass =" $a2tst3pass"	fail =" $a2tst3fail
	echo "audio test 4: 	Pass =" $a2tst4pass"	fail =" $a2tst4fail
	echo "audio test 5: 	Pass =" $a2tst5pass"	fail =" $a2tst5fail
	echo "audio test 6: 	Pass =" $a2tst6pass"	fail =" $a2tst6fail
	echo "audio test 7: 	Pass =" $a2tst7pass"	fail =" $a2tst7fail
	wait;

	if( $a2tst7pass == 0 ) {
		# Rerun audio -t7 ten more times to get it to pass
		echo "Audio test 7 failed three loops."
		echo "Press ENTER to run audio test 7 for 10 more loops"
		wait;
		$report=1
		$loopcount = 0;
		while ( $loopcount < 10 ) {
			a2tst = audio -t7
			if($a2tst) {
				$a2tst7fail = $a2tst7fail + 1;
			}
			else {
				$a2tst7pass = $a2tst7pass + 1;
				$loopcount = 10
			}
			$loopcount = $loopcount + 1;
		}
		if( $a2tst7pass == 0 ) {
			echo "Audio test 7 FAILED."
			echo "Reject this system with an Audio failure"
			$failed = 1;
		}
	}
}

boot_unix {
	echo "<<<< About to to boot UNIX......>>>>"
	boot dksc(0,1,0)unix;
}

teton {

#	echo "----------------------------------------------------\n"
	# fast iu test
#	if (fast_iu) {
#		$failed=1;
#		boot -f bootp()fast_iu.fail;
#        	wait;
#	}

	echo "----------------------------------------------------\n"
	# Test floating point unit
	if (fpu) {
		$failed=1;
		boot -f bootp()fpu.fail;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	# Test TCC FIFO
	if (tccfifo) {
		$failed=1;
		boot -f bootp()tccfifo.fail;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	# Test TCC Prefetch
	if (tccpref) {
		$failed=1;
		boot -f bootp()tccpref.fail;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	# Test Dcache
	$tmp = dcache
	if ($tmp) {
		echo "Failure detected in dcache test\n"
		$failed=1;
		boot -f bootp()dcache.fail;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	# Test Secondary cache
	if (scache) {
		$failed=1;
		boot -f bootp()scache.fail;
		wait;
	}
	echo "----------------------------------------------------\n"

	if(hpc3) {
		$failed=1;
		boot -f bootp()hpc3.fail;
		wait;
	}
}

tetonva {
	$cpu_failed=0
	$failed=0
	echo "Voltage changed to 4.75 V\n"
	chg_volt 0;
	ide_delay -s 15;
	teton
	if ($failed) {
		echo "FAILURES DETECTED IN PMT at 4.75V\n"
		$cpu_failed=1;
	}
	else {
		boot -f bootp()ip26_lowvolt.pass;
	}

	$failed=0
	echo "Voltage changed to 5.25 V\n"
	chg_volt 1;
	ide_delay -s 15;
	chg_volt 2;
	ide_delay -s 15;
	teton
	if ($failed) {
		echo "FAILURES DETECTED IN IP26 at 5.25V\n"
		$cpu_failed=1;
	}
	else {
		boot -f bootp()ip26_hivolt.pass;
	}

	$failed=0
	echo "Voltage changed to 5.0 V\n"
	chg_volt 1;
	ide_delay -s 15;
	teton

	echo "----------------------------------------------------\n"
	$tmp = ecc
	if($tmp){
		echo "Failure detected in ecc test\n"
		$failed=1;
		wait;
	}

	if ($failed) {
		echo "FAILURES DETECTED IN IP26 at 5.0V\n"
		$cpu_failed=1;
	}
	else {
		boot -f bootp()ip26_nomvolt.pass;
	}

	if ($cpu_failed) {
		echo "FAILURES DETECTED IN IP26"	
	}
	else
	{
		$cpu_failed=0;
		echo "ALL TESTS IN IP26 PASSED\n";
		boot dksc(0,1,0)unix;
	}
}

ip {
	echo "----------------------------------------------------\n"

	# Interrupt mask registers data test.
	if(int2) {
		$failed=1;
		if ($volts == 0) {
			boot -f bootp()mem_vlo.failed;
		}
		else {
		    if ($volts == 2) {
			boot -f bootp()mem_vhi.failed;
		    }
		}
	}
	else {
		boot -f bootp()memtest.pass;
	}
	echo "----------------------------------------------------\n"

	# Real time clock test. Verify the accuracy of the real time clock and
	# the carry circuitry by using the timer within the ctl1 gate array.
	if(clock) {
		$failed=1;
		wait;
	}

	echo "----------------------------------------------------\n"

	# illegal i3 e1 e2
	
# Duart External tests turned off and internal tests turned on  rwaits 9/23/92
# originally -i0, -i1 on -i2 off, -e0 off -e2, -e3 on
	echo "----------------------------------------------------\n"
	$tmp=duart -i0;
	
	if($tmp) {
		$failed=1;
#		wait;
	}
	
	$tmp= duart -i1;
	
	if($tmp) {
		$failed=1;
		wait;
	}
	
	
	echo "----------------------------------------------------\n"
	
	$tmp = led 0;
	
	if($tmp){
		$failed=1;
		wait;
	}
	
	$tmp = led 1;
	
	if($tmp){
		$failed=1;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	
	$status1 = scsi;
	if($status1) {
		$failed=1;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	if(timer){
		$failed=1;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	if ($skip_eisa != 1) {
	    if(eisa){
		$failed=1;
		wait;
	    }
	}
	else {
	    echo "Skipping EIU/EISA interface test"
	}

}	

ip26 {
        $skip_eisa = 0;
	$failed =0;
	$teton_failed=0;

	teton;
        if($failed) {
                if ($volts == 0) {
                        boot -f bootp()teton_vlo.failed;
                }
                else {
		    if ($volts == 2) {
                        boot -f bootp()teton_vhi.failed;
                    }
                }
                $teton_failed = 1;
        }
        else {
                boot -f bootp()pm1.pass;
        }

	echo "----------------------------------------------------\n"
	$tmp = ecc
	if($tmp){
		echo "Failure detected in ecc test\n"
		$failed=1;
		wait;
	}

	ip;
	echo "----------------------------------------------------\n"

	
	if($failed) {
		echo "FAILURES DETECTED IN IP26\n"
		$cpu_failed=1;
                if ($pm1_failed == 0) {
                        if ($volts == 0) {
                                boot -f bootp()ip_vlo.failed;
                        }
                        else {
			    if ($volts == 2) {
                                boot -f bootp()ip_vhi.failed;
                            }
                        }
                }
		wait;
	}
	else {
		$cpu_failed=0;
		echo "ALL TESTS IN IP26 PASSED\n";
	}
}

ip26va {

        $skip_eisa = 0;
	$failed =0;
	echo "\n*****************************\n"
	echo "Voltage changed to 4.75V\n"
	echo "\n*****************************\n"
	chg_volt 0;
	ide_delay -s 15;
        teton;

	echo "----------------------------------------------------\n"
	$tmp = ecc
	if($tmp){
		echo "Failure detected in ecc test\n"
		$failed=1;
		wait;
	}

	echo "\n*****************************\n"
	echo "Voltage changed to 5.25V\n"
	echo "\n*****************************\n"
	chg_volt 1;
	ide_delay -s 15;
	chg_volt 2;
	ide_delay -s 15;
	teton;

	echo "----------------------------------------------------\n"
	$tmp = ecc
	if($tmp){
		echo "Failure detected in ecc test\n"
		$failed=1;
		wait;
	}
	
	echo "\n*****************************\n"
	echo "Voltage changed to 5.0 V\n"
	echo "\n*****************************\n"
	chg_volt 1;
	ide_delay -s 15;
	
	echo "----------------------------------------------------\n"
	$tmp = ecc
	if($tmp){
		echo "Failure detected in ecc test\n"
		$failed=1;
		wait;
	}
	
	ip;

	echo "----------------------------------------------------\n"

	
	if($failed) {
		echo "FAILURES DETECTED IN IP26\n"
		$cpu_failed=1;
	}
	else {
		$cpu_failed=0;
		echo "ALL TESTS IN IP26 PASSED\n";
		boot dksc(0,1,0)unix;
	}
}

a2testva {
	chg_volt 0;
	ide_delay -s 15;
	a2test;
	chg_volt 1;
	ide_delay -s 15;
	chg_volt 2;
	ide_delay -s 15;
	a2test;
	chg_volt 1;
	ide_delay -s 15;
}


# Start of GR2 diagnostics 
# Initialize variables used by GR2.
$stride_failed=0 ;
$zb_failed=0 ;
$gr2_failed=0;
$chkbt457_failed=0;
$bp_failed=0;
$shramre3_failed=0;
$cpushram_failed=0;
$cpure3_failed=0;
$ctxsw_failed=0;
$vdma_failed=0;
$quad_failed=0;
$fourquad_failed=0;
$mon=0;

$test_xmap_failed = 0;
$test_xmap_clut_failed = 0;

gr2_vhwinit {
	gr2_videoclk 0x47
	if ($mon ==1 ) gr2_initclock 0x132;
	else gr2_initclock 0x107;
	fi
	gr2_wrconfig 0x0
	gr2_delay 3
	gr2_wrconfig 0x1
	gr2_vinitdac
}

gr2_initre {
	$a = 0;

	$a = gr2_getGR2ver;
	if ($a < 4) gr2_wrfifo 0 0;
	else if ($a == 4) gr2_wrfifo 0 1;
	else gr2_wrfifo 0 2;
}

gr2_initsys {
	$mon = 0;

	gr2_reset
	gr2_vhwinit
	$mon = gr2_getMonType;
	if ($mon == 1) {
		gr2_initvc1 4;
	}
	else {
		gr2_initvc1 20;
	}
	gr2_xcol
	gr2_inithq
	gr2_load_ucode ge
	gr2_load_ucode hq
	gr2_unstall
	gr2_initre
}

clear {
	gr2_wrfifo 35 0
	gr2_wrfifo 6 0
}

gr2_quad {
	gr2_wrfifo 33 0
}

gr2_fourquad {
	gr2_wrfifo 34 0
}

test_xmap {
	gr2_initsys;
	$a=gr2_txmap;
	return $a;
}

test_xmap_clut {
	gr2_initsys;
	$a=gr2_txmap_clut;
	return $a;
}

gr2_vdma {
	gr2_initsys;
	$b=gr2_cachefdma 32 1;
	$b=$b+gr2_cachefdma 256 1;
	$b=$b+gr2_cachefdma 512 1;
	$b=$b+gr2_cachefdma 128 1;
	$b=$b+gr2_yzoomdma ;
	$b=$b+gr2_yzoomdma 32 32;
	$b=$b+gr2_yzoomdma 128 128;
	$b=$b+gr2_yzoomdma 256 256;
	$b=$b+gr2_stridedma;
	$b=$b+gr2_stridedma 32 32;
	$b=$b+gr2_stridedma 256 1;
	$b=$b+gr2_stridedma 512 0;

	return $b;
}

gr2 {

	# Too verbose with report=4
	report=3;

	$a = 0;
	$b = 0;
	$mon = 0;

	$err = 0;

	$stride_failed=0 ;
	$zb_failed=0 ;
	$gr2_failed=0;
	$chkbt457_failed=0;
	$bp_failed=0;
	$shramre3_failed=0;
	$cpushram_failed=0;
	$cpure3_failed=0;
	$ctxsw_failed=0;
	$vdma_failed=0;
	$quad_failed=0;
	$fourquad_failed=0;

	$test_xmap_failed = 0;
	$test_xmap_clut_failed = 0;

	gr2_reset;
	buffon


# HQ2 internal register 19  must read 0xdeadbeef
	report = 2;
	gr2_rdhqint 19;
	report = 1;

# Test VC1 SRAM 
	gr2_vhwinit
	report =4 
	if (gr2_vc1_sram) {
		echo "VC1 SRAM test failed";
		resetcons;
		buffoff;
        	wait;
		$err = 1;
	}
# Test ram 0 at Ge7 at 0
	$tmp = gr2_tram 0;
	if ($tmp) {
		echo "GE7 at 0 RAM0 test failed"
		resetcons;
		buffoff;
		$err = 1;
        	wait;
	}
# Test ram 0 at Ge7 at 1
	$tmp = gr2_tram 1;
	if ($tmp) {
		echo "GE7 at 1 RAM0 test failed"
		resetcons;
		buffoff;
		$err = 1;
        	wait;
	}
# Test ram 0 at Ge7 at 2
       $tmp = gr2_tram 2;
       if ($tmp) {
		echo "GE7 at 2 RAM0 test failed"
		resetcons;
		buffoff;
		$err = 1;
        	wait;
	}
# Test ram 0 at Ge7 at 3
	$tmp = gr2_tram 3 ;
	if ($tmp) {
		echo "GE7 at 3 RAM0 test failed"
		resetcons;
		buffoff;
        	wait;
		$err = 1;
	}
# Test ram 0 at Ge7 at 4
	$tmp = gr2_tram 4 ;
	if ($tmp) {
		echo "GE7 at 4 RAM0 test failed"
		resetcons;
		buffoff;
        	wait;
		$err = 1;
	}
# Test ram 0 at Ge7 at 5
	$tmp = gr2_tram 5 ;
	if ($tmp) {
		echo "GE7 at 5 RAM0 test failed"
		resetcons;
		buffoff;
        	wait;
		$err = 1;
	}
# Test ram 0 at Ge7 at 6
	$tmp = gr2_tram 6 ;
	if ($tmp) {
		echo "GE7 at 6 RAM0 test failed"
		resetcons;
		buffoff;
        	wait;
		$err = 1;
	}
# Test ram 0 at Ge7 at 7
	$tmp = gr2_tram 7 ;
	if ($tmp) {
		echo "GE7 at 7 RAM0 test failed"
		resetcons;
		buffoff;
        	wait;
		$err = 1;
	}
# Test shram  
	$tmp = gr2_tram 8 ;
	if ($tmp) {
		echo "Share ram test failed "; 
		resetcons;
		buffoff;
        	wait;
		$err = 1;
	}
# Test Hq2uram
	$tmp = gr2_tram 9 ;
	if ($tmp) {
		echo "HQ2 uram test failed "; 
		resetcons;
		buffoff;
        	wait;
	    	$err = 1;
	}
# Test ge7uram
	$tmp = gr2_tram 10;
	if ($tmp) {
		echo "GE7 uram test failed "; 
		resetcons;
		buffoff;
        	wait;
	    	$err = 1;
	}
	gr2_initsys;
	clear;

# Test HQ2
	if(gr2_hq2test) {
		echo "HQ2 test failed "; 
		resetcons;
		buffoff;
        	wait;
	    	$err = 1;
	}
# Test shareram using Ucode
	if (gr2_shram) {
		echo "Shram test failed"
		resetcons;
		buffoff;
        	wait;
	    	$err = 1;
	}
# Test internal GE7 ram
	if (gr2_ram12) {
		echo "GE7 internal test failed"
		resetcons;
		buffoff;
        	wait;
	    	$err = 1;
	}
# Test seedrom 
	if (gr2_seedrom) {
		echo "GE7 seedrom test failed"
		resetcons;
		buffoff;
        	wait;
	    	$err = 1;
	}
# Test the squaroot rom
	if (gr2_sqrom) {
		echo "GE7 sqrom test failed"
		resetcons;
		buffoff;
        	wait;
	    	$err = 1;
	}
	gr2_initsys ;

# Test Ge 7 bus
	if (gr2_gebus) {
		echo "GE7 bus test failed"
		resetcons;
		buffoff;
        	wait;
	    	$err = 1;
	}

# Test ge floating point unit
	if (gr2_gefloat) {
		echo "GE7 floating point test failed"
		resetcons;
		buffoff;
        	wait;
	    	$err = 1;
	}
	gr2_initsys;
	clear;

	if ( $err ) {
		echo "HQ & GE Tests failed\n";
		resetcons;
		buffoff;
		if ($volts == 0) {
			boot -f bootp()gr2_hq_vlo.failed;
		}
		else {
		    if ($volts == 2) {
			boot -f bootp()gr2_hq_vhi.failed;
		    }	
		}	
		$err=0
		$gr2_failed=1
	}
	else {
		resetcons;
		buffoff;
		echo "HQ & GE Tests passed\n"
		if ($volts == 0) {
			boot -f bootp()gr2_hq_vlo.pass;
		}
		else {
		    if ($volts == 2) {
			boot -f bootp()gr2_hq_vhi.pass;
		    }	
		}	
	}
	buffon

# Test bt457 
	if (gr2_chkbt457) {
		resetcons;
		buffoff;
        	wait;
	    	$chkbt457_failed = 1;
	    	$err=1;
	}
# Test bitplane VM2
	gr2_initsys
	if (gr2_bp) {
		$bp_failed = 1;
		$err=1;
		resetcons;
		buffoff;
		wait;
	}
# Test Shared ram and Re
	gr2_initsys
	$tmp = gr2_shramre3
	if ($tmp) {
		resetcons;
		buffoff;
        	wait;
	    	$shramre3_failed =1;
	    	$err=1;
	}
# Test DMA between host and GE7 shared ram
	gr2_initsys
	clear
	$tmp = gr2_cpushram
	if ($tmp) {
		resetcons;
		buffoff;
        	wait;
	    	$cpushram_failed =1;
	    	$err=1;
	}
# Test DMA between host and and RE3
	resetcons
	buffon
	gr2_initsys
	$tmp = gr2_cpure3
	if ($tmp) {
		resetcons;
		buffoff;
        	wait;
	    	$cpure3_failed =1;
	    	$err=1;
	}
# Test GE7 context switching
	if(gr2_ctxsw) {
		resetcons;
		buffoff;
        	wait;
	    	$ctxsw_failed =1;
	    	$err=1;
	}
	clear;
# Test quad drawing
	$tmp = gr2_quad
	if ($tmp) {
		resetcons;
		buffoff;
        	wait;
	    	$quad_failed =1;
	    	$err=1;
	}
	$tmp = gr2_fourquad
	if ($tmp) {
		resetcons;
		buffoff;
        	wait;
	    	$fourquad_failed = 1;
	    	$err=1;
	}
	clear;
	if ($chkbt457_failed) echo "Bt457 test failed";
	if ($bp_failed)  echo "bitplane test failed";
	if ($shramre3_failed) echo "shramre3 test failed"
	if ($cpushram_failed) echo "CPU shram test failed";
	if ($cpure3_failed) echo "cpure3 test failed ";
	if ($ctxsw_failed) echo "context switching test failed ";
	if ($vdma_failed) echo "vdma controller test failed ";
	if ($quad_failed) echo "quad test failed";
	if ($fourquad_failed) echo "fourquad test failed";

	if ($err)
	{
	    if (!$report) {
		emfail 2;
		wait;
		exit;
	    }	
	    echo "******  PRESS RETURN TO CONTINUE OR ^C TO EXIT ************"
	    $err=0
	    $gr2_failed=1
	    resetcons;
	    buffoff;
	    wait;
	}
	else {
		resetcons;
		buffoff;
		echo "BT457, Bit-Plane, DMA and QUADs Tests Passed.\n"
	}
	buffon

# Test stridedma between shram and re3
	gr2_initsys
	$tmp = gr2_stride
	if ($tmp)  {
	    $stride_failed =1 ;
	    $err=1;
	    resetcons;
	    buffoff;
	    wait;
	}
# Test Zbuffer
	gr2_initsys
	$tmp=gr2_zb
	if($tmp)  {
	    $zb_failed =1;
	    $err=1;
	    resetcons;
	    buffoff;
	    wait;
	}
	resetcons
	buffoff
	echo "************************* RESULTS ********************************"
	if ($stride_failed)  {
	    echo "stride test failed";
	    $gr2_failed = 1;
	    wait;
	}
	if ($zb_failed) { 
	    echo "Zbuffer test failed";
	    $gr2_failed = 1;
	    wait;
	}
	if (!$gr2_failed) echo "Stride DMA, and Z-Buffer Test Passed.\n"
# Test Xmap 
	buffon
	echo "testing XMAP"
	if (test_xmap) {
    	    $test_xmap_failed =1;
	    $err=1;
	    resetcons;
	    buffoff;
	    wait;
	}
# Test Xmap CLUT 
	if (test_xmap_clut) {
	    $test_xmap_clut_failed =1;
	    $err=1;
	    resetcons;
	    buffoff;
	    wait;
	}
	resetcons
	buffoff
	echo "************************* RESULTS ********************************"
	if ($test_xmap_failed) {
	    echo "test_xmap test failed";
	    $gr2_failed = 1;
	}
	if ($test_xmap_clut_failed) {
	    echo "test_xmap_clut test failed";
	    $gr2_failed = 1;
	}
	if (!$err) echo "XMAPs Test Passed.\n"


	if ($gr2_failed) {
		echo "ERROR: Failure detected on graphics board."
		wait;
	}
	else echo "graphics board tests passed"
	echo " *****************END OF THE TEST *****************"

	# Restore verbosity
	report=4
}

gr2_all {
        $tmp = gr2_setboard 0;
        if ($tmp) {
		echo "Testing gr3/gu1 in slot 0."
                gr2;
        	if ($gr2_failed) {
			echo "ERROR: Failure detected on gr3/gu1 in slot 0."
			if ($volts == 0) {
				boot -f bootp()gr2_0_vlo.failed;
			}
			else {
			    if ($volts == 2) {
				boot -f bootp()gr2_0_vhi.failed;
			    }
			}
			wait;
		}
		else {
			boot -f bootp()gr2_0.pass;
		}
        }

        $tmp = gr2_setboard 1;
        if ($tmp) {
		echo "Testing gr3/gu1 in slot 1."
                gr2;
	        if ($gr2_failed) {
			echo "ERROR: Failure detected on gr3/gu1 in slot 1."
			if ($volts == 0) {
				boot -f bootp()gr2_1_vlo.failed;
			}
			else if ($volts == 2) {
				boot -f bootp()gr2_1_vhi.failed;
			}
			wait;
		}
		else {
			boot -f bootp()gr2_1.pass;
		}
        }
}
# END OF GR2 SUPPORT


# Top level functions

gfx_diag {
	gr2;
}


gfx {
    $express = gr2_probe;
    if ($express) {
	gr2_all;
    }
    boot_unix;
} 

gfxva {
    echo "Voltage changed to 4.75 V\n"
    chg_volt 0;
	ide_delay -s 15;
    $express = gr2_probe;
    if ($express) {
	gr2_all;
    }
    echo "Voltage changed to 5.25 V\n"
    chg_volt 1;
	ide_delay -s 15;
    chg_volt 2;
	ide_delay -s 15;
    $express = gr2_probe;
    if ($express) {
	gr2_all;
    }
    echo "Voltage changed to 5.0 V\n"
    chg_volt 1;
	ide_delay -s 20;
    boot_unix
}

echo "Voltage changed to 4.75 V\n"
chg_volt 0;
	ide_delay -s 15;
$skip_timer =0;
$volts=0;
$failed=0;
ip26;
if ($failed) {
	echo "FAILURES DETECTED IN IP26 at 4.75V\n"
}
else {
	boot -f bootp()ip26_lowvolt.pass;
}

# memory;
# if ($failed) {
# 	echo "MEMORY FAILURES DETECTED IN IP26 at 4.75V\n"
# }
# else {
# 	boot -f bootp()memtest_lowvolt.pass;
# }

$express = gr2_probe;
if ($express) {
	gr2_all;
}
if (!$gr2_failed) {
 	boot -f bootp()gfx_lowvolt.pass;
}

echo "Voltage changed to 5.25 V\n"
chg_volt 1;
	ide_delay -s 15;
chg_volt 2;
	ide_delay -s 15;
$skip_timer=1;
$volts=2;
report=4;
ip26;
if ($failed) {
	echo "FAILURES DETECTED IN IP26 at 5.25V\n"
}
else {
	boot -f bootp()ip26_hivolt.pass;
}

# memory;
# if ($failed) {
# 	echo "MEMORY FAILURES DETECTED IN IP26 at 5.25V\n"
# }
# else {
# 	boot -f bootp()memtest_hivolt.pass;
# }

$express = gr2_probe;
if ($express) {
	gr2_all;
}
if (!$gr2_failed) {
 	boot -f bootp()gfx_hivolt.pass;
}

echo "Voltage changed to 5.00 V\n"
chg_volt 1;
	ide_delay -s 15;
boot -f bootp()start_unix;
boot_unix
