📄 dk_client.c
字号:
ReplyCmd_p = dkThread->ReplyCmd_p;
replyBuf = (A_UCHAR *)(ReplyCmd_p->cmdBytes);
/* check that the size is appropriate before we access */
if( cmdLen != sizeof(pCmd->CMD_U.MEM_READ_BLOCK_CMD)+sizeof(pCmd->cmdID) )
{
uiPrintf("Error, command Len is not equal to size of MEM_READ_BLOCK_CMD\n");
return(COMMS_ERR_BAD_LENGTH);
}
#ifdef ENDIAN_SWAP
pCmd->CMD_U.MEM_READ_BLOCK_CMD.physAddr = ltob_l(pCmd->CMD_U.MEM_READ_BLOCK_CMD.physAddr);
pCmd->CMD_U.MEM_READ_BLOCK_CMD.length = ltob_l(pCmd->CMD_U.MEM_READ_BLOCK_CMD.length);
#endif
/* read the memory */
if(hwMemReadBlock(dkThread->currentDevIndex, replyBuf, pCmd->CMD_U.MEM_READ_BLOCK_CMD.physAddr,
pCmd->CMD_U.MEM_READ_BLOCK_CMD.length) == -1)
{
uiPrintf("Failed call to hwMemReadBlock()\n");
return(COMMS_ERR_READ_BLOCK_FAIL);
}
// Currently this functions reads the byte array starting from the
// phyaddr, therefore endianness free
/*
// Swap from big endian to little endian.
#ifdef ENDIAN_SWAP
{
int noWords;
int i;
A_UINT32 *wordPtr;
noWords = pCmd->CMD_U.MEM_READ_BLOCK_CMD.length/sizeof(A_UINT32);
wordPtr = (A_UINT32 *)replyBuf;
for (i=0;i<noWords;i++)
{
*(wordPtr + i) = btol_l(*(wordPtr + i));
}
}
#endif
*/
return(0);
}
/**************************************************************************
* processMemWriteBlockCmd - Process MEM_WRITE_BLOCK_CMD command
*
* RETURNS: 0 processed OK, an Error code if it is not
*/
A_UINT32 processMemWriteBlockCmd
(
struct dkThreadInfo *dkThread
)
{
PIPE_CMD *pCmd;
A_UINT32 cmdLen;
CMD_REPLY *ReplyCmd_p;
A_UCHAR *replyBuf;
pCmd = dkThread->PipeBuffer_p;
cmdLen = pCmd->cmdLen;
ReplyCmd_p = dkThread->ReplyCmd_p;
replyBuf = (A_UCHAR *)(ReplyCmd_p->cmdBytes);
#ifdef ENDIAN_SWAP
pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr = ltob_l(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr);
pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length = ltob_l(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length);
#endif
/* check the size , but need to access the structure to do it */
if( cmdLen != sizeof(pCmd->cmdID) + sizeof(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr) +
sizeof(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length) + pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length )
{
uiPrintf("Error: command Len is not equal to size of expected bytes for MEM_WRITE_BLOCK_CMD\n");
uiPrintf(" : got %d, expected %d\n", cmdLen, sizeof(pCmd->cmdID) +
sizeof(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr) +
sizeof(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length) + pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length);
return(COMMS_ERR_BAD_LENGTH);
}
// Currently this functions writes the byte array starting from the
// phyaddr, therefore endianness free
/*
// swap from little endian to big endian
#ifdef ENDIAN_SWAP
{
int noWords;
int i;
A_UINT32 *wordPtr;
noWords = pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length/sizeof(A_UINT32);
wordPtr = (A_UINT32 *)pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.bytes;
for (i=0;i<noWords;i++)
{
*(wordPtr + i) = btol_l(*(wordPtr + i));
}
}
#endif
*/
/* write the memory */
if(hwMemWriteBlock(dkThread->currentDevIndex,pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.bytes,
pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length,
&(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr)) == -1)
{
uiPrintf("Failed call to hwMemWriteBlock()\n");
return(COMMS_ERR_WRITE_BLOCK_FAIL);
}
/* copy the address into the return buffer */
*(A_UINT32 *)replyBuf = pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr;
#ifdef ENDIAN_SWAP
*((A_UINT32 *)replyBuf) = btol_l(*((A_UINT32 *)replyBuf));
#endif
return(0);
}
/**************************************************************************
* processTramReadBlockCmd - Process TRAM_READ_BLOCK_CMD command
*
* RETURNS: 0 processed OK, an Error code if it is not
*/
A_UINT32 processTramReadBlockCmd
(
struct dkThreadInfo *dkThread
)
{
PIPE_CMD *pCmd;
A_UINT32 cmdLen;
CMD_REPLY *ReplyCmd_p;
A_UCHAR *replyBuf;
pCmd = dkThread->PipeBuffer_p;
cmdLen = pCmd->cmdLen;
ReplyCmd_p = dkThread->ReplyCmd_p;
replyBuf = (A_UCHAR *)(ReplyCmd_p->cmdBytes);
/* check that the size is appropriate before we access */
if( cmdLen != sizeof(pCmd->CMD_U.MEM_READ_BLOCK_CMD)+sizeof(pCmd->cmdID) )
{
uiPrintf("Error, command Len is not equal to size of MEM_READ_BLOCK_CMD\n");
return(COMMS_ERR_BAD_LENGTH);
}
#ifdef ENDIAN_SWAP
pCmd->CMD_U.MEM_READ_BLOCK_CMD.physAddr = ltob_l(pCmd->CMD_U.MEM_READ_BLOCK_CMD.physAddr);
pCmd->CMD_U.MEM_READ_BLOCK_CMD.length = ltob_l(pCmd->CMD_U.MEM_READ_BLOCK_CMD.length);
#endif
/* read the memory */
if(hwTramReadBlock(dkThread->currentDevIndex,replyBuf, pCmd->CMD_U.MEM_READ_BLOCK_CMD.physAddr,
pCmd->CMD_U.MEM_READ_BLOCK_CMD.length) == -1)
{
uiPrintf("Failed call to hwTramReadBlock()\n");
return(COMMS_ERR_READ_BLOCK_FAIL);
}
// Swap from big endian to little endian.
#ifdef ENDIAN_SWAP
{
int noWords;
int i;
A_UINT32 *wordPtr;
noWords = pCmd->CMD_U.MEM_READ_BLOCK_CMD.length/sizeof(A_UINT32);
wordPtr = (A_UINT32 *)replyBuf;
for (i=0;i<noWords;i++)
{
*(wordPtr + i) = btol_l(*(wordPtr + i));
}
}
#endif
return(0);
}
/**************************************************************************
* processTramWriteBlockCmd - Process TRAM_WRITE_BLOCK_CMD command
*
* RETURNS: 0 processed OK, an Error code if it is not
*/
A_UINT32 processTramWriteBlockCmd
(
struct dkThreadInfo *dkThread
)
{
PIPE_CMD *pCmd;
A_UINT32 cmdLen;
CMD_REPLY *ReplyCmd_p;
A_UCHAR *replyBuf;
pCmd = dkThread->PipeBuffer_p;
cmdLen = pCmd->cmdLen;
ReplyCmd_p = dkThread->ReplyCmd_p;
replyBuf = (A_UCHAR *)(ReplyCmd_p->cmdBytes);
#ifdef ENDIAN_SWAP
pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr = ltob_l(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr);
pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length = ltob_l(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length);
#endif
/* check the size , but need to access the structure to do it */
if( cmdLen != sizeof(pCmd->cmdID) + sizeof(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr) +
sizeof(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length) + pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length )
{
uiPrintf("Error: command Len is not equal to size of expected bytes for MEM_WRITE_BLOCK_CMD\n");
uiPrintf(" : got %d, expected %d\n", cmdLen, sizeof(pCmd->cmdID) +
sizeof(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr) +
sizeof(pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length) + pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length);
return(COMMS_ERR_BAD_LENGTH);
}
// swap from little endian to big endian
#ifdef ENDIAN_SWAP
{
int noWords;
int i;
A_UINT32 *wordPtr;
noWords = pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length/sizeof(A_UINT32);
wordPtr = (A_UINT32 *)pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.bytes;
for (i=0;i<noWords;i++)
{
*(wordPtr + i) = btol_l(*(wordPtr + i));
}
}
#endif
/* write the memory */
if(hwTramWriteBlock(dkThread->currentDevIndex,pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.bytes,
pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.length,
pCmd->CMD_U.MEM_WRITE_BLOCK_CMD.physAddr) == -1)
{
uiPrintf("Failed call to hwTramWriteBlock()\n");
return(COMMS_ERR_WRITE_BLOCK_FAIL);
}
return(0);
}
/**************************************************************************
* processremapHwCmd - Process REMAP_HW_CMD command
*
* RETURNS: 0 processed OK, an Error code if it is not
*/
A_UINT32 processRemapHwCmd
(
struct dkThreadInfo *dkThread
)
{
PIPE_CMD *pCmd;
A_UINT32 cmdLen;
CMD_REPLY *ReplyCmd_p;
A_UCHAR *replyBuf;
pCmd = dkThread->PipeBuffer_p;
cmdLen = pCmd->cmdLen;
ReplyCmd_p = dkThread->ReplyCmd_p;
replyBuf = (A_UCHAR *)(ReplyCmd_p->cmdBytes);
/* check that the size is appropriate before we access */
if( cmdLen != sizeof(pCmd->CMD_U.REMAP_HW_CMD)+sizeof(pCmd->cmdID) )
{
uiPrintf("Error, command Len is not equal to size of REMAP_HW_CMD\n");
return(COMMS_ERR_BAD_LENGTH);
}
#ifdef ENDIAN_SWAP
pCmd->CMD_U.REMAP_HW_CMD.mapAddress = ltob_l(pCmd->CMD_U.REMAP_HW_CMD.mapAddress);
#endif
if(hwRemapHardware(dkThread->currentDevIndex,pCmd->CMD_U.REMAP_HW_CMD.mapAddress) == -1)
{
uiPrintf("Error: unable to remap hardware\n");
return(COMMS_ERR_REMAP_FAIL);
}
return(0);
}
/**************************************************************************
* processCreateEventCmd - Process CREATE_EVENT_CMD command
*
* RETURNS: 0 processed OK, an Error code if it is not
*/
A_UINT32 processCreateEventCmd
(
struct dkThreadInfo *dkThread
)
{
PIPE_CMD *pCmd;
A_UINT32 cmdLen;
CMD_REPLY *ReplyCmd_p;
A_UCHAR *replyBuf;
pCmd = dkThread->PipeBuffer_p;
cmdLen = pCmd->cmdLen;
ReplyCmd_p = dkThread->ReplyCmd_p;
replyBuf = (A_UCHAR *)(ReplyCmd_p->cmdBytes);
/* check that the size is appropriate before we access */
if( cmdLen != sizeof(pCmd->CMD_U.CREATE_EVENT_CMD)+sizeof(pCmd->cmdID) )
{
uiPrintf("Error, command Len is not equal to size of CREATE_EVENT_CMD\n");
return(COMMS_ERR_BAD_LENGTH);
}
#ifdef ENDIAN_SWAP
pCmd->CMD_U.CREATE_EVENT_CMD.type = ltob_l(pCmd->CMD_U.CREATE_EVENT_CMD.type);
pCmd->CMD_U.CREATE_EVENT_CMD.persistent = ltob_l(pCmd->CMD_U.CREATE_EVENT_CMD.persistent);
pCmd->CMD_U.CREATE_EVENT_CMD.param1 = ltob_l(pCmd->CMD_U.CREATE_EVENT_CMD.param1);
pCmd->CMD_U.CREATE_EVENT_CMD.param2 = ltob_l(pCmd->CMD_U.CREATE_EVENT_CMD.param2);
pCmd->CMD_U.CREATE_EVENT_CMD.param3 = ltob_l(pCmd->CMD_U.CREATE_EVENT_CMD.param3);
pCmd->CMD_U.CREATE_EVENT_CMD.eventHandle.eventID = ltob_s(pCmd->CMD_U.CREATE_EVENT_CMD.eventHandle.eventID);
pCmd->CMD_U.CREATE_EVENT_CMD.eventHandle.f2Handle = ltob_s(pCmd->CMD_U.CREATE_EVENT_CMD.eventHandle.f2Handle);
#endif
if(hwCreateEvent(dkThread->currentDevIndex,pCmd) == -1)
{
uiPrintf("Error: unable to Create event\n");
return(COMMS_ERR_EVENT_CREATE_FAIL);
}
return(0);
}
/**************************************************************************
* processGetEventCmd - Process GET_EVENT_CMD command
*
* Get the first event from the triggered Q
*
* RETURNS: 0 processed OK, an Error code if it is not
*/
A_UINT32 processGetEventCmd
(
struct dkThreadInfo *dkThread
)
{
PIPE_CMD *pCmd;
A_UINT32 cmdLen;
CMD_REPLY *ReplyCmd_p;
A_UCHAR *replyBuf;
MDK_WLAN_DEV_INFO *pdevInfo;
pCmd = dkThread->PipeBuffer_p;
cmdLen = pCmd->cmdLen;
ReplyCmd_p = dkThread->ReplyCmd_p;
replyBuf = (A_UCHAR *)(ReplyCmd_p->cmdBytes);
pdevInfo = globDrvInfo.pDevInfoArray[dkThread->currentDevIndex];
// check that the size is appropriate before we access
if( cmdLen != sizeof(pCmd->cmdID) ) {
uiPrintf("Error, command Len is not correct for GET_EVENT_CMD\n");
return(COMMS_ERR_BAD_LENGTH);
}
#ifdef JUNGO
// Check if the Q has an event. Set type to 0 if no events...
if(!(pdevInfo->pdkInfo->pSharedInfo->anyEvents)) {
((EVENT_STRUCT *)replyBuf)->type = 0;
} else {
//call into the kernel plugin to get the event, event will get
//copied straight into replyBuf
if(hwGetNextEvent(dkThread->currentDevIndex,(void *)replyBuf) == -1) {
uiPrintf("Error: Unable to get event from kernel plugin\n");
return(COMMS_ERR_NO_EVENTS);
}
}
#else
((EVENT_STRUCT *)replyBuf)->type = 0;
if (hwGetNextEvent(dkThread->currentDevIndex,(void *)replyBuf) == -1) {
uiPrintf("Error: Unable to get event from kernel plugin\n");
return(COMMS_ERR_NO_EVENTS);
}
#endif
#ifdef ENDIAN_SWAP
((EVENT_STRUCT *)replyBuf)->type = btol_l(((EVENT_STRUCT *)replyBuf)->type);
((EVENT_STRUCT *)replyBuf)->result = btol_l(((EVENT_STRUCT *)replyBuf)->result);
((EVENT_STRUCT *)replyBuf)->eventHandle.eventID = btol_s(((EVENT_STRUCT *)replyBuf)->eventHandle.eventID);
((EVENT_STRUCT *)replyBuf)->eventHandle.f2Handle = btol_s(((EVENT_STRUCT *)replyBuf)->eventHandle.f2Handle);;
#endif
return(0);
}
/**************************************************************************
* processIsrFeatureEnableCmd - Process ISR_FEATURE_ENABLE_CMD command
*
* RETURNS: 0 processed OK, an Error code if it is not
*/
A_UINT32 processIsrFeatureEnableCmd
(
struct dkThreadInfo *dkThread
)
{
PIPE_CMD *pCmd;
A_UINT32 cmdLen;
CMD_REPLY *ReplyCmd_p;
A_UCHAR *replyBuf;
pCmd = dkThread->PipeBuffer_p;
cmdLen = pCmd->cmdLen;
ReplyCmd_p = dkThread->ReplyCmd_p;
replyBuf = (A_UCHAR *)(ReplyCmd_p->cmdBytes);
/* check that the size is appropriate before we access */
if( cmdLen != sizeof(pCmd->CMD_U.ISR_FEATURE_ENABLE_CMD)+sizeof(pCmd->cmdID) )
{
uiPrintf("Error, command Len is not equal to size of ISR_FEATURE_ENABLE_CMD\n");
return(COMMS_ERR_BAD_LENGTH);
}
if(hwEnableFeature(dkThread->currentDevIndex,pCmd) == -1)
{
uiPrintf("Error: unable to Enable feature\n");
return(COMMS_ERR_EVENT_ENABLE_FEATURE_FAIL);
}
return(0);
}
/**************************************************************************
* processIsrFeatureDisableCmd - Process ISR_FEATURE_ENABLE_CMD command
*
* RETURNS: 0 processed OK, an Error code if it is not
*/
A_UINT32 processIsrFeatureDisableCmd
(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -