| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#ifndef __CARL9170FW_PRINTF_H |
| 26 |
#define __CARL9170FW_PRINTF_H |
| 27 |
|
| 28 |
#include <stdarg.h> |
| 29 |
#include "config.h" |
| 30 |
#include "carl9170.h" |
| 31 |
#include "uart.h" |
| 32 |
#include "fwcmd.h" |
| 33 |
|
| •34 |
void *memcpy(void *restrict, const void *restrict, size_t); |
| 35 |
void *memset(void *, int, size_t); |
| 36 |
|
| 37 |
#ifdef CONFIG_CARL9170FW_PRINTF |
| 38 |
void __attribute__((format (printf, 1, 2))) tfp_printf(const char *fmt, ...); |
| 39 |
|
| 40 |
#define printf tfp_printf |
| 41 |
|
| 42 |
#else |
| 43 |
void __attribute__((format (printf, 1, 2))) min_printf(const char *fmt, ...); |
| 44 |
|
| 45 |
#define printf min_printf |
| 46 |
#endif |
| 47 |
|
| 48 |
#define PRINT(fmt, args...) \ |
| 49 |
do { \ |
| 50 |
printf(fmt, ## args); \ |
| 51 |
} while (0) |
| 52 |
|
| 53 |
#define INFO(fmt, args...) PRINT(fmt, ## args) |
| 54 |
|
| 55 |
#define ERR(fmt, args...) PRINT(CARL9170_ERR_MAGIC fmt, ## args) |
| 56 |
|
| 57 |
#ifdef CONFIG_CARL9170FW_DEBUG |
| 58 |
#define DBG(fmt, args...) PRINT(fmt, ## args) |
| 59 |
#else |
| 60 |
#define DBG(...) do { } while (0); |
| 61 |
#endif |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
#define STALL() |
| 69 |
|
| 70 |
#define BUG(fmt, args...) \ |
| 71 |
do { \ |
| 72 |
PRINT(CARL9170_BUG_MAGIC" %s()@%d \"" fmt "\"" , \ |
| 73 |
__func__, __LINE__, ## args); \ |
| 74 |
STALL() \ |
| 75 |
} while (0); |
| 76 |
|
| 77 |
#define BUG_ON(condition) \ |
| 78 |
({ \ |
| 79 |
int __ret = !!(condition); \ |
| 80 |
if (unlikely(!!(__ret))) \ |
| 81 |
BUG(#condition); \ |
| 82 |
(__ret); \ |
| 83 |
}) |
| 84 |
|
| 85 |
static inline __inline void putcharacter(const char c __unused) |
| 86 |
{ |
| 87 |
#ifdef CONFIG_CARL9170FW_DEBUG_USB |
| 88 |
usb_putc(c); |
| 89 |
#endif |
| 90 |
|
| 91 |
#ifdef CONFIG_CARL9170FW_DEBUG_UART |
| 92 |
uart_putc(c); |
| 93 |
#endif |
| 94 |
} |
| 95 |
|
| 96 |
static inline __inline void print_hex_dump(const void *buf __unused, int len __unused) |
| 97 |
{ |
| 98 |
#ifdef CONFIG_CARL9170FW_DEBUG_USB |
| 99 |
usb_print_hex_dump(buf, len); |
| 100 |
#endif |
| 101 |
|
| 102 |
#ifdef CONFIG_CARL9170FW_DEBUG_UART |
| 103 |
uart_print_hex_dump(buf, len); |
| 104 |
#endif |
| 105 |
} |
| 106 |
|
| 107 |
#endif |
| 108 |
|