Ejemplo n.º 1
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;
}
Ejemplo n.º 2
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);
}