?? zl5011xtm.c
字號(hào):
status = zl5011xReadModWrite(zl5011xParams, address, bits, bitMask);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTmEnableTrace
Description:
There are 4 options for which data to collect in the trace buffer. Full
capture requires 4 entries per message, partial is only 2 and
source / timer are 1 entry each. The trace buffer is initialised (cleared)
and then enabled.
Inputs:
zl5011xParams Pointer to the structure for this device instance
defaultTimer set to ZL5011X_TRUE to use the default (slow) timer.
mode data collection mode - full, partial, source or timer
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTmConfigureTrace(zl5011xParamsS *zl5011xParams,
zl5011xTmTraceModeE mode, zl5011xBooleanE defaultTimer)
{
zlStatusE status = ZL5011X_OK;
Uint32T loop;
Uint32T bits, bitMask;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmConfigureTrace: trace mode %d, timer %d",
mode, defaultTimer, 0, 0, 0, 0);
/* Check parameters */
status = ZL5011X_CHECK_BOOLEAN(defaultTimer);
if(status == ZL5011X_OK)
{
status = ZL5011X_CHECK_TM_TRACE_MODE(mode);
}
/* Disable the trace buffer, to allow the buffer to be zero'd out */
if(status == ZL5011X_OK)
{
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_TM_CONTROL,
ZL5011X_1BIT_MASK << ZL5011X_TM_TRACE_ENABLE_BIT,
ZL5011X_1BIT_MASK << ZL5011X_TM_TRACE_ENABLE_BIT);
}
for (loop = 0; loop < ZL5011X_TM_TRACE_BUFFER_SIZE; loop++)
{
if(status != ZL5011X_OK)
{
break;
}
/* zero out the TM trace memory */
status = zl5011xWrite(zl5011xParams,
ZL5011X_TM_TRACE_BUFFER + (loop * sizeof(Uint32T)),
0);
}
/* Enable trace buffer */
if(status == ZL5011X_OK)
{
bits = (Uint32T)mode << ZL5011X_TM_TRACE_MODE_BITS;
bitMask = (ZL5011X_TM_TRACE_MODE_MASK << ZL5011X_TM_TRACE_MODE_BITS) |
(ZL5011X_1BIT_MASK << ZL5011X_TM_TRACE_ENABLE_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_TM_TRACE_TIMER_BIT);
if (defaultTimer == ZL5011X_FALSE)
{
/* set the timer bit if using the fast clock */
bits |= (ZL5011X_1BIT_MASK << ZL5011X_TM_TRACE_TIMER_BIT);
}
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_TM_CONTROL,
bits, bitMask);
/* store the settings in the device structure */
zl5011xParams->taskManager.tmTraceMode = mode;
zl5011xParams->taskManager.tmDefaultTimer = defaultTimer;
switch (mode)
{
case ZL5011X_TM_TRACE_FULL :
zl5011xParams->taskManager.tmBufferSize = 4;
break;
case ZL5011X_TM_TRACE_PARTIAL :
zl5011xParams->taskManager.tmBufferSize = 2;
break;
case ZL5011X_TM_TRACE_SHORT_TIME : /* intentional fall-through */
case ZL5011X_TM_TRACE_SHORT_SOURCE : /* intentional fall-through */
default :
zl5011xParams->taskManager.tmBufferSize = 1;
break;
}
zl5011xParams->taskManager.tmNumBuffers = ZL5011X_TM_TRACE_BUFFER_SIZE / zl5011xParams->taskManager.tmBufferSize;
}
return(status);
}
/*******************************************************************************
Function:
zl5011xTmDisableTrace
Description:
Used to allow the host to access the trace buffer.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
It is possible to read from the trace buffer without disabling it, but there
is a risk of reading incorrect data, since the device will continue to
write to the buffer.
*******************************************************************************/
zlStatusE zl5011xTmDisableTrace(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmDisableTrace:", 0, 0, 0, 0, 0, 0);
status = zl5011xReadModWrite(zl5011xParams, ZL5011X_TM_CONTROL,
ZL5011X_1BIT_MASK << ZL5011X_TM_TRACE_ENABLE_BIT,
ZL5011X_1BIT_MASK << ZL5011X_TM_TRACE_ENABLE_BIT);
return(status);
}
/*******************************************************************************
Function:
zl5011xTmGetTracePointer
Description:
Returns the index for the head of the trace buffer.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
tracePointer index for the trace buffer head
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xTmGetTracePointer(zl5011xParamsS *zl5011xParams,
Uint32T *tracePointer)
{
Uint32T readValue;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmGetTracePointer:", 0, 0, 0, 0, 0, 0);
status = zl5011xRead(zl5011xParams, ZL5011X_TM_TRACE_POINTER, &readValue);
/* shift and mask the read value to get the trace pointer */
readValue = (readValue >> ZL5011X_TM_TRACE_POINTER_BITS) & ZL5011X_TM_TRACE_POINTER_MASK;
/* the pointer currently points at an empty position, so subtract off one
buffer location, and handle wrapping */
readValue = (readValue - zl5011xParams->taskManager.tmBufferSize) % ZL5011X_TM_TRACE_BUFFER_SIZE;
/* divide by the size of each buffer, to give an index */
*tracePointer = readValue / zl5011xParams->taskManager.tmBufferSize;
return(status);
}
/*******************************************************************************
Function:
zl5011xTmDecodeTraceFull
Description:
Populates the trace message structure using the four 32 bit words
passed in.
Inputs:
zl5011xParams Pointer to the structure for this device instance
buffer raw data from the trace buffer
Outputs:
msg structure populated with the trace message. Unused fields are
set to all 1's
Returns:
zlStatusE
Remarks:
Using magic numbers for the bit positions in the TM buffer, since the bit
positions are unique to this function.
*******************************************************************************/
zlStatusE zl5011xTmDecodeTraceFull(zl5011xParamsS *zl5011xParams,
Uint32T *buffer, zl5011xTmTraceMessageS *msg)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmDecodeTraceFull:", 0, 0, 0, 0, 0, 0);
/* decode the first 32 bit word of the message */
msg->mpid = (Uint16T)((buffer[0] >> 0) & 0xffff);
msg->pktLen = (Uint16T)((buffer[0] >> 16) & 0x7ff);
msg->flowType = (zl5011xFlowTypeE)((buffer[0] >> 27) & 0x1f);
/* decode the second 32 bit word of the message */
msg->headGranule = (buffer[1] >> 0) & 0x3ffff;
msg->headerOffset = (Uint8T)((buffer[1] >> 18) & 0x7f);
msg->sourceBlock = (Uint8T)((buffer[1] >> 27) & 0x1f);
/* decode the third 32 bit word of the message */
msg->tailGranule = (buffer[2] >> 0) & 0x3ffff;
msg->granuleNum = (Uint8T)((buffer[2] >> 18) & 0x1f);
msg->miscField1 = (Uint16T)((buffer[2] >> 23) & 0x1ff);
/* the fourth 32 bit word takes on different meaning, depending on the
source block of the message, so just return to the calling function
unchanged. */
msg->miscField2 = buffer[3];
/* any fields not populated are set to invalid */
msg->timestamp = (Uint16T)ZL5011X_INVALID;
return(status);
}
/*******************************************************************************
Function:
zl5011xTmDecodeTracePartial
Description:
Populates the trace message structure using the two 32 bit words
passed in.
Inputs:
zl5011xParams Pointer to the structure for this device instance
buffer raw data from the trace buffer
Outputs:
msg structure populated with the trace message. Unused fields are
set to all 1's
Returns:
zlStatusE
Remarks:
Using magic numbers for the bit positions in the TM buffer, since the bit
positions are unique to this function.
*******************************************************************************/
zlStatusE zl5011xTmDecodeTracePartial(zl5011xParamsS *zl5011xParams,
Uint32T *buffer, zl5011xTmTraceMessageS *msg)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmDecodeTracePartial:", 0, 0, 0, 0, 0, 0);
/* decode the first 32 bit word of the message */
msg->timestamp = (Uint16T)((buffer[0] >> 0) & 0xfff);
msg->pktLen = (Uint16T)((buffer[0] >> 16) & 0x7ff);
msg->flowType = (zl5011xFlowTypeE)((buffer[0] >> 27) & 0x1f);
/* decode the second 32 bit word of the message */
msg->headGranule = (buffer[1] >> 0) & 0x3ffff;
msg->headerOffset = (Uint8T)((buffer[1] >> 18) & 0x7f);
msg->sourceBlock = (Uint8T)((buffer[1] >> 27) & 0x1f);
/* any fields not populated are set to invalid */
msg->mpid = (Uint16T)ZL5011X_INVALID;
msg->tailGranule = (Uint32T)ZL5011X_INVALID;
msg->granuleNum = (Uint8T)ZL5011X_INVALID;
msg->miscField1 = (Uint16T)ZL5011X_INVALID;
msg->miscField2 = (Uint32T)ZL5011X_INVALID;
return(status);
}
/*******************************************************************************
Function:
zl5011xTmDecodeTraceTime
Description:
Populates the trace message structure using the 32 bit word passed in.
Inputs:
zl5011xParams Pointer to the structure for this device instance
buffer raw data from the trace buffer
Outputs:
msg structure populated with the trace message. Unused fields are
set to all 1's
Returns:
zlStatusE
Remarks:
Using magic numbers for the bit positions in the TM buffer, since the bit
positions are unique to this function.
*******************************************************************************/
zlStatusE zl5011xTmDecodeTraceTime(zl5011xParamsS *zl5011xParams,
Uint32T *buffer, zl5011xTmTraceMessageS *msg)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_TM_FN_ID, "zl5011xTmDecodeTraceTime:", 0, 0, 0, 0, 0, 0);
/* decode the first 32 bit word of the message */
msg->headGranule = (buffer[0] >> 0) & 0x3ffff;
msg->timestamp = (Uint16T)((buffer[0] >> 18) & 0x1ff);
msg->flowType = (zl5011xFlowTypeE)((buffer[0] >> 27) & 0x1f);
/* any fields not populated are set to invalid */
msg->headerOffset = (Uint8T)ZL5011X_INVALID;
msg->sourceBlock = (Uint8T)ZL5011X_INVALID;
msg->mpid = (Uint16T)ZL5011X_INVALID;
msg->pktLen = (Uint16T)ZL5011X_INVALID;
msg->tailGranule = (Uint32T)ZL5011X_INVALID;
msg->granuleNum = (Uint8T)ZL5011X_INVALID;
msg->miscField1 = (Uint16T)ZL5011X_INVALID;
msg->miscField2 = (Uint32T)ZL5011X_INVALID;
return(status);
}
/*******************************************************************************
Function:
zl5011xTmDecodeTraceSource
Description:
Populates the trace message structure using the 32 bit word passed in.
Inputs:
zl5011xParams Pointer to the structure for this device instance
buffer raw data from the trace buffer
Outputs:
msg structure populated with the trace message. Unused fields are
set to all 1's
Returns:
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -