コード例 #1
0
/*
 *  ======== TIEvent_wait ========
 */
cl_int TIEvent_wait(cl_event event)
{
    RcmClient_Handle    rcmH = (RcmClient_Handle)(event->rcmClientH);
    UInt16              msgId = (UInt16)(0xFF & (UInt)(event->msgId));
    RcmClient_Message * msg;
    Int                 status;


    /* check if event has already completed */
    if (event->status == CL_COMPLETE) {
        return(CL_SUCCESS);
    }

    /* check if event terminated with error */
    /* TODO */

    /* event still pending, wait for command to complete */
    status = RcmClient_waitUntilDone(rcmH, msgId, &msg);

    if (status < 0) {
        /* TODO */
    }

    /* extract any return value from message? */
    /* TODO */

    /* free the rcm message */
    RcmClient_free(rcmH, msg);

    event->status = CL_COMPLETE;

    return(CL_COMPLETE);
}
コード例 #2
0
static Int dvsdk_grapx_display_exec_rpc   (Int instID, UInt32 rcmFxnIdx)
{
  Int status = 0;
  RcmClient_Message * rcmMsg;  
  IArg key;
  
 
  key = GateH_enter (g_RemoteStubContext.hGate);
  if (0 == status) {
    status = RcmClient_alloc(g_RemoteStubContext.hRcmClient,
              sizeof(UInt32), 
              &rcmMsg);
  }
  if (0 == status) {
   UInt32 *instIDPtr = &(rcmMsg->data[0]);
   *instIDPtr = instID;
   // fill in the remote command message
 rcmMsg->fxnIdx = rcmFxnIdx;
    //rcmMsg->msgId  = msgId; /* MsgId no longer part of RcmClient_Message */
 rcmMsg->result = 0;

 // execute the remote command message
 status = RcmClient_exec(g_RemoteStubContext.hRcmClient, rcmMsg, &rcmMsg);
  }
  if (status >= 0) {
    if (rcmMsg->result < 0) {
   status = -1;
 }
 RcmClient_free (g_RemoteStubContext.hRcmClient,rcmMsg);
  }
  GateH_leave (g_RemoteStubContext.hGate,key);
  return status;
}
コード例 #3
0
/*
 *  ======== TestExec ========
 */
Int TestExec (Void)
{
    Int                  status             = 0;
    Int                  loop;
    RcmClient_Message  * rcmMsg             = NULL;
    RcmClient_Message  * returnMsg          = NULL;
    UInt                 rcmMsgSize;
    RCM_Remote_FxnArgs * fxnDoubleArgs;

    Osal_printf ("\nTestExec: Testing exec API\n");

    for (loop = 1; loop <= LOOP_COUNT; loop++) {
        /* Allocate a remote command message */
        rcmMsgSize = sizeof(RCM_Remote_FxnArgs);

        Osal_printf ("TestExec: calling RcmClient_alloc \n");
        rcmMsg = NULL;
        status = RcmClient_alloc (rcmClientHandle, rcmMsgSize, &rcmMsg);
        if (status < 0) {
            Osal_printf ("TestExec: Error allocating RCM message\n");
            goto exit;
        }

        /* Fill in the remote command message */
        rcmMsg->fxnIdx = fxnDoubleIdx;
        fxnDoubleArgs = (RCM_Remote_FxnArgs *)(&rcmMsg->data);
        fxnDoubleArgs->a = loop;

        /* Execute the remote command message */
        Osal_printf ("TestExec: calling RcmClient_exec \n");
        status = RcmClient_exec (rcmClientHandle, rcmMsg, &returnMsg);
        if (status < 0) {
            Osal_printf ("TestExec: RcmClient_exec error, status = "
                         "[0x%x].\n", status);
            goto exit;
        }

        fxnDoubleArgs = (RCM_Remote_FxnArgs *)(&(returnMsg->data));
        Osal_printf ("TestExec: called fxnDouble(%d)), result = %d\n",
            fxnDoubleArgs->a, returnMsg->result);

        /* Return message to the heap */
        Osal_printf ("TestExec: calling RcmClient_free \n");
        RcmClient_free (rcmClientHandle, returnMsg);
        returnMsg = NULL;
    }

exit:
    Osal_printf ("TestExec: Leaving TestExec()\n");
    return status;
}
コード例 #4
0
/*
 *  ======== RcmClientCleanup ========
 */
Int RcmClientCleanup (Int testCase)
{
    Int                  status             = 0;
    RcmClient_Message  * rcmMsg             = NULL;
    RcmClient_Message  * returnMsg          = NULL;
    UInt                 rcmMsgSize;
    RCM_Remote_FxnArgs * fxnExitArgs;
#if !defined(SYSLINK_USE_DAEMON)
    ProcMgr_StopParams   stopParams;
#endif

    Osal_printf ("\nRcmClientCleanup: Entering RcmClientCleanup()\n");

    /* Send terminate message */
    /* Allocate a remote command message */
    rcmMsgSize = sizeof(RCM_Remote_FxnArgs);
    status = RcmClient_alloc (rcmClientHandle, rcmMsgSize, &rcmMsg);
    if (status < 0) {
        Osal_printf ("RcmClientCleanup: Error allocating RCM message\n");
        goto exit;
    }

    /* Fill in the remote command message */
    rcmMsg->fxnIdx = fxnExitIdx;
    fxnExitArgs = (RCM_Remote_FxnArgs *)(&rcmMsg->data);
    fxnExitArgs->a = 0xFFFF;

#if !defined(SYSLINK_USE_DAEMON)
    /* Execute the remote command message */
    Osal_printf ("RcmClientCleanup: calling RcmClient_execDpc \n");
    status = RcmClient_execDpc (rcmClientHandle, rcmMsg, &returnMsg);
    if (status < 0) {
        Osal_printf ("RcmClientCleanup: RcmClient_execDpc error [0x%x]\n",
                        status);
        goto exit;
    }
#endif /* !defined(SYSLINK_USE_DAEMON) */

    /* Return message to the heap */
    Osal_printf ("RcmClientCleanup: Calling RcmClient_free \n");
    RcmClient_free (rcmClientHandle, returnMsg);

    /* Delete the rcm client */
    Osal_printf ("RcmClientCleanup: Delete RCM client instance \n");
    status = RcmClient_delete (&rcmClientHandle);
    if (status < 0)
        Osal_printf ("RcmClientCleanup: Error in RCM Client instance delete"
                     " [0x%x]\n", status);
    else
        Osal_printf ("RcmClientCleanup: RcmClient_delete status: [0x%x]\n",
                        status);

    /* Rcm client module destroy */
    Osal_printf ("RcmClientCleanup: Destroy RCM client module \n");
    RcmClient_exit ();

    /* Finalize modules */
#if !defined(SYSLINK_USE_DAEMON)    // Do not call ProcMgr_stop if using daemon
    status = MessageQ_unregisterHeap (RCM_MSGQ_HEAPID);
    if (status < 0)
        Osal_printf ("RcmClientCleanup: Error in MessageQ_unregisterHeap"
                     " [0x%x]\n", status);
    else
        Osal_printf ("RcmClientCleanup: MessageQ_unregisterHeap status:"
                     " [0x%x]\n", status);

    if (heapHandle) {
        status = HeapBufMP_delete (&heapHandle);
        if (status < 0)
            Osal_printf ("RcmClientCleanup: Error in HeapBufMP_delete [0x%x]\n",
                            status);
        else
            Osal_printf ("RcmClientCleanup: HeapBufMP_delete status: [0x%x]\n",
                            status);
    }

    if (heapBufPtr) {
        Memory_free (srHeap, heapBufPtr, heapSize);
    }

    stopParams.proc_id = remoteIdClient;
    if (testCase == 2) {
        status = ProcMgr_stop(procMgrHandleClient1, &stopParams);
        if (status < 0)
            Osal_printf ("RcmClientCleanup: Error in ProcMgr_stop [0x%x]\n",
                            status);
        else
            Osal_printf ("RcmClientCleanup: ProcMgr_stop status: [0x%x]\n",
                            status);
        stopParams.proc_id = MultiProc_getId (SYSM3_PROC_NAME);
    }

    status = ProcMgr_stop(procMgrHandleClient, &stopParams);
    if (status < 0)
        Osal_printf ("RcmClientCleanup: Error in ProcMgr_stop [0x%x]\n",
                        status);
    else
        Osal_printf ("RcmClientCleanup: ProcMgr_stop status: [0x%x]\n",
                        status);
#endif

    if (testCase == 2) {
        status =  ProcMgr_detach (procMgrHandleClient1);
        Osal_printf ("RcmClientCleanup: ProcMgr_detach status [0x%x]\n",
                        status);

        status = ProcMgr_close (&procMgrHandleClient1);
        if (status < 0)
            Osal_printf ("RcmClientCleanup: Error in ProcMgr_close [0x%x]\n",
                            status);
        else
            Osal_printf ("RcmClientCleanup: ProcMgr_close status: [0x%x]\n",
                            status);
    }

    status =  ProcMgr_detach (procMgrHandleClient);
    Osal_printf ("RcmClientCleanup: ProcMgr_detach status [0x%x]\n", status);

    status = ProcMgr_close (&procMgrHandleClient);
    if (status < 0)
        Osal_printf ("RcmClientCleanup: Error in ProcMgr_close [0x%x]\n",
                        status);
    else
        Osal_printf ("RcmClientCleanup: ProcMgr_close status: [0x%x]\n",
                        status);

    status = Ipc_destroy ();
    if (status < 0)
        Osal_printf("RcmClientCleanup: Error in Ipc_destroy [0x%x]\n", status);
    else
        Osal_printf("RcmClientCleanup: Ipc_destroy status: [0x%x]\n", status);

exit:
    Osal_printf ("RcmClientCleanup: Leaving RcmClientCleanup()\n");
    return status;
}
コード例 #5
0
/*
 *  ======== TestExecNoWait ========
 */
Int TestExecNoWait(void)
{
    Int                     status                  = 0;
    Int                     loop, job;
    UInt16                  msgIdAry[JOB_COUNT];
    RcmClient_Message     * rcmMsg                  = NULL;
    RcmClient_Message     * returnMsg               = NULL;
    UInt                    rcmMsgSize;
    RCM_Remote_FxnArgs    * fxnDoubleArgs;

    Osal_printf ("\nTestExecNoWait: Testing TestExecNoWait API\n");

    for (loop = 1; loop <= LOOP_COUNT; loop++) {
        /* Issue process jobs */
        for (job = 1; job <= JOB_COUNT; job++) {
            /* Allocate a remote command message */
            rcmMsgSize = sizeof(RCM_Remote_FxnArgs);
            Osal_printf ("TestExecNoWait: calling RcmClient_alloc \n");
            status = RcmClient_alloc (rcmClientHandle, rcmMsgSize, &rcmMsg);
            if (status < 0) {
                Osal_printf ("TestExecNoWait: Error allocating RCM message\n");
                goto exit;
            }
            /* Fill in the remote command message */
            rcmMsg->fxnIdx = fxnDoubleIdx;
            fxnDoubleArgs = (RCM_Remote_FxnArgs *)(&rcmMsg->data);
            fxnDoubleArgs->a = job;

            /* Execute the remote command message */
            Osal_printf ("TestExecNoWait: calling RcmClient_execNoWait \n");
            status = RcmClient_execNoWait (rcmClientHandle, rcmMsg,
                                            &msgIdAry[job-1]);
            if (status < 0) {
                Osal_printf ("TestExecNoWait: RcmClient_execNoWait error. \n");
                goto exit;
            }
        }

        /* Reclaim process jobs */
        for (job = 1; job <= JOB_COUNT; job++) {
            Osal_printf ("TestExecNoWait: calling RcmClient_waitUntilDone \n");
            status = RcmClient_waitUntilDone (rcmClientHandle, msgIdAry[job-1],
                                                &returnMsg);
            if (status < 0) {
                Osal_printf ("TestExecNoWait: RcmClient_waitUntilDone error\n");
                goto exit;
            }

            Osal_printf ("TestExecNoWait: msgId: %d, result = %d",
                            msgIdAry[job-1], returnMsg->result);

            /* Return message to the heap */
            Osal_printf ("TestExecNoWait: calling RcmClient_free \n");
            RcmClient_free (rcmClientHandle, returnMsg);
        }
    }

exit:
    Osal_printf ("TestExecNoWait: Leaving TestExecNoWait()\n");
    return status;
}
コード例 #6
0
ファイル: RcmClient.c プロジェクト: GAnthony/sysbios-rpmsg
Int RcmClient_acquireJobId(RcmClient_Object *obj, UInt16 *jobIdPtr)
{
    RcmClient_Message *msg;
    RcmClient_Packet *packet;
    MessageQ_Msg msgqMsg;
    UInt16 msgId;
    Int rval;
    UInt16 serverStatus;
    Int status = RcmClient_S_SUCCESS;


    Log_print2(Diags_ENTRY,
        "--> "FXNN": (obj=0x%x, jobIdPtr=0x%x)", (IArg)obj, (IArg)jobIdPtr);

    /* allocate a message */
    status = RcmClient_alloc(obj, sizeof(UInt16), &msg);

    if (status < 0) {
        goto leave;
    }

    /* classify this message */
    packet = RcmClient_getPacketAddr_P(msg);
    packet->desc |= RcmClient_Desc_JOB_ACQ << RcmClient_Desc_TYPE_SHIFT;
    msgId = packet->msgId;

    /* set the return address to this instance's message queue */
    msgqMsg = (MessageQ_Msg)packet;
    MessageQ_setReplyQueue(obj->msgQue, msgqMsg);

    /* send the message to the server */
    rval = MessageQ_put((MessageQ_QueueId)obj->serverMsgQ, msgqMsg);

    if (rval < 0) {
        Log_error0(FXNN": unable to the send message to the server");
        status = RcmClient_E_FAIL;
        goto leave;
    }

    /* get the return message from the server */
    status = RcmClient_getReturnMsg_P(obj, msgId, &msg);

    if (status < 0) {
        goto leave;
    }

    /* check message status for error */
    packet = RcmClient_getPacketAddr_P(msg);
    serverStatus = (RcmClient_Desc_TYPE_MASK & packet->desc) >>
            RcmClient_Desc_TYPE_SHIFT;

    switch (serverStatus) {
        case RcmServer_Status_SUCCESS:
            break;

        default:
            Log_error1(FXNN": server returned error %d", (IArg)serverStatus);
            status = RcmClient_E_SERVERERROR;
            goto leave;
    }

    /* extract return value */
    *jobIdPtr = (UInt16)(msg->data[0]);


leave:
    if (msg != NULL) {
        RcmClient_free(obj, msg);
    }
    Log_print1(Diags_EXIT, "<-- "FXNN": %d", (IArg)status);
    return(status);
}
コード例 #7
0
ファイル: RcmClient.c プロジェクト: GAnthony/sysbios-rpmsg
Int RcmClient_getSymbolIndex(RcmClient_Object *obj, String name, UInt32 *index)
{
    SizeT len;
    RcmClient_Packet *packet;
    UInt16 msgId;
    MessageQ_Msg msgqMsg;
    Int rval;
    UInt16 serverStatus;
    RcmClient_Message *rcmMsg = NULL;
    Int status = RcmClient_S_SUCCESS;


    Log_print3(Diags_ENTRY,
        "--> "FXNN": (obj=0x%x, name=0x%x, index=0x%x",
        (IArg)obj, (IArg)name, (IArg)index);

    /* allocate a message */
    len = _strlen(name) + 1;
    rval = RcmClient_alloc(obj, len, &rcmMsg);

    if (rval < 0) {
        status = rval;
        goto leave;
    }

    /* copy the function name into the message payload */
    rcmMsg->dataSize = len;  //TODO this is not proper!
    _strcpy((Char *)rcmMsg->data, name);

    /* classify this message */
    packet = RcmClient_getPacketAddr_P(rcmMsg);
    packet->desc |= RcmClient_Desc_SYM_IDX << RcmClient_Desc_TYPE_SHIFT;
    msgId = packet->msgId;

    /* set the return address to this instance's message queue */
    msgqMsg = (MessageQ_Msg)packet;
    MessageQ_setReplyQueue(obj->msgQue, msgqMsg);

    /* send the message to the server */
    rval = MessageQ_put((MessageQ_QueueId)obj->serverMsgQ, msgqMsg);

    if (rval < 0) {
        Log_error0(FXNN": unable to the send message to the server");
        status = RcmClient_E_EXECFAILED;
        goto leave;
    }

    /* get the return message from the server */
    rval = RcmClient_getReturnMsg_P(obj, msgId, &rcmMsg);

    if (rval < 0) {
        status = rval;
        goto leave;
    }

    /* check message status for error */
    packet = RcmClient_getPacketAddr_P(rcmMsg);
    serverStatus = (RcmClient_Desc_TYPE_MASK & packet->desc) >>
            RcmClient_Desc_TYPE_SHIFT;

    switch (serverStatus) {
        case RcmServer_Status_SUCCESS:
            break;

        case RcmServer_Status_SYMBOL_NOT_FOUND:
            Log_error1(FXNN": symbol not found, name=0x%x", (IArg)name);
            status = RcmClient_E_SYMBOLNOTFOUND;
            goto leave;

        default:
            Log_error1(FXNN": server returned error %d", (IArg)serverStatus);
            status = RcmClient_E_SERVERERROR;
            goto leave;
    }

    /* extract return value */
    *index = rcmMsg->data[0];


leave:
    if (rcmMsg != NULL) {
        RcmClient_free(obj, rcmMsg);
    }
    Log_print1(Diags_EXIT, "<-- "FXNN": %d", (IArg)status);
    return(status);
}
コード例 #8
0
/*
 *  ======== Hello_exec ========
 */
Int Hello_exec(Void)
{
    RcmClient_Params    rcmP;
    RcmClient_Handle    rcmH;
    RcmClient_Message * msg;
    UInt32              size;
    Int                 status;


    /* must initialize the module before using it */
    RcmClient_init();

    /* create an rcm client instance */
    RcmClient_Params_init(&rcmP);
    rcmP.heapId = Global_RcmClientHeapId;

    /* retry in case the slave is still booting */
    do {
        status = RcmClient_create(Global_RcmServerName, &rcmP, &rcmH);
    } while (status == RcmClient_E_SERVERNOTFOUND);

    if (status < 0) {
        Log_error0("Hello_exec: RcmClient create failed");
        goto leave;
    }

    /* allocate a remote command message */
    size = sizeof(RcmClient_Message) + sizeof(UInt32[32]);
    status = RcmClient_alloc(rcmH, size, &msg);

    if (status < 0) {
        msg = NULL;
        Log_error1("Hello_exec: RcmClient_alloc() returned error %d",
            (IArg)status);
        goto leave;
    }

    /* fill in the remote command message */
    msg->fxnIdx = Global_Hello_idx;
    msg->data[0] = (UInt32)0xFFFFFFFF;
    System_sprintf((Char *)(&msg->data[1]), "@@@@"); 

    /* execute the remote command message */
    status = RcmClient_exec(rcmH, msg, &msg);

    if (status < 0) {
        Log_error1("Hello_exec: RcmClient_exec() returned error %d",
            (IArg)status);
        goto leave;
    }

    /* unmarshal return value */
    System_printf("%s\n", (Char *)(&msg->data[1]));

leave:
    /* return message to the heap */
    if (msg != NULL) {
        RcmClient_free(rcmH, msg);
        msg = NULL;
    }

    /* delete the rcm client instance */
    if (rcmH != NULL) {
        RcmClient_delete(&rcmH);
    }

    /* finalize the module to support clean shutdown */
    RcmClient_exit();

    return(status);
}