blob: c794220d9d242ffe94abb6a402d70bbb25451cc9 [file] [log] [blame]
/* utils.h - utility functions used by latency measurement */
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* DESCRIPTION
* This file contains function declarations, macroses and inline functions
* used in latency measurement.
*/
#define INT_IMM8_OFFSET 1
#define IRQ_PRIORITY 3
#ifdef CONFIG_PRINTK
#include <misc/printk.h>
#include <stdio.h>
#include "timestamp.h"
extern char tmpString[];
extern int errorCount;
#define TMP_STRING_SIZE 100
#define PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__)
#define PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define PRINT_FORMAT(fmt, ...) \
do { \
snprintf(tmpString, TMP_STRING_SIZE, fmt, ##__VA_ARGS__); \
PRINTF("|%-77s|\n", tmpString); \
} while (0)
/**
*
* @brief Print dash line
*
* @return N/A
*/
static inline void printDashLine(void)
{
PRINTF("|-------------------------------------------------------"
"----------------------|\n");
}
#define PRINT_END_BANNER() \
do { \
PRINTF("| E N D " \
" |\n"); \
printDashLine(); \
} while (0)
#define PRINT_NANO_BANNER() \
do { \
printDashLine(); \
PRINTF("| Nanokernel Latency Benchmark " \
" |\n"); \
printDashLine(); \
} while (0)
#define PRINT_MICRO_BANNER() \
do { \
printDashLine(); \
PRINTF("| Microkernel Latency Benchmark " \
" |\n"); \
printDashLine(); \
} while (0)
#define PRINT_TIME_BANNER() \
do { \
PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %u nsec", \
SYS_CLOCK_HW_CYCLES_TO_NS(1)); \
printDashLine(); \
} while (0)
#define PRINT_OVERFLOW_ERROR() \
PRINT_FORMAT(" Error: tick occurred")
#else
#error PRINTK configuration option needs to be enabled
#endif
void raiseIntFunc(void);
extern void raiseInt(uint8_t id);
/* test the interrupt latency */
int nanoIntLatency(void);
int nanoIntToFiber(void);
int nanoIntToFiberSem(void);
int nanoCtxSwitch(void);
int nanoIntLockUnlock(void);
/* pointer to the ISR */
typedef void (*ptestIsr) (void *unused);