printf.c 991 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * printf.c: Internal prom library printf facility.
  3. *
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (c) 2002 Pete Zaitcev (zaitcev@yahoo.com)
  6. *
  7. * We used to warn all over the code: DO NOT USE prom_printf(),
  8. * and yet people do. Anton's banking code was outputing banks
  9. * with prom_printf for most of the 2.4 lifetime. Since an effective
  10. * stick is not available, we deployed a carrot: an early printk
  11. * through PROM by means of -p boot option. This ought to fix it.
  12. * USE printk; if you need, deploy -p.
  13. */
  14. #include <linux/kernel.h>
  15. #include <asm/openprom.h>
  16. #include <asm/oplib.h>
  17. static char ppbuf[1024];
  18. void
  19. prom_write(const char *buf, unsigned int n)
  20. {
  21. char ch;
  22. while (n != 0) {
  23. --n;
  24. if ((ch = *buf++) == '\n')
  25. prom_putchar('\r');
  26. prom_putchar(ch);
  27. }
  28. }
  29. void
  30. prom_printf(char *fmt, ...)
  31. {
  32. va_list args;
  33. int i;
  34. va_start(args, fmt);
  35. i = vscnprintf(ppbuf, sizeof(ppbuf), fmt, args);
  36. va_end(args);
  37. prom_write(ppbuf, i);
  38. }