?? zl5011xcpu.c
字號:
if (status == ZL5011X_OK)
{
/* update structure */
zl5011xParams->cpuDmaIf.msgPadding= padding;
}
}
return status;
}
/*******************************************************************************
Function:
zl5011xCpuDmaGetTxStatus
Description:
This function returns the status of device with respect to the CPU
transmiting packets
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
pTxMode ZL5011X_DMA_ENABLED (=busy) or
ZL5011X_DMA_DISABLED (=idle)
pDebugDmaTxBusy An internal state indicator flag (for system debug only)
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
extern zlStatusE zl5011xCpuDmaGetTxStatus(zl5011xParamsS *zl5011xParams,
zl5011xDmaControlModeE *pTxControlMode,
zl5011xBooleanE *pDmaTxBusy)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits=0,bitMask=0; /* Read and set constat register only */
ZL5011X_TRACE(ZL5011X_CPU_FN_ID,"zl5011xCpuDmaGetTxStatus: ", 0, 0, 0, 0, 0, 0);
status = zl5011xCpuDmaStoreConstatRegister(zl5011xParams,bits,bitMask,
ZL5011X_DMA_READ_ONLY);
if(status == ZL5011X_OK)
{
*pDmaTxBusy = (zl5011xBooleanE)(( zl5011xParams->cpuIf.constat >> ZL5011X_DMA_GIF_TX_BUSY_BIT) & ZL5011X_1BIT_MASK);
if(((zl5011xParams->cpuIf.constat & (ZL5011X_1BIT_MASK <<ZL5011X_DMA_TX_ENABLE_BIT))) > 0)
{
*pTxControlMode = ZL5011X_DMA_ENABLED;
}
else
{
*pTxControlMode = ZL5011X_DMA_DISABLED;
}
}
ZL5011X_TRACE(ZL5011X_CPU_FN_ID, "zl5011xCpuDmaGetTxStatus: busy %d",*pDmaTxBusy, 0, 0, 0, 0, 0);
return(status);
}
/*******************************************************************************
Function:
zl5011xCpuDmaGetIntrStatus
Description:
This function returns the Tx & Rx status bit values as they appear in the
constat reg.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
pStatus ptr to value from intr status register
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
extern zlStatusE zl5011xCpuDmaGetIntrStatus(zl5011xParamsS *zl5011xParams,
Uint32T *pStatus)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits=0,bitMask = 0,/* Read and set constat register only */
intBitMask = (ZL5011X_1BIT_MASK << ZL5011X_DMA_TX_INTERRUPT_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_DMA_RX_INTERRUPT_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_DMA_STOP_ERROR_FLAG_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_DMA_START_ERROR_FLAG_BIT);
ZL5011X_TRACE(ZL5011X_CPU_FN_ID,"zl5011xCpuDmaGetIntrStatus: ", 0, 0, 0, 0, 0, 0);
status = zl5011xCpuDmaStoreConstatRegister(zl5011xParams,bits,bitMask,
ZL5011X_DMA_READ_ONLY);
if(status == ZL5011X_OK)
{
*pStatus = zl5011xParams->cpuIf.constat & intBitMask;
zl5011xParams->cpuIf.constat = zl5011xParams->cpuIf.constat & (~intBitMask);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xCpuDmaErrorFlagsEnable
Description:
This function will enable the interrupts that get generated when packets
destined for the CPU do not have consistant granules. The packet should
start with a granule which has the start bit set, and end with a granule
with has the stop bit set.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
extern zlStatusE zl5011xCpuDmaErrorFlagsEnable(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits = 0, /* Don't mask the interrupts */
bitMask= (ZL5011X_1BIT_MASK << ZL5011X_DMA_START_ERROR_MASK_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_DMA_STOP_ERROR_MASK_BIT);
ZL5011X_TRACE(ZL5011X_CPU_FN_ID,"zl5011xCpuDmaErrorFlagsEnable: ", 0, 0, 0, 0, 0, 0);
status = zl5011xCpuDmaStoreConstatRegister(zl5011xParams,bits,bitMask,
ZL5011X_DMA_READ_WRITE);
return(status);
}
/*******************************************************************************
Function:
zl5011xCpuDmaErrorFlagsDisable
Description:
This function will disable the interrupts that get generated when packets
destined for the CPU do not have consistant granules. The packet should
start with a granule which has the start bit set, and end with a granule
with has the stop bit set.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
extern zlStatusE zl5011xCpuDmaErrorFlagsDisable(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
Uint32T bits = (ZL5011X_1BIT_MASK << ZL5011X_DMA_START_ERROR_MASK_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_DMA_STOP_ERROR_MASK_BIT),
/* Mask all interrupts */
bitMask= (ZL5011X_1BIT_MASK << ZL5011X_DMA_START_ERROR_MASK_BIT) |
(ZL5011X_1BIT_MASK << ZL5011X_DMA_STOP_ERROR_MASK_BIT);
ZL5011X_TRACE(ZL5011X_CPU_FN_ID,"zl5011xCpuDmaErrorFlagsDisable: ", 0, 0, 0, 0, 0, 0);
status = zl5011xCpuDmaStoreConstatRegister(zl5011xParams,bits,bitMask,
ZL5011X_DMA_READ_WRITE);
return(status);
}
/*******************************************************************************
Function:
zl5011xCpuDmaResoureRegWrite
Description:
This function will write the specified number into the CPU resource
register.
Inputs:
zl5011xParams Pointer to the structure for this device instance
resourceNumber Number to write
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
extern zlStatusE zl5011xCpuDmaResoureRegWrite(zl5011xParamsS *zl5011xParams,
Uint32T resourceNumber)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_CPU_FN_ID,"zl5011xCpuDmaesoureRegWrite: ", 0, 0, 0, 0, 0, 0);
resourceNumber = resourceNumber & ZL5011X_CPU_RESOURCE_NUM_MASK;
status = zl5011xWrite(zl5011xParams,ZL5011X_CPU_RESOURCE,resourceNumber);
return(status);
}
/*******************************************************************************
Function:
zl5011xCpuDmaResoureRegRead
Description:
This function will read the number stored in the CPU resource register.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
resourceNumber Number to read
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
extern zlStatusE zl5011xCpuDmaResoureRegRead(zl5011xParamsS *zl5011xParams,
Uint32T *resourceNumber)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_CPU_FN_ID,"zl5011xCpuDmaesoureRegRead: ", 0, 0, 0, 0, 0, 0);
status = zl5011xRead(zl5011xParams,ZL5011X_CPU_RESOURCE,resourceNumber);
*resourceNumber = *resourceNumber & ZL5011X_CPU_RESOURCE_NUM_MASK;
return(status);
}
/*******************************************************************************
Function:
zl5011xCpuDmaPTHWrite
Description:
This function will write the PTH from the parameters supplied
Inputs:
pathType Desired destination
Any of: ZL5011X_FLOW_CPU_WAN,
ZL5011X_FLOW_CPU_PKT,
packetLength Packet length in bytes
context Multipurpose ID
blockId Source block number
intDone Generate an interrupt when the packet is sent
lastPacket Stop generating Dreq requests after sending the current
packet
transaction64Bit Set to ZL5011X_FALSE for DMA transfers performed 32 bit wide
set to ZL5011X_FALSE for 64 bit transfers
Outputs:
pth Pointer to an array of words to store the PTH constructed
Returns:
None
Remarks:
*******************************************************************************/
extern void zl5011xCpuDmaPTHWrite(Uint32T pathType,
Uint16T packetLength,
Uint16T context,
Uint16T blockId,
Uint16T intDone,
Uint16T lastPacket,
Uint16T sequenceNumber,
Uint16T tstampChksum,
zl5011xBooleanE transaction64Bit,
Uint32T *pth)
{
zlStatusE status = ZL5011X_OK;
Uint32T n,regValue[ZL5011X_PTH_WORDSIZE];
for(n=0;n<ZL5011X_PTH_WORDSIZE;n++)
{
pth[n] = 0;
}
ZL5011X_TRACE(ZL5011X_CPU_FN_ID,"zl5011xCpuDmaPTHWrite: ", 0, 0, 0, 0, 0, 0);
if (status == ZL5011X_OK)
{
/* Write PTH word 0 */
regValue[0] =
((pathType & ZL5011X_PATHTYPE_MASK) << ZL5011X_PATHTYPE_SHIFT) |
((packetLength & ZL5011X_PKT_LEN_MASK) << ZL5011X_PKT_LEN_SHIFT) |
((context & ZL5011X_MP_ID_MASK) << ZL5011X_MP_ID_SHIFT);
regValue[0] = ZL5011X_DMA_HEADER_BYTE_ORDER(regValue[0]);
/* Write PTH word 1 */
regValue[1] =
((blockId & ZL5011X_BLOCK_MASK) << ZL5011X_BLOCK_SHIFT)
| ((ZL5011X_H_OFF & ZL5011X_H_OFF_MASK) << ZL5011X_H_OFF_SHIFT);
regValue[1] = ZL5011X_DMA_HEADER_BYTE_ORDER(regValue[1]);
/* Write PTH word 2 */
regValue[2] =
((intDone & ZL5011X_INT_DONE_MASK) << ZL5011X_INT_DONE_SHIFT)
| ((lastPacket & ZL5011X_LAST_PKT_MASK) << ZL5011X_LAST_PKT_SHIFT);
regValue[2] = ZL5011X_DMA_HEADER_BYTE_ORDER(regValue[2]);
/* Write PTH word 3 */
regValue[3] =
((sequenceNumber & ZL5011X_SEQ_NO_MASK) << ZL5011X_SEQ_NO_SHIFT) |
((tstampChksum & ZL5011X_TSTAMPCHKSUM_MASK)
<< ZL5011X_TSTAMPCHKSUM_SHIFT);
regValue[3] = ZL5011X_DMA_HEADER_BYTE_ORDER(regValue[3]);
if (transaction64Bit == ZL5011X_TRUE)
{
pth[0] = regValue[1];
pth[1] = regValue[0];
pth[2] = regValue[3];
pth[3] = regValue[2];
}
else
{
pth[0] = regValue[0];
pth[1] = regValue[1];
pth[2] = regValue[2];
pth[3] = regValue[3];
}
}
}
/*******************************************************************************
Function:
zl5011xCpuDmaPRHRead
Description:
This function will read one or more words from the PRH and load them into
the parameters specified on the call line. Thus the PRH can be read in one
or several calls to this function.
Inputs:
prhWordToExtract PRH Word to extract (0 to 3)
prh Pointer to the word(s) containing the PRH to extract
Outputs:
rxResource The resource number specified at packet transmit
packetLength Packet length in bytes, excluding PRH and padding
queueNumber Receive queue number.
Any of: ZL5011X_QUEUE_0,
ZL5011X_QUEUE_1,
ZL5011X_QUEUE_2,
ZL5011X_QUEUE_3
nextPacketOffset Offset in words to the start of the next packet
sequenceNumber Sequence number for the packet. (This is not the same as
the sequence number that may have been supplied at packet
transmit).
parity PRH parity
Returns:
None
Remarks:
Parameters not read from the specified PRH word will remain unchanged.
This function will assume the first word of the array always has to be read.
i.e if prhWordToExtract is set to 2, it will read prh[0] to extract word 2.
*******************************************************************************/
extern void zl5011xCpuDmaPRHRead(Uint32T prhWordToExtract,
Uint32T *prh,
Uint16T *rxResource,
Uint16T *packetLength,
zl5011xQueueE *queueNumber,
Uint16T *nextPacketOffset,
Uint16T *sequenceNumber,
Uint16T *parity)
{
zlStatusE status = ZL5011X_OK;
Uint32T regValue = ZL5011X_DMA_HEADER_BYTE_ORDER(*prh);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -