init and deinit

This commit is contained in:
2025-02-16 19:43:48 +01:00
parent c8bda25d90
commit b66e82da87
4 changed files with 29 additions and 40 deletions

View File

@@ -31,25 +31,26 @@ void jprint(jtag_core *jc, const char *msg)
printf(msg);
}
jtag_core * bsexp_init(void)
jtag_core *bsexp_init(void)
{
jtag_core *jc = NULL;
script_ctx * sctx;
script_ctx *sctx;
/* initialize the JTAG library */
jc = jtagcore_init();
if (NULL == jc) goto end;
if (NULL == jc)
goto end;
jc->envvar = (void*)initEnv(NULL, NULL);
jc->envvar = (void *)initEnv(NULL, NULL);
jtagcore_setEnvVar( jc, "VERSION", "v"LIB_JTAG_CORE_VERSION);
jtagcore_setEnvVar(jc, "VERSION", "v" LIB_JTAG_CORE_VERSION);
sctx = jtagcore_initScript(jc);
execute_ram_script(sctx, config_script, config_script_len );
execute_ram_script(sctx, config_script, config_script_len);
execute_file_script( sctx, "config.script" );
execute_file_script(sctx, "config.script");
/* Log printing callback */
if (jtagcore_set_logs_callback(jc, jprint) < 0)
@@ -58,19 +59,27 @@ jtag_core * bsexp_init(void)
}
else
{
if(jtagcore_getEnvVar( jc, "LOG_MESSAGES_FILTER_LEVEL", NULL))
if (jtagcore_getEnvVar(jc, "LOG_MESSAGES_FILTER_LEVEL", NULL))
{
jtagcore_set_logs_level( jc, jtagcore_getEnvVarValue( jc, "LOG_MESSAGES_FILTER_LEVEL") );
jtagcore_set_logs_level(jc, jtagcore_getEnvVarValue(jc, "LOG_MESSAGES_FILTER_LEVEL"));
}
if(jtagcore_getEnvVar( jc, "LOG_MESSAGES_FILE_OUTPUT", NULL))
{
jtagcore_set_logs_file( jc, jtagcore_getEnvVar( jc, "LOG_MESSAGES_FILE_OUTPUT", NULL) );
}
deinit_script(sctx);
if (jtagcore_getEnvVar(jc, "LOG_MESSAGES_FILE_OUTPUT", NULL))
{
jtagcore_set_logs_file(jc, jtagcore_getEnvVar(jc, "LOG_MESSAGES_FILE_OUTPUT", NULL));
}
}
deinit_script(sctx);
end:
return jc;
}
}
void bsexp_deinit(jtag_core *jc)
{
if (NULL == jc) return;
envvar_entry *env = jc->envvar;
deinitEnv(env);
jtagcore_deinit(jc);
}