From 50a463a6fd6423c8fd48da0a23bfd67229e1e589 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 26 Dec 2015 22:44:50 +0800 Subject: [PATCH] runtime: support for RTIO logging --- artiq/runtime/analyzer.c | 2 +- artiq/runtime/ksupport.c | 10 +++++++--- artiq/runtime/rtio.c | 29 +++++++++++++++++++++++++++++ artiq/runtime/rtio.h | 1 + 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/artiq/runtime/analyzer.c b/artiq/runtime/analyzer.c index 4a3ec9de2..f40188ab6 100644 --- a/artiq/runtime/analyzer.c +++ b/artiq/runtime/analyzer.c @@ -71,7 +71,7 @@ void analyzer_start(void) analyzer_header.sent_bytes = analyzer_header.total_byte_count; analyzer_header.overflow_occured = rtio_analyzer_message_encoder_overflow_read(); - analyzer_header.log_channel = 0; + analyzer_header.log_channel = CONFIG_RTIO_LOG_CHANNEL; analyzer_header.dds_channel = CONFIG_RTIO_DDS_CHANNEL; #ifdef DDS_ONEHOT_SEL analyzer_header.dds_onehot_sel = 1; diff --git a/artiq/runtime/ksupport.c b/artiq/runtime/ksupport.c index 2f775cf4b..3da82f76f 100644 --- a/artiq/runtime/ksupport.c +++ b/artiq/runtime/ksupport.c @@ -107,6 +107,7 @@ static const struct symbol runtime_exports[] = { /* direct syscalls */ {"rtio_get_counter", &rtio_get_counter}, + {"rtio_log", &rtio_log}, {"ttl_set_o", &ttl_set_o}, {"ttl_set_oe", &ttl_set_oe}, @@ -167,13 +168,15 @@ int fprintf(FILE *stream, const char *fmt, ...) } /* called by libunwind */ -int dladdr (const void *address, Dl_info *info) { +int dladdr (const void *address, Dl_info *info) +{ /* we don't try to resolve names */ return 0; } /* called by libunwind */ -int dl_iterate_phdr (int (*callback) (struct dl_phdr_info *, size_t, void *), void *data) { +int dl_iterate_phdr (int (*callback)(struct dl_phdr_info *, size_t, void *), void *data) +{ Elf32_Ehdr *ehdr; struct dl_phdr_info phdr_info; int retval; @@ -200,7 +203,8 @@ int dl_iterate_phdr (int (*callback) (struct dl_phdr_info *, size_t, void *), vo return retval; } -static Elf32_Addr resolve_runtime_export(const char *name) { +static Elf32_Addr resolve_runtime_export(const char *name) +{ const struct symbol *sym = runtime_exports; while(sym->name) { if(!strcmp(sym->name, name)) diff --git a/artiq/runtime/rtio.c b/artiq/runtime/rtio.c index 0bf0fde5b..35c8bb309 100644 --- a/artiq/runtime/rtio.c +++ b/artiq/runtime/rtio.c @@ -38,3 +38,32 @@ void rtio_process_exceptional_status(int status, long long int timestamp, int ch timestamp, channel, 0); } } + +void rtio_log(long long int timestamp, char *message) +{ + unsigned int word; + int i; + + rtio_chan_sel_write(CONFIG_RTIO_LOG_CHANNEL); + rtio_o_timestamp_write(timestamp); + + i = 0; + word = 0; + while(1) { + word >>= 8; + word |= *message << 24; + if(*message == 0) { + rtio_o_data_write(word); + rtio_o_we_write(1); + break; + } + message++; + i++; + if(i == 4) { + rtio_o_data_write(word); + rtio_o_we_write(1); + word = 0; + i = 0; + } + } +} diff --git a/artiq/runtime/rtio.h b/artiq/runtime/rtio.h index 702c381c4..d8273f3f2 100644 --- a/artiq/runtime/rtio.h +++ b/artiq/runtime/rtio.h @@ -14,6 +14,7 @@ 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); static inline void rtio_write_and_process_status(long long int timestamp, int channel) {