code refactoring

This commit is contained in:
2025-02-16 19:32:01 +01:00
parent f3c2569a30
commit c8bda25d90
42 changed files with 439 additions and 543 deletions

View File

@@ -1,3 +1,5 @@
#ifndef _SCRIPT_H
#define _SCRIPT_H
/*
* JTAG Boundary Scanner
* Copyright (c) 2008 - 2024 Viveris Technologies
@@ -23,64 +25,15 @@
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
*/
#define _script_ctx_
#ifndef _script_printf_func_
typedef int (* SCRIPT_PRINTF_FUNC)(void * ctx, int MSGTYPE, char * string, ... );
#define _script_printf_func_
#endif
#ifdef SCRIPT_64BITS_SUPPORT
#define env_var_value uint64_t
#define STRTOVALUE strtoull
#define LONGHEXSTR "%llX"
#else
#define env_var_value uint32_t
#define STRTOVALUE strtoul
#define LONGHEXSTR "%.8X"
#endif
#define MAX_LABEL_SIZE 64
#define MAX_LABEL 256
typedef struct _script_label
{
char label_name[MAX_LABEL_SIZE];
unsigned int offset;
} script_label;
typedef struct _script_ctx
{
SCRIPT_PRINTF_FUNC script_printf;
void * app_ctx;
void * env;
void * cmdlist;
FILE * script_file;
char script_file_path[1024];
int cur_label_index;
script_label labels[MAX_LABEL];
int cur_script_offset;
int dry_run;
int last_error_code;
env_var_value last_data_value;
int last_flags;
char pre_command[1024 + 32];
uint32_t rand_seed;
} script_ctx;
#include "config/bs_defines.h"
script_ctx *jtagcore_initScript(jtag_core *jc);
script_ctx * init_script(void * app_ctx, unsigned int flags, void * env);
int execute_file_script( script_ctx * ctx, char * filename );
int execute_line_script( script_ctx * ctx, char * line );
int execute_ram_script( script_ctx * ctx, unsigned char * script_buffer, int buffersize );
void setOutputFunc_script( script_ctx * ctx, SCRIPT_PRINTF_FUNC ext_printf );
script_ctx * deinit_script(script_ctx * ctx);
int jtagcore_savePinsStateScript(jtag_core *jc, int device, char *script_path);
#endif