Пример #1
0
int main (int argc, char ** argv)
{
    Int status = 0;
    UInt numLoops = NUM_LOOPS_DFLT;
    UInt16 procId = PROC_ID_DFLT;

    /* Parse Args: */
    switch (argc) {
        case 1:
           /* use defaults */
           break;
        case 2:
           numLoops   = atoi(argv[1]);
           break;
        case 3:
           numLoops   = atoi(argv[1]);
           procId     = atoi(argv[2]);
           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_getNumProcessors())) {
        printf("ProcId (%d) must be nonzero and less than %d\n",
                procId, MultiProc_getNumProcessors());
        Ipc_stop();
        exit(0);
    }
    printf("Using numLoops: %d; procId : %d\n", numLoops, procId);

    if (status >= 0) {
        MessageQApp_execute(numLoops, procId);
        Ipc_stop();
    }
    else {
        printf("Ipc_start failed: status = %d\n", status);
    }

exit:
    return (status);
}
/*
 *  ======== main ========
 *  Synchronizes all processors (in Ipc_start) and calls BIOS_start
 */
Int main(Int argc, Char* argv[])
{
    Int status;

    nextProcId = (MultiProc_self() + 1) % MultiProc_getNumProcessors();

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

    /* Generate queue names based on own proc ID and total number of procs */
    System_sprintf(localQueueName, "%s", MultiProc_getName(MultiProc_self()));
    System_sprintf(nextQueueName, "%s",  MultiProc_getName(nextProcId));

    /*
     *  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");
    }

    BIOS_start();

    return (0);
}
Пример #3
0
/*
 *  ======== main ========
 *  Create a task.
 *  Synchronize all processors.
 *  Register an event with Notify.
 */
Int main(Int argc, Char* argv[])
{
    selfId = MultiProc_self();
    
    System_printf("main: MultiProc id = %d\n", selfId);
    System_printf("main: MultiProc name = %s\n", 
        MultiProc_getName(selfId));
    
    if (numCores == 0) {
        numCores = MultiProc_getNumProcessors();
    }
    
    /*
     *  Determine which processors Notify will communicate with based on the
     *  local MultiProc id. 
     */

    srcProc = ((selfId - 1 + numCores) % numCores);
    dstProc = ((selfId + 1) % numCores);
    
    attachAll(numCores);

    BIOS_start();

    return (0);
}
Пример #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);
}
Пример #5
0
/*
 *  ======== main ========
 */
Int main(Int argc, Char* argv[])
{  
    selfId = MultiProc_self();
    
    System_printf("Core (\"%s\") starting\n", MultiProc_getName(selfId));
    
    if (numCores == 0) {
        numCores = MultiProc_getNumProcessors();
    }
    
    attachAll(numCores);
    
    System_sprintf(localQueueName, "CORE%d", selfId);
    System_sprintf(nextQueueName, "CORE%d", 
        ((selfId + 1) % numCores));
    System_sprintf(prevQueueName, "CORE%d", 
        (selfId - 1 + numCores)
            % numCores);
            
    /* Create a message queue. */
    messageQ = MessageQ_create(localQueueName, NULL);    
    if (messageQ == NULL) {
        System_abort("MessageQ_create failed\n" );
    }
 
    BIOS_start();

    return (0);
}
Пример #6
0
int main (int argc, char * argv[])
{
    Int32 status = 0;
    UInt32 numLoops = NUM_LOOPS_DFLT;
    UInt32 payloadSize = MINPAYLOADSIZE;
    UInt16 procId = PROC_ID_DFLT;

    /* Parse args: */
    if (argc > 1) {
        numLoops = strtoul(argv[1], NULL, 0);
    }

    if (argc > 2) {
        payloadSize = MAX(strtoul(argv[2], NULL, 0), MINPAYLOADSIZE);
    }

    if (argc > 3) {
        procId  = atoi(argv[3]);
    }

    if (argc > 4) {
        printf("Usage: %s [<numLoops>] [<payloadSize>] [<ProcId>]\n", argv[0]);
        printf("\tDefaults: numLoops: %d; payloadSize: %d, ProcId: %d\n",
                   NUM_LOOPS_DFLT, MINPAYLOADSIZE, PROC_ID_DFLT);
        exit(0);
    }

    status = Ipc_start();

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

    if (status >= 0) {
        MessageQApp_execute(numLoops, payloadSize, procId);
        Ipc_stop();
    }
    else {
        printf("Ipc_start failed: status = %d\n", status);
    }

    return (status);
}
Пример #7
0
/*
 *  ======== Processor_getNumProcs ========
 */
UInt32 Processor_getNumProcs(Void)
{
#if MESSAGEQ_ENABLED
    return(MultiProc_getNumProcessors());
#else
    return (1);
#endif
}
Пример #8
0
int main (int argc, char ** argv)
{
    Int32 status = 0;
    UInt32 numLoops = NUM_LOOPS_DFLT;
    UInt16 procId = PROC_ID_DFLT;

    /* Parse Args: */
    switch (argc) {
        case 1:
           /* use defaults */
           break;
        case 2:
           numLoops   = atoi(argv[1]);
           break;
        case 3:
           numLoops   = atoi(argv[1]);
           procId     = atoi(argv[2]);
           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);
    }

    status = Ipc_start();

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

    if (status >= 0) {
        MessageQApp_execute(numLoops, procId);
        Ipc_stop();
    }
    else {
        printf("Ipc_start failed: status = %d\n", status);
    }

    return(0);
}
Пример #9
0
Void FirmwareLoad_printStatus (Void)
{
    Int             status = 0;
    ProcMgr_Handle  handle = NULL;
    UInt16          numProcs;
    UInt16          i;
    ProcMgr_State   state;
    Char            strState [32u];

    printf ("Current status of slave cores:\n");
    numProcs = MultiProc_getNumProcessors ();
    for (i = 0 ; (i < numProcs) && (i != MultiProc_self ()) ; i++) {
        {
            status = ProcMgr_open (&handle, i);
            if (status >= 0) {
                state = ProcMgr_getState (handle);
                switch (state)
                {
                    case ProcMgr_State_Unknown:
                        strncpy (strState, "Unknown", 32u);
                        break;
                    case ProcMgr_State_Powered:
                        strncpy (strState, "Powered", 32u);
                        break;
                    case ProcMgr_State_Reset:
                        strncpy (strState, "Reset", 32u);
                        break;
                    case ProcMgr_State_Loaded:
                        strncpy (strState, "Loaded", 32u);
                        break;
                    case ProcMgr_State_Running:
                        strncpy (strState, "Running", 32u);
                        break;
                    case ProcMgr_State_Unavailable:
                        strncpy (strState, "Unavailable", 32u);
                        break;
                    case ProcMgr_State_EndValue:
                        /* Not a valid value. */
                        break;
                }
                printf ("Slave core %d: %8s [%s]\n",
                             i,
                             MultiProc_getName (i),
                             strState);
                status = ProcMgr_close (&handle);
            }
        }
    }
}
Пример #10
0
/******************************************************************************
 * MAIN FUNCTION
 *****************************************************************************/
Int main(Int argc, Char* argv[]){

	srand(time(NULL));

	selfId = CSL_chipReadReg(CSL_CHIP_DNUM);

	if (numCores == 0){
		numCores = MultiProc_getNumProcessors();
	}

	/* Attach All Cores */
	attachAll(numCores);

	/* Create a MessageQ */
	System_sprintf(localQueueName, "%s", MultiProc_getName(MultiProc_self()));
	messageQ = MessageQ_create(localQueueName, NULL);
	if (messageQ == NULL){
		System_abort("MessageQ_create failed\n");
	}

	BIOS_start();

	return (0);
}
Пример #11
0
/**
 *  @brief      The BIOS main() entry point.
 *
 *  @remark     The purpose of this function is to create several BIOS worker
 *              tasks, one for each core including the one running this app,
 *              each of which will execute this simple example.
 *
 *  @remark     This is called during initialization, but before the BIOS
 *              scheduler has begun running.
 */
Void main(Int argc, String argv[])
{
    Thread_Params threadParams;
    int i;
    int numCores;

    sprintf(ti_sdo_ce_osal_bios_Global_CE_DEBUG, "1");
    ti_sdo_ce_osal_bios_Global_CE_DEBUG[0] = '2';
    ti_sdo_ce_osal_bios_Global_CE_DEBUG[1] = '\0';

    /* init Codec Engine */
    CERuntime_init();

    /* Enable all trace for xdc.runtime.Main */
    Diags_setMask("xdc.runtime.Main+EX1234567");

    Log_print0(Diags_USER2, "main> ti.sdo.ce.examples.apps.audio1_copy.sync");

    /* Determine number of cores on this device */
    numCores = MultiProc_getNumProcessors();

    /* Unfortunately, the rts library pre-built with CCS only supports 10
     * open files at a time (and 3 are reserved for stdin, stdout, stderr.
     * This app creates a thread for each core, and each thread requires 2
     * file handles.  So, if numCores is > 3, we will run out of file handles
     * _with the prebuilt rtslib.  You can modify the rtslib to support more
     * than 10 handles, and link that lib in, but that's beyond the scope of
     * this app.  We limit the number to 3 cores here.
     *
     * If you rebuild rtslib to support more open file handles, you can remove
     * the following numCores limiting assignment.
     */
    if (numCores > 3) {
        numCores = 3;
    }

    /* create a thread to communicate with each remote core */
    for (i = 0; i < numCores; i++) {
        Thread_Params_init(&threadParams);

        /* 6K stack size */
        threadParams.stackSize = 6 * 1024;

        /* priority - thread 0 gets lower pri as it uses a local alg */
        threadParams.priority = (i == 0) ? Thread_Priority_BELOW_NORMAL :
            Thread_Priority_ABOVE_NORMAL;

        /* task name */
        /* TODO, would be better if this taskName were unique for each task */
        threadParams.instance->name = taskName;

        /* unique arg for each thread - so in/out file names are unique */
        threadParams.arg = i;

        if (Thread_create(workerFxn, &threadParams, NULL) == NULL) {
            System_abort("main: failed to create smain thread.");
        }
    }

    BIOS_start();
}
Пример #12
0
/*!
 *  @brief      Function to initialize the Dm8168IpcInt module.
 *
 *  @param      cfg  Configuration for setup
 *
 *  @sa         Dm8168IpcInt_destroy
 */
Void
Dm8168IpcInt_setup (Dm8168IpcInt_Config * cfg)
{
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    Int            status = DM8168IPCINT_SUCCESS;
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    Int i = 0;
    Memory_MapInfo mapInfo;

    GT_1trace (curTrace, GT_ENTER, "Dm8168IpcInt_setup", cfg);

    GT_assert (curTrace, (cfg != NULL));

    /* The setup will be called only once, either from SysMgr or from
     * archipcdm8168 module. Hence it does not need to be atomic.
     */
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (cfg == NULL) {
        GT_setFailureReason (curTrace,
                        GT_4CLASS,
                        "Dm8168IpcInt_setup",
                        DM8168IPCINT_E_FAIL,
                        "config for driver specific setup can not be NULL");
    }
    else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */

        /* Map general control base */
        mapInfo.src      = AINTC_BASE_ADDR;
        mapInfo.size     = AINTC_BASE_SIZE;
        mapInfo.isCached = FALSE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        status =
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
        Memory_map (&mapInfo);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        if (status < 0) {
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "Dm8168IpcInt_setup",
                                 status,
                                 "Failure in Memory_map for general ctrl base");
            Dm8168IpcInt_state.archCoreCmBase = 0;
        }
        else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            Dm8168IpcInt_state.archCoreCmBase = mapInfo.dst;
            /* Map mailboxBase */
            mapInfo.src      = MAILBOX_BASE;
            mapInfo.size     = MAILBOX_SIZE;
            mapInfo.isCached = FALSE;
 #if !defined(SYSLINK_BUILD_OPTIMIZE)
            status =
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
                Memory_map (&mapInfo);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
            if (status < 0) {
                GT_setFailureReason (curTrace,
                                     GT_4CLASS,
                                     "Dm8168IpcInt_setup",
                                     status,
                                     "Failure in Memory_map for mailboxBase");
                Dm8168IpcInt_state.mailboxBase = 0;
            }
            else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
                Dm8168IpcInt_state.mailboxBase = mapInfo.dst;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
            }
        }
        if (status >= 0) {
            /*Registering dm8168 platform with ArchIpcInt*/
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
            ArchIpcInt_object.fxnTable = &Dm8168IpcInt_fxnTable;
            ArchIpcInt_object.obj      = &Dm8168IpcInt_state;

            for (i = 0; i < MultiProc_getNumProcessors(); i++ ) {
                Atomic_set (&(Dm8168IpcInt_state.isrObjects [i].asserted), 0);
            }

            /* Calling MultiProc APIs here in setup save time in ISR and makes
             * it small and fast with less overhead.
             */
            Dm8168IpcInt_state.procIds [DM8168_INDEX_DSP] = MultiProc_getId ("DSP");
            Dm8168IpcInt_state.procIds [DM8168_INDEX_VIDEOM3] =
                                                        MultiProc_getId ("VIDEO-M3");
            Dm8168IpcInt_state.procIds [DM8168_INDEX_VPSSM3] =
                                                    MultiProc_getId ("VPSS-M3");
            Dm8168IpcInt_state.maxProcessors = MultiProc_getNumProcessors();

            ArchIpcInt_object.isSetup  = TRUE;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        }
    }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_0trace (curTrace, GT_LEAVE, "Dm8168IpcInt_setup");
}
Пример #13
0
static Void * pingThreadFxn(void *arg)
{
    Int                      threadNum = *(int *)arg;
    Int32                    status     = 0;
    MessageQ_Msg             msg        = NULL;
    MessageQ_Params          msgParams;
    UInt16                   i;
    MessageQ_Handle          handle;
    MessageQ_QueueId         queueId = MessageQ_INVALIDMESSAGEQ;

    char             remoteQueueName[64];
    char             hostQueueName[64];

    printf ("Entered pingThreadFxn: %d\n", threadNum);

    sprintf(remoteQueueName, "%s_%d%d", SLAVE_MESSAGEQNAME, threadNum, (threadNum % (MultiProc_getNumProcessors() - 1)) + 1);
    sprintf(hostQueueName,   "%s_%d", HOST_MESSAGEQNAME,  threadNum );

    /* Create the local Message Queue for receiving. */
    MessageQ_Params_init (&msgParams);
    handle = MessageQ_create (hostQueueName, &msgParams);
    if (handle == NULL) {
        printf ("Error in MessageQ_create\n");
        goto exit;
    }
    else {
        printf ("thread: %d, Local Message: %s, QId: 0x%x\n",
            threadNum, hostQueueName, MessageQ_getQueueId(handle));
    }

    /* Poll until remote side has it's messageQ created before we send: */
    do {
        status = MessageQ_open (remoteQueueName, &queueId);
        sleep (1);
    } while (status == MessageQ_E_NOTFOUND);
    if (status < 0) {
        printf ("Error in MessageQ_open [0x%x]\n", status);
        goto cleanup;
    }
    else {
        printf ("thread: %d, Remote queue: %s, QId: 0x%x\n",
                 threadNum, remoteQueueName, queueId);
    }

    printf ("\nthread: %d: Exchanging messages with remote processor...\n",
            threadNum);
    for (i = 0 ; i < numLoops ; i++) {
        /* Allocate message. */
        msg = MessageQ_alloc (HEAPID, MSGSIZE);
        if (msg == NULL) {
            printf ("Error in MessageQ_alloc\n");
            break;
        }

        MessageQ_setMsgId (msg, i);

        /* Have the remote proc reply to this message queue */
        MessageQ_setReplyQueue (handle, msg);

        status = MessageQ_put (queueId, msg);
        if (status < 0) {
            printf ("Error in MessageQ_put [0x%x]\n", status);
            break;
        }

        status = MessageQ_get(handle, &msg, MessageQ_FOREVER);
        if (status < 0) {
            printf ("Error in MessageQ_get [0x%x]\n", status);
            break;
        }
        else {
            /* Validate the returned message. */
            if ((msg != NULL) && (MessageQ_getMsgId (msg) != i)) {
                printf ("Data integrity failure!\n"
                        "    Expected %d\n"
                        "    Received %d\n",
                        i, MessageQ_getMsgId (msg));
                break;
            }

            status = MessageQ_free (msg);
        }

        printf ("thread: %d: Exchanged %d msgs\n", threadNum, (i+1));
    }

    printf ("thread: %d: pingThreadFxn successfully completed!\n", threadNum);

    MessageQ_close (&queueId);

cleanup:
    /* Clean-up */
    status = MessageQ_delete (&handle);
    if (status < 0) {
        printf ("Error in MessageQ_delete [0x%x]\n", status);
    }

exit:

    return ((void *)status);
}
/*
 *  ======== Processor_getNumProcs ========
 */
UInt32 Processor_getNumProcs(Void)
{
    return(MultiProc_getNumProcessors());
}
Пример #15
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);
}