
/* REAL TIME LINUX 
   Right now this is just for the proc entry
   
   (c) Victor Yodaiken August 1998, GPL
   */
#include <linux/kernel.h>
/* #include <linux/rtl_version.h> */
#include <linux/version.h>

#include <linux/mm.h>
#include <linux/tty_driver.h>
#include <linux/smp_lock.h>
#include <linux/console.h>
#include <linux/init.h>

#include <asm/uaccess.h>
#include <linux/cons.h>
#include <linux/console.h>
#include <asm/spinlock.h>
#include <asm/rtl_sync.h>
#include <stdarg.h>


int get_rtl_status(char *buf)
{
	return(sprintf(buf, "RT-Linux version %s\n", UTS_RELEASE));
}


extern struct console *console_drivers;

void conpr(const char *s)
{
	long flags;
	static spinlock_t rtl_conpr_lock = SPIN_LOCK_UNLOCKED;
	struct console *c;
	int len = strlen(s);

	rtl_hard_savef_and_cli(flags);
	spin_lock(&rtl_conpr_lock);

	c = console_drivers;
	while(c) {
		if ((c->flags & CON_ENABLED) && c->write)
			c->write(c, s, len);
		c = c->next;
	}
	spin_unlock(&rtl_conpr_lock);
	rtl_hard_restore_flags(flags);
}


int rtl_printf(const char * fmt, ...)
{
	static char buf[2048];
	int flags;
	int i;
	va_list args;
	static spinlock_t rtl_cprintf_lock = SPIN_LOCK_UNLOCKED;

	rtl_hard_savef_and_cli(flags);
	spin_lock(&rtl_cprintf_lock);

	va_start(args, fmt);
	i=vsprintf(buf,fmt,args);
	va_end(args);
	conpr(buf);

	rtl_hard_cli();
	spin_unlock(&rtl_cprintf_lock);
	rtl_hard_restore_flags(flags);

	return i;
}


