#ifndef __RTL_CONS_H__
#define __RTL_CONS_H__
/*
 * debugging routines for RT-Linux
 *
 * Copyright (C) Michael Barabanov 1997
 * Copyright (C) VJY Associates 1999
 * Released under the terms of the GPL
 *
 */

#include <asm/system.h>

extern void conpr(const char * b);

extern int rtl_printf(const char * fmt, ...);

static inline void conprn(const unsigned int hexnum)
{
	int i;
	unsigned int d;
	unsigned int n = hexnum;
    	char s[10];
	s[9] = 0;
	s[8] = ' ';
	for (i=7; i>=0; i--) {
		d = n % 16;
		if (d < 10) {
			d += '0';
		} else {
			d += 'a' - 10;
		}
		s[i] = d; 
		n = n / 16;
	}
    	conpr(s);
}

static inline void conprd(const unsigned int num)
{
	int i;
	unsigned int d;
	unsigned int n = num;
    	char s[12];
	s[11] = 0;
	s[10] = ' ';
	for (i=9; i>=0; i--) {
		d = n % 10;
		if (d < 10) {
			d += '0';
		} else {
			d += 'a' - 10;
		}
		s[i] = d; 
		n = n / 10;
	}
    	conpr(s);
}

#define rt_check_cli() { long flags; r_save_flags(flags); \
	if (flags & 0x200) { \
		conpr("interrupts are enabled!\n"); \
	} \
}

#define CONPRX(a,b)  {conpr(a); conprn((int)(b)); conpr("\n");}
#define conprll(ll) { conprn((int)((ll) >> 32)); conprn((int) (ll)); }
#define conprtime(ts) { conprd((ts).tv_sec); conprd((ts).tv_nsec); }

#define PRINTAX \
	"pushl %%eax\n\t" \
	"pushl %%ebp\n\t" \
	"pushl %%edi\n\t" \
	"pushl %%esi\n\t" \
	"pushl %%edx\n\t" \
	"pushl %%ecx\n\t" \
	"pushl %%ebx\n\t" \
	"pushl %%eax\n\t" \
	"call "SYMBOL_NAME_STR(conprn)"\n\t" \
	"add $4, %%esp\n\t" \
	"popl %%ebx\n\t \
	popl %%ecx\n\t \
	popl %%edx\n\t \
	popl %%esi\n\t \
	popl %%edi\n\t \
	popl %%ebp\n\t \
	popl %%eax\n\t"

extern inline void conf(void) {
 int i;
 for ( i=0; i< 10000000; i++); 
}

#endif
