Example #1
0
/*
 *  ======== tsk1_func ========
 *  Receive and return messages until the die request comes.
 */
Void tsk1_func(UArg arg0, UArg arg1) {
    UInt16 hostProcId = MultiProc_getId("MPU");
    while (Ipc_attach(hostProcId) < 0);
    UInt16 appProcId = MultiProc_getId("AppM3");
    while (Ipc_attach(appProcId) < 0);

    comInitCoPro();
    computationThread();
    comClear();

    Ipc_detach(appProcId);
    Ipc_detach(hostProcId);
}
Example #2
0
/*
 *  ======== taskLoad ========
 */
Void task(UArg arg1, UArg arg2)
{   
    UInt count = 1;
    Int status = Ipc_S_SUCCESS;
    UInt16 remoteProcId = MultiProc_getId("HOST");
    
    do {
        status = Ipc_attach(remoteProcId);
    } while (status < 0);
    
    Notify_registerEvent(remoteProcId, 0, SHUTDOWN,
                         (Notify_FnNotifyCbck)notifyCallbackFxn, 0);

    
    while (shutdownFlag == FALSE) {        
        Semaphore_pend(sem, BIOS_WAIT_FOREVER);
        
        /* Benchmark how long it takes to flip all the bits */
        Log_write1(UIABenchmark_start, (xdc_IArg)"Reverse");
        reverseBits(buffer, sizeof(buffer));
        Log_write1(UIABenchmark_stop, (xdc_IArg)"Reverse");
        
        Log_print1(Diags_USER1, "count = %d", count++);        
    }
    
    /* Start shutdown process */
    Notify_unregisterEvent(remoteProcId, 0, SHUTDOWN,
                           (Notify_FnNotifyCbck)notifyCallbackFxn, 0);
    
    do {
        status = Ipc_detach(remoteProcId);
    } while (status < 0);

    Ipc_stop();
}
Int SystemCfg_detach(SystemCfg_Object *obj)
{
    Int status;

    Log_print1(Diags_ENTRY,
        "--> "FXNN": (remoteProcId=%d)", (IArg)obj->remoteProcId);

    /* connect to remote processor */
    do {
        status = Ipc_detach(obj->remoteProcId);

        if (status < 0) {
            Task_yield();
        }
    } while (status < 0);  // TODO: status == E_RETRY

    if (status < 0) {
        Log_error1(FXNN": Ipc_detach() failed, error=%d", (IArg)status);
        goto leave;
    }
    Log_print1(Diags_INFO, FXNN": remoteProcId=%d", (IArg)obj->remoteProcId);

leave:
    Log_print1(Diags_EXIT, "<-- "FXNN": %d", (IArg)status);
    return(status);
}
Example #4
0
/*
 *  ======== IPC_threadGeneratedReset ========
 */
Void IPC_threadGeneratedReset()
{
    Int status;
    UInt16 masterId;

    masterId = MultiProc_getId("HOST");

    do {
        status = Ipc_detach(masterId);
    } while (status < 0);

    do {
        status = Ipc_stop();
    } while (status < 0);

    do {
        status = Ipc_start();
    } while (status < 0);
}
Void smain(UArg arg0, UArg arg1)
{
    HeapBufMP_Params    heapBufMPP;
    HeapBufMP_Handle    heapH = NULL;
    UInt16              serverProcId;
    Int                 status = 0;


    /* create heap for rcm messages */
    HeapBufMP_Params_init(&heapBufMPP);
    heapBufMPP.name = Global_RcmClientHeapName;
    heapBufMPP.regionId = 0;
    heapBufMPP.blockSize = 0x80;  /* 128 B */
    heapBufMPP.numBlocks = 4;

    heapH = HeapBufMP_create(&heapBufMPP);

    if (heapH == NULL) {
        Log_error0(FXNN": HeapBuf_create() failed");
        goto leave;
    }

    /* register this heap with MessageQ */
    MessageQ_registerHeap((Ptr)heapH, Global_RcmClientHeapId);

    /* attach to the server processor */
    serverProcId = MultiProc_getId(Global_ServerProcName);

    do {
        status = Ipc_attach(serverProcId);

        if (status < 0) {
#ifdef __ARCTIC__
            Task_yield();  /* no timers on EVE simulator */
#else
            Task_sleep(10); /* 10ms (when 1 tick == 1 ms) */
#endif
        }
    } while (status < 0);

    /* delay 500ms to give server a chance to boot */
#ifdef __ARCTIC__
    Task_yield();
#else
    Task_sleep(500);
#endif

    /* invoke the application entry point */
    App_exec(NULL);


leave:
    /* detach from server processor */
    Ipc_detach(serverProcId);

    /* unregister the heap and delete it */
    if (heapH != NULL) {
        MessageQ_unregisterHeap(Global_RcmClientHeapId);
        HeapBufMP_delete(&heapH);
    }

    /* report if error */
    if (status < 0) {
        System_printf("FAIL: example encountered errors\n");
    }
    return;
}
Example #6
0
int main (int argc, char ** argv)
{
    Int status = 0;
    int opt;
    UInt numLoops = NUM_LOOPS_DFLT;
    UInt16 procId = PROC_ID_DFLT;
    UInt32 faultId = 0;

    while ((opt = getopt(argc, argv, "f:")) != -1) {
        switch (opt) {
          case 'f':
            /*
             * Argument for -f corresponds to remote-side "fault" commands.
             * Negative commands cause remote fault before remote MessageQ_put.
             * Positive commands cause remote fault after remote MessageQ_put.
             */
            faultId = atoi(optarg);
            printf("fault %d will be sent in 1st msg\n", faultId);
            break;

          default:
            fprintf(stderr, "Unknown arg '%s'\n", optarg);
            return 1;
        }
    }

    /* Parse Args: */
    switch (argc - optind + 1) {
        case 1:
           /* use defaults */
           break;
        case 2:
           numLoops   = atoi(argv[optind]);
           break;
        case 3:
           numLoops   = atoi(argv[optind]);
           procId     = atoi(argv[optind + 1]);
           break;
        default:
           printf("Usage: %s [<numLoops>] [<ProcId>]\n", argv[0]);
           printf("\tDefaults: numLoops: %d; ProcId: %d\n",
                   NUM_LOOPS_DFLT, PROC_ID_DFLT);
           exit(0);
    }

    /* configure the transport factory */
    Ipc_transportConfig(&TransportRpmsg_Factory);

    /* IPC initialization */
    status = Ipc_start();

    if (status < 0) {
        printf("Error: Ipc_start failed, error=%d\n", status);
        goto exit;
    }

    if ((procId == 0) || (procId >= (MultiProc_getBaseIdOfCluster() + MultiProc_getNumProcessors()))) {
        printf("ProcId (%d) must be nonzero and less than %d\n",
                procId, MultiProc_getBaseIdOfCluster() + MultiProc_getNumProcessors());
        Ipc_stop();
        exit(0);
    }
    printf("Using numLoops: %d; procId : %d\n", numLoops, procId);

    if (MessageQApp_execute(numLoops, procId, faultId) < 0) {
        int nAttachAttempts = 1;

        printf("MessageQApp_execute failed, attempting detach/attach...\n");
        Ipc_detach(procId);
        while (Ipc_attach(procId) != Ipc_S_SUCCESS) {
            nAttachAttempts++;
            if ((nAttachAttempts % 1000) == 0) {
                printf("Ipc_attach(%d) failed\n", procId);
            }
        }
        printf("Ipc_attach(%d) succeeded (after %d tries)\n", procId, nAttachAttempts);

        /* call without fault this time */
        MessageQApp_execute(numLoops, procId, 0);
    }

    Ipc_stop();

exit:
    return (status);
}