initial commit with v2.6.9
[linux-2.6.9-moxart.git] / arch / mips / baget / print.c
blob50f0dfa16c003ce2253361401174dfe83811b8cd
1 /*
2 * print.c: Simple print fascility
4 * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov
5 */
6 #include <stdarg.h>
7 #include <linux/kernel.h>
8 #include <linux/init.h>
10 #include <asm/baget/baget.h>
13 * Define this to see 'baget_printk' (debug) messages
15 // #define BAGET_PRINTK
18 * This function is same for BALO and Linux baget_printk,
19 * and normally prints characted to second (UART A) console.
22 static void delay(void) {}
24 static void outc_low(char c)
26 int i;
27 vac_outb(c, VAC_UART_B_TX);
28 for (i=0; i<10000; i++)
29 delay();
32 void outc(char c)
34 if (c == '\n')
35 outc_low('\r');
36 outc_low(c);
39 void outs(char *s)
41 while(*s) outc(*s++);
44 void baget_write(char *s, int l)
46 while(l--)
47 outc(*s++);
50 int baget_printk(const char *fmt, ...)
52 #ifdef BAGET_PRINTK
53 va_list args;
54 int i;
55 static char buf[1024];
57 va_start(args, fmt);
58 i = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf)-4 */
59 va_end(args);
60 baget_write(buf, i);
61 return i;
62 #else
63 return 0;
64 #endif
67 static __inline__ void puthex( int a )
69 static char s[9];
70 static char e[] = "0123456789ABCDEF";
71 int i;
72 for( i = 7; i >= 0; i--, a >>= 4 ) s[i] = e[a & 0x0F];
73 s[8] = '\0';
74 outs( s );
77 void __init balo_printf( char *f, ... )
79 int *arg = (int*)&f + 1;
80 char c;
81 int format = 0;
83 while((c = *f++) != 0) {
84 switch(c) {
85 default:
86 if(format) {
87 outc('%');
88 format = 0;
90 outc( c );
91 break;
92 case '%':
93 if( format ){
94 format = 0;
95 outc(c);
96 } else format = 1;
97 break;
98 case 'x':
99 if(format) puthex( *arg++ );
100 else outc(c);
101 format = 0;
102 break;
103 case 's':
104 if( format ) outs((char *)*arg++);
105 else outc(c);
106 format = 0;
107 break;
112 void __init balo_hungup(void)
114 outs("Hunging up.\n");
115 while(1);