printf.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/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_AP1000
  31. ap_write(1,bptr,strlen(bptr));
  32. #else
  33. #ifdef CONFIG_KGDB
  34. if (kgdb_initialized) {
  35. printk("kgdb_initialized = %d\n", kgdb_initialized);
  36. putpacket(bptr, 1);
  37. } else
  38. #else
  39. while((ch = *(bptr++)) != 0) {
  40. if(ch == '\n')
  41. prom_putchar('\r');
  42. prom_putchar(ch);
  43. }
  44. #endif
  45. #endif
  46. va_end(args);
  47. return;
  48. }