Files
bs_explorer/modules/config/bs_defines.h
François Dausseur 5dfe5b123e compiles and works
2025-02-18 11:36:18 +01:00

195 lines
3.9 KiB
C

#ifndef _BS_TYPES_H
#define _BS_TYPES_H
#include <stdio.h>
#include <stdint.h>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Functions Error / return codes
#define JTAG_CORE_NO_ERROR 0
#define JTAG_CORE_BAD_PARAMETER -1
#define JTAG_CORE_ACCESS_ERROR -2
#define JTAG_CORE_IO_ERROR -3
#define JTAG_CORE_MEM_ERROR -4
#define JTAG_CORE_NO_PROBE -5
#define JTAG_CORE_NOT_FOUND -6
#define JTAG_CORE_CMD_NOT_FOUND -7
#define JTAG_CORE_INTERNAL_ERROR -8
#define JTAG_CORE_BAD_CMD -9
#define JTAG_CORE_I2C_BUS_NOTFREE -10
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#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
#define DEFAULT_BUFLEN 1024
enum {
GET_DRV_ID = 1,
GET_DRV_DESCRIPTION,
GET_DRV_FUNCPTR,
GET_DRV_DETECT
};
// Output message types/levels
enum MSGTYPE
{
MSG_DEBUG = 0,
MSG_INFO_0,
MSG_INFO_1,
MSG_WARNING,
MSG_ERROR,
MSG_NONE
};
typedef struct _script_label
{
char label_name[MAX_LABEL_SIZE];
unsigned int offset;
} script_label;
typedef struct _script_ctx script_ctx;
typedef int (*SCRIPT_PRINTF_FUNC)(script_ctx * ctx, enum MSGTYPE typ, char *string, ...);
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;
#define MAX_NB_JTAG_DEVICE 64
#define MAX_NUMBER_BITS_IN_CHAIN (256 * 1024)
#define MAX_NUMBER_PINS_PER_DEV (64 * 1024)
#define MAX_BSDL_FILE_SIZE (1024 * 1024)
#define MAX_NUMBER_OF_BSDL_LINES (64 * 1024)
#define MAX_PATH_LEN 4096
typedef struct _jtag_device
{
void *bsdl;
unsigned long devices_id;
unsigned char *out_boundary_scan;
unsigned char *in_boundary_scan;
int boundary_scan_size;
int scan_mode;
} jtag_device;
#define MAX_BUS_WIDTH 32
typedef struct _jtag_core jtag_core;
typedef int (*DRV_DETECT) (jtag_core* jc);
typedef int (*DRV_INIT) (jtag_core* jc,int sub_drv,char * params);
typedef int (*DRV_TXRXDATA) (jtag_core* jc, unsigned char * str_out, unsigned char * str_in, int size);
typedef int (*DRV_TXTMS) (jtag_core* jc, unsigned char * str_out, int size);
typedef int (*DRV_GETMODULEINFOS) (jtag_core* jc,int sub_drv,unsigned int infotype, void * returnvalue);
typedef int (*DRV_DEINIT) (jtag_core* jc);
typedef struct drv_ptr_
{
DRV_DETECT drv_Detect;
DRV_INIT drv_Init;
DRV_DEINIT drv_DeInit;
DRV_TXTMS drv_TX_TMS;
DRV_TXRXDATA drv_TXRX_DATA;
DRV_GETMODULEINFOS drv_Get_ModInfos;
} drv_ptr;
typedef struct _jtag_core
{
drv_ptr io_functions;
void *jtagcore_print_callback;
int logs_level;
void *envvar;
int t;
int nb_of_devices_in_chain;
int total_IR_lenght;
jtag_device devices_list[MAX_NB_JTAG_DEVICE];
int IR_filled;
// I2C over JTAG
int i2c_sda_device;
int i2c_scl_device;
int i2c_sda_pin;
int i2c_scl_pin;
// SPI over JTAG
int spi_mosi_device;
int spi_miso_device;
int spi_cs_device;
int spi_clk_device;
int spi_mosi_pin;
int spi_miso_pin;
int spi_cs_pin;
int spi_clk_pin;
int spi_cs_pol;
int spi_clk_pol;
int spi_mosi_pol;
int spi_miso_pol;
int spi_lsb_first;
// MDIO over JTAG
int mdio_mdc_pin;
int mdio_mdc_device;
int mdio_mdio_pin;
int mdio_mdio_device;
// Memory over JTAG
int ram_address_pin[MAX_BUS_WIDTH];
int ram_address_device[MAX_BUS_WIDTH];
int ram_data_pin[MAX_BUS_WIDTH];
int ram_data_device[MAX_BUS_WIDTH];
int ram_ctrl_pin[16];
int ram_ctrl_pin_pol[16];
int ram_ctrl_device[16];
char log_file_path[MAX_PATH_LEN];
} jtag_core;
#endif