printf.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* $Id: printf.c,v 1.5 1996/04/04 16:31:07 tridge Exp $
  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/config.h>
  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_AP1000
  32. ap_write(1,bptr,strlen(bptr));
  33. #else
  34. #ifdef CONFIG_KGDB
  35. if (kgdb_initialized) {
  36. printk("kgdb_initialized = %d\n", kgdb_initialized);
  37. putpacket(bptr, 1);
  38. } else
  39. #else
  40. while((ch = *(bptr++)) != 0) {
  41. if(ch == '\n')
  42. prom_putchar('\r');
  43. prom_putchar(ch);
  44. }
  45. #endif
  46. #endif
  47. va_end(args);
  48. return;
  49. }