printf.c 922 B

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