19 #ifdef HAVE_ARPA_INET_H 
   20 #include <arpa/inet.h> 
   24 #include <netinet/tcp.h> 
   27 #define SERVER_ADDRESS  "127.0.0.1" 
   28 #define SERVER_PORT 5555 
   42         LOG_ERROR(
"%s: NULL 'buf' argument, file %s, line %d",
 
   43             __func__, __FILE__, __LINE__);
 
   46     if (write(
sockfd, buf, len) != (ssize_t)len) {
 
   47         LOG_ERROR(
"%s: %s, file %s, line %d", __func__,
 
   48             strerror(errno), __FILE__, __LINE__);
 
   57         LOG_ERROR(
"%s: NULL 'buf' argument, file %s, line %d",
 
   58             __func__, __FILE__, __LINE__);
 
   61     if (read(
sockfd, buf, len) != (ssize_t)len) {
 
   62         LOG_ERROR(
"%s: %s, file %s, line %d", __func__,
 
   63             strerror(errno), __FILE__, __LINE__);
 
   76     char *buf = 
"reset\n";
 
   79     LOG_DEBUG_IO(
"JTAG DRIVER DEBUG: reset trst: %i srst %i", trst, srst);
 
   85             LOG_ERROR(
"write_sock() fail, file %s, line %d",
 
  116         LOG_ERROR(
"jtag_build_buffer call failed, data_buf == NULL, " 
  117             "file %s, line %d", __FILE__, __LINE__);
 
  124         last_ir_buf = (uint8_t *)malloc(bytes * 
sizeof(uint8_t));
 
  126             LOG_ERROR(
"%s: malloc fail, file %s, line %d",
 
  127                 __func__, __FILE__, __LINE__);
 
  134     snprintf(buf, 
sizeof(buf), 
"%s %d\n", 
cmd->ir_scan ? 
"ib" : 
"db", num_bits);
 
  137         LOG_ERROR(
"write_sock() fail, file %s, line %d",
 
  143         LOG_ERROR(
"write_sock() fail, file %s, line %d",
 
  147     ret = 
read_sock((
char *)data_buf, bytes);
 
  149         LOG_ERROR(
"read_sock() fail, file %s, line %d",
 
  156         LOG_ERROR(
"jtag_read_buffer() fail, file %s, line %d",
 
  174         LOG_ERROR(
"%s: NULL 'data_buf' argument, file %s, line %d",
 
  175             __func__, __FILE__, __LINE__);
 
  179         LOG_ERROR(
"%s: 'num_bits' invalid value, file %s, line %d",
 
  180             __func__, __FILE__, __LINE__);
 
  185     read_scan = (uint8_t *)malloc(bytes * 
sizeof(uint8_t));
 
  187         LOG_ERROR(
"%s: malloc fail, file %s, line %d",
 
  188             __func__, __FILE__, __LINE__);
 
  191     snprintf(buf, 
sizeof(buf), 
"ib %d\n", num_bits);
 
  192     while (num_cycles > 0) {
 
  195             LOG_ERROR(
"write_sock() fail, file %s, line %d",
 
  201             LOG_ERROR(
"write_sock() fail, file %s, line %d",
 
  205         ret = 
read_sock((
char *)read_scan, bytes);
 
  207             LOG_ERROR(
"read_sock() fail, file %s, line %d",
 
  212         num_cycles -= num_bits + 6;
 
  257             LOG_ERROR(
"BUG: unknown JTAG command type 0x%X",
 
  269     sockfd = socket(AF_INET, SOCK_STREAM, 0);
 
  271         LOG_ERROR(
"socket: %s, function %s, file %s, line %d",
 
  272             strerror(errno), __func__, __FILE__, __LINE__);
 
  284             LOG_ERROR(
"%s: strdup fail, file %s, line %d",
 
  285                 __func__, __FILE__, __LINE__);
 
  292     if (
serv_addr.sin_addr.s_addr == INADDR_NONE) {
 
  302     if (
serv_addr.sin_addr.s_addr == htonl(INADDR_LOOPBACK)) {
 
  307         setsockopt(
sockfd, IPPROTO_TCP, TCP_NODELAY, (
char *)&
flag, 
sizeof(
int));
 
  345                 LOG_ERROR(
"%s: strdup fail, file %s, line %d",
 
  346                     __func__, __FILE__, __LINE__);
 
  355             LOG_ERROR(
"%s: strdup fail, file %s, line %d",
 
  356                 __func__, __FILE__, __LINE__);
 
  368         .handler = &jtag_dpi_set_port,
 
  370         .help = 
"set the port of the DPI server",
 
  374         .name = 
"set_address",
 
  375         .handler = &jtag_dpi_set_address,
 
  377         .help = 
"set the address of the DPI server",
 
  378         .usage = 
"[address]",
 
  387         .help = 
"perform jtag_dpi management",
 
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer)
int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd)
#define DEBUG_CAP_TMS_SEQ
void jtag_sleep(uint32_t us)
static struct jtag_interface jtag_dpi_interface
static int jtag_dpi_runtest(unsigned int num_cycles)
static int jtag_dpi_reset(int trst, int srst)
jtag_dpi_reset - ask to reset the JTAG device
static int last_ir_num_bits
static const struct command_registration jtag_dpi_command_handlers[]
static int jtag_dpi_stableclocks(unsigned int num_cycles)
static int jtag_dpi_execute_queue(struct jtag_command *cmd_queue)
static const struct command_registration jtag_dpi_subcommand_handlers[]
static uint8_t * last_ir_buf
static int write_sock(char *buf, size_t len)
static uint16_t server_port
COMMAND_HANDLER(jtag_dpi_set_port)
static int read_sock(char *buf, size_t len)
static int jtag_dpi_quit(void)
static int jtag_dpi_scan(struct scan_command *cmd)
jtag_dpi_scan - launches a DR-scan or IR-scan
static struct sockaddr_in serv_addr
static int jtag_dpi_init(void)
static char * server_address
struct adapter_driver jtag_dpi_adapter_driver
#define LOG_DEBUG_IO(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
const char * usage
a string listing the options and arguments, required or optional
Represents a driver for a debugging interface.
unsigned int supported
Bit vector listing capabilities exposed by this driver.
The scan_command provide a means of encapsulating a set of scan_field structures that should be scann...
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.