forked from M-Labs/artiq
runtime: add lognonl{,_va} functions.
The kernels have print(), which prints aggregates (such as arrays) piece-by-piece, and newlines would interfere.
This commit is contained in:
parent
cd294e2986
commit
aae2923c4c
|
@ -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"
|
||||
|
|
|
@ -175,7 +175,11 @@ void kloader_service_essential_kmsg(void)
|
|||
case MESSAGE_TYPE_LOG: {
|
||||
struct msg_log *msg = (struct msg_log *)umsg;
|
||||
|
||||
if(msg->no_newline) {
|
||||
lognonl_va(msg->fmt, msg->args);
|
||||
} else {
|
||||
log_va(msg->fmt, msg->args);
|
||||
}
|
||||
mailbox_acknowledge();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <console.h>
|
||||
|
||||
#include <generated/csr.h>
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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, ...);
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ struct msg_rpc_reply {
|
|||
struct msg_log {
|
||||
int type;
|
||||
const char *fmt;
|
||||
int no_newline;
|
||||
va_list args;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue