Commit 056c6ada authored by Federico Vaga's avatar Federico Vaga

rt: add debug over HMQ

add rt_send_debug() function that will allow mock-turtle users to
send debug values over the HMQ interface.

This will be much faster than using the pp_printf
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent c937bc16
......@@ -45,6 +45,7 @@ enum rt_action_standard {
RT_ACTION_SEND_FIELD_GET,
RT_ACTION_SEND_STRUCT_GET,
RT_ACTION_SEND_VERSION,
RT_ACTION_SEND_DEBUG,
__RT_ACTION_RECV_STANDARD_NUMBER,
};
......
......@@ -23,6 +23,41 @@
uint32_t msg_seq = 0;
struct rt_application *_app;
#ifdef APPRT_DEBUG
/**
* The function can be used to debug the code as alternative to the pp_printf().
*/
int rt_send_debug(struct rt_application *app, int slot, int n_values, ...)
{
va_list ap;
struct trtl_msg out_buf;
uint32_t *buf;
struct trtl_proto_header hdr = {
.rt_app_id = app->version.rt_id,
.msg_id = RT_ACTION_SEND_DEBUG,
.slot_io = slot & 0xF,
.seq = 0,
.len = n_values,
.flags = 0x0,
.trans = 0x0,
.time = 0x0,
};
int i;
out_buf = rt_mq_claim_out(&hdr);
buf = (uint32_t *)rt_proto_payload_get(out_buf.data);
va_start(ap, n_values);
for (i = 0; i < n_values;++i)
buf[i] = va_arg(ap, uint32_t);
va_end(ap);
rt_proto_header_set((void *) out_buf.data, &hdr);
rt_mq_msg_send(&out_buf);
return 0;
}
#endif
/**
* Since the hardware does not allow byte addressing, copy word by word
......
......@@ -20,6 +20,9 @@
#define __LIBRT_H__
#include <stdint.h>
#ifdef APPRT_DEBUG
#include <stdarg.h>
#endif
#include "mockturtle-common.h"
#include "hw/mockturtle_cpu_lr.h"
#include "mockturtle-rt-common.h"
......@@ -61,6 +64,7 @@ static inline void rt_print_header(struct trtl_proto_header *h)
}
#endif
extern uint32_t msg_seq;
#define RT_VARIABLE_FLAG_WO (1 << 0)
......@@ -175,4 +179,18 @@ static inline void rt_mq_msg_send(struct trtl_msg *msg)
hdr->len + (sizeof(struct trtl_proto_header) / 4));
}
/**
* Application debug tools
*/
#ifdef APPRT_DEBUG
extern int rt_send_debug(struct rt_application *app, int slot, int n_values, ...);
#else
static inline int rt_send_debug(struct rt_application *app,
int slot, int n_values, ...)
{
return 0;
}
#endif
#endif /* __LIBRT_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment