]> git.sur5r.net Git - openocd/commitdiff
jtag_vpi: make the server address configurable
authorFranck Jullien <franck.jullien@gmail.com>
Sun, 29 Dec 2013 15:18:51 +0000 (16:18 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Tue, 31 Dec 2013 12:00:49 +0000 (12:00 +0000)
Change-Id: I58e89c789b79ffb0b54ef94d208be876c271ddf7
Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Reviewed-on: http://openocd.zylin.com/1840
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/jtag/drivers/jtag_vpi.c
tcl/interface/jtag_vpi.cfg

index 29dbd4821eeeba3234798aff0b16f0cdd4fc1256..7c42220d62ef4c9e357db54a7bd0faad23d28d4e 100644 (file)
@@ -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
 };
 
index 2756b254f42be92e49813ef63d38c3dd98080a25..a37a11ed058fb10bb7e71e8cd157bc44611362d3 100644 (file)
@@ -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