/*   MTAT2 => new command id  */
	SET_TRIG_OUT_ACT,
	TRACE_ACTION,
	READ_STAMP,
	SPA_SET_RANGE,
	SPA_CLEAR_RANGE,
	SPA_GET_MA_INFO,
	SPA_GET_TA_INFO
	SPA_GET_CC_INFO
	SPA_CLOSE,
	SPA_SETBKPT,
	SPA_OPEN,
	R_FLASH_ROM,
	W_FLASH_ROM,
	SET_TRACE_OFF_FULL

// Struct and Type definition

typedef enum { 
	UNDEFINE_ADDR, SINGLE_ADDR, RANGE_ADDR, MASK_ADDR , RANGE_MASK
} ADDR_SPEC;
typedef enum { 
	UNDEFINE_DATA = 0, SINGLE_DATA = 1, MASK_DATA = 3 
} DATA_SPEC;

typedef U32 EP_ADDR;
typedef U32 EP_DATA;

typedef struct {
	U32 statusLow,
	       statusHigh;
	U8  TraceBitLow,
	       TraceBitHigh;
}EP_STATUS;

typedef struct {
	U16 physet;		// used for trace on the fly. If physet is TRUE , it will set
				// event to HW. otherwise , it is just dummy operation.
	ADDR_SPEC addrSpec;
	EP_ADDR addrLow;
	EP_ADDR addrHigh;
	EP_ADDR addrRangeMask;
	DATA_SPEC dataSpec;
	EP_DATA dataLow;
	EP_DATA dataHigh;
	EP_STATUS status;
}BUS_EVENT;

typedef struct {
	U16 physet;	/* used for trace on the fly. If physet is TRUE , it will set trigger to HW. otherwise , it is just dummy operation. */
	U16 ev[11]; 	/* bus event : 1 ~ 8 ; ext-in : 9, cnt0 ~1 : 10, 11; 0: null */
	U16 act[11]; 
/* bit :	  0	     1	   2		3		4		5
		"LV0",   "LV1",   "BRK",  "TC0 RST", "TC1 RST", "TC0 START",
		     6		7	   8		  9		10
		"TC1 START", "TC0 STOP","TC1 STOP", "TOFF", "TSTART",
		   11		12		13
		"TSTOP", "TRIG OUTT", "HIZ"
*/
	U16 mode;  /* backward : 0 ; forward : 1 ; center : 2; delay : 3 */
	U16 delay;
} TRIGGER;

typedef struct {
	U16 count;
	U32 totalStamp;
	U8 totalStampMSB;
} SPA_MA_INFO_NODE;

#define SPA_TA_TIME_NO	9
typedef struct {
	U16 count[SPA_TA_TIME_NO];
	U32 tmpStamp;
	U8 stampMSB;
	U32 totalStamp,longest,shortest;
} SPA_TA_INFO_NODE;

5. new ABI Routines for MTAT-II Trace

5. 1	EmuSetTrigOut -- Set trigger out action

Syntax
	STATUS EmuSetTrigOut(U16 trigOut)

Description
	Set the trigger out action mode.

Parameter
	trigOut : 0 : active low, 1 : active high , 2 : High-Z mode

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = SET_TRIG_OUT_ACT(0x64)
INPUT SEQ :
OUTPUT SEQ : 

5. 2	EmuTraceAction -- control trace action

Syntax
	STATUS EmuTraceAction(U16 traceAct)

Description
	control trace action, start or stop.

Parameter
	traceAct : 0 : trace stop, 1 : trace start

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = TRACE_ACTION(0x65)
INPUT SEQ :
OUTPUT SEQ : 

5. 3	EmuReadFlash -- read trace module EEPROM data

Syntax
	STATUS EmuReadFlash(U8 *data)

Description
	read EEPROM data of trace module.

Parameter
	data[32] : a pointer to get returned data. 

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = R_FLASH_ROM(0x6f)
INPUT SEQ :
OUTPUT SEQ : 

5. 4	EmuWriteFlash -- write trace module EEPROM data

Syntax
	STATUS EmuWriteFlush(U8 *data)

Description
	write EEPROM data of trace module.

Parameter
	data[32] : a pointer of writing data. 

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = W_FLASH_ROM(0x70)
INPUT SEQ :
OUTPUT SEQ : 

5. 5	EmuSPASetRange -- set SPA range information

Syntax
	STATUS EmuSPASetRange(U8 type,U8 id,ADDR start,ADDR end)

Description
	set SPA range information.

Parameter
	type : 	MA_RANGE, TA_RANGE or CC_RANGE. 
	id : 		MA => 0~3, TA => 0 , CC => no nused
	start : 	start address of range
	end : 	end address of range

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = SPA_SET_RANGE(0x67)
INPUT SEQ :
OUTPUT SEQ : 

5. 6	EmuSPAClearRange -- clear SPA range information

Syntax
	STATUS EmuSPAClearRange(U8 type)

Description
	clear SPA range information.

Parameter
	type : MA_RANGE= 0, TA_RANGE = 1, CC_RANGE = 2. 

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = SPA_CLEAR_RANGE(0x68)
INPUT SEQ :
OUTPUT SEQ : 

5. 7	EmuSPASetBkpt -- set breakpoint using in SPA operation

Syntax
	STATUS EmuSPASetBkpt(U8 enable,ADDR addr)

Description
	set breakpoint using in SPA operation

Parameter
	enable : enable or disable breakpoint setting 
	addr : breakpoint address

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = SPA_SETBKPT(0x6d)
INPUT SEQ :
OUTPUT SEQ : 

5. 8	EmuSPAOpen -- first function for SPA operation

Syntax
	STATUS EmuSPAOpen(VOID)

Description
	initial for SPA operation.
	backup current event and trigger setting.

Parameter
	none

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = SPA_OPEN(0x6e)
INPUT SEQ :
OUTPUT SEQ : 

5. 9	EmuSPAClose -- lastest function for SPA operation

Syntax
	STATUS EmuSPAClose(VOID)

Description
	recover event and trigger setting to original setting.

Parameter
	none

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = SPA_CLOSE(0x6c)
INPUT SEQ :
OUTPUT SEQ : 

5. 10	EmuSPAGetMAInfo -- read Module Analysis result information

Syntax
	STATUS EmuSPAGetMAInfo(U32 *totalTime,MA_INFO_NODE *info,BOOLEAN *flagHalt)

Description
	read Module Analysis result information.

Parameter
	totalTime :	get the total running time
	info[4] : 	get the module analysis result for the four ranges
	haltFlag :	report the cpu is halted or not. 

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = SPA_GET_MA_INFO(0x69)
INPUT SEQ :
OUTPUT SEQ :  
		
2	1	1	1	4	1	7	7	7	7	1	
status	len1	flag	len2	time
Stamp	len3	inf[0]	info[1]	info[2]	info[3]	ending	

5. 11	EmuSPAGetTAInfo -- read Time Analysis result information

Syntax
	STATUS EmuSPAGetTAInfo(U32 *timeStamp,U16 *info,BOOLEAN *flagHalt)

Description
	read Time Analysis result information.

Parameter
	timeStamp[3] : get the three timestamp result => total, shortest and longest.
	info[9] : get the result timestamp for the nine ranges :  0 ~ 10us,  10us~100us,  100us~1ms,  1ms~10ms,  10ms~100ms,  100ms~1s,  1s~10s,  10s~100s,  100s~  
	haltFlag : report the cpu is halted or not. 

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = SPA_GET_TA_INFO(0x6a)
INPUT SEQ :
OUTPUT SEQ : 

2	1	1	1	4	1	4	1	4	
status	len1	flag	len2	total	len3	shortest	len4	longest	

1	2*9	1	
len5	info[0]~
info[8]	ending	

5. 12	EmuSPAGetCCInfo -- read Code Coverage result information

Syntax
	STATUS EmuSPAGetCCInfo(ADDR start,U16 len,U8 *buf,BOOLEAN flagHalt)

Description
	read Code Coverage result information.

Parameter
	start : start address to get result information
	len : length
	buf : buf to get the result information
	haltFlag : report the cpu is halted or not. 

	/* The returned information will start with a 8-byte address boundary.	 For example : if start address is 0x1234, it will be shifted to address0x1230. Ane the result will start with address 0x1230.
	*/

Return Value	
	ICE_OK			Normal return

following is only for FW:
COMMAND ID = SPA_GET_CC_INFO(0x6b)
INPUT SEQ :
OUTPUT SEQ : 

2	1	1	2	len2-bytes	1	
status	len1	flag	len2	buf	ending	

// special : used 2-bytes storage for buffer length