//#----------------------------------------------------------------------
//  LUL TEST WITH RADNOM WR (Will be replaced by "N" BI TEST) about 4/6
//#-----------------------------------------------------------------------
void main()
{
    int nRet,nCnt, iCnt, loaddata;
    int nHalfCYL;
    int nMaxCYL;
    int n14CYL;
    strcpy(StringParam1,"MUN42SB.UTS");
    @MESSAGE_Step(NUM); @MESSAGE_SCRIPTNAME();

    @MESSAGE_Step(NUM); @WINSTAR_load_port();                        
    delays(NET_PORT * 10);
//    setvoltage(nCnt, NET_PORT, 3.3, 12.0 );
//    delays(10);
    @MESSAGE_Step(NUM); @WINSTAR_set_timeout(480000);
    LastPowerOnLimit = 480000;        
    @MESSAGE_Step(NUM); @WINSTAR_time_stamp(0); 

//#-------------------------------------
//  Resonance Screen
//#------------------------------------- 

@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
                    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_reset();
@MESSAGE_Step(NUM); @WINSTAR_init();

                    strcpy(FILENAME,"NB01nB92.bin"); // b/i code
@MESSAGE_Step(NUM); @WINSTAR_download_microcode(7);
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  


@MESSAGE_Step(NUM); @WINSTAR_set_timeout(3600000);
@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
                    delays(30);
@MESSAGE_Step(NUM); @WINSTAR_reset();
@MESSAGE_Step(NUM); @WINSTAR_init();
@MESSAGE_Step(NUM); @WINSTAR_set_PIO(4);
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB0, 0, 0x17, 0); // sub-cmd, cyl, sc, sn  //Resonance Screen
                    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  

@MESSAGE_Step(NUM); @WINSTAR_set_timeout(120000);

//#-------------------------------------
//  End Of Resonance Screen
//#------------------------------------- 

@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
                    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_reset();
@MESSAGE_Step(NUM); @WINSTAR_init();

                    strcpy(FILENAME,"NB05aM01.bin"); // main code 
@MESSAGE_Step(NUM); @WINSTAR_download_microcode(7);
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  

//# ------------------------------------------
//# Parameter Screen 1 (Abnormal Bias Screen)
//# ------------------------------------------

@MESSAGE_Step(NUM); LastPowerOnLimit = 120000;   
@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
                    delays(2);                                      
@MESSAGE_Step(NUM); @WINSTAR_reset();
@MESSAGE_Step(NUM); @WINSTAR_init();
@MESSAGE_Step(NUM); @WINSTAR_set_PIO(4);

@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB0, 0, 0x1C, 0); // RE- Bias Cal
		    delays(2);
//@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB0, 0, 0x1B, 0); // Abnormal Bias Screen, Difference > 200
//		    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB0, 0, 0x1C, 0); // RE- Bias Cal
		    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB0, 0, 0x1B, 0); // Abnormal Bias Screen, Difference > 200
		    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB0, 0, 0x1C, 0); // RE- Bias Cal
		    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB0, 0, 0x1B, 0); // Abnormal Bias Screen, Difference > 200
		    delays(2);

@MESSAGE_Step(NUM); @WINSTAR_power_off();                        
                    delays(7); 

//# -------------------------------------------------
//# End of Parameter Screen 1 (Abnormal Bias Screen)
//# -------------------------------------------------

@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
            delays(2);                                      
@MESSAGE_Step(NUM); @WINSTAR_reset();
@MESSAGE_Step(NUM); @WINSTAR_init();
@MESSAGE_Step(NUM); @WINSTAR_set_retry(10);
@MESSAGE_Step(NUM); @WINSTAR_set_PIO(4);
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB5, 0, 0 , 0);   // sub-cmd, cyl, sc, sn  /// START COMMAND OF LUL TEST
                    for(nCnt=0; nCnt<80; )  // 480SEC
                    {
                        @MESSAGE_Loop(nCnt+1);
                        @MESSAGE_Step(NUM); 
                        delays(6);  //  Delay for LUL TEST (Orignal 40min, dealy 7 ==>6 for Reduced time )
                        nCnt++;
                    }
                    @MESSAGE_Loop(0);
                    delays(2); 
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB6, 0, 0 , 0);   // sub-cmd, cyl, sc, sn  /// END COMMAND OF LUL TEST
                    delays(6);      
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  
for(nCnt=0; nCnt < 10; ){
@MESSAGE_Step(NUM); @WINSTAR_set_timeout(3600000);
@MESSAGE_Step(NUM); LastPowerOnLimit = 120000;
@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
            delays(2);                                      
@MESSAGE_Step(NUM); @WINSTAR_reset();
@MESSAGE_Step(NUM); @WINSTAR_init();
@MESSAGE_Step(NUM); @WINSTAR_set_retry(10);
@MESSAGE_Step(NUM); @WINSTAR_set_PIO(4);
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB7, 0, 0 , 0);   // sub-cmd, cyl, sc, sn  /// START COMMAND OF LUL TEST
                    for(nCnt=0; nCnt<25; )  // 150SEC
                    {
                        @MESSAGE_Loop(nCnt+1);
                        @MESSAGE_Step(NUM); 
                        delays(6);  //  Delay for LUL TEST (Orignal 40min, dealy 7 ==>6 for Reduced time )
                        nCnt++;
                    }
                    @MESSAGE_Loop(0);
                        delays(2); 
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB8, 0, 0 , 0);   
                    rtsk();
                    if(TF_SC !=0)
                    {
                        strcpy(StringParam1,"LUL");
            @MESSAGE_TEXT3();
                strcpy(StringParam1,"SRN2");
            gErrorCode = 208;                              // JJW 1.3g
            @MESSAGE_TEXT4();
            stoptest();
                    }                 
                    delays(2);      
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  
     nCnt++;
}

 

@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
@MESSAGE_Step(NUM); @WINSTAR_init();
                    Lba48Bit = 0;                                                                 
@MESSAGE_Step(NUM); @WINSTAR_set_UDMA(4);                                                                                                         
@MESSAGE_Step(NUM); @WINSTAR_set_retry(10);
@MESSAGE_Step(NUM); @WINSTAR_read ( BY_CHS | BY_VENDOR, 0, 10000, 256, 0); 
@MESSAGE_Step(NUM); @WINSTAR_read ( BY_CHS | BY_VENDOR, 55000, MAX_CYL, 256, 0); 
                    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  

//#-------------------------------------
//  Physical Random W/R Test Unitl 10K Loop 
//#-------------------------------------     
@MESSAGE_Step(NUM); LastPowerOnLimit = 120000;
@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
@MESSAGE_Step(NUM); @WINSTAR_init();
                    Lba48Bit = 0;                                                                 
@MESSAGE_Step(NUM); @WINSTAR_set_UDMA(4); // UDMA 4 LBA Write                                                
@MESSAGE_Step(NUM); @WINSTAR_set_pattern(0x0000);                                              
@MESSAGE_Step(NUM); @WINSTAR_set_retry(10);
srand(3333);  
for( nCnt=0 ; nCnt<3000 ; )
{
	rand(CYL,64,MAX_CYL);
	rand(HD,0,MHD);
	pwtk(CYL,HD);
        prtk(CYL,HD);
      
	nCnt++;
}
 
delays(10);  
@MESSAGE_Step(NUM); @WINSTAR_power_off();
 delays(7);  


//#-------------------------------------
//  CSS 10 Loop ( CSS DISABLE FOR REDUCED TIME )
//#-------------------------------------     

@MESSAGE_Step(NUM); @WINSTAR_css_test( CSS_TEST, 5, 0, 3);  // CSS TEST FOR SCRATCH DEFECT SCREEN


//#-------------------------------------
//    Physical Sequential Write
//#-------------------------------------    
@MESSAGE_Step(NUM); LastPowerOnLimit = 120000;
@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
@MESSAGE_Step(NUM); @WINSTAR_init();
                    Lba48Bit = 0;                                                                 
@MESSAGE_Step(NUM); @WINSTAR_set_UDMA(4);                                                              
@MESSAGE_Step(NUM); @WINSTAR_set_pattern(0x0000);                                             
@MESSAGE_Step(NUM); @WINSTAR_set_retry(10);
@MESSAGE_Step(NUM); @WINSTAR_write ( BY_CHS | BY_VENDOR, 0, MAX_CYL, 256, 0); 
                    delays(10);   
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  


    @MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
    delays(2);                                      
    @MESSAGE_Step(NUM); @WINSTAR_reset();
    @MESSAGE_Step(NUM); @WINSTAR_init();   
@MESSAGE_Step(NUM); @WINSTAR_set_retry(10);
//############################### ATW Test 500 times ##############################
nHalfCYL = MAX_CYL/2;           //Zn7
n14CYL = MAX_CYL-6000;         //Zn14
nMaxCYL  = MAX_CYL-500;      //Zn15            

//@WINSTAR_set_UDMA(4);                              // UDMA MODE 4   
strcpy( PATTERN, "CCCC" );                         // Pattern 'CCCC'
@WINSTAR_set_pattern3(4);                          // Pattern3 '2 byte pattern'

// Parameters:   v1: number of on-track reads 
//             v2; offtrack value 
//             v3: number of offtrack writes 
//             v4; number of on-track writes 
//             v5: option to target cylinder 

@MESSAGE_Step(NUM);
@WINSTAR_interfer_test(100, 0, 500, 1, 1000);      // ATW 100 at OD Zone, Zn0
@MESSAGE_Step(NUM); 
@WINSTAR_interfer_test(100, 0, 500, 1, nHalfCYL);     // ATW 100 at MD Zone, Zn7      
@MESSAGE_Step(NUM); 
@WINSTAR_interfer_test(100, 0, 500, 1, n14CYL);     // ATW 100 at ID Zone, Zn14       
@MESSAGE_Step(NUM); 
@WINSTAR_interfer_test(100, 0, 500, 1, nMaxCYL);     // ATW 100 at ID Zone, Zn15
delays(2);                                                      

@WINSTAR_init();                                    
//@WINSTAR_set_UDMA(4);                              // UDMA MODE 4   
@WINSTAR_set_pattern(0x0000);
@WINSTAR_set_direction(0);
Lba48Bit = 0;
@MESSAGE_Step(NUM);                
@WINSTAR_read( BY_CHS | BY_VENDOR | BY_TRACK, 950, 1050, MAX_BLKCNT,0);
@MESSAGE_Step(NUM);
@WINSTAR_read( BY_CHS | BY_VENDOR | BY_TRACK, nHalfCYL-50, nHalfCYL+50, MAX_BLKCNT,0);
@MESSAGE_Step(NUM);
@WINSTAR_read( BY_CHS | BY_VENDOR | BY_TRACK, n14CYL-50, n14CYL+50, MAX_BLKCNT,0);
@MESSAGE_Step(NUM);
@WINSTAR_read( BY_CHS | BY_VENDOR | BY_TRACK, nMaxCYL-50, nMaxCYL+50, MAX_BLKCNT,0);

@MESSAGE_Step(NUM);
@WINSTAR_write( BY_CHS | BY_VENDOR | BY_TRACK, 950, 1050, MAX_BLKCNT,0);
@MESSAGE_Step(NUM);
@WINSTAR_write( BY_CHS | BY_VENDOR | BY_TRACK, nHalfCYL-50, nHalfCYL+50, MAX_BLKCNT,0);
@MESSAGE_Step(NUM);
@WINSTAR_write( BY_CHS | BY_VENDOR | BY_TRACK, n14CYL-50, n14CYL+50, MAX_BLKCNT,0);       
@MESSAGE_Step(NUM);
@WINSTAR_read( BY_CHS | BY_VENDOR | BY_TRACK, nMaxCYL-50, nMaxCYL+50, MAX_BLKCNT,0);
delays(2);                                                             
                          
    @MESSAGE_Step(NUM); @WINSTAR_power_off();                        
    delays(10);  

//#-------------------------------------
//  CSS 10 Loop ( CSS 10 ==> 3 FOR REDUCED TIME ) 
//#-------------------------------------     

@MESSAGE_Step(NUM); @WINSTAR_css_test( CSS_TEST, 5, 0, 3);  // CSS TEST FOR SCRATCH DEFECT SCREEN

//#-------------------------------------
//  High Temp Motor RRO Screen
//#-------------------------------------    
@MESSAGE_Step(NUM); LastPowerOnLimit = 120000;
@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
                    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_reset();
@MESSAGE_Step(NUM); @WINSTAR_init();
@MESSAGE_Step(NUM); @WINSTAR_set_PIO(4);
@MESSAGE_Step(NUM); @WINSTAR_reserved(0xB0, 0, 0x19, 0); // sub-cmd, cyl, sc, sn  //High Temp Motor RRO Screen
                    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  

//#-------------------------------------
//    Physical Sequential Read
//#-------------------------------------    

@MESSAGE_Step(NUM); LastPowerOnLimit = 10000;
@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
@MESSAGE_Step(NUM); @WINSTAR_init();
                    Lba48Bit = 0;                                                                 
@MESSAGE_Step(NUM); @WINSTAR_set_UDMA(4);                                                              
@MESSAGE_Step(NUM); @WINSTAR_set_retry(10);
@WINSTAR_set_pattern(0x0000);   
//@MESSAGE_Step(NUM); @WINSTAR_write ( BY_CHS | BY_VENDOR, 0, MAX_CYL, 256, 0);
@MESSAGE_Step(NUM); @WINSTAR_read ( BY_CHS | BY_VENDOR, 0, MAX_CYL, 256, 0);
                    delays(10);   
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  


//################################ MC Read ########################################

@MESSAGE_Step(NUM); @WINSTAR_power_on(STOP_BURNIN_);
@MESSAGE_Step(NUM); @WINSTAR_init();                                                    
/*
@MESSAGE_Step(NUM); @WINSTAR_set_UDMA(4);
@MESSAGE_Step(NUM); //AAM
@WINSTAR_set_features(0x8042);
@MESSAGE_Step(NUM); //UID SMART
@WINSTAR_reserved(0x87,0,1,1); // Reserved(135)
delays(1);           
@WINSTAR_set_smart(0xDE); // SMART Initialize 
setUID(0x1402,0,1);
setUID(0x1403,0,1); 
*/
                    Lba48Bit = 0;                                      // disable 48bit mode
@MESSAGE_Step(NUM); @WINSTAR_read( BY_CHS | BY_VENDOR | BY_MCYL | BY_TRACK, 1, 50, MAX_BLKCNT,0); // Mc Read    
delays(2);  
 
//################################ End Of MC Read ##################################


//################################ CHECK ALIST #####################################

@MESSAGE_Step(NUM); @WINSTAR_init();
@MESSAGE_Step(NUM); @WINSTAR_set_UDMA(4); // UDMA 4 LBA Write  
                    Lba48Bit = 0;                                                                 
	            strcpy(PATTERN,"00000000");
@WINSTAR_verify_signature(50,0,105,16,BY_HEXA);    // Check Alist
                    delays(2);
@MESSAGE_Step(NUM); @WINSTAR_power_off();
                    delays(7);  

//################################ End Of CHECK ALIST ###############################



    @MESSAGE_Step(NUM); @WINSTAR_set_timeout(25000);     // SET COMMAND TIMEOUT              
    LastPowerOnLimit = 360000;
    @MESSAGE_Step(NUM);  @WINSTAR_power_on(STOP_BURNIN_); // POWER ON, SPINUP, & CHECK READY.
    @MESSAGE_Step(NUM);  @WINSTAR_init();                            
    @MESSAGE_Step(NUM); @WINSTAR_time_stamp(1); 
    @MESSAGE_Step(NUM); @MESSAGE_DrivePass();
}
//################################# End of file ################################

