Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /* $Id: print.c,v 1.1 1999/01/17 03:49:38 ralf Exp $ * * print.c: Simple print fascility * * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov * */ #include <stdarg.h> #include <linux/kernel.h> #include <linux/init.h> #include <asm/baget/baget.h> /* * Define this to see 'baget_printk' (debug) messages */ // #define BAGET_PRINTK /* * This function is same for BALO and Linux baget_printk, * and normally prints characted to second (UART A) console. */ static void delay(void) {} static void outc_low(char c) { int i; vac_outb(c, VAC_UART_B_TX); for (i=0; i<10000; i++) delay(); } void outc(char c) { if (c == '\n') outc_low('\r'); outc_low(c); } void outs(char *s) { while(*s) outc(*s++); } void baget_write(char *s, int l) { while(l--) outc(*s++); } int baget_printk(const char *fmt, ...) { #ifdef BAGET_PRINTK va_list args; int i; static char buf[1024]; va_start(args, fmt); i = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf)-4 */ va_end(args); baget_write(buf, i); return i; #else return 0; #endif } static __inline__ void puthex( int a ) { static char s[9]; static char e[] = "0123456789ABCDEF"; int i; for( i = 7; i >= 0; i--, a >>= 4 ) s[i] = e[a & 0x0F]; s[8] = '\0'; outs( s ); } void __init balo_printf( char *f, ... ) { int *arg = (int*)&f + 1; char c; int format = 0; while((c = *f++) != 0) { switch(c) { default: if(format) { outc('%'); format = 0; } outc( c ); break; case '%': if( format ){ format = 0; outc(c); } else format = 1; break; case 'x': if(format) puthex( *arg++ ); else outc(c); format = 0; break; case 's': if( format ) outs((char *)*arg++); else outc(c); format = 0; break; } } } void __init balo_hungup(void) { outs("Hunging up.\n"); while(1); } |