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

#
menu {
echo "///////////////////////////////////////////////////////////////////////////"
echo "                       FUNCTIONAL TEST OPTIONS "
echo "                       -----------------------"
echo "Command   Description"
echo ""
echo "hp2vm     HP2 diagnostics with manual voltage change"
echo "hp2va     HP2 diagnostics with automatic voltage change"
echo ""
echo "gfxvm     LG2/GR2/Dual Head diagnostics with manual voltage change"
echo "gfxva     LG2/GR2/Dual Head diagnostics with automatic voltage change"
echo "kva       Galileo video board diagnostics with automatic voltage change"
echo ""
echo "                     TECHNICIAN BENCH OPTIONS"
echo "                     ------------------------"
echo "hp2       HP2 diagnostics with no voltage change"
echo "gfx       LG2/GR2/Dual Head diagnostics with no voltage change"
echo "zb        GR2 Z-buffer test"
echo "bp/vm2    GR2 VM2(Bit-planes) test"
echo "kv        Galileo video board diagnostics with no voltage change"
echo ""
echo "///////////////////////////////////////////////////////////////////////////"
}

hp2_diag {

$failed=0;
	echo "----------------------------------------------------\n"
	if(tlb){
		$failed=1;
		wait;
	}
	

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

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

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

	echo "----------------------------------------------------\n"
	if(!fpu) {
		$failed=1;
		wait;
	}
	echo "----------------------------------------------------\n"

	if(linpack) {
		$failed=1;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	
	if(hpc1) {
		$failed=1;
		wait;
	}
	
	
	echo "----------------------------------------------------\n"
	if(int2) {
		$failed=1;
		wait;
	}
	echo "----------------------------------------------------\n"
	if(!clock) {
		$failed=1;
		wait;
	}

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

	report=2
	echo "            AUDIO DIAGNOSTICS\n"
	$tmp = audio -h;
	if ($tmp) {
		$failed=1;
		wait;
	}
	echo "----------------------------------------------------\n"

#	if(dsp56 ) {
#		$failed=1;
#		wait;
#	}

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

	report=4
	
	# added on 19th June
	#dsp_reset

#	if(cpudsp_sram) {
#		$failed=1;
#		wait;
#	}
	
	echo "----------------------------------------------------\n"
	$tmp = memtest  0xa8800000:0xa9000000
	if($tmp) {
		$failed=1;
		wait;
	}
	
	
	if ($dram_needed) {
	  echo "----------------------------------------------------\n"
	  echo  "PLEASE WAIT ... "
	
	  $tmp = dram -p 0xa8800000#2M;
	  if($tmp) {
		$failed=1;
		wait;
	  }
	}	
	echo "----------------------------------------------------\n"
	# it takes about 3 minutes
	echo  "PLEASE WAIT ... THE FOLLOWING TEST TAKES ABOUT 1 1/2 MINUTES"
	
	$tmp = ldram -p;
	
	if($tmp){
		$failed=1;
		wait;
	}
	# 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;
	}
	
	$tmp= duart -i2;
	
	if($tmp) {
		$failed=1;
		wait;
	}
	
	$tmp= duart -i3;
	
	if($tmp) {
		$failed=1;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	#external loop back needed, fails otherwise
	
	#$tmp= duart -e0;
	
	#if($tmp) {
	#	$failed=1;
	#	wait;
	#}
	
	#loop back needed, fails otherwise
#Added duart -e2 on 11-1-91 since wyse terminal is no longer attached and hence
#duart 2 has to be tested
#        $tmp= duart -e2;
#	if($tmp) {
#		$failed=1;
#		wait;
#		}
#
#	echo "----------------------------------------------------\n"
#	$tmp= duart -e3;
#	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"
#	if(nvram1){
#		$failed=1;
#		wait;
#	}
	
#	echo "----------------------------------------------------\n"
#	if(nvram3){
#		$failed=1;
#		wait;
#	}
	
#	echo "----------------------------------------------------\n"
#	if(nvram4){
#		$failed=1;
#		wait;
#	}
	
#	echo "----------------------------------------------------\n"
#	if(nvram5){
#		$failed=1;
#		wait;
#	}
	
	echo "----------------------------------------------------\n"
	
	if(parity){
		$failed=1;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	if(scsi){
		$failed=1;
		wait;
	}
	
	echo "----------------------------------------------------\n"
	if(!timer){
		$failed=1;
		wait;
	}
	echo "----------------------------------------------------\n"
	if(print3){
		$failed=1;
		wait;
	}
	

	if($auto_volt) 
		chg_volt 0	
	
	echo "----------------------------------------------------\n"

	
	if($failed) {
		echo "FAILURES DETECTED IN HP2\n"
		$cpu_failed=1;
		}
	else
		{
		$cpu_failed=0;
		echo "ALL TESTS IN HP2 PASSED\n";
	}
	fi
}
unix {
	echo "<<<< About to to boot UNIX......>>>>"
	boot -f dksc(0,1,8)sashIP20 dksc(0,1,0)unix.IP20;
     }

boot_unix {
        if ($cpu_failed == 0) unix;
}

hp2_volt_diag {

	if ($auto_volt){
		echo "<<<<<<<<<<< SETTING  VOLTAGE TO 4.8 >>>>>>>>>>>>>>"
		chg_volt 0
	}
	else {
		echo "<<<<<<<<<<< SET  VOLTAGE TO 4.8 >>>>>>>>>>>>>>"
		wait;
	}

	$dram_needed = 1;
	hp2_diag

	if ($auto_volt){
		echo "<<<<<<<<<<< SETTING  VOLTAGE TO 5.25 >>>>>>>>>>>>>>"
		chg_volt 2
	}
	else {
		echo "<<<<<<<<<<< SET  VOLTAGE TO 5.25 >>>>>>>>>>>>>>"
		wait;
	}

	# dram test not needed in the second run

	$dram_needed = 0;
	hp2_diag

	if ($auto_volt){
		echo "<<<< SETTING VOLTAGE TO 5.0 >>>>>"
		chg_volt 1
	}
	else {
		echo "<<<< SET VOLTAGE TO 5.0 >>>>>"
#		wait;
	}

	boot_unix;
}

hp2ns {
	report=4
	$auto_volt = 0;
	hp2_diag
}

hp2nsvm {

	report=4
	$auto_volt = 0;
	hp2_volt_diag;
}

hp2nsva {

	report=4
	$auto_volt = 1;
	hp2_volt_diag;
}

hp2 {
	report=4
	$auto_volt = 0;
	hp2_diag
}

hp2vm {

	report=4
	$auto_volt = 0;
	hp2_volt_diag;
}

hp2va {

	report=4
	$auto_volt = 1;
	hp2_volt_diag;
}


# Express diagnostics 



# Start of GR2 diagnostics 
gr2_vhwinit {
gr2_videoclk 0x4
gr2_wrconfig 0x0
$mon = gr2_getMonType;
if ($mon == 1) gr2_initclock 0x132;
else gr2_initclock 0x107b;
fi
gr2_wrconfig 0x40
gr2_vinitdac
}
gr2_initsys {
gr2_reset
gr2_vhwinit
gr2_lt 3
gr2_xcol
$mon = gr2_getMonType;
if ($mon == 1) gr2_initvc1 4;
else gr2_initvc1 20;
fi
gr2_inithq
gr2_load_ucode ge
gr2_load_ucode hq
gr2_unstall
gr2_wrfifo 0 0
}
clear {
gr2_wrfifo 35 0
gr2_wrfifo 6 0
}
gr2_quad {
gr2_wrfifo 33 0
}
gr2_fourquad {
gr2_wrfifo 34 0
}
srv2 {
lg1_video
lg1_video -f -l5
lg1_video -c -l5
}
zb {
	buffon
	gr2_initsys;
	$tmp = gr2_zb;
	if ($tmp) {
		echo "Z-buffer test failed\n"
		wait
	}
	resetcons;
	buffoff
	}
bp {
	buffon
	gr2_initsys;
	$tmp = gr2_bp;
	if ($tmp) {
		echo "Bit-planes test failed\n"
		wait
	}
	resetcons;
	buffoff
	}

vm2 {
	bp
}	
$tmp = 0;
$failed = 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;
	}

$err=0;
gr2 {
	$chkbt457_failed=0;
	$shramre3_failed=0;
	$cpushram_failed=0;
	$cpure3_failed=0;
	$ctxsw_failed=0;
	$quad_failed=0;
	$fourquad_failed=0;
	$bp_failed=0;
	$stride_failed=0;
	$zb_failed=0;
	$test_xmap_failed=0;
	$test_xmap_clut_failed=0;

	$gr2_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 failded";
		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;
wait
$err=0
$gr2_failed=1
}
else {
	resetcons;
	buffoff;
	echo "HQ & GE Tests passed\n"
     }
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;
	}
#buffoff
#echo "testing vdma"
#buffon
# Test VDMA controller
#	if(gr2_vdma) {
#	    if (!$report) {
#        	emfail 2;
#        	wait;
#        	exit;
#    	    }	
#	    $vdma_failed =1;
#	    $err=1;
#	}
#buffoff
#echo "testing ctxsw"
#buffon
# 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 ($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
#	resetcons
#	buffon
	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;
}
if ($zb_failed) { 
   echo "Zbuffer test failed";
  $gr2_failed = 1;
}
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;
	exit;
}
else echo "graphics board tests passed"
fi
echo " *****************END OF THE TEST *****************"
}
gr2_all {
        $tmp = gr2_setboard 0;
        if ($tmp) {
			
		echo "Testing gfx in slot 0."
                gr2;
        	if ($gr2_failed) 
			echo "ERROR: Failure detected on gfx in  slot 0."
        }

        $tmp = gr2_setboard 1;
        if ($tmp) {
		echo "Testing gfx in slot 1."
                gr2;
	        if ($gr2_failed) 
			echo "ERROR: Failure detected on gfx in slot 1."
        }
}
# END OF GR2 SUPPORT
# LG1 VDMA DIAGNOSTICS.

lg1_dma {
        initgr
        lg1_probe
        lg1_cachefdma   800
        lg1_yzoomdma    800 700
        lg1_stridedma   512 0
        lg1_stridedma   512 -512
        lg1_mfilldma    1024 1
        lg1_mfilldma    1 1024
        lg1_sbdma       512 0
        lg1_sbdma       512 1
        lg1_sbdma       512 2
        lg1_sbdma       512 3
	lg1_decreadrdma 512 
        buffon;
}
# END OF LG1 VDMA DIAGNOSTICS
# lg1/lg2/dual head lg2  diagnostics
#

lg1_output {

resetcons;
buffoff;

if ($lg1failed) {
    led 2;
    if ($rexfailed) {
	echo "ERROR:  Failure detected in REX chip."
	$rexfailed=0;
    }
    if ($vramfailed){
	echo "ERROR:  Failure detected in VRAM."
	$vramfailed=0;
    }
    if ($cidfailed){
	echo "ERROR:  Failure detected in CID DRAM."
	$cidfailed=0;
    }	
    if ($vc1failed){
	echo "ERROR:  Failure detected in VC1 chip."
	$vc1failed=0;
    }
    if ($sramfailed){
	echo "ERROR:  Failure detected in SRAM."
	$sramfailed=0;
    }
    if ($dacfailed){
	echo "ERROR:  Failure detected in Bt479 RAMDAC."
	$dacfailed=0;
    }
    if ($dmafailed){
	echo "ERROR:  Failure detected in Graphics DMA."
	$dmafailed=0;
    }
    echo "Failures were detected in LG1 diagnostic tests.";
    wait;
}
else {
    led 1;
    echo "LG1 diagnostic tests completed with no failures detected.";
} 

# END OF lg1_output
}

lg1_new {
$lg1failed=0;
initgr
lg1_wsysctl 0x3d
buffon;
#lg1_ginit;

# REX register test
if (lg1_rexregs) {
    $rexfailed = -1;
    $lg1failed=1;
}

# VRAM test
if (lg1_vram) {
    $vramfailed = -1;
    $lg1failed=1;
}

# CID test
if (lg1_cid) {
    $cidfailed = -1;
    $lg1failed=1;
}

# VC1 register test
if (lg1_vc1regs) {
    $vc1failed = -1;
    $lg1failed=1;
}

# VC1 SRAM test
if (lg1_sram) {
    $sramfailed = -1;
    $lg1failed=1;
}

# DAC test
if (lg1_dac) {
    $dacfailed = -1;
    $lg1failed=1;
}

# DMA test
if ($lg1_board1 == 0) {
	if (lg1_dma) {
    		$dmafailed = -1;
    		$lg1failed=1;
	}			
}

if ($lg1_output_needed)
	lg1_output;
} 


lg1 {
	lg1_setboard 0
	$lg1_output_needed = 1;
	lg1_new
}

#  The following is same as lg1 except that it does not output errors(if any).
#


# Multi-head support for LG1

lg1_all {
	$lg1_board1 = 0;
        $lg1failed = 2;
        $tmp = lg1_setboard 0;
        if ($tmp) {
		$lg1_output_needed=1
                lg1_new;
        }
        $lg1_board0_failed = $lg1failed;

        $lg1failed = 2;
        $tmp = lg1_setboard 1;
        if ($tmp) {
		$lg1_output_needed=1
		$lg1_board1 = 1;
                lg1_new;
        }
        $lg1_board1_failed = $lg1failed;

        led 2;
        if ($lg1_board0_failed == 1) {
                led 1;
                echo "Failure detected on LG1 board 0.";
        }
        if ($lg1_board0_failed == 2) echo "LG1 board 0 not found.";
        if (!$lg1_board0_failed)
                echo "LG1 board 0 tests completed with no errors.";

        if ($lg1_board1_failed == 1) {
                led 1;
                echo "Failure detected on LG1 board 1.";
        }
        if ($lg1_board1_failed == 2) echo "LG1 board 1 not found.";
        if (!$lg1_board1_failed)
                echo "LG1 board 1 tests completed with no errors.";
}

#Start of Galileo diagnostics
CheckSlot {
		echo "GR2 Board Found in slot 0."
}

cc1 {
	CheckSlot;
	echo "CC1 Frame Buffer Test";
	$status =ev1_init ;
	if ($status)  {
		echo " Galileo Board Initialization FAILED"
		return ($status);
	}
	echo "Galileo Board Initialized Properly"
	echo "CC1 Memory Test";
	$status = cc1_mem;
	if ($status) 
		wait;
	echo "CC1 (DMA MODE)Memory Test";
	$status = cc1_dma;
	if ($status) 
		wait;
}

ab1_red {
	CheckSlot;
	$status =ev1_init ;
	if ($status)  {
		echo " Galileo Board Initialization FAILED"
		return ($status);
	}
	echo "Galileo Board Initialized Properly"
	echo "AB1 Red Channel Memory Test ";
	ab1_rmem;
}

ab1_blue {
	CheckSlot;
	$status =ev1_init ;
	if ($status)  {
		echo " Galileo Board Initialization FAILED"
		return ($status);
	}
	echo "Galileo Board Initialized Properly"
	echo "AB1 Blue Channel Memory Test ";
	ab1_bmem;
}

ab1_green {
	CheckSlot;
	$status =ev1_init ;
	if ($status)  {
		echo " Galileo Board Initialization FAILED"
		return ($status);
	}
	echo "Galileo Board Initialized Properly"
	echo "AB1 Green Channel Memory Test ";
	ab1_gmem;
}

ab1 {
	CheckSlot;
	$status =ev1_init ;
	if ($status)  {
		echo " Galileo Board Initialization FAILED"
		return ($status);
	}
	echo "Galileo Board Initialized Properly"
	echo "AB1 Memory Test (Red, Green, Blue)";
	status = ab1_mem;
	if ($status) 
		wait;
}

kv {
	CheckSlot;
	$status =ev1_init ;
	if ($status)  {
		echo " Galileo Board Initialization FAILED"
		return ($status);
	}
	echo "Galileo Board Initialized Properly"
	echo "Test Disply Control Bus";
	$status = ev1_dcb;
	if ($status)
		wait;
	echo "CC1 Memory Test";
	cc1;
	echo "AB1 Memory Test (Red, Green, Blue)";
	ab1;
	unix;
}


kva {
	CheckSlot;
    	echo "Voltage changed to 4.75 V\n"
    	chg_volt 0;
	$status =ev1_init ;
	if ($status)  {
		echo " Galileo Board Initialization FAILED"
		return ($status);
	}
	echo "Galileo Board Initialized Properly"
	echo "Test Display Control Bus";
	$status = ev1_dcb;
	if ($status)
		wait;
	echo "CC1 Memory Test";
	cc1;
	echo "AB1 Memory Test (Red, Green, Blue)";
	ab1;

    	echo "Voltage changed to 5.25 V\n"
    	chg_volt 2;
	$status =ev1_init ;
	if ($status)  {
		echo " Galileo Board Initialization FAILED"
		return ($status);
	}
	echo "Galileo Board Initialized Properly"
	echo "Test Display Control Bus";
	$status = ev1_dcb;
	if ($status)
		wait;
	echo "CC1 Memory Test";
	cc1;
	echo "AB1 Memory Test (Red, Green, Blue)";
	ab1;

    	echo "Voltage changed to 5.0 V\n"
    	chg_volt 1;
	$status =ev1_init ;
	if ($status)  {
		echo " Galileo Board Initialization FAILED"
		return ($status);
	} 
	echo "Galileo Board Initialized Properly"
	echo "Test Display Control Bus";
	$status = ev1_dcb;
	if ($status)
		wait;
	echo "CC1 Memory Test";
	cc1;
	echo "AB1 Memory Test (Red, Green, Blue)";
	ab1;
	unix;
}
#END of Galileo diagnostics


# Top level functions

gfx_diag {

	buffon
	$express = gr2_probe
	buffoff
	if($express)  {
		gr2;
	}
	else {
           $dualhead = lg1_setboard 1;
	   if ($dualhead)
		lg1_all
	   else
		lg1
	}
}

gfx_volt_diag {

	buffon
	$express = gr2_probe
	buffoff

	if ($express) {
		gr2;
	}
	else {
           $dualhead = lg1_setboard 1;
	   if($dualhead)
		lg1_all
	   else {
		$lg1failed=0;
		$lg1_output_needed=0;
		repeat 5 lg1_new
		lg1_output
	   }
	}

	if ($auto_volt=1) {
		echo "<<<<<<<<<<< SETTING VOLTAGE TO 5.25 >>>>>>>>>>>>>>"
		chg_volt 2
	}
	else {
		echo "<<<<<<<<<<< SET VOLTAGE TO 5.25 >>>>>>>>>>>>>>"
		wait
	}
	if ($express)
		gr2;
	else {
	   if($dualhead)
		lg1_all
	   else {
		$lg1failed=0;
		$lg1_output_needed=0;
		repeat 5 lg1_new
		lg1_output
	   }
	}
	if ($auto_volt=1) {
		echo "<<SETTING VOLTAGE TO 5.0 ... ABOUT TO BOOT UNIX >>"
		chg_volt 1
	}
	else {
		echo "<<SET VOLTAGE TO 5.0 ... ABOUT TO BOOT UNIX >>"
		wait
	}
	boot_unix;
}

gfx {

    gfx_diag;
} 
gfxvm {

    $auto_volt = 0;
    gfx_volt_diag;
} 
gfxva {

	echo "<<<<<<<<<<< SETTING VOLTAGE TO 4.8 >>>>>>>>>>>>>>"
	chg_volt 0
	resetcons;
	buffoff;
	$express =  gr2_probe;
	if ($express)
		gr2;
	else {
	   if($dualhead)
		lg1_all
	   else {
		$lg1failed=0;
		$lg1_output_needed=0;
		repeat 5 lg1_new
		lg1_output
	   }
	}
	echo "<<<<<<<<<<< SETTING VOLTAGE TO 5.25 >>>>>>>>>>>>>>"
	chg_volt 2
	resetcons;
	buffoff;
	$express =  gr2_probe;
	if ($express)
		gr2;
	else {
	   if($dualhead)
		lg1_all
	   else {
		$lg1failed=0;
		$lg1_output_needed=0;
		repeat 5 lg1_new
		lg1_output
	   }
	}
	echo "<<SETTING VOLTAGE TO 5.0 ... ABOUT TO BOOT UNIX >>"
	chg_volt 1
	boot_unix;

}
menu
