Exemple #1
0
Void Ducati_AppTask (UArg arg1, UArg arg2)
{
	FCSettings_init();
	Diags_setMask(FCSETTINGS_MODNAME"+12345678LEXAIZFS");
	CESettings_init();
	Diags_setMask(CESETTINGS_MODNAME"+12345678LEXAIZFS");
//	Diags_setMask("ti.sdo.rcm.RcmServer-12");
//	Diags_setMask("ti.sysbios.utils.Load-4");

    init_IVAHDFrwk();
    HDVICP_Reset(NULL, NULL);
    platform_init();

    /* how do we know when to unload.. */
    while (1) {
        Task_sleep(0x7fffffff);
    }

    /*The test cases will run in this task's context in the init call.
    Once init returns, testcases have exited so do deinit*/
    platform_deinit();

    exit_IVAHDFrwk();

    System_exit(0);
}
/* ARGSUSED */
int main(Int argc, Char * argv[])
{
    IRES_Status status;
    Int         size = 0;

    FCSettings_init();
    Diags_setMask(FCSETTINGS_MODNAME"+EX1234567");
    Diags_setMask("xdc.runtime.Main+EX1234567");
    Diags_setMask("ti.sdo.fc.%+EX1234567");

    Log_print0(Diags_ENTRY, "[+E] _main> Enter");

    status = RMAN_init();
    if (IRES_OK != status) {
        Log_print1(Diags_USER7, "[+7] main> RMAN_init() failed [%d]",
                   (IArg)status);
        System_abort("RMAN_init() failed, aborting...\n");
    }

    Log_print0(Diags_EXIT, "[+X] main> Exit");

    BIOS_start();

    return(0);
}
Exemple #3
0
int codecEngineInit(bool _verbose)
{
  CERuntime_init(); /* init Codec Engine */

  if (_verbose)
  {
    Diags_setMask("xdc.runtime.Main+EX1234567");
    Diags_setMask(Engine_MODNAME"+EX1234567");
  }

  return 0;
}
/* ARGSUSED */
int main(Int argc, Char * argv[])
{
    IRES_Status        status;

    /* Set default Diags mask to all, to get trace for init() functions */
    FCSettings_init();
    Diags_setMask(FCSETTINGS_MODNAME"+EX1234567");

    buf = Memory_calloc(NULL, BUFSIZE, BUFALIGN, NULL);

    if (buf == NULL) {
        System_abort("Allocation of buffer for BUFRES failed. Aborting.\n");
    }

    status = RMAN_init();

    //Diags_setMask(RMAN_MODNAME"+EX1234567");

    if (IRES_OK != status) {
        System_printf("main> RMAN initialization Failed [%d]\n", status);
        System_abort("Aborting...\n");
    }

    config.iresConfig.size = sizeof(BUFRES_Params);
//    config.iresConfig.allocFxn = _ALG_allocMemory;
//    config.iresConfig.freeFxn = _ALG_freeMemory;
    config.iresConfig.allocFxn = DSKT2_allocPersistent;
    config.iresConfig.freeFxn = DSKT2_freePersistent;

    config.base = buf;
    config.length = (UInt32)BUFSIZE;

    status = RMAN_register(&BUFRES_MGRFXNS, (IRESMAN_Params *)&config);

    /*
     *  Now that are resource is initialized,
     *  set default Diags mask to warnings and errors
     */
    Diags_setMask(FCSETTINGS_MODNAME"-EX12345");
    //Diags_setMask(BUFRES_MODNAME"-EX12345");

    if (status != IRES_OK) {
        /* Test failed */
        System_printf("BUFRES_init() failed [0x%x]\n", status);
        System_abort("Aborting.\n");
        return (-1);
    }

    smain(argc, argv);

    return (0);
}
Exemple #5
0
Void smain (UArg arg0, UArg arg1)
{
    int status = 0;

    Log_print0(Diags_ENTRY | Diags_INFO, "--> smain:");

    /* turn on Diags_INFO trace */
    Diags_setMask("Server+F");

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

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

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

leave:
    Log_print1(Diags_EXIT, "<-- smain: %d", (IArg)status);
    return;
}
Exemple #6
0
/*
 *  ======== Server_delete ========
 */
Int Server_delete()
{
    Int         status;
    GateMPApp_Msg *           msg;
    MessageQ_QueueId    queId;

    Log_print0(Diags_ENTRY, "--> Server_delete:");

    /* wait for inbound message */
    status = MessageQ_get(Module.slaveQue, (MessageQ_Msg *)&msg,
        MessageQ_FOREVER);

    if (status < 0) {
        goto leave;
    }
    Log_print0(Diags_ENTRY, "--> Server_delete: got msg");
    if (msg->cmd != GATEMPAPP_CMD_SHUTDOWN) {
        status = GATEMPAPP_E_UNEXPECTEDMSG;
        goto leave;
    }

    /* send message back to say that GateMP has been cleaned up */
    queId = MessageQ_getReplyQueue(msg); /* type-cast not needed */
    msg->cmd = GATEMPAPP_CMD_SHUTDOWN_ACK;
    MessageQ_put(queId, (MessageQ_Msg)msg);

    /* delete the video message queue */
    status = MessageQ_delete(&Module.slaveQue);
    if (status < 0) {
        Log_print0(Diags_ENTRY, "Server_delete: MessageQ_delete failed");
        goto leave;
    }

    Log_print0(Diags_ENTRY, "Server_delete: MessageQ deleted");

    /* delete slave GateMP */
    status = GateMP_delete(&Module.slaveGateMPHandle);
    if (status < 0) {
        Log_print0(Diags_ENTRY, "Server_delete: GateMP_delete failed");
        goto leave;
    }

    Log_print0(Diags_ENTRY, "Server_delete: slave GateMP deleted");

leave:
    if (status < 0) {
        Log_error1("Server_delete: error=0x%x", (IArg)status);
    }

    /* disable log events */
    Log_print1(Diags_EXIT, "<-- Server_delete: %d", (IArg)status);
    Diags_setMask(MODULE_NAME"-EXF");

    return(status);
}
Exemple #7
0
/*
 *  ======== CESettings_setDiags ========
 */
Void CESettings_setDiags(String modName)
{
    Char              diags[MAXLEN];
    Char             *curPtr;

    Assert_isTrue(strlen(modName) <= MAXMODLEN, (Assert_Id)NULL);

    if (strlen(modName) > MAXMODLEN) {
        /* Module name is too long, cannot set the Diags bits */
        return;
    }

    strcpy(diags, modName);
    curPtr = diags + strlen(modName);

    CESettings_getDiags(curPtr, MAXLEN - strlen(modName));

    Diags_setMask(diags);
}
Exemple #8
0
/*
 *  ======== Server_create ========
 */
Int Server_create()
{
    Int                 status = 0;
    MessageQ_Params     msgqParams;
    GateMP_Params       gateParams;

    /* enable some log events */
    Diags_setMask(MODULE_NAME"+EXF");

    /* create GateMP */
    GateMP_Params_init(&gateParams);

    gateParams.name             = GATEMP_SLAVE_NAME;
    gateParams.localProtect     = GateMP_LocalProtect_PROCESS;
    gateParams.remoteProtect    = GateMP_RemoteProtect_SYSTEM;

    Module.slaveGateMPHandle = GateMP_create (&gateParams);

    if (Module.slaveGateMPHandle == NULL) {
        status = GATEMPAPP_E_FAILURE;
        Log_print0(Diags_INFO, "Server_create: Failed to create GateMP");
        goto leave;
    }

    /* create local message queue (inbound messages) */
    MessageQ_Params_init(&msgqParams);
    Module.slaveQue = MessageQ_create(GateMPApp_SlaveMsgQueName, &msgqParams);

    if (Module.slaveQue == NULL) {
        status = -1;
        Log_print0(Diags_INFO, "Server_create: Failed to create MessageQ");
        GateMP_delete(&Module.slaveGateMPHandle);
        goto leave;
    }

    Log_print0(Diags_INFO,"Server_create: Slave is ready");

leave:
    Log_print1(Diags_EXIT, "<-- Server_create: %d", (IArg)status);
    return (status);
}
Exemple #9
0
/*
 *  ======== smain ========
 */
Void smain(UArg arg0, UArg arg1)
{
    Int                 status = 0;

    Log_print0(Diags_ENTRY | Diags_INFO, "--> smain:");

    /* initialize modules */
    Server_init();

    /* turn on Diags_INFO trace */
    Diags_setMask("Server+F");

    /* server setup phase */
    status = Server_create();

    if (status < 0) {
        goto leave;
    }

    /* server execute phase */
    status = Server_exec();

    if (status < 0) {
        goto leave;
    }

    /* server shutdown phase */
    status = Server_delete();

    if (status < 0) {
        goto leave;
    }

    /* finalize modules */
    Server_exit();

leave:
    Log_print1(Diags_EXIT, "<-- smain: %d", (IArg)status);
    return;
}
/**
 *  @brief      The BIOS main() entry point.
 *
 *  @remark     The purpose of this function is to create a BIOS worker task
 *              to house our example.
 *
 *  @remark     This is called during BIOS_init, but before the scheduler
 *              has begun running.
 */
Void main(Int argc, String argv[])
{
    Thread_Params threadParams;

    /* init Codec Engine */
    CERuntime_init();

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

    Log_print0(Diags_USER2, "[+2] main> Welcome to app's main().");

    Thread_Params_init(&threadParams);
    threadParams.stackSize = 6 * 1024;
    threadParams.instance->name = taskName;

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

    BIOS_start();
}
Exemple #11
0
/**
 *  @brief      The BIOS main() entry point.
 *
 *  @remark     The purpose of this function is to create a BIOS worker task
 *              to house our example.
 *
 *  @remark     This is called during BIOS_init, but before the scheduler
 *              has begun running.
 */
Void main(Int argc, String argv[])
{
    Thread_Params threadParams;

    /* init Codec Engine */
    CERuntime_init();

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

    Log_print0(Diags_USER2, "[+2] main> ti.sdo.ce.examples.apps.image_copy");

    Thread_Params_init(&threadParams);
    threadParams.stackSize = 6 * 1024;
    threadParams.instance->name = taskName;

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

    BIOS_start();
}
/**
 *  @brief      The BIOS main() entry point.
 *
 *  @remark     The purpose of this function is to create a BIOS worker task
 *              to house our example.
 *
 *  @remark     This is called during BIOS_init, but before the scheduler
 *              has begun running.
 */
Void main(Int argc, String argv[])
{
    Thread_Params threadParams;
    Engine_Desc    engDesc;
    Engine_AlgDesc algDesc;
    Engine_Error status;

    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.speech1_copy");

    /*
     *  Create the Engine and add our sphdec1_copy and sphenc1_copy algs to
     *  it.  Note, this can also be done in a config script.
     */
     Engine_initDesc(&engDesc);
     engDesc.name = "speech1_copy";
     engDesc.remoteName = NULL;

    status = Engine_add(&engDesc);
    if (status != Engine_EOK) {
        Log_print1(Diags_ERROR, "main-> ERROR: Runtime Engine_add() "
                "failed (0x%x)\n", status);
        /* don't continue */
        while (1) {}
    }

    /*
         *  Add the "sphdecl_copy" and "sphenc1_copy" algs to the
         *  "speech1_copy" engine.
         */

    Engine_initAlgDesc(&algDesc); /* Set fields to defaults */

    algDesc.name = "sphdec1_copy";
    algDesc.fxns = (IALG_Fxns *)&SPHDEC1COPY_TI_ISPHDEC1COPY;
    algDesc.idmaFxns = NULL;
    algDesc.isLocal = TRUE;
    algDesc.groupId = 0;
    algDesc.iresFxns = NULL;
    algDesc.types = SPHDEC1_VISATYPE;

    status = Engine_addAlg("speech1_copy", NULL, NULL, &algDesc);

    if (status != Engine_EOK) {
        Log_print1(Diags_USER7, "App-> ERROR: can't add Alg (0x%x)\n",
                (IArg)status);
        /* don't continue */
        while (1) {}
    }

    algDesc.name = "sphenc1_copy";
    algDesc.fxns = (IALG_Fxns *)&SPHENC1COPY_TI_ISPHENC1COPY;
    algDesc.idmaFxns = NULL;
    algDesc.isLocal = TRUE;
    algDesc.groupId = 0;
    algDesc.iresFxns = NULL;
    algDesc.types = SPHENC1_VISATYPE;

    status = Engine_addAlg("speech1_copy", NULL, NULL, &algDesc);

    if (status != Engine_EOK) {
        Log_print1(Diags_USER7, "App-> ERROR: can't add Alg (0x%x)\n",
                (IArg)status);
        /* don't continue */
        while (1) {}
    }

    /* Spawn a task to run once the BIOS scheduler is started */
    Thread_Params_init(&threadParams);

    /* 6K stack size */
    threadParams.stackSize = 6 * 1024;
    /* task name */
    threadParams.instance->name = taskName;

    /* used for in/out file names */
    threadParams.arg = 0;

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

    /* Start the BIOS scheduler */
    BIOS_start();
}
Int main(Int argc, char* argv[])
{
    RcmServer_Params  rcmServerParams;

    System_printf("%s starting..\n", MultiProc_getName(MultiProc_self()));

    /*
     * Enable use of runtime Diags_setMask per module:
     *
     * Codes: E = ENTRY, X = EXIT, L = LIFECYCLE, F = INFO, S = STATUS
     */
    Diags_setMask("ti.ipc.rpmsg.MessageQCopy=EXLFS");

    /* Setup the table of services, so clients can create and connect to
     * new service instances:
     */
    ServiceMgr_init();

    /* initialize RcmServer create params */
    RcmServer_Params_init(&rcmServerParams);

    /* The first function, at index 0, is a special create function, which
     * gets passed a Service_Handle argument.
     * We set this at run time as our C compiler is not allowing named union
     * field initialization:
     */
    OMXServer_fxnTab.elem[0].addr.createFxn = RPC_SKEL_GetHandle;

    rcmServerParams.priority    = Thread_Priority_ABOVE_NORMAL;
    rcmServerParams.fxns.length = OMXServer_fxnTab.length;
    rcmServerParams.fxns.elem   = OMXServer_fxnTab.elem;

    /* Register an OMX service to create and call new OMX components: */
    ServiceMgr_register("OMX", &rcmServerParams);

    /* Some background ping testing tasks, used by rpmsg samples: */
    //start_ping_tasks();

#if 0 /* DSP or CORE0 or IPU */
    /* Run a background task to test rpmsg_resmgr service */
    start_resmgr_task();
#endif

#if 0  /* DSP or CORE0 or IPU */
    /* Run a background task to test hwspinlock */
    start_hwSpinlock_task();
#endif

    /* Create 1 task with priority 15 */
    Error_init(&eb0);
    Task_Params_init(&taskParams0);
    //taskParams0.stackSize = 512;
    taskParams0.priority = 15; 
    taskParams0.affinity = 1; 
    taskParams0.arg0 = (xdc_UArg)(&(t1)) ;
    taskParams0.arg1 = 0 ;

    /* Create 1 task with priority 15 */
    Error_init(&eb1);
    Task_Params_init(&taskParams1);
    //taskParams1.stackSize = 512;
    taskParams1.priority = 15; 
    taskParams1.affinity = 0;
    taskParams1.arg0 = (xdc_UArg)(&(t2)) ;
    taskParams1.arg1 = 1 ;

    /* create an Event object. All events are binary */
    Error_Block eb;
    Error_init(&eb);
    edgeDetectEvent = Event_create(NULL, &eb);
    if (edgeDetectEvent == NULL) {
	    System_abort("Event create failed");
    }

    local_barrier_sense = local_barrier_counter = 2 ;

    sem0 = Semaphore_create(1, NULL, NULL) ;

    /* Start the ServiceMgr services */
    ServiceMgr_start(0);

    BIOS_start();

    return (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();
}
/*
 *  ======== main ========
 */
Int main(Int argc, String argv[])
{
    String procId;
    String procSuffix;
    String engineName;
    String mapFileName = NULL;
    String inFile;
    String outFile;
    Char defaultEngineName[32];
    Bool useExtLoader = FALSE;  /* Set to TRUE if using external loader */
    String options = "e:m:p:s:";
    Int option;
    char serverName[MAXSERVERNAMELEN];
    Engine_Error retVal;
    Engine_Desc engDesc;

    /* Initialize defaults. */
    procId = "DSP";
    procSuffix = "x64P";
    engineName = defaultEngineName;
    sprintf(defaultEngineName, "remote_copy_%s", procId);
    inFile = "./in.dat";
    outFile = "./out.dat";

    while ((option = getopt(argc, argv, options)) != -1) {
        switch (option) {
          case 'e':
            engineName = optarg;

            break;

          case 'm':
              /*
               *  If specifying the slave's memory mapping, then assume that
               *  Codec Engine will be loading the slave.
               */
            mapFileName = optarg;
            useExtLoader = FALSE;

            break;

          case 'p':
            procId = optarg;
            sprintf(defaultEngineName, "remote_copy_%s", procId);

            break;

          case 's':
            procSuffix = optarg;

            break;

          default:
            Log_print1(Diags_USER7, " unrecognized option '%c'\n", option);

            break;
        }
    }

    if (argc == (optind + 1)) {
        inFile = argv[optind];
    }
    else if (argc == (optind + 2)) {
        inFile = argv[optind];
        outFile = argv[optind + 1];
    }
    else if (argc != optind) {
        fprintf(stderr, usage, argv[0]);
        exit(1);
    }

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

    /*
     * Create the Engine with a remote Server and add register the
     * appropriate stub functions.
     *
     * Note, this can also be done in a config script.
     */
    retVal = Engine_addStubFxns("UNIVERSAL_STUBS",
            (IALG_Fxns *)&UNIVERSAL_STUBS);
    if (retVal != Engine_EOK) {
        printf("App-> ERROR: Runtime Engine_addStubFxns() failed (0x%x)\n",
                retVal);
        /* don't continue */
        while (1) {}
    }

    Engine_initDesc(&engDesc);
    engDesc.name = engineName;
    engDesc.memMap = mapFileName;
    engDesc.useExtLoader = useExtLoader;
    sprintf(serverName, "all_%s.%s", procId, procSuffix);
    engDesc.remoteName = serverName;

    retVal = Engine_add(&engDesc);
    if (retVal != Engine_EOK) {
        Log_print1(Diags_ERROR, "main-> ERROR: Runtime Engine_add() "
                "failed (0x%x)\n", retVal);
        /* don't continue */
        while (1) {}
    }

    return (smain(argv[0], procId, engineName, inFile, outFile));
}
Void smain(UArg arg0, UArg arg1)
{
    Int                 status = 0;
    SystemCfg_Params    systemCfgP;
    SystemCfg_Handle    systemCfgH = NULL;
    ComputeDevice_Cfg   compDevCfg;


    /* initialize modules */
    SystemCfg_init();
    ComputeDevice_init();

    /* start all statically created threads now */
    Thread_start(NULL);

    /* turn on some trace */
//  Diags_setMask("SystemCfg+F;ComputeDevice+F");
    Diags_setMask("ComputeDevice+FEX");

    /* create a SystemCfg instance for the remote processor */
    SystemCfg_Params_init(&systemCfgP);
    systemCfgP.remoteProcName = SystemCfg_Host_ProcName;

    status = SystemCfg_create(&systemCfgP, &systemCfgH);

    if (status < 0) {
        goto leave;
    }

    /* let the host know this processor has started */
    status = SystemCfg_startAck(systemCfgH);

    if (status < 0) {
        Log_error0(FXNN": SystemCfg_startAck() failed");
        goto leave;
    }

    /* attach to the remote processor, blocks until remote side attaches */
    status = SystemCfg_attach(systemCfgH);

    if (status < 0) {
        Log_error0(FXNN": SystemCfg_attach() failed");
        goto leave;
    }

    /* start the compute device, start the OpenCL Runtime */
    compDevCfg.rcmServerName = SystemCfg_RcmServer_CompDev;

    status = ComputeDevice_start((Ptr)(&compDevCfg));

    if (status < 0) {
        Log_error0(FXNN": ComputeDevice_start() failed");
        goto leave;
    }

    /* send ready event */
    SystemCfg_sendEvent(systemCfgH, SystemCfg_EvtReady);

    /*
     *  BEGIN execute phase
     */

    /* wait for the shutdown signal */
    SystemCfg_waitForEvent(systemCfgH, SystemCfg_EvtShutdown);

    /*
     *  END execute phase
     */

    /* stop the compute device */
    status = ComputeDevice_stop((Ptr)(&compDevCfg));

    if (status < 0) {
        Log_error0(FXNN": ComputeDevice_stop() failed");
        goto leave;
    }

    /* wait for handshake before terminating */
    SystemCfg_handshakeEvent(systemCfgH, SystemCfg_EvtDone);

    /* detach from the remote processor */
    SystemCfg_detach(systemCfgH);

    /* prepare to be stopped */
    SystemCfg_stop(systemCfgH);

    /* delete SystemCfg instance */
    SystemCfg_delete(&systemCfgH);

    /* finalize modules */
    ComputeDevice_exit();
    SystemCfg_exit();

leave:
    Log_print1(Diags_EXIT, "<-- "FXNN": %d", (IArg)status);
    return;
}
/*
 *  ======== smain ========
 */
Void smain(UArg arg0, UArg arg1)
{
    Int                 status = 0;
    Error_Block         eb;
    SystemCfg_Params    systemCfgP;
    SystemCfg_Handle    systemCfgH = NULL;
    ComputeDevice_Cfg   compDevCfg;


    Log_print0(Diags_ENTRY | Diags_INFO, LOGSTR(2));

    Error_init(&eb);

    /* initialize modules */
    SystemCfg_init();
    ComputeDevice_init();

    /* start all statically created threads now */
    Thread_start(NULL);

    /* turn on some trace */
//  Diags_setMask("SystemCfg+F;ComputeDevice+F");
    Diags_setMask("ComputeDevice+F");
//  Diags_setMask("TsrKnl+F1");

    /* create a SystemCfg instance for the remote processor */
    SystemCfg_Params_init(&systemCfgP);
    systemCfgP.remoteProcName = SystemCfg_Host_ProcName;

    status = SystemCfg_create(&systemCfgP, &systemCfgH);

    if (status < 0) {
        goto leave;
    }

    /* let the host know this processor has started */
    status = SystemCfg_startAck(systemCfgH);

    if (status < 0) {
        Log_error0(LOGSTR(4));
        goto leave;
    }

    /* attach to the remote processor */
    status = SystemCfg_attach(systemCfgH);

    if (status < 0) {
        Log_error0(LOGSTR(5));
        goto leave;
    }

    /* create local resources */
    status = SystemCfg_createResources(systemCfgH);

    if (status < 0) {
        Log_error0(LOGSTR(6));
        goto leave;
    }

    /* wait for handshake before opening remote resources */
    SystemCfg_handshakeEvent(systemCfgH, SystemCfg_EvtCreateDone);

    /* open shared resources from remote core */
    status = SystemCfg_openResources(systemCfgH);

    if (status < 0) {
        Log_error0(LOGSTR(7));
        goto leave;
    }

    /* start the compute device, start the OpenCL Runtime */
    compDevCfg.rcmServerName = SystemCfg_RcmServer_CompDev;
    status = ComputeDevice_start((Ptr)(&compDevCfg));

    if (status < 0) {
        Log_error0(LOGSTR(8));
        goto leave;
    }

    /* send ready event */
    SystemCfg_sendEvent(systemCfgH, SystemCfg_EvtReady);

    /*
     *  BEGIN execute phase
     */

    /* wait for the shutdown signal */
    SystemCfg_waitForEvent(systemCfgH, SystemCfg_EvtShutdown);

    /*
     *  END execute phase
     */

    /* stop the compute device */
    status = ComputeDevice_stop((Ptr)(&compDevCfg));

    if (status < 0) {
        Log_error0(LOGSTR(9));
        goto leave;
    }

    /* close shared resources from remote core */
    status = SystemCfg_closeResources(systemCfgH);

    if (status < 0) {
        Log_error0(LOGSTR(10));
        goto leave;
    }

    /* wait for handshake before deleting local resources */
    SystemCfg_handshakeEvent(systemCfgH, SystemCfg_EvtCloseDone);

    /* delete local resources */
    status = SystemCfg_deleteResources(systemCfgH);

    if (status < 0) {
        Log_error0(LOGSTR(11));
        goto leave;
    }

    /* wait for handshake before terminating */
    SystemCfg_handshakeEvent(systemCfgH, SystemCfg_EvtDone);

#if 0  /* SDOCM85206, SDOCM85207 */
    /* detach from the remote processor */
    status = SystemCfg_detach(systemCfgH);

    if (status < 0) {
        Log_error1(LOGSTR(12), (IArg)status);
        goto leave;
    }

    /* prepare to be stopped */
    SystemCfg_stop(systemCfgH);
#endif

    /* delete SystemCfg instance */
    if (systemCfgH != NULL) {
        SystemCfg_delete(&systemCfgH);
    }

    /* finalize modules */
    ComputeDevice_exit();
    SystemCfg_exit();

leave:
    Log_print1(Diags_EXIT, LOGSTR(3), (IArg)status);
    return;
}
/*
 *  ======== main ========
 */
Int main(Int argc, String argv[])
{
    String procId;
    String procSuffix;
    String engineName;
    String mapFileName = NULL;
    String inFile;
    String outFile;
    Char defaultEngineName[32];
    Bool useExtLoader = FALSE;  /* Set to TRUE if using external loader */
    Engine_Error status;
    String options = "e:m:p:s:";
    Int option;
    Engine_Desc desc;

    /* Initialize defaults. */
    procId = "DSP";
    procSuffix = "x64P";
    engineName = defaultEngineName;
    sprintf(defaultEngineName, "remote_copy_%s", procId);
    inFile = "./in.dat";
    outFile = "./out.dat";

    while ((option = getopt(argc, argv, options)) != -1) {
        switch (option) {
          case 'e':
            engineName = optarg;

            break;

          case 'm':
              /*
               *  If specifying the slave's memory mapping, then assume that
               *  Codec Engine will be loading the slave.
               */
            mapFileName = optarg;
            useExtLoader = FALSE;

            break;

          case 'p':
            procId = optarg;
            sprintf(defaultEngineName, "remote_copy_%s", procId);

            break;

          case 's':
            procSuffix = optarg;

            break;

          default:
            Log_print1(Diags_USER7, " unrecognized option '%c'\n", option);

            break;
        }
    }

    if (argc == (optind + 1)) {
        inFile = argv[optind];
    }
    else if (argc == (optind + 2)) {
        inFile = argv[optind];
        outFile = argv[optind + 1];
    }
    else if (argc != optind) {
        fprintf(stderr, usage, argv[0]);
        exit(1);
    }

    /* init Codec Engine */
    CERuntime_init();

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

    Log_print0(Diags_USER2, "[+2] main> Welcome to app's main().");

    /*
     *  Set the memory map in the engine's descriptor, and change to use
     *  (or not use) an external loader for loading.  If using an external
     *  loader, then desc.memMap should be set to NULL;
     */
    status = Engine_getDesc(engineName, &desc);
    desc.useExtLoader = useExtLoader;
    desc.memMap = mapFileName;

    status = Engine_setDesc(engineName, &desc);
    if (status != Engine_EOK) {
        Log_print2(Diags_USER6, "[+2] main> Unable to change \'useExtLoader\' "
                "in descriptor for engine %s to %s", (IArg)engineName,
                (IArg)(useExtLoader ? "TRUE" : "FALSE"));
    }

    return (smain(argv[0], procId, engineName, inFile, outFile));
}
Exemple #19
0
Int main(Int argc, char* argv[])
{
    RcmServer_Params  rcmServerParams;

    System_printf("%s starting..\n", MultiProc_getName(MultiProc_self()));

    /*
     * Enable use of runtime Diags_setMask per module:
     *
     * Codes: E = ENTRY, X = EXIT, L = LIFECYCLE, F = INFO, S = STATUS
     */
    Diags_setMask("ti.ipc.rpmsg.MessageQCopy=EXLFS");

    /* Setup the table of services, so clients can create and connect to
     * new service instances:
     */
    ServiceMgr_init();

    /* initialize RcmServer create params */
    RcmServer_Params_init(&rcmServerParams);

    /* The first function, at index 0, is a special create function, which
     * gets passed a Service_Handle argument.
     * We set this at run time as our C compiler is not allowing named union
     * field initialization:
     */
    OMXServer_fxnTab.elem[0].addr.createFxn = RPC_SKEL_GetHandle;

    rcmServerParams.priority    = Thread_Priority_ABOVE_NORMAL;
    rcmServerParams.fxns.length = OMXServer_fxnTab.length;
    rcmServerParams.fxns.elem   = OMXServer_fxnTab.elem;

	int i = 0;
	for (i = 0; i < 255; i ++)
		bit_num[i] = ((i&1) != 0) + ((i&2) != 0) + ((i&4) != 0) + ((i&8) != 0) + ((i&16) != 0) + ((i&32) != 0) + ((i&64) != 0) + ((i&128) != 0);
	
    /* Register an OMX service to create and call new OMX components: */
    ServiceMgr_register("OMX", &rcmServerParams);

#if 0
    /* Some background ping testing tasks, used by rpmsg samples: */
    start_ping_tasks();
#endif

#if 0 /* DSP or CORE0 or IPU */
    /* Run a background task to test rpmsg_resmgr service */
    start_resmgr_task();
#endif

#if 0  /* DSP or CORE0 or IPU */
    /* Run a background task to test hwspinlock */
    start_hwSpinlock_task();
#endif

    /* Start the ServiceMgr services */
    ServiceMgr_start(0);

    BIOS_start();


    return (0);
}
/*
 *  ======== main ========
 */
Int main(Int argc, String argv[])
{
    String procId;
    String engineName;
    String inFile;
    String outFile;
    Char defaultEngineName[32];
    String options = "e:p:";
    Int option;
    Engine_Desc    engDesc;
    Engine_AlgDesc algDesc;
    Engine_Error status;

    /* Initialize defaults. */
    procId = "DSP";
    engineName = defaultEngineName;
    sprintf(defaultEngineName, "speech1_copy");
    inFile = "./in.dat";
    outFile = "./out.dat";

    while ((option = getopt(argc, argv, options)) != -1) {
        switch (option) {
          case 'e':
            engineName = optarg;
            break;

          case 'p':
            procId = optarg;
            break;

          default:
            Log_print1(Diags_USER7, " unrecognized option '%c'\n", option);
            break;
        }
    }

    if (argc == (optind + 1)) {
        inFile = argv[optind];
    }
    else if (argc == (optind + 2)) {
        inFile = argv[optind];
        outFile = argv[optind + 1];
    }
    else if (argc != optind) {
        fprintf(stderr, usage, argv[0]);
        exit(1);
    }

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

    /* Add a "speechl_copy" engine */
    Engine_initDesc(&engDesc);
    engDesc.name = "speech1_copy";

    status = Engine_add(&engDesc);
    if (status != Engine_EOK) {
        Log_print1(Diags_USER7, "App-> ERROR: can't add engine (0x%x)\n",
                (IArg)status);
        return (0);
    }

    /*
         *  Add the "sphdecl_copy" and "sphenc1_copy" algs to the
         *  "speech1_copy" engine.
         */

    Engine_initAlgDesc(&algDesc); /* Set fields to defaults */

    algDesc.name = "sphdec1_copy";
    algDesc.fxns = (IALG_Fxns *)&SPHDEC1COPY_TI_ISPHDEC1COPY;
    algDesc.idmaFxns = NULL;
    algDesc.isLocal = TRUE;
    algDesc.groupId = 0;
    algDesc.iresFxns = NULL;
    algDesc.types = SPHDEC1_VISATYPE;

    status = Engine_addAlg("speech1_copy", NULL, NULL, &algDesc);

    if (status != Engine_EOK) {
            Log_print1(Diags_USER7, "App-> ERROR: can't add Alg (0x%x)\n",
                (IArg)status);
            return (0);
    }

    algDesc.name = "sphenc1_copy";
    algDesc.fxns = (IALG_Fxns *)&SPHENC1COPY_TI_ISPHENC1COPY;
    algDesc.idmaFxns = NULL;
    algDesc.isLocal = TRUE;
    algDesc.groupId = 0;
    algDesc.iresFxns = NULL;
    algDesc.types = SPHENC1_VISATYPE;

    status = Engine_addAlg("speech1_copy", NULL, NULL, &algDesc);

    if (status == Engine_EOK) {
        return (smain(argv[0], procId, engineName, inFile, outFile));
    }
    else {
        Log_print1(Diags_USER7, "App-> ERROR: can't add Alg (0x%x)\n",
                (IArg)status);
    }

    Log_print0(Diags_USER1, "[+1] app done.");
    return (0);
}