18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * printf.c: Internal prom library printf facility. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* This routine is internal to the prom library, no one else should know 98c2ecf20Sopenharmony_ci * about or use it! It's simple and smelly anyway.... 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/kernel.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <asm/openprom.h> 158c2ecf20Sopenharmony_ci#include <asm/oplib.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#ifdef CONFIG_KGDB 188c2ecf20Sopenharmony_ciextern int kgdb_initialized; 198c2ecf20Sopenharmony_ci#endif 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistatic char ppbuf[1024]; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_civoid 248c2ecf20Sopenharmony_ciprom_printf(char *fmt, ...) 258c2ecf20Sopenharmony_ci{ 268c2ecf20Sopenharmony_ci va_list args; 278c2ecf20Sopenharmony_ci char ch, *bptr; 288c2ecf20Sopenharmony_ci int i; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci va_start(args, fmt); 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#ifdef CONFIG_KGDB 338c2ecf20Sopenharmony_ci ppbuf[0] = 'O'; 348c2ecf20Sopenharmony_ci i = vsprintf(ppbuf + 1, fmt, args) + 1; 358c2ecf20Sopenharmony_ci#else 368c2ecf20Sopenharmony_ci i = vsprintf(ppbuf, fmt, args); 378c2ecf20Sopenharmony_ci#endif 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci bptr = ppbuf; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#ifdef CONFIG_KGDB 428c2ecf20Sopenharmony_ci if (kgdb_initialized) { 438c2ecf20Sopenharmony_ci pr_info("kgdb_initialized = %d\n", kgdb_initialized); 448c2ecf20Sopenharmony_ci putpacket(bptr, 1); 458c2ecf20Sopenharmony_ci } else 468c2ecf20Sopenharmony_ci#else 478c2ecf20Sopenharmony_ci while((ch = *(bptr++)) != 0) { 488c2ecf20Sopenharmony_ci if(ch == '\n') 498c2ecf20Sopenharmony_ci prom_putchar('\r'); 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci prom_putchar(ch); 528c2ecf20Sopenharmony_ci } 538c2ecf20Sopenharmony_ci#endif 548c2ecf20Sopenharmony_ci va_end(args); 558c2ecf20Sopenharmony_ci return; 568c2ecf20Sopenharmony_ci} 57