| Adrian Bunk | f30828a | 2008-07-17 21:16:08 +0200 | [diff] [blame] | 1 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * printf.c:  Internal prom library printf facility. | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) | 
|  | 5 | */ | 
|  | 6 |  | 
|  | 7 | /* This routine is internal to the prom library, no one else should know | 
|  | 8 | * about or use it!  It's simple and smelly anyway.... | 
|  | 9 | */ | 
|  | 10 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/kernel.h> | 
|  | 12 |  | 
|  | 13 | #include <asm/openprom.h> | 
|  | 14 | #include <asm/oplib.h> | 
|  | 15 |  | 
|  | 16 | #ifdef CONFIG_KGDB | 
|  | 17 | extern int kgdb_initialized; | 
|  | 18 | #endif | 
|  | 19 |  | 
|  | 20 | static char ppbuf[1024]; | 
|  | 21 |  | 
|  | 22 | void | 
|  | 23 | prom_printf(char *fmt, ...) | 
|  | 24 | { | 
|  | 25 | va_list args; | 
|  | 26 | char ch, *bptr; | 
|  | 27 | int i; | 
|  | 28 |  | 
|  | 29 | va_start(args, fmt); | 
|  | 30 |  | 
|  | 31 | #ifdef CONFIG_KGDB | 
|  | 32 | ppbuf[0] = 'O'; | 
|  | 33 | i = vsprintf(ppbuf + 1, fmt, args) + 1; | 
|  | 34 | #else | 
|  | 35 | i = vsprintf(ppbuf, fmt, args); | 
|  | 36 | #endif | 
|  | 37 |  | 
|  | 38 | bptr = ppbuf; | 
|  | 39 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #ifdef CONFIG_KGDB | 
|  | 41 | if (kgdb_initialized) { | 
|  | 42 | printk("kgdb_initialized = %d\n", kgdb_initialized); | 
|  | 43 | putpacket(bptr, 1); | 
|  | 44 | } else | 
|  | 45 | #else | 
|  | 46 | while((ch = *(bptr++)) != 0) { | 
|  | 47 | if(ch == '\n') | 
|  | 48 | prom_putchar('\r'); | 
|  | 49 |  | 
|  | 50 | prom_putchar(ch); | 
|  | 51 | } | 
|  | 52 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | va_end(args); | 
|  | 54 | return; | 
|  | 55 | } |