/*
 * Copyright (c) 2003 Linuxant inc.
 * Copyright (c) 2001-2003 Conexant Systems, Inc.
 *
 * NOTE: The use and distribution of this software is governed by the terms in
 * the file LICENSE, which is included in the package. You must read this and
 * agree to these terms before using or distributing this software.
 *
 */
/*************************************************************************

  File Name: OsDebug.c

  File Description: This file implements some os-specific debug utilities.

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

#include "oscompat.h"

#include "framewrk.h"
#include "ossysenv.h"

void    OsErrorVPrintf       (const char *szFormat, va_list args)
{
	char printk_buf[1024];

	printk_buf[0]= '\0';
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) )
	vsprintf(printk_buf, szFormat, args);
#else
	vsnprintf(printk_buf, sizeof(printk_buf), szFormat, args);
#endif

	printk_buf[sizeof(printk_buf)-1]= '\0';

#if 0
	{
		static int lasthadnl=1;
		if(lasthadnl)
			printk(KERN_ERR"%s", printk_buf);
		else
			printk("%s", printk_buf);

		lasthadnl = printk_buf[strlen(printk_buf) - 1] == '\n';
	}
#else
	printk("%s", printk_buf);
#endif
}

void    OsErrorPrintf       (const char *szFormat, ...)
{
	va_list args;

	va_start(args, szFormat);
	OsErrorVPrintf(szFormat, args);
	va_end(args);
}

void    OsDebugVPrintf       (const char *szFormat, va_list args)
{
	char printk_buf[1024];

	printk_buf[0]= '\0';
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) )
	vsprintf(printk_buf, szFormat, args);
#else
	vsnprintf(printk_buf, sizeof(printk_buf), szFormat, args);
#endif

	printk_buf[sizeof(printk_buf)-1]= '\0';

	printk("%s", printk_buf);
}

void    OsDebugPrintf       (const char *szFormat, ...)
{
	va_list args;

	va_start(args, szFormat);
	OsDebugVPrintf(szFormat, args);
	va_end(args);
}

void    OsDebugBreakpoint   ( LPCSTR szMsg )
{
	OsDebugPrintf("%s: %s\n", __FUNCTION__, szMsg);
	KDB_ENTER();
}

void OsDebugDumpData(PUINT8 data, UINT32 len)
{
	OsDebugPrintf("%s: data=%p len=%ld\n", __FUNCTION__, data, len);
}

