2 #include "si_osdebug.h"
3 #include <linux/slab.h>
4 #include <linux/string.h>
5 #define ChannelIndex(channel) (channel >> 3)
6 #define ChannelMask(channel) (1 << (channel & 7))
7 extern unsigned char DebugChannelMasks
[];
8 extern ushort DebugFormat
;
9 void SiiOsDebugChannelEnable(SiiOsalDebugChannels_e channel
)
12 uint8_t index
= ChannelIndex(channel
);
13 uint8_t mask
= ChannelMask(channel
);
14 DebugChannelMasks
[index
] |= mask
;
18 void SiiOsDebugChannelDisable(SiiOsalDebugChannels_e channel
)
21 uint8_t index
= ChannelIndex(channel
);
22 uint8_t mask
= ChannelMask(channel
);
23 DebugChannelMasks
[index
] &= ~mask
;
27 bool_t
SiiOsDebugChannelIsEnabled(SiiOsalDebugChannels_e channel
)
30 uint8_t index
= ChannelIndex(channel
);
31 uint8_t mask
= ChannelMask(channel
);
32 return (DebugChannelMasks
[index
] & mask
) ? true : false;
38 void SiiOsDebugSetConfig(uint16_t flags
)
45 uint16_t SiiOsDebugGetConfig(void)
54 void SiiOsDebugPrintSimple(SiiOsalDebugChannels_e channel
, char *pszFormat
, ...)
57 /* #if defined(DEBUG) */
58 if (SiiOsDebugChannelIsEnabled(channel
)) {
60 va_start(ap
, pszFormat
);
61 printk(pszFormat
, ap
);
67 void SiiOsDebugPrintShort(SiiOsalDebugChannels_e channel
, char *pszFormat
, ...)
69 /* #if defined(DEBUG) */
71 if (SiiOsDebugChannelIsEnabled(channel
)) {
73 va_start(ap
, pszFormat
);
74 SiiOsDebugPrint(NULL
, 0, channel
, pszFormat
, ap
);
80 #define MAX_DEBUG_MSG_SIZE 512
81 void SiiOsDebugPrint(const char *pszFileName
, uint32_t iLineNum
, uint32_t channel
,
82 const char *pszFormat
, ...)
87 int remainingBufLen
= MAX_DEBUG_MSG_SIZE
;
90 if (SiiOsDebugChannelIsEnabled(channel
)) {
91 pBuf
= kmalloc(remainingBufLen
, GFP_KERNEL
);
95 if (pszFileName
!= NULL
&& (SII_OS_DEBUG_FORMAT_FILEINFO
& DebugFormat
)) {
97 for (pc
= &pszFileName
[strlen(pszFileName
)]; pc
>= pszFileName
; --pc
) {
107 len
= scnprintf(pBufOffset
, remainingBufLen
, "%s:%d ", pc
, (int)iLineNum
);
112 remainingBufLen
-= len
;
115 if (SII_OS_DEBUG_FORMAT_CHANNEL
& DebugFormat
) {
116 len
= scnprintf(pBufOffset
, remainingBufLen
, "Chan:%d ", channel
);
121 remainingBufLen
-= len
;
124 va_start(ap
, pszFormat
);
125 vsnprintf(pBufOffset
, remainingBufLen
, pszFormat
, ap
);