printf.c 959 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * printf.c: Internal prom library printf facility.
  4. *
  5. * Copyright (C) 1995 David S. Miller ([email protected])
  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. #include <linux/kernel.h>
  11. #include <asm/openprom.h>
  12. #include <asm/oplib.h>
  13. #ifdef CONFIG_KGDB
  14. extern int kgdb_initialized;
  15. #endif
  16. static char ppbuf[1024];
  17. void
  18. prom_printf(char *fmt, ...)
  19. {
  20. va_list args;
  21. char ch, *bptr;
  22. int i;
  23. va_start(args, fmt);
  24. #ifdef CONFIG_KGDB
  25. ppbuf[0] = 'O';
  26. i = vsprintf(ppbuf + 1, fmt, args) + 1;
  27. #else
  28. i = vsprintf(ppbuf, fmt, args);
  29. #endif
  30. bptr = ppbuf;
  31. #ifdef CONFIG_KGDB
  32. if (kgdb_initialized) {
  33. pr_info("kgdb_initialized = %d\n", kgdb_initialized);
  34. putpacket(bptr, 1);
  35. } else
  36. #else
  37. while((ch = *(bptr++)) != 0) {
  38. if(ch == '\n')
  39. prom_putchar('\r');
  40. prom_putchar(ch);
  41. }
  42. #endif
  43. va_end(args);
  44. return;
  45. }