Beispiel #1
0
/*
 *  ======== Algorithm_init ========
 */
Void Algorithm_init()
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_algorithm_desc,
                Algorithm_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Algorithm_MODNAME);
        }
        regInit = 1;
    }

    if (curInit != TRUE) {
        curInit = TRUE;
        RMAN_init();
        Global_atexit((Fxn)Algorithm_exit);
    }
}
Beispiel #2
0
/*
 *  ======== Loader_init ========
 */
Void Loader_init(Void)
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_osal_Loader_desc,
                                    Loader_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Loader_MODNAME);
        }
        regInit = 1;
    }

    if (curInit++ == 0) {
        Global_atexit((Fxn)cleanup);
    }
}
Beispiel #3
0
/*
 *  ======== SemMP_init ========
 */
Void SemMP_init(Void)
{
    if (curInit++ == 0) {
        GT_create(&curTrace, SemMP_GTNAME);

        Global_atexit((Fxn)cleanup);
    }
}
Beispiel #4
0
/*
 *  ======== Lock_init ========
 */
Void Lock_init(Void)
{
    if (curInit == FALSE) {
        curInit = TRUE;
        Lock_system = Lock_create(NULL);
    }

    Global_atexit((Fxn)cleanup);
}
Beispiel #5
0
/*
 *  ======== Memory_init ========
 */
Bool Memory_init(Void)
{

    if (curInit != TRUE) {
        curInit = TRUE;
        GT_create(&curTrace, Memory_GTNAME);
        Global_atexit((Fxn)cleanup);
    }

    return (TRUE);
}
Beispiel #6
0
/*
 *  ======== GTConfig_posixInit ========
 */
Int GTConfig_posixInit(Void)
{
    String fileName;
    String fileFlags = "a"; /* assign here to keep compiler quiet */

    if (curInit != TRUE) {

        curInit = TRUE;

        if ((fileName = getenv("CE_TRACEFILE")) != NULL) {
            if ((fileFlags = getenv("CE_TRACEFILEFLAGS")) == NULL) {
                fileFlags = "a";
            }
            GT_config_traceOutStream = fopen(fileName, fileFlags);
            if (GT_config_traceOutStream != NULL) {
                Int flags = fcntl(fileno(GT_config_traceOutStream), F_GETFD);
                if (flags != -1) {
                    fcntl(fileno(GT_config_traceOutStream), F_SETFD,
                         flags | FD_CLOEXEC);
                }
                traceOutStreamOpenedHere = GT_config_traceOutStream;
            }
        }
        if (GT_config_traceOutStream == NULL) {
            GT_config_traceOutStream = stdout;
            if ((fileName != NULL) && (fileName[0] != '\0')) {
                printf("Warning: could not open file '%s' in mode '%s' "
                    "for writing trace.\n", fileName, fileFlags);
            }
        }

        /* use line buffering to ensure timely output of trace */
        setvbuf(GT_config_traceOutStream, (char *)NULL, _IOLBF, 0);

        /* initialize mutex */
        pthread_mutexattr_init(&mattrs);
        /* "adaptive" below means "fast", as opposed to "recursive" */
        pthread_mutexattr_settype(&mattrs, PTHREAD_MUTEX_ADAPTIVE_NP);
        pthread_mutex_init(&mutex,  &mattrs);

        /* call Global_atexit() to schedule our cleanup. Global module
         * has not been initialized yet, but he knows we'll call him
         * here so he knows how to deal with this call.
         */
         Global_atexit((Fxn)cleanup);
    }
    return (1);
}
/*
 *  ======== Memory_init ========
 */
Bool Memory_init(Void)
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_osal_Memory_desc,
                Memory_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Memory_MODNAME);
        }
        regInit = 1;
    }

    if (curInit != TRUE) {
        curInit = TRUE;
        moduleLock = Lock_create(NULL);
        if (moduleLock == NULL) {
            Log_print0(Diags_USER7, "[+7] Memory_init> "
                    "ERROR: could not create pthread mutex.");
            assert(FALSE);
        }

        if (CMEM_init() == -1) {
            Log_print0(Diags_USER7, "[+7] Memory_init> "
                    "ERROR: Failed to initialize CMEM");
        }
        else {
            cmemInitialized = TRUE;
        }

        Global_atexit((Fxn)cleanup);
    }

    return (cmemInitialized);
}
/*
 *  ======== Algorithm_init ========
 */
Void Algorithm_init()
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_algorithm_desc,
                Algorithm_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Algorithm_MODNAME);
        }
        regInit = 1;
    }

    if (curInit++ == 0) {
        RMAN_init();
        DMAN3_CE_init();

        /*
         *  NOTE: We are calling ALG_init() here rather than calling it in
         *  CERuntime_init(). This simplifies the auto-generation of
         *  CERuntime_init(), since ALG is not used in Algorithm_BIOS.c.
         *  Since ALG_init() is called here, to keep the symmetry, we will
         *  also call ALG_exit() from Algorithm_exit(), rather than having
         *  ALG_init() register its exit function through Global_atexit().
         */
        ALG_init();
        Global_atexit((Fxn)Algorithm_exit);
    }
}
Beispiel #9
0
/*
 *  ======== Processor_init ========
 */
Void Processor_init(Void)
{
    if (curInit != TRUE) {
        curInit = TRUE;

        GT_create(&curTrace, Processor_GTNAME);

        /* Semaphore with count 0, will be posted when a command is present */
        dcmd.cmdPresent = Sem_create(CMDKEY, 0);

        /* Semaphore with count 0, will be posted when reply is ready */
        dcmd.replyPresent = Sem_create(REPLYKEY, 0);

        /*
         *  Create lock to allow only one thread at a time to send command
         *  to the daemon.
         */
        dcmd.gate = Lock_create(NULL);

        if ((dcmd.cmdPresent == NULL) || (dcmd.replyPresent == NULL) ||
                (dcmd.gate == NULL)) {
            // TODO: Shouldn't we abort?
            GT_0trace(curTrace, GT_7CLASS, "Processor_init> ERROR: cannot"
                " create semaphores or lock\n");
        }

        if ((dcmd.dproc = Thread_create((Fxn)daemon, NULL)) == NULL) {
            GT_0trace(curTrace, GT_7CLASS, "Processor_init> "
                "ERROR: cannot create DSP daemon\n");
        }

        Power_init();

        Global_atexit((Fxn)cleanup);
    }
}
/*
 * ======== TraceUtil_init ========
 */
Void TraceUtil_init()
{
    String mask;
    String fileName;
    String flags;
    String s;
    Char   armTraceFileName[ MAXCMDLINESIZE ];

    extern Void GT_config_setOutTrace(FILE *newOutTrace);

    if (getenv( "CE_DEBUG" ) != NULL) {
        return;
    }

    if (curInit == TRUE) {
        return;
    }
    curInit = TRUE;

    s = getenv("TRACEUTIL_VERBOSE");
    if (s != NULL) {
        verbose = (s[0] == '2' ? 2 : 1);
    }

    INFO("Relevant environment variables:\n");
    #define INFO_ENV(env,pad) INFO("%s %s= %s\n", \
            (env), (pad), getenv(env) ? getenv(env) : "undefined")
    INFO_ENV("CE_TRACE", "               ");
    INFO_ENV("CE_TRACEFILE", "           ");
    INFO_ENV("TRACEUTIL_DSP0TRACEFILE", "");
    INFO_ENV("TRACEUTIL_DSP0BIOSFILE", " ");
    INFO_ENV("TRACEUTIL_DSP0TRACEMASK", "");
    INFO_ENV("TRACEUTIL_REFRESHPERIOD", "");
    INFO_ENV("CE_TRACEFILEFLAGS", "      ");
    INFO_ENV("TRACEUTIL_CMDPIPE", "      ");
    INFO_ENV("TRACEUTIL_VERBOSE", "      ");

    /*
     * We run after GT has performed initialization but before
     * anything has been printed yet.
     */

    flags = getenv("CE_TRACEFILEFLAGS");

    if (flags == NULL) {
        flags = TraceUtil_traceFileFlags;
    }
    if (flags == NULL || flags[0] == '\0') {
        flags = "w";
    }

    /* Local trace file */
    fileName = getenv("CE_TRACEFILE");

    if (fileName == NULL) {
        fileName = TraceUtil_localTraceFile;
    }

    INFO("Local trace file name: %s\n", (fileName && fileName[0]) ?
         fileName : "stdout");

    armTraceFileName[0] = '\0';

    /* NULL means stdout */
    if (fileName != NULL && fileName[0] != '\0') {
        localTraceFilePtr = fopen(fileName, flags);

        if (localTraceFilePtr == NULL) {
            WARN("Failed to open local log file \"%s\", using stdout\n",
                fileName);
            localTraceFilePtr = stdout;
        } else {
            strncpy(armTraceFileName, fileName, MAXCMDLINESIZE);
            fileSetCloseOnExec(localTraceFilePtr);
        }
    }
    else {
        localTraceFilePtr = stdout;
    }

    GT_config_setOutTrace(localTraceFilePtr);

    /* DSP CE trace file */
    fileName = getenv("TRACEUTIL_DSP0TRACEFILE");

    if (fileName == NULL) {
        fileName = TraceUtil_dsp0TraceFile;
    }

    INFO("DSP CE trace file name: %s\n", (fileName && fileName[0]) ?
         fileName : "stdout");

    /* NULL means stdout */
    if (fileName != NULL && fileName[0] != '\0') {

        if (!strcmp(armTraceFileName, fileName)) {
            /* local and DSP trace names are the same */
            dsp0TraceFilePtr = localTraceFilePtr;
        } else {
            dsp0TraceFilePtr = fopen(fileName, flags);
            if (dsp0TraceFilePtr == NULL) {
                WARN("Failed to open dsp CE log file \"%s\", using stdout\n",
                    fileName);
                dsp0TraceFilePtr = stdout;
            } else {
                fileSetCloseOnExec(dsp0TraceFilePtr);
            }
        }
    }
    else {
        dsp0TraceFilePtr = stdout;
    }

    /* DSP/BIOS trace file */
    fileName = getenv("TRACEUTIL_DSP0BIOSFILE");

    if (fileName == NULL) {
        fileName = TraceUtil_dsp0BiosFile;
    }

    INFO("DSP/BIOS log file name: %s\n", (fileName && fileName[0]) ?
         fileName : "none");

    if (fileName != NULL && fileName[0] != '\0') {
        dsp0BiosFilePtr = fopen(fileName, flags);

        if (dsp0BiosFilePtr == NULL) {
            WARN("Failed to open dsp/bios log file \"%s\", disabling log\n",
                fileName);
        } else {
            fileSetCloseOnExec(dsp0BiosFilePtr);
        }
    }

    /* trace command pipe we open in the separate thread -- because whoever comes
     * first to the pipe is blocked until another pipe party arives. So we don't
     * want to block here, in the main thread, and we only determine its name.
     */
    cmdPipeFile = getenv("TRACEUTIL_CMDPIPE");

    if (cmdPipeFile == NULL) {
        cmdPipeFile = TraceUtil_cmdPipeFile;
    }
    INFO("Command pipe name: %s\n", (cmdPipeFile && cmdPipeFile[0]) ?
         cmdPipeFile : "none");

    /* Set the local trace mask */
    mask = getenv("CE_TRACE");

    if (mask == NULL) {
        mask = TraceUtil_localTraceMask;
    }

    INFO("Arm trace mask: \"%s\"\n", mask);
    GT_set(mask);

    /* Set the remote trace mask */
    dsp0mask = getenv("TRACEUTIL_DSP0TRACEMASK");

    if (dsp0mask == NULL) {
        dsp0mask = TraceUtil_dsp0TraceMask;
    }

    INFO("DSP trace mask: \"%s\"\n", dsp0mask);
    setenv("CE_DSP0TRACE", dsp0mask, 1);

    Global_atexit((Fxn)TraceUtil_exit);
}
Beispiel #11
0
/*
 *  ======== CERuntime_init ========
 */
Void CERuntime_init(Void)
{
    if (ceInit++ == 0) {

        CESettings_init();
        FCSettings_init();


        /* if CE_DEBUG is set, turn on tracing and DSP auto trace collection */
        if (Global_getenv("CE_DEBUG") != NULL) {
            extern Bool   Engine_alwaysCollectDspTrace;
            extern String Engine_ceDebugDspTraceMask;

            Engine_alwaysCollectDspTrace = TRUE;

            /*
             * Note the strategy for setting trace masks below...
             * For any mods not yet registered, we set the
             * [FC|CE]SETTINGS_MODNAME mask.  For any mods already
             * registered, we Diags_setMask() them.
             */

            if (Global_getenv("CE_DEBUG")[0] == '1') {
                /* Turn on CE/FC levels 6 and 7 */
                xdc_runtime_Diags_setMask(CESETTINGS_MODNAME"+67");
                xdc_runtime_Diags_setMask(FCSETTINGS_MODNAME"+67");
                xdc_runtime_Diags_setMask("ti.sdo.ce.%+67");
                xdc_runtime_Diags_setMask("ti.sdo.fc.%+67");

                /* Same for any Servers */
                Engine_ceDebugDspTraceMask = "ti.sdo.ce.%+67;ti.sdo.fc.%+67";
            }
            else if (Global_getenv("CE_DEBUG")[0] == '2') {
                xdc_runtime_Diags_setMask(CESETTINGS_MODNAME"+EX1234567");
                xdc_runtime_Diags_setMask(FCSETTINGS_MODNAME"+EX1234567");
                xdc_runtime_Diags_setMask("ti.sdo.ce.%+EX1234567");
                xdc_runtime_Diags_setMask("ti.sdo.fc.%+EX1234567");

                Engine_ceDebugDspTraceMask =
                    // Current Diags mask: (time=2 ==> display time in delta usec
                    "ti.sdo.ce.%+EX1234567;ti.sdo.fc.%+EX12345678;ti.sdo.ce.rms=67;ti.sdo.fc.dman3-2;ti.sdo.fc.dskt2-2;time=2";
            }
            else if (Global_getenv("CE_DEBUG")[0] == '0') {
                /* Don't set anything if someone tries to turn CE_DEBUG off */
            } else {
                xdc_runtime_Diags_setMask("ti.sdo.ce.%+EX1234567");
                xdc_runtime_Diags_setMask("ti.sdo.fc.%+EX1234567");

                Engine_ceDebugDspTraceMask =
                    "time=2;ti.sdo.fc.%+EX1234567;ti.sdo.ce.%+EX1234567;ti.sdo.fc.dskt2-2";
            }
        }
        else {
            //xdc_runtime_Diags_setMask("ti.sdo.ce.Engine-EX1234567");
            //xdc_runtime_Diags_setMask("ti.sdo.ce.VISA-EX1234567");
        }

        if (Global_getenv("CE_CHECK") != NULL) {
            extern Bool VISA_checked;

            /*
             * Currently just change _this_ processor's value... perhaps we
             * should enable remote processors as well?
             */
            if (Global_getenv("CE_CHECK")[0] == '1') {
                VISA_checked = TRUE;
                xdc_runtime_Diags_setMask("ti.sdo.ce.%+7");
            } else if (Global_getenv("CE_CHECK")[0] == '0') {
                VISA_checked = FALSE;
            } else {
                /* leave it whatever it was. maybe we should drop a warning? */
            }
        }

        /* allow user to over-ride via CE_TRACE. */
        if (Global_getenv("CE_TRACE") != NULL) {
            xdc_runtime_Diags_setMask(Global_getenv("CE_TRACE"));
        }
        Global_init();


        ti_sdo_ce_osal_Memory_init();
        Comm_init();
        Processor_init();
        Algorithm_init();
        XdmUtils_init();

        Trace_init();
        RMS_init();
        Global_atexit((Fxn)RMS_exit);

        Engine_init();
        _VISA_init();
        Loader_init();
       Server_init();
        if ((Global_getenv("CE_DEBUG") != NULL) &&
                (Global_getenv("CE_DEBUG")[0] == '2')) {

            /*
             *  set up masks that must be deferred until the modules have been
             *  initialized.
             */
            //xdc_runtime_Diags_setMask(Comm_MODNAME"-EX12345");
            xdc_runtime_Diags_setMask("ti.sdo.ce.osal.%-EX123");
            //xdc_runtime_Diags_setMask(Algorithm_MODNAME"-EX12345");

            xdc_runtime_Diags_setMask("ti.sdo.ce.Engine-3");
            xdc_runtime_Diags_setMask("ti.sdo.ce.ipc.Comm=67");
        }

        /*
         *  Allow user to over-ride via CE_TRACE. Putting this after module
         *  initialization, since it will have no effect if called before.
         *  Only wildcard settings seem to work when placed before module
         *  initialization.
         */
        if (Global_getenv("CE_TRACE") != NULL) {
            xdc_runtime_Diags_setMask(Global_getenv("CE_TRACE"));
        }
    }
}
/*
 *  ======== Processor_init ========
 */
Void Processor_init(Void)
{
    GateThread_Params params;
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_ipc_processor_desc,
                Processor_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Processor_MODNAME);
        }
        regInit = 1;
    }

    if (curInit != TRUE) {
        curInit = TRUE;

        /* Semaphore with count 0, will be posted when a command is present */
        dcmd.cmdPresent = SemThread_create(0, NULL, NULL);

        /* Semaphore with count 0, will be posted when reply is ready */
        dcmd.replyPresent = SemThread_create(0, NULL, NULL);

        /*
         *  Create lock to allow only one thread at a time to send command
         *  to the daemon.
         */
        GateThread_Params_init(&params);
        dcmd.gate = GateThread_create(&params, NULL);

        if ((dcmd.cmdPresent == NULL) || (dcmd.replyPresent == NULL) ||
                (dcmd.gate == NULL)) {
            // TODO: Shouldn't we abort?
            Log_print0(Diags_USER7, "[+7] Processor_init> ERROR: cannot"
                    " create semaphores or lock");
        }

        Log_print0(Diags_USER2, "[+2] Processor_init> SysLink_setup()...");

        SysLink_setup();
        Log_print0(Diags_USER2, "[+2] Processor_init> "
                "... SysLink_setup() done");

        if ((dcmd.dproc = Thread_create((Thread_RunFxn)daemon, NULL, NULL))
                == NULL) {
            Log_print0(Diags_USER7, "[+7] Processor_init> "
                    "ERROR: cannot create DSP daemon");
        }

        if (Thread_start(NULL) != TRUE) {
            Log_print0(Diags_USER7, "[+7] Processor_init> "
                    "ERROR: cannot start threads");
        }

        Global_atexit((Fxn)cleanup);
    }
}