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/+/9716

-- gerrit

commit fb759c732abf180e754169ac8223ffb7123aad9e
Author: Marc Schink <[email protected]>
Date:   Wed May 20 18:43:23 2026 +0200

    adapter/jtag-dpi: 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_dpi set_address' and 'jtag_dpi 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: I127b56874944ca124bfd810d5e71c2ef5a08885b
    Signed-off-by: Marc Schink <[email protected]>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index e78c599d22..c73f886671 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -3718,17 +3718,18 @@ Both values can use hexadecimal notation with prefix 0x.
 @end deffn
 
 @deffn {Interface Driver} {jtag_dpi}
-SystemVerilog Direct Programming Interface (DPI) compatible driver for
-JTAG devices in emulation. The driver acts as a client for the SystemVerilog
-DPI server interface.
+SystemVerilog Direct Programming Interface (DPI) compatible driver for JTAG
+devices in emulation. The driver acts as a client of a SystemVerilog DPI 
server.
 
-@deffn {Config Command} {jtag_dpi set_port} port
-Specifies the TCP/IP port number of the SystemVerilog DPI server interface.
-@end deffn
+To connect to a JTAG DPI server on @t{localhost} and port @t{9810}, use:
 
-@deffn {Config Command} {jtag_dpi set_address} address
-Specifies the hostname or IP address of the SystemVerilog DPI server interface.
-@end deffn
+@example
+adapter driver jtag_dpi
+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.
 @end deffn
 
 @deffn {Interface Driver} {jtag_vpi}
diff --git a/src/jtag/drivers/jtag_dpi.c b/src/jtag/drivers/jtag_dpi.c
index d5a42b1fb1..a2aa8152b6 100644
--- a/src/jtag/drivers/jtag_dpi.c
+++ b/src/jtag/drivers/jtag_dpi.c
@@ -15,6 +15,7 @@
 #include "config.h"
 #endif
 
+#include <jtag/adapter.h>
 #include <jtag/interface.h>
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
@@ -266,25 +267,46 @@ static int jtag_dpi_execute_queue(struct jtag_command 
*cmd_queue)
 
 static int jtag_dpi_init(void)
 {
-       if (!server_address) {
-               server_address = strdup(SERVER_ADDRESS);
-               if (!server_address) {
-                       LOG_ERROR("%s: strdup fail, file %s, line %d",
-                               __func__, __FILE__, __LINE__);
-                       return ERROR_FAIL;
-               }
-       }
-
        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(SERVER_ADDRESS);
+                       if (!server_address) {
+                               LOG_ERROR("%s: strdup fail, file %s, line %d",
+                                       __func__, __FILE__, __LINE__);
+                               return ERROR_FAIL;
+                       }
+               }
+
+               LOG_WARNING("DEPRECATED! use 'adapter remote' not 'jtag_dpi 
set_address' and 'jtag_dpi set_port'");
+               address = server_address;
+               port = server_port;
+       }
+
+       if (!port) {
+               port = 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);
+       snprintf(port_str, sizeof(port_str), "%" PRIu16, 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));
@@ -304,8 +326,7 @@ static int jtag_dpi_init(void)
        }
 
        if (!rp) {
-               LOG_ERROR("Can't connect to %s : %" PRIu16, server_address,
-                       server_port);
+               LOG_ERROR("Can't connect to %s : %" PRIu16, address, port);
                freeaddrinfo(result);
                return ERROR_FAIL;
        }
@@ -334,7 +355,7 @@ static int jtag_dpi_init(void)
 
        freeaddrinfo(result);
 
-       LOG_INFO("Connection to %s : %" PRIu16 " succeed", server_address, 
server_port);
+       LOG_INFO("Connection to %s : %" PRIu16 " succeed", address, port);
 
        return ERROR_OK;
 }

-- 

Reply via email to