//##############################################################################
//#
//#                  WUTT DOALL.UTS   -  Samsung DoAll Process
//#             ( Run ServoCopy, Functional/BurnIn, Final and AT Test )
//#
//#               For All Promise PATA/SATA , SATA II Host Adapters
//#       (PATA UDMA 33/66/100/100TX2/133TX2 and SATA 150TX4 and SATA II 300)
//#
//# CHANGE HISTORY:
//# FILE+VER  MMM-DD-YYYY  NAME H/T VER DESCRIPTION OF CHANGE
//# --------  --- -- ----  ---- ------- ---------------------
//# F31STD01  07-10-2009 Fabre Draft
//# F31STD02 07 21 2009 Fabre add TCC/GOD Patch for Fuji & e8jj B/I
//#				add HSTR check
//# F31STD03 07 22 2009 Fabre add BER screen
//#		07 24 2009 Fabre  execute TCC/FOD patch for all Disk
//#		07 30 2009 Fabre  scan M/C to 46cyl
//#		09 18 2009 Jaewoo -Add S-grade Patch
//#		09 21 2009 Fabre use default download function
//#		09 23 2009 Fabre fix abrt error by patch code D/L skip for Fuji disk
//# F31STD05	10 06 2009 Fabre S2P
//#		10 14 2009 Fabre S2P setting
//#		10 16 2009 Fabre add OEM_END2END_DATA_PROTECTION|OEM_ENABLE_E2E_CORRECTION in feature flag
//# F31PSTD1	11 12 2009 Fabre block S2 model, init SSC
//#		11 13 2009 Fabre Enable WATE
//#		12 11 2009 Jaewoo Delay 7 sec after Pass
//#		12 22 2009 Jaewoo Add END_DELAY
//#		12 28 2009 Jaewoo DPP disabled 
//#		12 29 2009 Jaewoo Add UID_ATWH_SAVE_INFLUSH
//# F31PSTD2	01 11 2009 Fabre add ATWH init at test end
//#   		01 15 2009 Jaewoo Disable Virgin Reassign
//#   		01 27 2009 Fabre add 8M 250G model handling
//# F31PSTD3	03 11 2010 Jaewoo Add DPP on & Virgin Reassign enable
//# 		03 24 2010 Jaewoo ECC_VOTING_CONTROL Enable
//# 		04 02 2010 Jaewoo add Block OASTW "24"
//# 		04 09 2010 Jaewoo Add strcpy(gszCODEREV,"$UROM") Previous MES_Check
//# 		04 12 2010 Fabre init staggered spin up(disable)
//# 		04 26 2010 Fabre add SN Writing option
//#		06 04 2010 Fabre check Engineering version 5th digit for blocking s3m
//#		09 30 2010 Fabre add a AtwThreshold setting condition
//#		12 20 2010 Fabre add SATA6G model anme handling
//#		03 14 2011 Fabre - disable WV reassign
//# F31PSTD5	03 23 2011 Fabre - disable ECC voting
//#		03 31 2011 Fabre - disable WV_ENABLE_LBA0
//#
//##############################################################################
//#               Copyright (C) Samsung Information Systems, 2005
//##############################################################################
/*--------------------------------------------------------------------
  SET THE SCRIPT FILENAME (FOR RESULT DISPLAY/VERSION CONTROL).
  MUST UPDATE WITH EACH CHANGE/VERSION.
  CHECK CORRECT MODEL BEFORE BI DUE TO UNIVERSAL HEAD.
--------------------------------------------------------------------*/
void Trinity_check_seektime();
void Trinity_Check_ALIST_Count(int nMCId,int nOffs);
void F3_verify_model();

void main()
{
	int nRet,nPatch;
	int nSAE,nSEDA;	
	int nFeatureFlag,nAtwThreshold,nAtwWideThreshold;
	int nV1,nV2,nV3,nV4,nV5,nV6;

	nSAE=0;nSEDA=0;
	nSAE=1; //$SITE(SAE)
	nSEDA=1; //$SITE(SEDA)
	
	@WINSTAR_set_timeout(25000); // SET COMMAND TIMEOUT                 
	strcpy(StringParam1,"TC_10");	
	@MESSAGE_TESTPHASE();
	@WINSTAR_load_port();                                                        
	END_DELAY = 7;
	@WINSTAR_set_testoption(LOG_ACPT); // A/T Tester
@MESSAGE_Step(NUM); 
	LastPowerOnLimit = 60000;
	@WINSTAR_power_on(STOP_BURNIN_); // POWER ON, SPINUP, & CHECK READY.
	@WINSTAR_set_PIO (4);              
@MESSAGE_Step(NUM); 
	@WINSTAR_init_smtcode();
	strcpy(PATTERN, "RE_SC");
	@WINSTAR_screen_processcode(0,0x50); //'P', SMT code
	@WINSTAR_screen_processcode(0,0x53); //'S', S/C code
@MESSAGE_Step(NUM); 
	@WINSTAR_init();                            
	@ACPT_start();
//#--------------------------------------------------------------------
//# VERIFY BURNIN RESULTS & Model.
//#--------------------------------------------------------------------
@MESSAGE_Step(NUM);
	@WINSTAR_verify_burnin();    
@MESSAGE_Step(NUM);
	strcpy(PATTERN,"$MODEL");
	F3_verify_model();
@MESSAGE_Step(NUM);
	if(gszCODENEGREV[10]==0x31 || gszCODENEGREV[10]==0x36)
	{
		gErrorCode = 59; //model error
		stoptest();
	}
@MESSAGE_Step(NUM);
	if(gszCODENEGREV[4] >= 0x61) //'a'
	{
		gErrorCode = 59; //model error
		stoptest();
	}
@MESSAGE_Step(NUM);
	if(gszCODENEGREV[10]==0x32 && gszCODENEGREV[11]==0x34) // Block OASTW "24"
	{
		gErrorCode = 59; //model error
		stoptest();
	}
@MESSAGE_Step(NUM);
/*
	strcpy(PATTERN,"HSTR");	
	nRet=verify_signature(9,0,1,0x6C,BY_TEXT|BY_FID); 
	if(nRet!=0)
	{
		gErrorCode = 53; // final not run
		stoptest();
	}
*/
//#---------------------------------------------------------------------
//# D/L B/I code & patch
//#---------------------------------------------------------------------
@MESSAGE_Step(NUM);
	@WINSTAR_set_serialnumber();
//#---------------------------------------------------------------------
//# DOWNLOAD THE MAIN CODE BEFORE STARTING FINAL TEST.
//#---------------------------------------------------------------------
@MESSAGE_Step(NUM);
	strcpy(FILENAME,"$MCODE");
	@WINSTAR_download_microcode(7);	
	@WINSTAR_power_off();
	delays(1);                                         
//#--------------------------------------------------------------------
//# POWER UP AND INITIALIZE DRIVE PARAMETERS.
//#--------------------------------------------------------------------
@MESSAGE_Step(NUM);
	LastPowerOnLimit = 17000;
	@WINSTAR_power_on(STOP_BURNIN_); // POWER ON, SPINUP, & CHECK READY.
	@WINSTAR_set_PIO (4); 
	@WINSTAR_init();  
	strcpy(gszCODEREV,"$UROM");
	@ACPT_MES_Check(); @WINSTAR_set_testoption(LOG_RESULT); // INIT (RST,UNLK,IDFY,RCAL,SETPARMS)
	@WINSTAR_set_timeout(7500); // SET COMMAND TIMEOUT                 
@MESSAGE_Step(NUM); 
	strcpy(PATTERN,"$MODEL");
	F3_verify_model();
@MESSAGE_Step(NUM);
	DEVICE_CONFIGURATION2(DCO_RESTORE,0);   
@MESSAGE_Step(NUM);
	strcpy(PATTERN, "0000");
	@WINSTAR_modify_sector(7,0,2,2,48,BY_HEXA|BY_FID); // DELETE 2'ND S/N
@MESSAGE_Step(NUM);
	@WINSTAR_reserved(0x07,0,0,1); //UID clear
	@WINSTAR_set_standby(0);
	@WINSTAR_power_off();                       
	delays(1);        
@MESSAGE_Step(NUM); 
	LastPowerOnLimit = 17000;
	@WINSTAR_power_on(STOP_BURNIN_); // POWER ON, SPINUP, & CHECK READY.
@MESSAGE_Step(NUM); 
	@WINSTAR_set_PIO (4);              
	@WINSTAR_init(); // INIT (RST,UNLK,IDFY,RCAL,SETPARMS)
@MESSAGE_Step(NUM);
	@WINSTAR_set_features(0x00D7); // Transrate 3.0G
	setfeatures(0xD9,0,0,0); // cmd time out default
	@WINSTAR_set_features(0x00DA); //Desktop model
	@WINSTAR_set_features(0x00DB);//Retract Method : default(voltage)
	setfeatures(0x56,0x00,1,2); // restore SSC 
	@WINSTAR_reserved(0xCE,0,0,1); // insitu Enable
	setfeatures(0x56,0x00,0x05,0); // disable staggered spin up
@MESSAGE_Step(NUM);
	// Disable Info Patch option by non-volatile h = 8; fmtu 0x68;
	usercmd( 0, 0x68, 0, 1, 0, 0, 0x08, 0x8F, 0, 0); 
@MESSAGE_Step(NUM); // Change DRAM size and Model name in case of 250GB
// Set DRAM size, SectorCount=DRAM size(MB)
	@WINSTAR_reserved(0xEC,0,0xFF,1); //$250G
@MESSAGE_Step(NUM);
	@WINSTAR_reserved(0x97,0,0,1); // init  ATWH
	@WINSTAR_reserved(0x95,0,0,1); // enable ATWH
@MESSAGE_Step(NUM);
	setUID(0x3316,0,4); //UID_ATWH_MAX_ADJUST_COUNT_FOR_FIT
	setUID(0x3317,0,5); //UID_ATWH_MIN_ADJUST_COUNT_FOR_FIT
	setUID(0x331C,0,15); //UID_ATWH_WIDE_LBA_MARGIN
	setUID(0x3310,0,0x02); //UID_ATWH_CONTROL_FLAG

	nAtwThreshold=10000; //DFLT_ATWH_THRESHOLD
	nAtwWideThreshold=10000*4; //DFLT_ATWH_THRESHOLD_WIDE
	strcpy(PATTERN,"16"); //20
	nRet=verify_signature(9,0,1,0x13E,BY_HEXA|BY_FID);
	if(nRet==0)
	{
		nAtwThreshold=3000; //DFLT_ATWH_THRESHOLD_HTPI
		nAtwWideThreshold=3000*4; //DFLT_ATWH_THRESHOLD_WIDE_HTPI
	}
	strcpy(PATTERN,"04"); 
	nRet=verify_signature(11,0,7,0xD02,BY_HEXA|BY_FID);
	if(nRet==0)
	{
		nAtwThreshold=3000; //DFLT_ATWH_THRESHOLD_HTPI
		nAtwWideThreshold=3000*4; //DFLT_ATWH_THRESHOLD_WIDE_HTPI
	}
	setUID(0x3311,0,nAtwThreshold);	//UID_ATWH_WRITE_THRESHOLD
	setUID(0x331B,0,nAtwWideThreshold); // UID_ATWH_WIDE_WRITE_THRESHOLD
	setUID(0x331A,0,10); // UID_ATWH_SAVE_INFLUSH
@MESSAGE_Step(NUM);
//OEM_WRITE_VERIFY		0x00040000     //b18    enabled write verify
//OEM_ATWHEALING_MODE		0x00004000     //b14    enabled ATW healing
//OEM_WRITE_REAS_VERIFY		0x01000000     //b24    write fault reassign verification
//OEM_END2END_DATA_PROTECTION	0x00008000
//OEM_ENABLE_E2E_CORRECTION	0x80000000
       	nFeatureFlag=0x8104C000;	// DPP ON
	setUID(0x1221,0,nFeatureFlag); //UID_FEATURE_OPTION_FLAG
//DFLT_HIDDEN_REASSIGN_NUM 	10
//DFLT_PM_WRITE_VERIFY_COUNT      100
//DFLT_VIRGIN_RETRY_INDEX         16
//DFLT_RING_DETECT_COUNT          64
//DFLT_PM_CONTROL_FLAG		5
	setUID(0x3209,0,10); //UID_HIDDEN_GLIST_COUNT
	setUID(0x1232,0,5);  //UID_PM_CONTROL_FLAG
	setUID(0x3305,0,100);//UID_WV_COUNT_LUL
	setUID(0x320B,0,16); //UID_GLIST_VIRGIN_RETRY_INDEX
	setUID(0x4025,0,64);//UID_CACHE_6RING_DETECT_COUNT
	setUID(0x3330,0,0);	//UID_ECC_VOTING_CONTROL  - Disable  
@MESSAGE_Step(NUM);
	setUID(0x330F,0,0);//disable WV reassign
	setUID(0x3327,0,0);//disable WV_ENALBE_LBA0
	@WINSTAR_set_standby(0);
	@WINSTAR_power_off();
	delays(1); 
//#--------------------------------------------------------------------
//# SEEK TIME TEST (HDSWITCH, 1 TRK, 1/3 STROKE, AVG, & FULL STROKE).
//#--------------------------------------------------------------------
@MESSAGE_Step(NUM);
	LastPowerOnLimit = 17000;
	@WINSTAR_power_on(STOP_BURNIN_); // POWER ON, SPINUP, & CHECK READY.
	@WINSTAR_set_PIO (4); 
	@WINSTAR_init();
@MESSAGE_Step(NUM); 
	@WINSTAR_set_retry(30); // SET RETRY LEVEL
	@WINSTAR_set_PIO (3); // PIO 3              
	@WINSTAR_set_timeout(7500); // SET COMMAND TIMEOUT                 
@MESSAGE_Step(NUM); 
	//@WINSTAR_check_seektime(); // SPC(1000)
	Trinity_check_seektime();

//#############################################################################
//#############################################################################
//## LOGICAL TESTING FROM HERE ON 
//#############################################################################
//#############################################################################
//#--------------------------------------------------------------------
//# DATA COMPARE TEST - ESMT TEST
//#--------------------------------------------------------------------
@MESSAGE_Step(NUM); 
	@WINSTAR_set_UDMA(5); // UDMA MODE 5
	Lba48Bit = 1;
	@WINSTAR_set_datacompare(1); // DATACOMPARE ON	  
	@WINSTAR_ESMT_test( 1000, 0, 200000 );
	Lba48Bit = 0;
	@WINSTAR_set_datacompare(0); // DATACOMPARE OFF
//#--------------------------------------------------------------------
//# CHECK Zero ptrn test
//#--------------------------------------------------------------------
@MESSAGE_Step(NUM); 
	@WINSTAR_set_UDMA(7);              
	@WINSTAR_set_datacompare(1); // ENABLE DATACOMPARE
	Lba48Bit = 0;
@MESSAGE_Step(NUM);
	@WINSTAR_set_pattern(0x0000);                                              
	@WINSTAR_write ( BY_CHS|BY_DMA, 0, 100, 256, 0);                                    
@MESSAGE_Step(NUM); 
	@WINSTAR_read ( BY_CHS|BY_DMA, 0, 1000, 256, 0);
@MESSAGE_Step(NUM);
	Lba48Bit = 0;
	@WINSTAR_write_read (BY_CHS|BY_DMA|BY_RANDOM|BY_BIT_CHECK, 0, 100, 256, 200);
@MESSAGE_Step(NUM);
	@WINSTAR_set_pattern(0x0000);                                              
	@WINSTAR_write ( BY_CHS|BY_DMA, 0, 110, 256, 0);                                    
@MESSAGE_Step(NUM); 
	@WINSTAR_read ( BY_CHS|BY_DMA, 0, 110, 256, 0);                                    

//#--------------------------------------------------------------------
//# UDMA MODE TRANSFER CHECK.
//#--------------------------------------------------------------------
@MESSAGE_Step(NUM); 
	@WINSTAR_set_pattern(0x0000);                                              
	@WINSTAR_write (BY_LBA | BY_DMA , 1001, 1256, 256, 0);                                                             
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_LBA | BY_DMA , 1001, 1256, 256, 0);
@MESSAGE_Step(NUM);
	@WINSTAR_set_UDMA(0); // UDMA MODE 0
	@WINSTAR_write (BY_CHS | BY_DMA, 100, 110, 128, 0);                                                             
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_CHS | BY_DMA, 100, 110, 128, 0);
@MESSAGE_Step(NUM);
	@WINSTAR_set_UDMA(1); // UDMA MODE 1
	@WINSTAR_write (BY_CHS | BY_DMA, 500, 510, 64, 0);                                                             
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_CHS | BY_DMA, 500, 510, 64, 0);
@MESSAGE_Step(NUM);
	@WINSTAR_set_UDMA(2); // UDMA MODE 2
	@WINSTAR_write (BY_CHS | BY_DMA, 1000, 1010, 128, 0);                                                             
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_CHS | BY_DMA, 1000, 1010, 128, 0);
@MESSAGE_Step(NUM);
	@WINSTAR_set_UDMA(3); // UDMA MODE 3
	@WINSTAR_write (BY_CHS | BY_DMA, 1500, 1510, 64, 0);                                                             
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_CHS | BY_DMA, 1500, 1510, 64, 0);
@MESSAGE_Step(NUM);
	@WINSTAR_set_UDMA(4); // UDMA MODE 4
	@WINSTAR_write (BY_CHS | BY_DMA, 2000, 2010, 128, 0);                                                             
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_CHS | BY_DMA, 2000, 2010, 128, 0);
@MESSAGE_Step(NUM); 
	@WINSTAR_set_UDMA(5); // UDMA MODE 5
	@WINSTAR_write (BY_CHS | BY_DMA, 2500, 2510, 64, 0);                                                             
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_CHS | BY_DMA, 2500, 2510, 64, 0);
@MESSAGE_Step(NUM); 
	@WINSTAR_set_UDMA(6); // UDMA MODE 6
	@WINSTAR_write (BY_CHS | BY_DMA, 3000, 3010, 64, 0);                                                             
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_CHS | BY_DMA, 3000, 3010, 64, 0);
@MESSAGE_Step(NUM); 
	@WINSTAR_set_UDMA(7); // UDMA MODE 7
	@WINSTAR_write (BY_CHS | BY_DMA, 3500, 3510, 128, 0);                                                             
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_CHS | BY_DMA, 3500, 3510, 128, 0);
@MESSAGE_Step(NUM); 
	Lba48Bit = 1;       
	readdmaext(rdbuf,MAX_LBA,1);  // Access Max LBA


//#--------------------------------------------------------------------
//# LBA TAG Test - T3P : START
//#--------------------------------------------------------------------
@MESSAGE_Step(NUM); 
	@WINSTAR_set_datacompare(1);
	@WINSTAR_set_pattern(0);
	getflag(FLAGS);
	setflag(FLAGS|0x0004);
	@WINSTAR_write( BY_LBA|BY_DMA, 0, 0x10000, 255, 0 ); // write LBA Tag
@MESSAGE_Step(NUM); 
	@WINSTAR_read ( BY_LBA|BY_DMA, 0, 0x10000, 255, 0 ); // read LBA Tag
	getflag(FLAGS);
	setflag(FLAGS&0xFFFB);
@MESSAGE_Step(NUM); 
	@WINSTAR_set_datacompare(1);
	@WINSTAR_set_pattern(0);
	@WINSTAR_write( BY_LBA|BY_DMA, 0, 0x10000, 255, 0 ); // write zero pattern
@MESSAGE_Step(NUM); 
	@WINSTAR_read ( BY_LBA|BY_DMA, 0, 0x10000, 255, 0 ); // read zero pattern
	@WINSTAR_set_datacompare(0);

//#--------------------------------------------------------------------
//# Scan OD
//#--------------------------------------------------------------------
@MESSAGE_Step(NUM);
	for(HD=0; HD<= MHD;)
	{
		for(CYL = 64; CYL < 3000;)
		{
			prtk(CYL,HD);
			CYL=CYL+3;
		}
		HD++;
	}

//#--------------------------------------------------------------------
//# CHECK TO ENSURE SYS CYL READ OK.
//#--------------------------------------------------------------------
@MESSAGE_Step(NUM); 
	Lba48Bit = 0;
	@WINSTAR_set_direction(0);                                  
	if(MHD>2) MHD=2;               
	@WINSTAR_read(BY_CHS | BY_VENDOR | BY_MCYL | BY_TRACK, 0, 46, MAX_BLKCNT,0);
	delays(3);
	@WINSTAR_set_standby(0);
	@WINSTAR_power_off();
	delays(1);                                      

//############################################################################
//# NEW AT TEST                                                               
//############################################################################
@MESSAGE_Step(NUM); 
	LastPowerOnLimit = 17000;
	@WINSTAR_power_on(STOP_BURNIN_); // POWER ON, SPINUP, & CHECK READY.
	@WINSTAR_set_PIO (4); // PIO 4
	@WINSTAR_init();    
@MESSAGE_Step(NUM); 
	@WINSTAR_set_features(0xFE42); //AAM Fast
	DEVICE_CONFIGURATION2(DCO_RESTORE,0);
@MESSAGE_Step(NUM);
	@WINSTAR_set_serialnumber();
@MESSAGE_Step(NUM); 
	strcpy(PATTERN,"SAMSUNG"); // CHECK TO VERIFY IDFY DATA & ATA INTF
	@WINSTAR_verify_model();
@MESSAGE_Step(NUM); 
	strcpy(PATTERN,"$UROM");
	@WINSTAR_verify_firmware(BY_MAIN);
@MESSAGE_Step(NUM); 
	strcpy(PATTERN,"$EROM");
	@WINSTAR_verify_firmware(BY_ENGINEERING); //$EROM
@MESSAGE_Step(NUM); 
	strcpy(PATTERN,"$MODEL");
	@WINSTAR_verify_model(); // T133P VERIFY MODEL
@MESSAGE_Step(NUM); 
	@WINSTAR_set_features(0x$AAMV); // AAM
@MESSAGE_Step(NUM); 	
	//@Winstar_Check_ALIST_Count(19,20);
	Trinity_Check_ALIST_Count(19,20);
@MESSAGE_Step(NUM); 
	@WINSTAR_set_retry(30); // SET RETRY LEVEL
	@WINSTAR_set_pattern(0x0000);
	@WINSTAR_set_UDMA(7);
	@WINSTAR_set_datacompare(0);
	Lba48Bit = 0;
	@WINSTAR_write (BY_LBA|BY_DMA, 0, 2000, 256, 0);
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_LBA|BY_DMA, 0, 2000, 256, 0);
@MESSAGE_Step(NUM);
	@WINSTAR_set_UDMA(7);
	Lba48Bit = 1;
	@WINSTAR_write (BY_LBA | BY_DMA, 0, 2000, 255, 0);
@MESSAGE_Step(NUM); 
	@WINSTAR_read (BY_LBA | BY_DMA, 0, 2000, 255, 0);
@MESSAGE_Step(NUM); 
	@WINSTAR_set_timeout(25000); // SET COMMAND TIMEOUT    
	@WINSTAR_reserved(135,0,0,1); // SMART Initialize
	@WINSTAR_set_smart(0xDE); // SMART Initialize
	@WINSTAR_set_smart(0xD8); //$SMART_E
	@WINSTAR_set_smart(0xD9); //$SMART_D
	@WINSTAR_set_smart(0xD8); // $SMART_S
	@WINSTAR_set_smart(0xF1D2); // $SMART_S
	@WINSTAR_set_smart(0xD8);   //$SMART_A
	@WINSTAR_set_smart(0xF1D2); //$SMART_A
	@WINSTAR_set_smart(0xF8DB); //$SMART_A
	delays(3);
	@WINSTAR_set_standby(0);
	@WINSTAR_power_off();
	delays(7);
@MESSAGE_Step(NUM);
	LastPowerOnLimit = 17000;
	@WINSTAR_power_on(STOP_BURNIN_); // POWER ON, SPINUP, & CHECK READY.
	@WINSTAR_set_PIO (4); // PIO 4
	@WINSTAR_init();              
@MESSAGE_Step(NUM); 
	strcpy(PATTERN, "B0F85009");             //$80G
	strcpy(PATTERN, "B09EA112"); 		 //$160G
	strcpy(PATTERN, "B090932E");                   //$400G
	strcpy(PATTERN, "70591C1D");                   //$250G
	strcpy(PATTERN, "B0EA4225");                   //$320G
	strcpy(PATTERN, "3060383A");                   //$500G
	strcpy(PATTERN, "B082854A");                   //$640G
	strcpy(PATTERN, "F0665457");                   //$750G
	strcpy(PATTERN, "B06D7074");                   //$1000G
	nRet=verify_signature(0,0,0,200,BY_HEXA|BY_IDFY);
	if(nRet!=0)
	{
		gErrorCode = 57; // Bad Capa Fail!!
		stoptest();
	}
@MESSAGE_Step(NUM);
	nV1=getUID(0x1221,0); // UID_FEATURE_OPTION_FLAG
	nV2=getUID(0x3209,0); // UID_HIDDEN_GLIST_COUNT
	nV3=getUID(0x3305,0); //UID_WV_COUNT_LUL
	nV4=getUID(0x320B,0); //UID_GLIST_VIRGIN_RETRY_INDEX
	nV5=getUID(0x4025,0); //UID_CACHE_RING_DETECT_COUNT
	if(nV1!=nFeatureFlag || nV2!=10 || nV3!=100 || nV4!=16 ||nV5!=64)
	{
		gErrorCode = 137;	//sign error	
		stoptest();		
	}
@MESSAGE_Step(NUM);
	nV1=getUID(0x1232,0);  //UID_PM_CONTROL_FLAG
	if(nV1!=5)
	{
		gErrorCode = 137;	//sign error	
		stoptest();				
	}
@MESSAGE_Step(NUM);
	nV1=getUID(0x3311,0); //UID_ATWH_WRITE_THRESHOLD
	nV2=getUID(0x3316,0); //UID_ATWH_MAX_ADJUST_COUNT_FOR_FIT
	nV3=getUID(0x3317,0); //UID_ATWH_MIN_ADJUST_COUNT_FOR_FIT
	nV4=getUID(0x331B,0); //UID_ATWH_WIDE_WRITE_THRESHOLD
	nV5=getUID(0x3327,0);//WV_ENALBE_LBA0
	if(nV1!=nAtwThreshold || nV2!=4 || nV3!=5 || nV4!=nAtwWideThreshold || nV5!=0)
	{
		gErrorCode = 137;	//sign error	
		stoptest();
	}
@MESSAGE_Step(NUM);
	nV1=getUID(0x331C,0); //UID_ATWH_WIDE_LBA_MARGIN
	nV2=getUID(0x3310,0); //UID_ATWH_CONTROL_FLAG
	nV3=getUID(0x331A,0); //UID_ATWH_SAVE_INFLUSH
	nV4=getUID(0x3330,0); //UID_ECC_VOTING_CONTROL
	nV5=getUID(0x330F,0);//disable WV reassign
	if(nV1!=15 || nV2!=0x02 || nV3!=10 || nV4!=0 || nV5!=0)
	{
		gErrorCode = 137;	//sign error	
		stoptest();
	}
//############################################################################
//# CHECK TEST CONFIG - CHKUTS.TXT                                                               
//############################################################################

//$INSERT_CHKSPT

@MESSAGE_Step(NUM); 
//$INSERT(INLINE=="YES","@ACPT_Pause();")
//$INSERT(INLINE=="YES"&&"S/N Write"!="D","@ACPT_Request_SN();")
//$INSERT(INLINE=="YES"&&"S/N Write"=="LO","@WINSTAR_change_pn2sn(4+2+1,0);")
//$INSERT(INLINE=="YES"&&"S/N Write"=="RO","@WINSTAR_change_pn2sn(4+2+1,1);")
//$INSERT(INLINE=="YES"&&"S/N Write"!="D","@WINSTAR_check_WWN();")
//$INSERT(INLINE=="YES"&&"S/N Write"!="D"&&"PPID"=="E","@WINSTAR_Write_PPID();")
@MESSAGE_Step(NUM); 
	@WINSTAR_reserved(0x97,0,0,1); // init  ATWH
	@WINSTAR_set_standby(0);
	@MESSAGE_DrivePass(); // make report file
}
void Trinity_check_seektime()
{
	float fA,fB,fC,fD,fE,fF;

	//  get seektime values
	mcrd(usrbuf,88,0,1);
	if(usrbuf[ 20]==0 && usrbuf[ 21]==0) 
	{
		f1TkSeekTime[0] = usrbuf[23]<<8 | usrbuf[22];
		f3ODSeekTime[0] = usrbuf[27]<<8 | usrbuf[26];
		f3MDSeekTime[0] = usrbuf[29]<<8 | usrbuf[28];
		f3IDSeekTime[0] = usrbuf[31]<<8 | usrbuf[30];
		fFulSeekTime[0] = usrbuf[33]<<8 | usrbuf[32];
		fRndSeekTime[0] = usrbuf[35]<<8 | usrbuf[34];
													
		f1TkSeekTime[1] = usrbuf[37]<<8 | usrbuf[36];
		f3ODSeekTime[1] = usrbuf[41]<<8 | usrbuf[40];
		f3MDSeekTime[1] = usrbuf[43]<<8 | usrbuf[42];
		f3IDSeekTime[1] = usrbuf[45]<<8 | usrbuf[44];
		fFulSeekTime[1] = usrbuf[47]<<8 | usrbuf[46];
		fRndSeekTime[1] = usrbuf[49]<<8 | usrbuf[48];
	}
	else
	{
		f1TkSeekTime[0] = usrbuf[ 9]<<8 | usrbuf[ 8];
		f3ODSeekTime[0] = usrbuf[13]<<8 | usrbuf[12];
		f3MDSeekTime[0] = usrbuf[15]<<8 | usrbuf[14];
		f3IDSeekTime[0] = usrbuf[17]<<8 | usrbuf[16];
		fFulSeekTime[0] = usrbuf[19]<<8 | usrbuf[18];
		fRndSeekTime[0] = usrbuf[21]<<8 | usrbuf[20];
													
		f1TkSeekTime[1] = usrbuf[23]<<8 | usrbuf[22];
		f3ODSeekTime[1] = usrbuf[27]<<8 | usrbuf[26];
		f3MDSeekTime[1] = usrbuf[29]<<8 | usrbuf[28];
		f3IDSeekTime[1] = usrbuf[31]<<8 | usrbuf[30];
		fFulSeekTime[1] = usrbuf[33]<<8 | usrbuf[32];
		fRndSeekTime[1] = usrbuf[35]<<8 | usrbuf[34];		
	}
		
	f1TkSeekTime[0] = f1TkSeekTime[0]/1000;
	f3ODSeekTime[0] = f3ODSeekTime[0]/1000;
	f3MDSeekTime[0] = f3MDSeekTime[0]/1000;
	f3IDSeekTime[0] = f3IDSeekTime[0]/1000;
	fFulSeekTime[0] = fFulSeekTime[0]/1000;
	fRndSeekTime[0] = fRndSeekTime[0]/1000;
										 
	f1TkSeekTime[1] = f1TkSeekTime[1]/1000;
	f3ODSeekTime[1] = f3ODSeekTime[1]/1000;
	f3MDSeekTime[1] = f3MDSeekTime[1]/1000;
	f3IDSeekTime[1] = f3IDSeekTime[1]/1000;
	fFulSeekTime[1] = fFulSeekTime[1]/1000;
	fRndSeekTime[1] = fRndSeekTime[1]/1000;

	check_seektime();
	return;
}
void Trinity_Check_ALIST_Count(int nMCId,int nOffs)
{
	int nReassignCnt;

	if(nMCId==0)
	{
		phrd(rdbuf,1,0,372,1);
	}
	else
	{
		mcrd(rdbuf,nMCId,0,1);
	}
	nReassignCnt=((rdbuf[nOffs+1]&0xFF)<<8)|(rdbuf[nOffs]&0xFF);
	if(nReassignCnt>1)
	{
		strcpy(StringParam1,"ALst");
		gErrorCode = 124;
		@MESSAGE_TEXT4();
		stoptest();
	}	
}
void F3_verify_model()
{
	int nRet,nModel;

	strstr( gszMODEL,"HD25", nRet );
	strstr( PATTERN,"HD25", nModel );
	if(nRet!=0 && nModel!=0)
	{
		strstr( gszMODEL,"HD254GJ", nRet );
		if(nRet!=0) return;        	
		strstr( gszMODEL,"HD253GM", nRet );
		if(nRet!=0) return;
	} 
	strstr( gszMODEL,"HE25", nRet );
	strstr( PATTERN,"HD25", nModel );
	if(nRet!=0 && nModel!=0)
	{
		strstr( gszMODEL,"HE253GJ", nRet );
		if(nRet!=0) return;
	}

	strstr( gszMODEL,"HD50", nRet );
	strstr( PATTERN,"HD50", nModel );
	if(nRet!=0 && nModel!=0)
	{
		strstr( gszMODEL,"HD502HM", nRet );
		if(nRet!=0) return;        	

	} 
	strstr( gszMODEL,"HE50", nRet );
	strstr( PATTERN,"HD50", nModel );
	if(nRet!=0 && nModel!=0)
	{
		strstr( gszMODEL,"HE502HJ", nRet );
		if(nRet!=0) return;
	} 

	@WINSTAR_verify_model();
}
//################################# End of file ################################
