⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pvr_debug.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
字号:
/*******************************************************************************
<module>
* Name         : pvr_debug.c
* Title        : PVR Debug Functionality
* Author       : J R Morrissey, P M Keohan
* Created      : 20 May 2002
*
* Copyright    : 2002 by Imagination Technologies Limited.
*                All rights reserved.  No part of this software, either
*                material or conceptual may be copied or distributed,
*                transmitted, transcribed, stored in a retrieval system
*                or translated into any human or computer language in any
*                form by any means, electronic, mechanical, manual or
*                other-wise, or disclosed to third parties without the
*                express written permission of Imagination Technologies
*                Limited, Unit 8, HomePark Industrial Estate,
*                King's Langley, Hertfordshire, WD4 8LZ, U.K.
*
* Description  : Implements PVR debug-specific features
*
* Platform     : Hitachi Solution Engine SH7750SE
*
* Platform     : Linux
*
</module>
********************************************************************************/

#include <stdarg.h>
#include "img_types.h"
#include "pvr_debug.h"
#if defined(PVR_KERNEL)
#ifndef _WIN32
#include <asm/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#endif
#else
#include <stdio.h>
#include <string.h>
#endif
#ifdef _WIN32
#ifdef UNDER_CE
#include <wtypes.h>
#endif
#include <windows.h>
#include "tstring.h"
#endif


/******************************************************************************/

IMG_UINT32	gPVRDebugLevel = DBGPRIV_WARNING;
#define PVR_STRING_TERMINATOR		'\0'
#define PVR_IS_FILE_SEPARATOR(character) ( ((character) == '\\') || ((character) == '/') )

/******************************************************************************/


/*----------------------------------------------------------------------------
<function>
	FUNCTION   : PVRDebugAssertFail
	PURPOSE    : To indicate to the user that a debug assertion has failed and
	             to prevent the program from continuing.
	PARAMETERS : In : pszFile - The name of the source file where the assertion failed
	             In : uLine - The line number of the failed assertion
	RETURNS    : NEVER!
</function>
------------------------------------------------------------------------------*/
void PVRDebugAssertFail(const IMG_CHAR* pszFile, IMG_UINT32 uLine)
{
	PVRDebugPrintf(DBGPRIV_FATAL, pszFile, uLine, "Debug assertion failed!");
	DebugBreak();
}


/*----------------------------------------------------------------------------
<function>
	FUNCTION   : PVRDebugPrintf
	PURPOSE    : To output a debug message to the user
	PARAMETERS : In : uDebugLevel - The current debug level
	             In : pszFile - The source file generating the message
	             In : uLine - The line of the source file
	             In : pszFormat - The message format string
	             In : ... - Zero or more arguments for use by the format string
	RETURNS    : None
</function>
------------------------------------------------------------------------------*/
void PVRDebugPrintf	(
						IMG_UINT32	uDebugLevel,
						const IMG_CHAR*	pszFilepath,
						IMG_UINT32	uLine,
						const IMG_CHAR*	pszFormat,
						...
					)
{
	static IMG_CHAR szMessage[PVR_MAX_DEBUG_MESSAGE_LEN+1];
	IMG_CHAR* pszEndOfMessage = IMG_NULL;
	const IMG_CHAR* pszFilename = IMG_NULL;
	const IMG_CHAR* pszCurrentChar;
	va_list ArgList;

	if (uDebugLevel <= gPVRDebugLevel)
	{
		strncpy(szMessage, "PVR: ", PVR_MAX_DEBUG_MESSAGE_LEN);

		pszEndOfMessage = &szMessage[strlen(szMessage)];

		va_start(ArgList, pszFormat);
		vsprintf(pszEndOfMessage, pszFormat, ArgList);
		va_end(ArgList);

		pszFilename = pszFilepath;
		pszCurrentChar = pszFilepath;

		/* Strip the path from the filename */
		while (*pszCurrentChar != PVR_STRING_TERMINATOR)
		{
			if (PVR_IS_FILE_SEPARATOR(*pszCurrentChar))
			{
				pszFilename = pszCurrentChar + 1;
			}
			++pszCurrentChar;
		}

		pszEndOfMessage = &szMessage[strlen(szMessage)];

		sprintf(pszEndOfMessage, " (%u,%s)\n", (unsigned int)uLine, pszFilename);

#ifdef _WIN32 
#ifndef UNICODE
		OutputDebugString(szMessage);
#else
		{
			TCHAR szUnicodeMessage[PVR_MAX_DEBUG_MESSAGE_LEN+1];
			ASCIITOTSTR( szUnicodeMessage, szMessage, PVR_MAX_DEBUG_MESSAGE_LEN );
			OutputDebugString(szUnicodeMessage);
		}
#endif
#else
	#if defined(PVR_KERNEL)
		printk(KERN_INFO "%s", szMessage);
	#else
		fprintf(stderr, szMessage);
	#endif	/* PVR_KERNEL */
#endif /* __WIN32 */
	}
}


/*----------------------------------------------------------------------------
<function>
	FUNCTION   : PVRTrace
	PURPOSE    : Simple trace without line numbers
	PARAMETERS : In : pszFormat - The message format string
	             In : ... - Zero or more arguments for use by the format string
	RETURNS    : None
</function>
------------------------------------------------------------------------------*/
void PVRTrace	( const IMG_CHAR* pszFormat, ... )
{
	va_list Parameters;
	static IMG_CHAR szPVRTrace[PVR_MAX_DEBUG_MESSAGE_LEN+1];

	va_start(Parameters, pszFormat);
	_vsnprintf(szPVRTrace, PVR_MAX_DEBUG_MESSAGE_LEN, pszFormat, Parameters);
	va_end(Parameters);

	strcat(szPVRTrace, "\n");

#ifdef _WIN32 
#ifndef UNICODE
		OutputDebugString(szPVRTrace);
#else
		{
			TCHAR szUnicodeMessage[PVR_MAX_DEBUG_MESSAGE_LEN+1];
			ASCIITOTSTR( szUnicodeMessage, szPVRTrace, PVR_MAX_DEBUG_MESSAGE_LEN );
			OutputDebugString(szUnicodeMessage);
			//HostWaitus(20);
		}
#endif
#else
	#if defined(PVR_KERNEL)
		printk(KERN_INFO "%s", szPVRTrace);
	#else
		fprintf(stderr, szPVRTrace);
	#endif	/* PVR_KERNEL */
#endif /* __WIN32 */
	


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -