From: Franck Jullien Date: Sun, 29 Dec 2013 15:18:51 +0000 (+0100) Subject: jtag_vpi: make the server address configurable X-Git-Tag: v0.8.0-rc1~142 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bc256b17d5e659dff56b33217a2aca94d38cc010;p=openocd jtag_vpi: make the server address configurable Change-Id: I58e89c789b79ffb0b54ef94d208be876c271ddf7 Signed-off-by: Franck Jullien Reviewed-on: http://openocd.zylin.com/1840 Tested-by: jenkins Reviewed-by: Spencer Oliver --- diff --git a/src/jtag/drivers/jtag_vpi.c b/src/jtag/drivers/jtag_vpi.c index 29dbd482..7c42220d 100644 --- a/src/jtag/drivers/jtag_vpi.c +++ b/src/jtag/drivers/jtag_vpi.c @@ -42,6 +42,7 @@ #define CMD_STOP_SIMU 4 int server_port = SERVER_PORT; +char *server_address; int sockfd; struct sockaddr_in serv_addr; @@ -379,7 +380,10 @@ static int jtag_vpi_init(void) serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(server_port); - serv_addr.sin_addr.s_addr = inet_addr(SERVER_ADDRESS); + if (!server_address) + server_address = strdup(SERVER_ADDRESS); + + serv_addr.sin_addr.s_addr = inet_addr(server_address); if (serv_addr.sin_addr.s_addr == INADDR_NONE) { LOG_ERROR("inet_addr error occured"); @@ -388,17 +392,18 @@ static int jtag_vpi_init(void) if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { close(sockfd); - LOG_ERROR("Can't connect to %s : %u", SERVER_ADDRESS, server_port); + LOG_ERROR("Can't connect to %s : %u", server_address, server_port); return ERROR_COMMAND_CLOSE_CONNECTION; } - LOG_INFO("Connection to %s : %u succeed", SERVER_ADDRESS, server_port); + LOG_INFO("Connection to %s : %u succeed", server_address, server_port); return ERROR_OK; } static int jtag_vpi_quit(void) { + free(server_address); return close(sockfd); } @@ -414,6 +419,20 @@ COMMAND_HANDLER(jtag_vpi_set_port) return ERROR_OK; } +COMMAND_HANDLER(jtag_vpi_set_address) +{ + free(server_address); + + if (CMD_ARGC == 0) { + LOG_WARNING("You need to set an address"); + server_address = strdup(SERVER_ADDRESS); + } else + server_address = strdup(CMD_ARGV[0]); + + LOG_INFO("Set server address to %s", server_address); + + return ERROR_OK; +} static const struct command_registration jtag_vpi_command_handlers[] = { { @@ -423,6 +442,13 @@ static const struct command_registration jtag_vpi_command_handlers[] = { .help = "set the port of the VPI server", .usage = "description_string", }, + { + .name = "jtag_vpi_set_address", + .handler = &jtag_vpi_set_address, + .mode = COMMAND_CONFIG, + .help = "set the address of the VPI server", + .usage = "description_string", + }, COMMAND_REGISTRATION_DONE }; diff --git a/tcl/interface/jtag_vpi.cfg b/tcl/interface/jtag_vpi.cfg index 2756b254..a37a11ed 100644 --- a/tcl/interface/jtag_vpi.cfg +++ b/tcl/interface/jtag_vpi.cfg @@ -1,10 +1,18 @@ interface jtag_vpi -# Set the VPI JTAG server address +# Set the VPI JTAG server port if { [info exists VPI_PORT] } { set _VPI_PORT $VPI_PORT } else { - set _VPI_PORT 50020 + set _VPI_PORT 5555 +} + +# Set the VPI JTAG server address +if { [info exists VPI_ADDRESS] } { + set _VPI_ADDRESS $VPI_ADDRESS +} else { + set _VPI_ADDRESS "127.0.0.1" } jtag_vpi_set_port $_VPI_PORT +jtag_vpi_set_address $_VPI_ADDRESS