Ejemplo n.º 1
0
/*
 *  ======== main ========
 */
Int main(Int argc, Char* argv[])
{
    UInt32 myArg1 = 12345;
    UInt32 myArg2 = 67890;
    UInt16 myProcId = MultiProc_self();
    Int status;
    
    /* Register the functions to be called */
    System_printf("Registering myFxn1 & myArg1 to event #%d..\n", EVENT);
    Notify_registerEvent(myProcId, 0, EVENT,
                         (Notify_FnNotifyCbck)myFxn1, (UArg)&myArg1);

    System_printf("Registering myFxn2 & myArg2 to event #%d..\n", EVENT);
    Notify_registerEvent(myProcId, 0, EVENT,
                         (Notify_FnNotifyCbck)myFxn2, (UArg)&myArg2);

    /* Send an event */
    System_printf("Sending event #%d (myFxn1 and myFxn2 should run)\n", EVENT);
    Notify_sendEvent(myProcId, 0, EVENT, 0xaaaaa, TRUE);

    /* Unregister one of the functions */
    System_printf("Unregistering myFxn1 + myArg1\n");
    status = Notify_unregisterEvent(myProcId, 0, EVENT,
                                    (Notify_FnNotifyCbck)myFxn1, 
                                    (UArg)&myArg1);
    if (status < 0) {
        System_abort("Listener not found! (THIS IS UNEXPECTED)\n");
    }

    /* Send an event */
    System_printf("Sending event #%d (myFxn2 should run)\n", EVENT);
    Notify_sendEvent(myProcId, 0, EVENT, 0xbbbbb, TRUE);

    /* Disable event */
    System_printf("Disabling event #%d:\n", EVENT);
    Notify_disableEvent(myProcId, 0, EVENT);

    /* Send an event (nothing should happen) */
    System_printf("Sending event #%d (nothing should happen)\n", EVENT);
    Notify_sendEvent(myProcId, 0, EVENT, 0xbbbbb, TRUE);

    /* Enable event */
    System_printf("Enabling event #%d:\n", EVENT);
    Notify_enableEvent(myProcId, 0, EVENT);

    /* Send an event */
    System_printf("Sending event #%d (myFxn2 should run)\n", EVENT);
    Notify_sendEvent(myProcId, 0, EVENT, 0xbbbbb, TRUE);
    
    System_printf("Test completed\n");
    return (0);
}
Ejemplo n.º 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_attachHook(UArg userCtx, UInt16 remoteProcId)
{
    Int                 status;
    List_Elem *         elem = NULL;
    SystemCfg_Object *  obj = NULL;
    IArg                key;

    /* find object on module list */
    key = GateH_enter(Mod_gate);

    while ((elem = List_next(Mod_objList, elem)) != NULL) {
        obj = (SystemCfg_Object *)elem;
        if (obj->remoteProcId == remoteProcId) {
            break;
        }
        obj = NULL;
    }

    GateH_leave(Mod_gate, key);

    if (obj != NULL) {
        status = Notify_registerEvent(remoteProcId, SystemCfg_NotifyLineId,
            SystemCfg_HostDspEvtNum, SystemCfg_notifyCB, (UArg)obj);

        if (status < 0) {
            Log_error1(FXNN": Notify_registerEvent() error %d", (IArg)status);
        }
    }

    return(status);
}
Ejemplo n.º 4
0
/*
 *  ======== main ========
 *  Synchronizes all processors (in Ipc_start), calls BIOS_start, and registers 
 *  for an incoming event
 */
Int main(Int argc, Char* argv[])
{
    Int status;
    UInt numProcs = MultiProc_getNumProcessors();

    /*
     *  Determine which processors Notify will communicate with based on the
     *  local MultiProc id.  Also, create a processor-specific Task.
     */
    srcProc = ((MultiProc_self() - 1 + numProcs) % numProcs);
    dstProc = ((MultiProc_self() + 1) % numProcs);

    System_printf("main: MultiProc id = %d\n", MultiProc_self());
    System_printf("main: MultiProc name = %s\n", 
        MultiProc_getName(MultiProc_self()));
    
    /*
     *  Register call back with Notify. It will be called when the processor
     *  with id = srcProc sends event number EVENTID to this processor.
     */
    status = Notify_registerEvent(srcProc, INTERRUPT_LINE, EVENTID,
                                  (Notify_FnNotifyCbck)cbFxn, NULL);
    if (status < 0) {
        System_abort("Notify_registerEvent failed\n");
    }

    BIOS_start();
    
    return (0);
}
Ejemplo n.º 5
0
/*
 *  ======== SemaphoreMP_registerEvent ========
 */
Int SemaphoreMP_registerEvent(UArg arg, UInt16 remoteProcId) 
{
    Int status;
    
    status = Notify_registerEvent(remoteProcId, 0, SemaphoreMP_notifyEventId, 
            SemaphoreMP_cbFxn, NULL);
            
    Assert_isTrue(status >= 0, ti_sdo_ipc_Ipc_A_internal);
    
    return (0);
}
Ejemplo n.º 6
0
/*
 *  ======== main ========
 */
Int main(Int argc, Char* argv[])
{
    Int status;

    armProcId = MultiProc_getId("HOST");

    System_printf("main: MultiProc id = %d\n", MultiProc_self());

    /*  
     *  Ipc_start() calls Ipc_attach() to synchronize all remote processors
     *  because 'Ipc.procSync' is set to 'Ipc.ProcSync_ALL' in *.cfg
     */
    status = Ipc_start();
    if (status < 0) {
        System_abort("Ipc_start failed\n");
    }

    /*
     *  Register cbFxn with Notify. It will be called when Arm
     *  sends event number EVENTID to instance.
     *  Passing in 0xFEED as the arg just for validation.
     */
    status = Notify_registerEvent(armProcId, LINE_0, EVENTID,
                              (Notify_FnNotifyCbck)cbFxnLine0, 0xFEED);
    if (status < 0) {
        System_abort("Notify_registerEvent failed\n");
    }

    status = Notify_registerEvent(armProcId, LINE_1, EVENTID,
                              (Notify_FnNotifyCbck)cbFxnLine1, 0xBEEF);
    if (status < 0) {
        System_abort("Notify_registerEvent failed\n");
    }

    BIOS_start();
    return (0);
}
Ejemplo n.º 7
0
Int32 System_ipcNotifyInit()
{
    UInt32 procId, i;
    Int32 status;

    memset(gSystem_ipcObj.notifyCb, 0, sizeof(gSystem_ipcObj.notifyCb));

    i = 0;
    while (gSystem_ipcEnableProcId[i] != SYSTEM_PROC_MAX)
    {
        procId = gSystem_ipcEnableProcId[i];
        if ((procId != System_getSelfProcId()) && (procId != SYSTEM_PROC_INVALID))
        {
            Vps_printf
                (" %d: SYSTEM: Notify register to [%s] line %d, event %d ... \n",
                 Utils_getCurTimeInMsec(), MultiProc_getName(procId),
                 SYSTEM_IPC_NOTIFY_LINE_ID, SYSTEM_IPC_NOTIFY_EVENT_ID);

            if (Notify_intLineRegistered(procId, SYSTEM_IPC_NOTIFY_LINE_ID) ==
                FALSE)
            {
                UTILS_assert(0);
            }
            if (Notify_eventAvailable
                (procId, SYSTEM_IPC_NOTIFY_LINE_ID,
                 SYSTEM_IPC_NOTIFY_EVENT_ID) == FALSE)
            {
                UTILS_assert(0);
            }

            status = Notify_registerEvent(procId,
                                          SYSTEM_IPC_NOTIFY_LINE_ID,
                                          SYSTEM_IPC_NOTIFY_EVENT_ID,
                                          System_ipcNotifyHandler, NULL);

            UTILS_assert(status == Notify_S_SUCCESS);
        }
        i++;
    }

    return status;
}
Int SystemCfg_createLocalResources(Void)
{
    Error_Block eb;
    SemThread_Params semThreadP;
    HeapBufMP_Params heapBufMPP;
    Int count;
    Char heapName[32];
    Int status = 0;
    struct SystemCfg *stateObj = &SystemCfg_State;
    static Int heapId = 1;


    Log_print1(Diags_ENTRY, "--> %s: ()", (IArg)FXNN);

    Error_init(&eb);

    /* create sync object used to wait on remote core startup */
    SemThread_Params_init(&semThreadP);
    semThreadP.mode = SemThread_Mode_COUNTING;
    SemThread_construct(&stateObj->semObj, 0, &semThreadP, &eb);

    if (Error_check(&eb)) {
        /* Log_error() */
        Log_print3(Diags_USER8,
            "Error: %s, line %d: %s: SemThread_construct() failed",
            (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN);
        status = -1;
        goto leave;
    }
    stateObj->semH = SemThread_handle(&stateObj->semObj);

    /* register notify callback for ready event from remote core */
    status = Notify_registerEvent(stateObj->hostProcId, Global_NotifyLineId,
        Global_HostDspEvtNum, SystemCfg_notifyCB__P, (UArg)stateObj);

    if (status < 0) {
        /* Log_error() */
        Log_print4(Diags_USER8,
            "Error: %s, line %d: %s: "
            "Notify_registerEventSingle() returned error %d",
            (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN, (IArg)status);
        goto leave;
    }

    /* create a heap for tiler usage */
    Log_print0(Diags_USER2, FXNN": HeapBufMP_create for tiler");

    HeapBufMP_Params_init(&heapBufMPP);
    heapBufMPP.regionId = 0;
    heapBufMPP.blockSize = 0x200;  /* 512 B */
    heapBufMPP.numBlocks = 8;

    /* hack: make a unique heap name */
    System_sprintf(heapName, "rcmHeap-%d", heapId);
    heapBufMPP.name = heapName;

    stateObj->heapH = HeapBufMP_create(&heapBufMPP);

    if (stateObj->heapH == NULL) {
        /* Log_error() */
        Log_print3(Diags_USER8,
            "Error: %s, line %d: %s: HeapBuf_create() failed",
            (IArg)FXNN, (IArg)__FILE__, (IArg)__LINE__);
        status = -1;
        goto leave;
    }

    /* register this heap with MessageQ */
    Log_print2(Diags_USER2,
        FXNN": MessageQ_registerHeap: (heapH: 0x%x, heapId: %d)",
        (IArg)(stateObj->heapH), (IArg)Global_TilerHeapId);

    MessageQ_registerHeap((Ptr)(stateObj->heapH), Global_TilerHeapId);


    /*  Send create done event to remote core. Need to loop in case
     *  the remote core has not yet registered with notify to receive
     *  this event.
     */
    Log_print0(Diags_USER1, FXNN": send EvtCreateDone to remote core");

    count = 0;
    do {
        status = Notify_sendEvent(stateObj->hostProcId, Global_NotifyLineId,
            Global_HostDspEvtNum, Global_EvtCreateDone, TRUE);

        if (status == Notify_E_EVTNOTREGISTERED) {
            Thread_sleep(500, &eb); /* 0.5 ms */
        }
    } while ((++count < 10) && (status == Notify_E_EVTNOTREGISTERED));

    if (status < 0) {
        /* Log_error() */
        Log_print5(Diags_USER8,
            "Error: %s, line %d: %s: Notify_sendEvent() returned error %d,"
            "giving up after %d tries", (IArg)__FILE__, (IArg)__LINE__,
            (IArg)FXNN, (IArg)status, (IArg)count);
        goto leave;
    }

    /* wait for create done event from remote core */
    Log_print0(Diags_USER1, FXNN": waiting for EvtCreateDone event...");

    SemThread_pend(stateObj->semH, SemThread_FOREVER, &eb);

    if (Error_check(&eb)) {
        /* Log_error() */
        Log_print3(Diags_USER8,
            "Error: %s, line %d: %s:  SemThread_pend() returned with error",
            (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN);
        status = -1;
        goto leave;
    }
    Log_print0(Diags_USER1, FXNN": ...received EvtCreatDone event");


leave:
    Log_print2(Diags_EXIT, "<-- %s: %d", (IArg)FXNN, (IArg)status);
    return(status);
}