I tried to pass message by a message buffer from DSP to ARM. I use dsplink sample message for test.
I added the following code to allocate a message buffer and translate GPP memory address to DSP one,
typedef struct _MSG_buf {
MSGQ_MsgHeader header;
Char8 *Msg_buf;
} MSG_buf;
/*
* allocate the GPP's message buffer
*/
status = POOL_alloc (POOL_makePoolId(processorId, SAMPLE_POOL_ID), (Void **) &MessageBuf, BUFSIZE) ;
if (DSP_FAILED (status)) {
MESSAGE_1Print ("POOL_alloc () failed. Status = [0x%x]\n",
status) ;
}
MESSAGE_1Print ("POOL_translateAddr () GPP address 0x%x\n", MessageBuf) ;
status = POOL_translateAddr ( POOL_makePoolId(processorId, SAMPLE_POOL_ID),
&DspMessageBuf, AddrType_Dsp, (Void *) MessageBuf, AddrType_Usr);
if (DSP_FAILED (status)) {
MESSAGE_1Print ("POOL_translateAddr () failed. Status = [0x%x]\n",
status) ;
POOL_free (POOL_makePoolId(processorId, SAMPLE_POOL_ID), (Void *) MessageBuf, BUFSIZE);
} else
MESSAGE_1Print ("POOL_translateAddr () successful DSP address 0x%x\n",
DspMessageBuf) ;
Then I write a message to MessageBuf and call
msg->Msg_buf = DspMessageBuf;
POOL_writeback(POOL_makePoolId(processorId, SAMPLE_POOL_ID), MessageBuf, BUFSIZE);
status = MSGQ_put (SampleDspMsgq, (MSGQ_Msg) msg) ;
On the DSP side, I modified the message buffer as follows,
status = MSGQ_get (info->localMsgq, (MSGQ_Msg *) &msg, SYS_FOREVER) ;
MSGQ_setMsgId ((MSGQ_Msg) msg, info->sequenceNumber) ;
MSGQ_setSrcQueue ((MSGQ_Msg) msg, info->localMsgq) ;
memcpy(msg->Msg_buf, "hello", 6);
/* Send the message back */
status = MSGQ_put (info->locatedMsgq, (MSGQ_Msg) msg) ;
When I receive message on ARM side, the message is not changed. I don't know what are missing.
I also tried to allocate message buffer on DSP side and send message to ARM, but the buffer has nothing.
Thanks,
Kai