diff --git a/artiq/compiler/targets.py b/artiq/compiler/targets.py index e0715674b..1b89e039e 100644 --- a/artiq/compiler/targets.py +++ b/artiq/compiler/targets.py @@ -83,4 +83,4 @@ class NativeTarget(Target): class OR1KTarget(Target): triple = "or1k-linux" attributes = ["mul", "div", "ffl1", "cmov", "addc"] - print_function = "log" + print_function = "lognonl" diff --git a/soc/runtime/kloader.c b/soc/runtime/kloader.c index 0cdf56634..136fd7cbb 100644 --- a/soc/runtime/kloader.c +++ b/soc/runtime/kloader.c @@ -175,7 +175,11 @@ void kloader_service_essential_kmsg(void) case MESSAGE_TYPE_LOG: { struct msg_log *msg = (struct msg_log *)umsg; - log_va(msg->fmt, msg->args); + if(msg->no_newline) { + lognonl_va(msg->fmt, msg->args); + } else { + log_va(msg->fmt, msg->args); + } mailbox_acknowledge(); break; } diff --git a/soc/runtime/ksupport.c b/soc/runtime/ksupport.c index eb7a784b7..8e8677059 100644 --- a/soc/runtime/ksupport.c +++ b/soc/runtime/ksupport.c @@ -147,12 +147,25 @@ int rpc(int rpc_num, ...) return retval; } +void lognonl(const char *fmt, ...) +{ + struct msg_log request; + + request.type = MESSAGE_TYPE_LOG; + request.fmt = fmt; + request.no_newline = 1; + va_start(request.args, fmt); + mailbox_send_and_wait(&request); + va_end(request.args); +} + void log(const char *fmt, ...) { struct msg_log request; request.type = MESSAGE_TYPE_LOG; request.fmt = fmt; + request.no_newline = 0; va_start(request.args, fmt); mailbox_send_and_wait(&request); va_end(request.args); diff --git a/soc/runtime/log.c b/soc/runtime/log.c index 4f1750f2f..ebc7990ec 100644 --- a/soc/runtime/log.c +++ b/soc/runtime/log.c @@ -1,5 +1,6 @@ #include #include +#include #include @@ -8,7 +9,7 @@ static int buffer_index; static char buffer[LOG_BUFFER_SIZE]; -void log_va(const char *fmt, va_list args) +void lognonl_va(const char *fmt, va_list args) { char outbuf[256]; int i, len; @@ -18,16 +19,29 @@ void log_va(const char *fmt, va_list args) buffer[buffer_index] = outbuf[i]; buffer_index = (buffer_index + 1) % LOG_BUFFER_SIZE; } - buffer[buffer_index] = '\n'; - buffer_index = (buffer_index + 1) % LOG_BUFFER_SIZE; #ifdef CSR_ETHMAC_BASE /* Since main comms are over ethernet, the serial port * is free for us to use. */ - puts(outbuf); + putsnonl(outbuf); #endif } +void lognonl(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + lognonl_va(fmt, args); + va_end(args); +} + +void log_va(const char *fmt, va_list args) +{ + lognonl_va(fmt, args); + lognonl("\n"); +} + void log(const char *fmt, ...) { va_list args; diff --git a/soc/runtime/log.h b/soc/runtime/log.h index 814155b1c..0fb7ce8b1 100644 --- a/soc/runtime/log.h +++ b/soc/runtime/log.h @@ -5,6 +5,9 @@ #define LOG_BUFFER_SIZE 4096 +void lognonl_va(const char *fmt, va_list args); +void lognonl(const char *fmt, ...); + void log_va(const char *fmt, va_list args); void log(const char *fmt, ...); diff --git a/soc/runtime/messages.h b/soc/runtime/messages.h index 221b394a3..b0685105d 100644 --- a/soc/runtime/messages.h +++ b/soc/runtime/messages.h @@ -80,6 +80,7 @@ struct msg_rpc_reply { struct msg_log { int type; const char *fmt; + int no_newline; va_list args; };