xref: /linux/arch/m68k/sun3/prom/printf.c (revision 6fdcba32711044c35c0e1b094cbd8f3f0b4472c9)
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 	int i;
29 
30 	va_start(args, fmt);
31 
32 #ifdef CONFIG_KGDB
33 	ppbuf[0] = 'O';
34 	i = vsprintf(ppbuf + 1, fmt, args) + 1;
35 #else
36 	i = vsprintf(ppbuf, fmt, args);
37 #endif
38 
39 	bptr = ppbuf;
40 
41 #ifdef CONFIG_KGDB
42 	if (kgdb_initialized) {
43 		pr_info("kgdb_initialized = %d\n", kgdb_initialized);
44 		putpacket(bptr, 1);
45 	} else
46 #else
47 	while((ch = *(bptr++)) != 0) {
48 		if(ch == '\n')
49 			prom_putchar('\r');
50 
51 		prom_putchar(ch);
52 	}
53 #endif
54 	va_end(args);
55 	return;
56 }
57