1 /* $Id: printf.c,v 1.3 1997/03/18 18:00:00 jj Exp $
2 * printf.c: Internal prom library printf facility.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 */
7
8 /* This routine is internal to the prom library, no one else should know
9 * about or use it! It's simple and smelly anyway....
10 */
11
12 #include <linux/kernel.h>
13
14 #include <asm/openprom.h>
15 #include <asm/oplib.h>
16
17 static char ppbuf[1024];
18
19 extern void prom_puts (char *, int);
20
21 void
prom_printf(char * fmt,...)22 prom_printf(char *fmt, ...)
23 {
24 va_list args;
25 char ch, *bptr, *last;
26 int i;
27
28 va_start(args, fmt);
29 i = vsprintf(ppbuf, fmt, args);
30
31 bptr = ppbuf;
32 last = ppbuf;
33
34 while((ch = *(bptr++)) != 0) {
35 if(ch == '\n') {
36 if (last < bptr - 1)
37 prom_puts (last, bptr - 1 - last);
38 prom_putchar('\r');
39 last = bptr - 1;
40 }
41 }
42 if (last < bptr - 1)
43 prom_puts (last, bptr - 1 - last);
44 va_end(args);
45 return;
46 }
47