init and deinit
This commit is contained in:
39
bs/init.c
39
bs/init.c
@@ -31,25 +31,26 @@ void jprint(jtag_core *jc, const char *msg)
|
|||||||
printf(msg);
|
printf(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
jtag_core * bsexp_init(void)
|
jtag_core *bsexp_init(void)
|
||||||
{
|
{
|
||||||
jtag_core *jc = NULL;
|
jtag_core *jc = NULL;
|
||||||
script_ctx * sctx;
|
script_ctx *sctx;
|
||||||
|
|
||||||
/* initialize the JTAG library */
|
/* initialize the JTAG library */
|
||||||
jc = jtagcore_init();
|
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);
|
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 */
|
/* Log printing callback */
|
||||||
if (jtagcore_set_logs_callback(jc, jprint) < 0)
|
if (jtagcore_set_logs_callback(jc, jprint) < 0)
|
||||||
@@ -58,19 +59,27 @@ jtag_core * bsexp_init(void)
|
|||||||
}
|
}
|
||||||
else
|
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))
|
if (jtagcore_getEnvVar(jc, "LOG_MESSAGES_FILE_OUTPUT", NULL))
|
||||||
{
|
{
|
||||||
jtagcore_set_logs_file( jc, jtagcore_getEnvVar( jc, "LOG_MESSAGES_FILE_OUTPUT", NULL) );
|
jtagcore_set_logs_file(jc, jtagcore_getEnvVar(jc, "LOG_MESSAGES_FILE_OUTPUT", NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit_script(sctx);
|
|
||||||
}
|
}
|
||||||
|
deinit_script(sctx);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
return jc;
|
return jc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bsexp_deinit(jtag_core *jc)
|
||||||
|
{
|
||||||
|
if (NULL == jc) return;
|
||||||
|
|
||||||
|
envvar_entry *env = jc->envvar;
|
||||||
|
deinitEnv(env);
|
||||||
|
jtagcore_deinit(jc);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef _BS_INIT_H
|
#ifndef _BS_INIT_H
|
||||||
#define _BS_INIT_H
|
#define _BS_INIT_H
|
||||||
|
|
||||||
#include "jtag_core/jtag_core.h"
|
#include "config/bs_defines.h"
|
||||||
|
|
||||||
typedef int (*command_call)(jtag_core *jc, int argc, char *argv[]);
|
typedef int (*command_call)(jtag_core *jc, int argc, char *argv[]);
|
||||||
|
|
||||||
@@ -13,5 +13,6 @@ typedef struct {
|
|||||||
extern Command commands[];
|
extern Command commands[];
|
||||||
|
|
||||||
jtag_core *bsexp_init(void);
|
jtag_core *bsexp_init(void);
|
||||||
|
void bsexp_deinit(jtag_core *jc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -115,4 +115,6 @@ int main() {
|
|||||||
|
|
||||||
err:
|
err:
|
||||||
return error;
|
return error;
|
||||||
|
end:
|
||||||
|
bsexp_deinit(jc);
|
||||||
}
|
}
|
||||||
@@ -47,29 +47,6 @@ jtag_core * jtagcore_init()
|
|||||||
if ( jc )
|
if ( jc )
|
||||||
{
|
{
|
||||||
memset( jc, 0, sizeof(jtag_core) );
|
memset( jc, 0, sizeof(jtag_core) );
|
||||||
/*
|
|
||||||
jc->envvar = (void*)initEnv(NULL, NULL);
|
|
||||||
|
|
||||||
jtagcore_setEnvVar( jc, "LIBVERSION", "v"jtag_core_VERSION);
|
|
||||||
|
|
||||||
sctx = jtagcore_initScript(jc);
|
|
||||||
|
|
||||||
jtagcore_execScriptRam( sctx, config_script, config_script_len );
|
|
||||||
|
|
||||||
jtagcore_execScriptFile( sctx, "config.script" );
|
|
||||||
|
|
||||||
if(jtagcore_getEnvVar( jc, "LOG_MESSAGES_FILTER_LEVEL", NULL))
|
|
||||||
{
|
|
||||||
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) );
|
|
||||||
}
|
|
||||||
|
|
||||||
jtagcore_deinitScript(sctx);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return jc;
|
return jc;
|
||||||
|
|||||||
Reference in New Issue
Block a user