xref: /linux/arch/m68k/sun3/prom/printf.c (revision 8e07e0e3964ca4e23ce7b68e2096fe660a888942)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * printf.c:  Internal prom library printf facility.
4  *
5  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
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 #ifdef CONFIG_KGDB
18 extern int kgdb_initialized;
19 #endif
20 
21 static char ppbuf[1024];
22 
23 void
24 prom_printf(char *fmt, ...)
25 {
26 	va_list args;
27 	char ch, *bptr;
28 
29 	va_start(args, fmt);
30 
31 #ifdef CONFIG_KGDB
32 	ppbuf[0] = 'O';
33 	vsprintf(ppbuf + 1, fmt, args) + 1;
34 #else
35 	vsprintf(ppbuf, fmt, args);
36 #endif
37 
38 	bptr = ppbuf;
39 
40 #ifdef CONFIG_KGDB
41 	if (kgdb_initialized) {
42 		pr_info("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
53 	va_end(args);
54 	return;
55 }
56