This is an automated email from Gerrit.

"Marc Schink <[email protected]>" just uploaded a new patch set to Gerrit, which you 
can find at https://review.openocd.org/c/openocd/+/9717

-- gerrit

commit 8fffe2dac98f78f82dd74547569249d502604dcc
Author: Marc Schink <[email protected]>
Date:   Wed May 20 19:43:56 2026 +0200

    adapter/jtag-vpi: Use adapter core for remote address handling
    
    Use the remote address handling provided by the adapter core instead of
    implementing it directly in the driver.
    
    Keep the legacy commands 'jtag_vpi set_address' and 'jtag_vpi set_port'
    for backwards compatibility, but mark them as deprecated.
    
    Remove the implicit 'localhost' default for 'adapter remote' and require
    an explicit address, matching USB behavior where no connection is made
    to the first available USB device. Legacy commands keep the 'localhost'
    default but now emit a deprecation warning.
    
    Change-Id: Iea86b49db507c99f36477783bb7792a3435535dd
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index c73f886671..267716401d 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -3733,15 +3733,18 @@ This adapter does not support Unix domain sockets.
 @end deffn
 
 @deffn {Interface Driver} {jtag_vpi}
-A JTAG driver acting as a client for the JTAG VPI server interface.
+Adapter driver that acts as a client for a JTAG VPI server.
+The server reference implementation can be found here: 
@url{https://github.com/fjullien/jtag_vpi}.
 
-@deffn {Config Command} {jtag_vpi set_address} address
-Specifies the hostname or IP address of the JTAG VPI server.
-@end deffn
+To connect to a JTAG VPI server on @t{localhost} and port @t{9810}, use:
 
-@deffn {Config Command} {jtag_vpi set_port} port
-Specifies the TCP/IP port number of the JTAG VPI server.
-@end deffn
+@example
+adapter driver jtag_vpi
+adapter remote localhost:9810
+@end example
+
+If no port is specified, the default port @t{5555} is used.
+This adapter does not support Unix domain sockets.
 
 @deffn {Config Command} {jtag_vpi stop_sim_on_exit} (@option{on}|@option{off})
 Specifies whether simulation stop command shall be sent before OpenOCD exits.
diff --git a/src/jtag/drivers/jtag_vpi.c b/src/jtag/drivers/jtag_vpi.c
index 18656b7973..00860c94a8 100644
--- a/src/jtag/drivers/jtag_vpi.c
+++ b/src/jtag/drivers/jtag_vpi.c
@@ -13,6 +13,7 @@
 #include "config.h"
 #endif
 
+#include <jtag/adapter.h>
 #include <jtag/interface.h>
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
@@ -526,19 +527,41 @@ static int jtag_vpi_execute_queue(struct jtag_command 
*cmd_queue)
 
 static int jtag_vpi_init(void)
 {
-       if (!server_address)
-               server_address = strdup(DEFAULT_SERVER_ADDRESS);
-
        const struct addrinfo hints = {
                .ai_family = AF_UNSPEC,
                .ai_socktype = SOCK_STREAM
        };
 
+       const struct adapter_remote *remote = adapter_get_remote();
+       const char *address = remote->address;
+       uint16_t port = remote->port;
+
+       if (remote->address && remote->type == ADAPTER_REMOTE_TYPE_UNIX) {
+               LOG_ERROR("Unix domain socket is not supported by this 
adapter");
+               return ERROR_FAIL;
+       }
+
+       if (!remote->address) {
+               if (!server_address) {
+                       LOG_WARNING("A hostname must be specified in future 
versions, 'localhost' is used for now because none was provided");
+                       server_address = strdup(DEFAULT_SERVER_ADDRESS);
+               }
+
+               LOG_WARNING("DEPRECATED! use 'adapter remote' not 'jtag_vpi 
set_address' and 'jtag_vpi set_port'");
+               address = server_address;
+               port = server_port;
+       }
+
+       if (!port) {
+               port = DEFAULT_SERVER_PORT;
+               LOG_DEBUG("No port specified, using default port %" PRIu16, 
port);
+       }
+
        char port_str[5 + 1];
        snprintf(port_str, sizeof(port_str), "%" PRIu16, server_port);
 
        struct addrinfo *result;
-       int ret = getaddrinfo(server_address, port_str, &hints, &result);
+       int ret = getaddrinfo(address, port_str, &hints, &result);
 
        if (ret != 0) {
                LOG_ERROR("getaddrinfo: %s", gai_strerror(ret));
@@ -558,8 +581,8 @@ static int jtag_vpi_init(void)
        }
 
        if (!rp) {
-               LOG_ERROR("jtag_vpi: Can't connect to %s : %" PRIu16,
-                       server_address, server_port);
+               LOG_ERROR("jtag_vpi: Can't connect to %s : %" PRIu16, address,
+                       port);
                freeaddrinfo(result);
                return ERROR_FAIL;
        }
@@ -588,8 +611,8 @@ static int jtag_vpi_init(void)
 
        freeaddrinfo(result);
 
-       LOG_INFO("jtag_vpi: Connection to %s : %" PRIu16 " successful",
-               server_address, server_port);
+       LOG_INFO("jtag_vpi: Connection to %s : %" PRIu16 " successful", address,
+               port);
 
        return ERROR_OK;
 }

-- 

Reply via email to