ulxlife.c 9.25 KB
/*
 *  F i l e N a m e  :  U L X L I F E . C
 *
 ****************************************************************************
 *        Created    Tomohiro Teshima.
 *                   Peripheral Div. Quality Assurance Dpt.
 *                   (C) CopyRight ALPS Electric Co., Ltd. 1996
 ****************************************************************************
 *  Version
 *
 *  ver     Date
 *  ----  --------
 *  1.01  '96.07.17  Deleted DC2/EEC status .
 *  1.00  '96.07.10  Initial revision .
 ****************************************************************************
*/
/*===========================================*/
/* レオドライブ用テストソフトのコマンド発行ルーチン           */
/*===========================================*/

#include <ultra64.h>
#include "ulxmain.h"
#include "ulxlib.h"
#include "ulxutil.h"

extern u16	key;
extern union	leo_sys_form LEO_sys_data;
extern void	disp_leosys_data( void );
extern void     setparameter( void );


/*==========================================================*/

void life_disp_init( u8 *chr )
{
    ClrDisp();

    Disp_Ready(0, 0, CYAN );
    sprintf( STR, chr );
    Disp_Fin();

    Disp_Ready(0, 2, GREEN );
    if( pass_count == CONTINUE )
        sprintf( STR, "  TEST PASS      : CONTINUE" );
    else
        sprintf( STR, "  TEST PASS      : %u", pass_count );
    Disp_Fin();

    Disp_Ready(0, 3, GREEN );
    sprintf( STR, "  HD Load Time   : -- " );
    Disp_Fin();
    Disp_Ready(0, 4, GREEN );
    sprintf( STR, "  HD UnLoad Time : --" );
    Disp_Fin();

    Disp_Ready(0, 5, GREEN );
    sprintf( STR, "  POST : %d                     ",Post );
    Disp_Fin();

    Disp_Ready(0, 7, GREEN );
    sprintf( STR, "  EXEC PASS :         SEQUENCE:     " );
    Disp_Fin();
    Disp_Ready(0, 8, GREEN );
    sprintf( STR, "  EXEC LBA  : ---                  " );
    Disp_Fin();
    Disp_Ready(0, 9, GREEN );
    sprintf( STR, "  EXEC BLOCK: ---                  " );
    Disp_Fin();

    Disp_Ready(0, 11, GREEN );
    sprintf( STR, "  STATUS:   SENSECODE:   CMP: -   " );
    Disp_Fin();
    Disp_Ready(0, 12, GREEN );
    sprintf( STR, "  ERROR NUM :                      " );
    Disp_Fin();
    Disp_Ready(0, 14, YELLOW );
    sprintf( STR, "  B:ABORT  START:PAUSE " );
    Disp_Fin();
}

u16 ld_uld_key(void)
{
    switch( key ) {
        case	CONT_B:	
	    GetChr();
	    return(1);
	    break;

        case CONT_START:
            ulxPrint0(5, 13, RED, " PAUSE   Hit any key to start" );
            GetChr();
            ulxPrint0(5, 13, RED, "                             " );
            break;

	default	: break;
    }
    return 0;
}
u16	ld_uld_life( void )
{
    static	u8	ldtime=2, uldtime=2;
	u8	stbyflg=1, sta=0, ret=LEO_STATUS_GOOD;
	u32	pass=CONTINUE, err=0;
	u32	tcount_aft, tlba=0;

	Post = 0; 
        ldtime  = GetNum8A( ldtime,  "Input HD Load Time(sec)   ", 2, 13, YELLOW );
        uldtime = GetNum8A( uldtime, "Input HD Un-Load Time(sec)", 2, 13, YELLOW ); 
        tlba    = GetNum32( tlba, "Input LBA", 2, 13, YELLOW ); 
 	stbyflg = GetNumFlg( stbyflg, "StandBy[1] or Sleep[0]    ", 2, 13, YELLOW ); 

	StartStop( stbyflg, sta ) ;
	life_disp_init( "HEAD LD/ULD LIFE TEST" );
	ulxPrint1(0, 3, GREEN , "  HD Load Time   : %d Sec", ldtime);
	ulxPrint1(0, 4, GREEN , "  HD UnLoad Time : %d Sec", uldtime);

	do {
	    /**** Disp Status **********************************/
    	    ulxPrint1(14, 7, WHITE, "%u", pass );
	    ulxPrint1(9, 11, WHITE, "%02X", Status );
	    ulxPrint1(22, 11, WHITE, "%02d", SCode );
	    if( ret != LEO_STATUS_GOOD )
                err++;
            ulxPrint1(13, 12, WHITE, "%d", err );

            key = InCtrlData();

            if (ld_uld_key())
                return 0;

	    /****  Head Load ***********************************/
	    ulxPrint0(31, 7, WHITE, "LD " );
            ret = ReadDrive( tlba, (u32)1, RDB );
	    Wait_Timer( (u16)ldtime );
            if (ld_uld_key())
                return 0;

	    /**** Head Un-Load Time ****************************/
	    ulxPrint0(31, 7, WHITE, "ULD" );
	    sta=0;
	    ret |= StartStop( stbyflg, sta );
	    Wait_Timer( (u16)uldtime );
            if (ld_uld_key())
                return 0;

	    pass++;

/*
	    switch( key ) {
		case	CONT_B:	
			GetChr();
			return(0);
			break;

                case CONT_START:
                    	Disp_Ready(5, 13, RED );
      	            	sprintf( STR, " PAUSE   Hit any key to start" );
                    	Disp_Fin();
                    	GetChr();
                    	Disp_Ready(5, 13, RED );
                    	sprintf( STR, "                             " );
                    	Disp_Fin();
                    	break;

		default	:	break;
	    }	
*/
            if( (pass_count != CONTINUE) && ( pass >= pass_count) )
            {
	    	ulxPrint1(14, 7, WHITE, "%u", pass );
                GetChr();
                return( 0 );
             }
 
	}while( 1 );
}



u16 seek_life( void )
{
    u8  ret=0, i, skflg=1;
    u32 pass=0, err=0;
    u32 blk=1;
    u32 tlba[33]={ 0,1198,2020,3624,2554,3266,2232,3518,336,970,2418,1392,
                   0,2718,2402,4291,562,4120,2528,3414,2452,3762,222,4250,
                   92,3938,1980,4048,528,3142,614,4020
                 };

    key = Post = 0;
    skflg = GetNumFlg( skflg, "Seek CMD[1] or Read CMD[0]    ", 2, 13, YELLOW ); 
    if( skflg ) {
        life_disp_init( "SEEK LIFE TEST(SEEK CMD)" );
    } else {
        life_disp_init( "SEEK LIFE TEST(READ CMD)" );
	Disp_Ready(14, 9, WHITE );
	sprintf( STR, "%d  ",blk );
	Disp_Fin();
        Disp_Ready(0, 5, GREEN );
    	sprintf( STR, "  POST : %d                    ", Post );
    	Disp_Fin();
    }

    do
    {
        for( i=0; i<32; i++ )
        {
	    Disp_Ready(14, 8, WHITE );
	    sprintf( STR, "%X     ",tlba[i] );
	    Disp_Fin();

            if( skflg )
	    	ret = SeekDrive( tlba[i] );
	    else
                ret = ReadDrive( tlba[i], blk, RDB );

	    /**** Disp Status **********************************/
    	    Disp_Ready(14, 7, WHITE );
    	    sprintf( STR, "%u", pass );
    	    Disp_Fin();

	    Disp_Ready(9, 11, WHITE );
	    sprintf( STR, "%02X", Status );
	    Disp_Fin();

	    Disp_Ready(22, 11, WHITE );
	    sprintf( STR, "%02d", SCode );
	    Disp_Fin();

	    if( ret != LEO_STATUS_GOOD )	err++;
            Disp_Ready(13, 12, WHITE );
            sprintf( STR, "%u", err );
            Disp_Fin();

            if ( ret != LEO_STATUS_GOOD && err_stop == ENABLE )
            {
                Disp_Ready(3, 13, RED );
                sprintf( STR, "ERROR. Hit any key to start" );
                Disp_Fin();

                GetChr();

                Disp_Ready(3, 13, RED );
                sprintf( STR, "                           " );
                Disp_Fin();
                if (key != CONT_B)
                    key = 0;
 	    }
            else
                key = InCtrlData();

	    switch( key ) {
		case	CONT_B:	
			GetChr();
			return(0);
			break;

                case CONT_START:
                    	Disp_Ready(5, 13, RED );
      	            	sprintf( STR, " PAUSE   Hit any key to start" );
                    	Disp_Fin();
                    	GetChr();
                    	Disp_Ready(5, 13, RED );
                    	sprintf( STR, "                             " );
                    	Disp_Fin();
                    	break;

		default	:	break;
	    }	

            if( (pass_count != CONTINUE) && ( pass >= pass_count) )
            {
	    	Disp_Ready(14, 7, WHITE );
    	        sprintf( STR, "%d", pass );
    	        Disp_Fin();
                GetChr();
                return( 0 );
             }

         }

        pass++ ;

    } while (1);

    return( 0 );
}


void    life_test( void )
{
    u16 num=1, xpos=2 ,ypos=13 ,clr=YELLOW ;
    u16 x_l= 2, y_l=2, col_l=2;
    u16 x_r=18, y_r=2, col_r=7;
    u8  *left_d[2] = {  "SEEK LIFE      ",
                        "HD LD/ULD LIFE "
                     };
    u8  *right_d[7] = { "SET PARAMETER  ",
			"               ",
			"DISP SYS. DATA ",
                        "CLEAR BUFFER   ",
                        "COMPARE BUFFER ",
                        "BUFFER HANDLE  ",
                        "EXIT           " 
                      };
static u8  stbyflg, stby, sleep, sta, wrt, tbl;
static u32 slba, blk, inb;

    slba   = blk   = (u32)0x00;
    inb    = (u32)0x01;

    do
    {
        ClrDisp();
        Disp_Ready(0, 0, CYAN);
        sprintf( STR, "LIFE TEST MENU " );
        Disp_Fin();

        ListDisp( x_l, y_l, col_l, left_d, x_r, y_r, col_r, right_d, GREEN );
        num = SelStr2( x_l, y_l, col_l, left_d, x_r, y_r, col_r, right_d, num, GREEN );

        switch( num )
        {
            case 1:
		seek_life();
		break;

	    case 2:
		ld_uld_life();
		break;

	    /***********************************************/

            case 3:    
                setparameter();
                break;

            case 4:
                break;

            case 5:
                disp_leosys_data();
                break;

            case 6:
                ClrBuf();
                break;

            case 7:
                CompBufDisp();
                break;

            case 8:
                bufhandle();
                break;

            case 9:
                num = ESC;
                break;

            default:
                break;
        }
        if (num <= 2)
            GetChr();

    } while( num != ESC );
}