semihosting: permit redirection of semihosting I/O to TCP

This command permits the usage of a TCP port to perform debug and stdio
operations:
 - debug : READC, WRITEC and WRITE0
 - stdio : READ, WRITE

This will permit the separation of semihosting message from OpenOCD log,
and separate semihosting messages per core.

syntax: arm semihosting_redirect (disable | tcp <port> [debug|stdio|all])

this allows to select which operations to be performed via TCP (debug,
stdio or all (default)).

Note: for stdio operations, only I/O from/to ':tt' file descriptors are
redirected.

tested using netcat on ubuntu

Change-Id: I37053463667ba109d52429d4f98bc98d0ede298d
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/5562
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Tarek BOCHKATI
2020-04-06 13:30:26 +01:00
committed by Antonio Borneo
parent 4e5dbecd9b
commit b9526f1401
3 changed files with 343 additions and 17 deletions

View File

@@ -26,6 +26,7 @@
#include <stdbool.h>
#include <time.h>
#include "helper/replacements.h"
#include <server/server.h>
/*
* According to:
@@ -95,6 +96,13 @@ enum semihosting_reported_exceptions {
ADP_STOPPED_RUN_TIME_ERROR = ((2 << 16) + 35),
};
enum semihosting_redirect_config {
SEMIHOSTING_REDIRECT_CFG_NONE,
SEMIHOSTING_REDIRECT_CFG_DEBUG,
SEMIHOSTING_REDIRECT_CFG_STDIO,
SEMIHOSTING_REDIRECT_CFG_ALL,
};
struct target;
/*
@@ -105,6 +113,15 @@ struct semihosting {
/** A flag reporting whether semihosting is active. */
bool is_active;
/** Semihosting STDIO file descriptors */
int stdin_fd, stdout_fd, stderr_fd;
/** redirection configuration, NONE by default */
enum semihosting_redirect_config redirect_cfg;
/** Handle to redirect semihosting print via tcp */
struct connection *tcp_connection;
/** A flag reporting whether semihosting fileio is active. */
bool is_fileio;