Commit 71641cfb authored by Adam Wujek's avatar Adam Wujek 💬

sw:rt:fw: use if(HAS_*) instead of #ifdef CONFIG_*

If the configuration item is not selected the code inside if statement
will not be present in the final binary, but it will be compiled.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 502e8be8
......@@ -145,14 +145,14 @@ static inline struct trtl_proto_header *rt_proto_header_get(void *raw_msg)
static inline void rt_proto_header_set(void *raw_msg,
struct trtl_proto_header *header)
{
#if CONFIG_MOCKTURTLE_FRAMEWORK_32BIT_ALIGN
int i;
for (i = 0; i < sizeof(struct trtl_proto_header) / 4; ++i)
((uint32_t *)raw_msg)[i] = ((uint32_t *)header)[i];
#else
memcpy(raw_msg, header, sizeof(struct trtl_proto_header));
#endif
if (HAS_MOCKTURTLE_FRAMEWORK_32BIT_ALIGN) {
int i;
for (i = 0; i < sizeof(struct trtl_proto_header) / 4; ++i)
((uint32_t *)raw_msg)[i] = ((uint32_t *)header)[i];
} else {
memcpy(raw_msg, header, sizeof(struct trtl_proto_header));
}
}
......
......@@ -48,13 +48,17 @@ int rt_version_getter(struct trtl_proto_header *hin, void *pin,
* it overwrite a data structure with the one contained in the input
* payload. If the message is syncrnous it will copy back the data structure.
*/
#ifdef CONFIG_MOCKTURTLE_FRAMEWORK_BUFFER_ENABLE
int rt_buffer_setter(struct trtl_proto_header *hin, void *pin,
struct trtl_proto_header *hout, void *pout)
{
unsigned int offset = 0, index, size;
uint32_t *din = pin;
if (!HAS_MOCKTURTLE_FRAMEWORK_BUFFER_ENABLE) {
rt_send_nack(hin, pin, hout, NULL);
return 0;
}
while (offset < hin->len) {
pr_debug("%s: offset %d/%d\n\r", __func__, offset, hin->len);
......@@ -83,21 +87,11 @@ int rt_buffer_setter(struct trtl_proto_header *hin, void *pin,
return 0;
}
#else
int rt_buffer_setter(struct trtl_proto_header *hin, void *pin,
struct trtl_proto_header *hout, void *pout)
{
rt_send_nack(hin, pin, hout, NULL);
return 0;
}
#endif
/**
* This is an @ref action_t function type. Accorind the message request,
* it copies one of the declared data structure to the output payload.
*/
#ifdef CONFIG_MOCKTURTLE_FRAMEWORK_BUFFER_ENABLE
int rt_buffer_getter(struct trtl_proto_header *hin, void *pin,
struct trtl_proto_header *hout, void *pout)
{
......@@ -105,6 +99,11 @@ int rt_buffer_getter(struct trtl_proto_header *hin, void *pin,
uint32_t *din = pin;
uint32_t *dout = pout;
if (!HAS_MOCKTURTLE_FRAMEWORK_BUFFER_ENABLE) {
rt_send_nack(hin, pin, hout, NULL);
return 0;
}
hout->msg_id = TRTL_MSG_ID_BUF_GET_ANS;
while (offset < hin->len) {
......@@ -131,22 +130,12 @@ int rt_buffer_getter(struct trtl_proto_header *hin, void *pin,
return 0;
}
#else
int rt_buffer_getter(struct trtl_proto_header *hin, void *pin,
struct trtl_proto_header *hout, void *pout)
{
rt_send_nack(hin, pin, hout, NULL);
return 0;
}
#endif
/**
* This is an @ref action_t function type. Accorind the message request,
* it writes a number of declared variables. If the message is synchronous
* it copies back the values in the output payload.
*/
#ifdef CONFIG_MOCKTURTLE_FRAMEWORK_VARIABLE_ENABLE
int rt_variable_setter(struct trtl_proto_header *hin, void *pin,
struct trtl_proto_header *hout, void *pout)
{
......@@ -154,6 +143,12 @@ int rt_variable_setter(struct trtl_proto_header *hin, void *pin,
uint32_t *din = pin, *mem, val;
int i;
if (!HAS_MOCKTURTLE_FRAMEWORK_VARIABLE_ENABLE) {
pr_debug("Variable set action not supported\n\r");
rt_send_nack(hin, pin, hout, NULL);
return 0;
}
/* we always have a pair of values */
if (hin->len % 2)
rt_send_nack(hin, pin, hout, pout);
......@@ -184,22 +179,11 @@ int rt_variable_setter(struct trtl_proto_header *hin, void *pin,
return 0;
}
#else
int rt_variable_setter(struct trtl_proto_header *hin, void *pin,
struct trtl_proto_header *hout, void *pout)
{
pr_debug("Variable set action not supported\n\r");
rt_send_nack(hin, pin, hout, NULL);
return 0;
}
#endif
/**
* This is an @ref action_t function type. Accorind the message request,
* it copies a number of declared variables.
*/
#ifdef CONFIG_MOCKTURTLE_FRAMEWORK_VARIABLE_ENABLE
int rt_variable_getter(struct trtl_proto_header *hin, void *pin,
struct trtl_proto_header *hout, void *pout)
{
......@@ -207,6 +191,12 @@ int rt_variable_getter(struct trtl_proto_header *hin, void *pin,
uint32_t *dout = pout, *din = pin, *mem, val;
int i;
if (!HAS_MOCKTURTLE_FRAMEWORK_VARIABLE_ENABLE) {
pr_debug("Variable get action not supported\n\r");
rt_send_nack(hin, pin, hout, NULL);
return 0;
}
if (!hout || !pout)
return -1;
......@@ -237,17 +227,6 @@ int rt_variable_getter(struct trtl_proto_header *hin, void *pin,
return 0;
}
#else
int rt_variable_getter(struct trtl_proto_header *hin, void *pin,
struct trtl_proto_header *hout, void *pout)
{
pr_debug("Variable get action not supported\n\r");
rt_send_nack(hin, pin, hout, NULL);
return 0;
}
#endif
/**
* List of standard actions
......
......@@ -18,7 +18,6 @@
* @param[in] n_values number of variadic arguments
* @return 0 on success. -1 on error
*/
#ifdef CONFIG_MOCKTURTLE_FRAMEWORK_DEBUG_ENABLE
int rt_send_debug(int mq_in, int n_values, ...)
{
va_list ap;
......@@ -36,6 +35,10 @@ int rt_send_debug(int mq_in, int n_values, ...)
};
int i;
if (!HAS_MOCKTURTLE_FRAMEWORK_DEBUG_ENABLE) {
return 0;
}
out_buf = rt_mq_claim_out(&hdr);
buf = (uint32_t *)rt_proto_payload_get(out_buf.data);
......@@ -49,22 +52,17 @@ int rt_send_debug(int mq_in, int n_values, ...)
return 0;
}
#else
int rt_send_debug(int mq_in, int n_values, ...)
{
return 0;
}
#endif
/**
* It prints on the serial interface the given message header
* @param[in] h message header to print
*/
#ifdef CONFIG_MOCKTURTLE_FRAMEWORK_DEBUG_ENABLE
void rt_print_header(struct trtl_proto_header *h)
{
if (!HAS_MOCKTURTLE_FRAMEWORK_DEBUG_ENABLE) {
return;
}
pr_debug(" app_id 0x%x | msg_id %d | slot_io 0x%x | seq %"PRIu32"d\n\r",
h->rt_app_id, h->msg_id, h->slot_io, h->seq);
delay(1000);
......@@ -72,32 +70,22 @@ void rt_print_header(struct trtl_proto_header *h)
h->len, h->flags, h->trans, h->time);
delay(1000);
}
#else
void rt_print_header(struct trtl_proto_header *h)
{
return;
}
#endif
/**
* It prints on the serial interface a buffer
* @param[in] d buffer data
* @param[in] count number of 32bit words to show
*/
#ifdef CONFIG_MOCKTURTLE_FRAMEWORK_DEBUG_ENABLE
void rt_print_data(uint32_t *d, unsigned int count)
{
int i;
if (!HAS_MOCKTURTLE_FRAMEWORK_DEBUG_ENABLE) {
return;
}
for (i = 0; i < count; i++) {
pr_debug("%s: data[%d] = 0x%"PRIx32"\n\r", __func__, i , d[i]);
delay(1000);
}
}
#else
void rt_print_data(uint32_t *d, unsigned int count)
{
return ;
}
#endif
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