mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
Make rtio_log() accept variable number of arguments.
This commit is contained in:
parent
cd7f12e4b1
commit
b9448c069a
@ -103,6 +103,7 @@ static const struct symbol runtime_exports[] = {
|
||||
{"watchdog_clear", &watchdog_clear},
|
||||
|
||||
{"core_log", &core_log},
|
||||
{"rtio_log", &rtio_log},
|
||||
{"send_rpc", &send_rpc},
|
||||
{"recv_rpc", &recv_rpc},
|
||||
|
||||
|
@ -39,25 +39,28 @@ void rtio_process_exceptional_status(int status, long long int timestamp, int ch
|
||||
}
|
||||
}
|
||||
|
||||
void rtio_log(long long int timestamp, char *message)
|
||||
void rtio_log_va(long long int timestamp, const char *fmt, va_list args)
|
||||
{
|
||||
unsigned int word;
|
||||
int i;
|
||||
// This executes on the kernel CPU's stack, which is specifically designed
|
||||
// for allocation of this kind of massive buffers.
|
||||
int len = vsnprintf(NULL, 0, fmt, args);
|
||||
char *buf = __builtin_alloca(len + 1);
|
||||
vsnprintf(buf, len + 1, fmt, args);
|
||||
|
||||
rtio_chan_sel_write(CONFIG_RTIO_LOG_CHANNEL);
|
||||
rtio_o_timestamp_write(timestamp);
|
||||
|
||||
i = 0;
|
||||
word = 0;
|
||||
int i = 0;
|
||||
unsigned int word = 0;
|
||||
while(1) {
|
||||
word <<= 8;
|
||||
word |= *message & 0xff;
|
||||
if(*message == 0) {
|
||||
word |= *buf & 0xff;
|
||||
if(*buf == 0) {
|
||||
rtio_o_data_write(word);
|
||||
rtio_o_we_write(1);
|
||||
break;
|
||||
}
|
||||
message++;
|
||||
buf++;
|
||||
i++;
|
||||
if(i == 4) {
|
||||
rtio_o_data_write(word);
|
||||
@ -67,3 +70,12 @@ void rtio_log(long long int timestamp, char *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rtio_log(long long int timestamp, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
rtio_log_va(timestamp, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef __RTIO_H
|
||||
#define __RTIO_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <generated/csr.h>
|
||||
#include "artiq_personality.h"
|
||||
|
||||
@ -14,7 +15,8 @@
|
||||
void rtio_init(void);
|
||||
long long int rtio_get_counter(void);
|
||||
void rtio_process_exceptional_status(int status, long long int timestamp, int channel);
|
||||
void rtio_log(long long int timestamp, char *message);
|
||||
void rtio_log(long long int timestamp, const char *format, ...);
|
||||
void rtio_log_va(long long int timestamp, const char *format, va_list args);
|
||||
|
||||
static inline void rtio_write_and_process_status(long long int timestamp, int channel)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user