Exemplo n.º 1
0
void SiiOsDebugPrint(const char *pszFileName, uint32_t iLineNum, uint32_t channel, const char *pszFormat, ...)
{
#if defined(DEBUG)
	uint8_t		*pBuf = NULL;
	uint8_t		*pBufOffset;
	int			remainingBufLen = MAX_DEBUG_MSG_SIZE;
	int			len;
	va_list		ap;
    if (SiiOsDebugChannelIsEnabled( channel ))
    {
	    pBuf = kmalloc(remainingBufLen, GFP_KERNEL);
	    if(pBuf == NULL)
	    	return;
	    pBufOffset = pBuf;
        if(pszFileName != NULL && (SII_OS_DEBUG_FORMAT_FILEINFO & DebugFormat))
        {
        	const char *pc;
            for(pc = &pszFileName[strlen(pszFileName)];pc  >= pszFileName;--pc)
            {
                if ('\\' == *pc)
                {
                    ++pc;
                    break;
                }
                if ('/' ==*pc)
                {
                    ++pc;
                    break;
                }
            }
            len = scnprintf(pBufOffset, remainingBufLen, "%s:%d ",pc,(int)iLineNum);
            if(len < 0) {
            	kfree(pBuf);
            	return;
            }
            remainingBufLen -= len;
            pBufOffset += len;
        }
        if (SII_OS_DEBUG_FORMAT_CHANNEL & DebugFormat)
        {
        	len = scnprintf(pBufOffset, remainingBufLen, "Chan:%d ", channel);
        	if(len < 0) {
        		kfree(pBuf);
        		return;
        	}
            remainingBufLen -= len;
            pBufOffset += len;
        }
        va_start(ap,pszFormat);
        vsnprintf(pBufOffset, remainingBufLen, pszFormat, ap);
        va_end(ap);
    	printk(pBuf);
		kfree(pBuf);
    }
#endif 
}
void SiiOsDebugPrintUseGlobal(
#ifndef __KERNEL__
const
#endif
char *pszFormat, ...)
{
#if defined(DEBUG)
	uint8_t		*pBuf = NULL;
	uint8_t		*pBufOffset;
	int			remainingBufLen = MAX_DEBUG_MSG_SIZE;
	int			len;
	va_list		ap;

    if (SiiOsDebugChannelIsEnabled( g_channelArg ))
    {
	    pBuf = kmalloc(remainingBufLen, GFP_KERNEL);
	    if(pBuf == NULL)
	    	return;
	    pBufOffset = pBuf;

        if(g_debugFileName!= NULL && (SII_OS_DEBUG_FORMAT_FILEINFO & DebugFormat))
        {
            len = scnprintf(pBufOffset, remainingBufLen, "%s:%d ",findLastSlash(g_debugFileName),(int)g_debugLineNo);
            if(len < 0) {
            	kfree(pBuf);
            	return;
            }

            remainingBufLen -= len;
            pBufOffset += len;
        }

        if (SII_OS_DEBUG_FORMAT_CHANNEL & DebugFormat)
        {
        	len = scnprintf(pBufOffset, remainingBufLen, "Chan:%d ", g_channelArg);
        	if(len < 0) {
        		kfree(pBuf);
        		return;
        	}
            remainingBufLen -= len;
            pBufOffset += len;
        }
        if (NULL != pszFormat)
        {
            va_start(ap,pszFormat);
            vsnprintf(pBufOffset, remainingBufLen, pszFormat, ap);
            va_end(ap);
        	printk(pBuf);
        }

		kfree(pBuf);
    }
#endif // #if defined(DEBUG)
}
void SiiOsDebugPrintSimple(SiiOsalDebugChannels_e channel, char *pszFormat,...)
{
#if defined(DEBUG)
    if (SiiOsDebugChannelIsEnabled( channel ))
    {
    	va_list ap;
    	va_start(ap,pszFormat);
    	printk(pszFormat, ap);
    	va_end(ap);
    }
#endif
}
Exemplo n.º 4
0
void SiiOsDebugPrintShort(SiiOsalDebugChannels_e channel, char *pszFormat,...)
{
//#if defined(DEBUG)
#if 1
    if (SiiOsDebugChannelIsEnabled( channel ))
    {
	    va_list ap;
	    va_start(ap,pszFormat);
	    SiiOsDebugPrint(NULL, 0, channel, pszFormat, ap);
	    va_end(ap);
	}
#endif
}
void SiiOsDebugPrint(const char *pszFileName, uint32_t iLineNum, uint32_t channel, const char *pszFormat, ...)
{
#if defined(DEBUG)
	uint8_t		*pBuf = NULL;
	uint8_t		*pBufOffset;
	int			remainingBufLen = MAX_DEBUG_MSG_SIZE;
	int			len;
	va_list		ap;


    if (SiiOsDebugChannelIsEnabled( channel ))
    {
	    //pBuf = kmalloc(remainingBufLen, GFP_KERNEL);  //TB - removed kmalloc
    	pBuf = g_PrintBuffer;
	    if(pBuf == NULL)
	    	return;
	    pBufOffset = pBuf;

        if(pszFileName != NULL && (SII_OS_DEBUG_FORMAT_FILEINFO & DebugFormat))
        {
            len = scnprintf(pBufOffset, remainingBufLen, "%s:%d ",findLastSlash(pszFileName),(int)iLineNum);
            if(len < 0) {
            	//kfree(pBuf);  //TB - no need to free using global buffer
            	return;
            }

            remainingBufLen -= len;
            pBufOffset += len;
        }

        if (SII_OS_DEBUG_FORMAT_CHANNEL & DebugFormat)
        {
        	len = scnprintf(pBufOffset, remainingBufLen, "Chan:%d ", channel);
        	if(len < 0) {
        		//kfree(pBuf);  //TB - no need to free using global buffer
        		return;
        	}
            remainingBufLen -= len;
            pBufOffset += len;
        }

        va_start(ap,pszFormat);
        vsnprintf(pBufOffset, remainingBufLen, pszFormat, ap);
        va_end(ap);

    	printk(pBuf);
    	//kfree(pBuf);  //TB - no need to free using global buffer
    }
#endif // #if defined(DEBUG)
}