Пример #1
0
/*!
******************************************************************************
	@Function    PVRSRVDebugPrintf
	@Description To output a debug message to the user
	@Input       uDebugLevel - The current debug level
	@Input       pszFile - The source file generating the message
	@Input       uLine - The line of the source file
	@Input       pszFormat - The message format string
	@Input       ... - Zero or more arguments for use by the format string
	@Return      None
 ******************************************************************************/
IMG_VOID PVRSRVDebugPrintf	(
						IMG_UINT32	ui32DebugLevel,
						const IMG_CHAR*	pszFullFileName,
						IMG_UINT32	ui32Line,
						const IMG_CHAR*	pszFormat,
						...
					)
{
	IMG_BOOL bTrace;
	const IMG_CHAR *pszFileName = pszFullFileName;

	bTrace = (IMG_BOOL)(ui32DebugLevel & DBGPRIV_CALLTRACE) ? IMG_TRUE : IMG_FALSE;

	if (gPVRDebugLevel & ui32DebugLevel)
	{
		va_list vaArgs;
		unsigned long ulLockFlags = 0;
		IMG_CHAR *pszBuf;
		IMG_UINT32 ui32BufSiz;

		SelectBuffer(&pszBuf, &ui32BufSiz);

		va_start(vaArgs, pszFormat);

		GetBufferLock(&ulLockFlags);

		/* Add in the level of warning */
		if (bTrace == IMG_FALSE)
		{
			switch(ui32DebugLevel)
			{
				case DBGPRIV_FATAL:
				{
					strncpy (pszBuf, "PVR_K:(Fatal): ", (ui32BufSiz -1));
					break;
				}
				case DBGPRIV_ERROR:
				{
					strncpy (pszBuf, "PVR_K:(Error): ", (ui32BufSiz -1));
					break;
				}
				case DBGPRIV_WARNING:
				{
					strncpy (pszBuf, "PVR_K:(Warning): ", (ui32BufSiz -1));
					break;
				}
				case DBGPRIV_MESSAGE:
				{
					strncpy (pszBuf, "PVR_K:(Message): ", (ui32BufSiz -1));
					break;
				}
				case DBGPRIV_VERBOSE:
				{
					strncpy (pszBuf, "PVR_K:(Verbose): ", (ui32BufSiz -1));
					break;
				}
				case DBGPRIV_BUFFERED:
				{
					strncpy (pszBuf, "PVR_K: ", (ui32BufSiz -1));
					break;
				}
				default:
				{
					strncpy (pszBuf, "PVR_K:(Unknown message level): ", (ui32BufSiz -1));
					break;
				}
			}
		}
		else
		{
			strncpy (pszBuf, "PVR_K: ", (ui32BufSiz -1));
		}

		if (VBAppend(pszBuf, ui32BufSiz, pszFormat, vaArgs))
		{
			printk(KERN_INFO "PVR_K:(Message Truncated): %s\n", pszBuf);
		}
		else
		{
			if (ui32DebugLevel & DBGPRIV_BUFFERED)
			{
				/* We don't need the full path here */
				const IMG_CHAR *pszShortName = strrchr(pszFileName, '/') + 1;
				if(pszShortName)
					pszFileName = pszShortName;

				AddToBufferCCB(pszFileName, ui32Line, pszBuf);
			}
			else
			{
				printk(KERN_INFO "%s\n", pszBuf);
			}
		}

		ReleaseBufferLock(ulLockFlags);

		va_end (vaArgs);
	}
}
Пример #2
0
/*************************************************************************/ /*!
@Function       PVRSRVDebugPrintf
@Description    To output a debug message to the user
@Input          uDebugLevel The current debug level
@Input          pszFile     The source file generating the message
@Input          uLine       The line of the source file
@Input          pszFormat   The message format string
@Input          ...         Zero or more arguments for use by the format string
*/ /**************************************************************************/
void PVRSRVDebugPrintf(IMG_UINT32 ui32DebugLevel,
			   const IMG_CHAR *pszFullFileName,
			   IMG_UINT32 ui32Line,
			   const IMG_CHAR *pszFormat,
			   ...)
{
	IMG_BOOL bNoLoc;
	const IMG_CHAR *pszFileName = pszFullFileName;
	IMG_CHAR *pszLeafName;

	bNoLoc = (IMG_BOOL)((ui32DebugLevel & DBGPRIV_CALLTRACE) |
						(ui32DebugLevel & DBGPRIV_BUFFERED)) ? IMG_TRUE : IMG_FALSE;

	if (gPVRDebugLevel & ui32DebugLevel)
	{
		va_list vaArgs;
		unsigned long ulLockFlags = 0;
		IMG_CHAR *pszBuf;
		IMG_UINT32 ui32BufSiz;

		SelectBuffer(&pszBuf, &ui32BufSiz);

		va_start(vaArgs, pszFormat);

		GetBufferLock(&ulLockFlags);

		switch (ui32DebugLevel)
		{
			case DBGPRIV_FATAL:
			{
				strncpy(pszBuf, "PVR_K:(Fatal): ", (ui32BufSiz - 2));
				break;
			}
			case DBGPRIV_ERROR:
			{
				strncpy(pszBuf, "PVR_K:(Error): ", (ui32BufSiz - 2));
				break;
			}
			case DBGPRIV_WARNING:
			{
				strncpy(pszBuf, "PVR_K:(Warn):  ", (ui32BufSiz - 2));
				break;
			}
			case DBGPRIV_MESSAGE:
			{
				strncpy(pszBuf, "PVR_K:(Mesg):  ", (ui32BufSiz - 2));
				break;
			}
			case DBGPRIV_VERBOSE:
			{
				strncpy(pszBuf, "PVR_K:(Verb):  ", (ui32BufSiz - 2));
				break;
			}
			case DBGPRIV_DEBUG:
			{
				strncpy(pszBuf, "PVR_K:(Debug): ", (ui32BufSiz - 2));
				break;
			}
			case DBGPRIV_CALLTRACE:
			case DBGPRIV_ALLOC:
			case DBGPRIV_BUFFERED:
			default:
			{
				strncpy(pszBuf, "PVR_K:  ", (ui32BufSiz - 2));
				break;
			}
		}
		pszBuf[ui32BufSiz - 1] = '\0';

		(void) BAppend(pszBuf, ui32BufSiz, "%u: ", current->pid);


		if (VBAppend(pszBuf, ui32BufSiz, pszFormat, vaArgs))
		{
			printk(KERN_ERR "PVR_K:(Message Truncated): %s\n", pszBuf);
		}
		else
		{
#if !defined(__sh__)
			pszLeafName = (IMG_CHAR *)strrchr (pszFileName, '/');

			if (pszLeafName)
			{
				pszFileName = pszLeafName+1;
			}
#endif /* __sh__ */

			if (BAppend(pszBuf, ui32BufSiz, " [%u, %s]", ui32Line, pszFileName))
			{
				printk(KERN_ERR "PVR_K:(Message Truncated): %s\n", pszBuf);
			}
			else
			{
				if (ui32DebugLevel & DBGPRIV_BUFFERED)
				{
					AddToBufferCCB(pszFileName, ui32Line, pszBuf);
				}
				else
				{
					printk(KERN_ERR "%s\n", pszBuf);
				}
			}
		}

		ReleaseBufferLock(ulLockFlags);

		va_end (vaArgs);
	}
}