drivers/jtag_vpi: Added "jtag_vpi:" prefixes to log messages
[fw/openocd] / src / jtag / drivers / jtag_vpi.c
index a6609d21ec04910c13d61451df6660d7705d99ce..0fc688edf2bc9c2917a9a0807e46af824a4edb04 100644 (file)
@@ -33,7 +33,7 @@
 #include <netinet/tcp.h>
 #endif
 
-#include <string.h>
+#include "helper/replacements.h"
 
 #define NO_TAP_SHIFT   0
 #define TAP_SHIFT      1
@@ -159,7 +159,7 @@ retry_write:
                /* This means we could not send all data, which is most likely fatal
                   for the jtag_vpi connection (the underlying TCP connection likely not
                   usable anymore) */
-               LOG_ERROR("Could not send all data through jtag_vpi connection.");
+               LOG_ERROR("jtag_vpi: Could not send all data through jtag_vpi connection.");
                exit(-1);
        }
 
@@ -227,8 +227,8 @@ static int jtag_vpi_reset(int trst, int srst)
  * @param nb_bits number of TMS bits (between 1 and 8)
  *
  * Write a series of TMS transitions, where each transition consists in :
- *  - writing out TCK=0, TMS=<new_state>, TDI=<???>
- *  - writing out TCK=1, TMS=<new_state>, TDI=<???> which triggers the transition
+ *  - writing out TCK=0, TMS=\<new_state>, TDI=\<???>
+ *  - writing out TCK=1, TMS=\<new_state>, TDI=\<???> which triggers the transition
  * The function ensures that at the end of the sequence, the clock (TCK) is put
  * low.
  */
@@ -253,8 +253,8 @@ static int jtag_vpi_tms_seq(const uint8_t *bits, int nb_bits)
  * @param cmd path transition
  *
  * Write a series of TMS transitions, where each transition consists in :
- *  - writing out TCK=0, TMS=<new_state>, TDI=<???>
- *  - writing out TCK=1, TMS=<new_state>, TDI=<???> which triggers the transition
+ *  - writing out TCK=0, TMS=\<new_state>, TDI=\<???>
+ *  - writing out TCK=1, TMS=\<new_state>, TDI=\<???> which triggers the transition
  * The function ensures that at the end of the sequence, the clock (TCK) is put
  * low.
  */
@@ -344,6 +344,7 @@ static int jtag_vpi_queue_tdi_xfer(uint8_t *bits, int nb_bits, int tap_shift)
  * jtag_vpi_queue_tdi - short description
  * @param bits bits to be queued on TDI (or NULL if 0 are to be queued)
  * @param nb_bits number of bits
+ * @param tap_shift
  */
 static int jtag_vpi_queue_tdi(uint8_t *bits, int nb_bits, int tap_shift)
 {
@@ -495,7 +496,7 @@ static int jtag_vpi_execute_queue(void)
        struct jtag_command *cmd;
        int retval = ERROR_OK;
 
-       for (cmd = jtag_command_queue; retval == ERROR_OK && cmd != NULL;
+       for (cmd = jtag_command_queue; retval == ERROR_OK && cmd;
             cmd = cmd->next) {
                switch (cmd->type) {
                case JTAG_RESET:
@@ -540,7 +541,7 @@ static int jtag_vpi_init(void)
 
        sockfd = socket(AF_INET, SOCK_STREAM, 0);
        if (sockfd < 0) {
-               LOG_ERROR("Could not create socket");
+               LOG_ERROR("jtag_vpi: Could not create client socket");
                return ERROR_FAIL;
        }
 
@@ -555,13 +556,13 @@ static int jtag_vpi_init(void)
        serv_addr.sin_addr.s_addr = inet_addr(server_address);
 
        if (serv_addr.sin_addr.s_addr == INADDR_NONE) {
-               LOG_ERROR("inet_addr error occurred");
+               LOG_ERROR("jtag_vpi: inet_addr error occurred");
                return ERROR_FAIL;
        }
 
        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("jtag_vpi: Can't connect to %s : %u", server_address, server_port);
                return ERROR_COMMAND_CLOSE_CONNECTION;
        }
 
@@ -572,7 +573,7 @@ static int jtag_vpi_init(void)
                setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
        }
 
-       LOG_INFO("Connection to %s : %u succeed", server_address, server_port);
+       LOG_INFO("jtag_vpi: Connection to %s : %u successful", server_address, server_port);
 
        return ERROR_OK;
 }
@@ -639,23 +640,23 @@ COMMAND_HANDLER(jtag_vpi_stop_sim_on_exit_handler)
        return ERROR_OK;
 }
 
-static const struct command_registration jtag_vpi_command_handlers[] = {
+static const struct command_registration jtag_vpi_subcommand_handlers[] = {
        {
-               .name = "jtag_vpi_set_port",
+               .name = "set_port",
                .handler = &jtag_vpi_set_port,
                .mode = COMMAND_CONFIG,
                .help = "set the port of the VPI server",
                .usage = "tcp_port_num",
        },
        {
-               .name = "jtag_vpi_set_address",
+               .name = "set_address",
                .handler = &jtag_vpi_set_address,
                .mode = COMMAND_CONFIG,
                .help = "set the address of the VPI server",
                .usage = "ipv4_addr",
        },
        {
-               .name = "jtag_vpi_stop_sim_on_exit",
+               .name = "stop_sim_on_exit",
                .handler = &jtag_vpi_stop_sim_on_exit_handler,
                .mode = COMMAND_CONFIG,
                .help = "Configure if simulation stop command shall be sent "
@@ -665,6 +666,17 @@ static const struct command_registration jtag_vpi_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
+static const struct command_registration jtag_vpi_command_handlers[] = {
+       {
+               .name = "jtag_vpi",
+               .mode = COMMAND_ANY,
+               .help = "perform jtag_vpi management",
+               .chain = jtag_vpi_subcommand_handlers,
+               .usage = "",
+       },
+       COMMAND_REGISTRATION_DONE
+};
+
 static struct jtag_interface jtag_vpi_interface = {
        .supported = DEBUG_CAP_TMS_SEQ,
        .execute_queue = jtag_vpi_execute_queue,