console_32.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * console.c: Routines that deal with sending and receiving IO
  3. * to/from the current console device using the PROM.
  4. *
  5. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6. * Copyright (C) 1998 Pete Zaitcev <zaitcev@yahoo.com>
  7. */
  8. #include <linux/types.h>
  9. #include <linux/kernel.h>
  10. #include <linux/sched.h>
  11. #include <asm/openprom.h>
  12. #include <asm/oplib.h>
  13. #include <asm/system.h>
  14. #include <linux/string.h>
  15. extern void restore_current(void);
  16. /* Non blocking put character to console device, returns -1 if
  17. * unsuccessful.
  18. */
  19. static int prom_nbputchar(const char *buf)
  20. {
  21. unsigned long flags;
  22. int i = -1;
  23. spin_lock_irqsave(&prom_lock, flags);
  24. switch(prom_vers) {
  25. case PROM_V0:
  26. i = (*(romvec->pv_nbputchar))(*buf);
  27. break;
  28. case PROM_V2:
  29. case PROM_V3:
  30. if ((*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout,
  31. buf, 0x1) == 1)
  32. i = 0;
  33. break;
  34. default:
  35. break;
  36. };
  37. restore_current();
  38. spin_unlock_irqrestore(&prom_lock, flags);
  39. return i; /* Ugh, we could spin forever on unsupported proms ;( */
  40. }
  41. /* Blocking version of put character routine above. */
  42. void prom_putchar(const char *buf)
  43. {
  44. while (1) {
  45. int err = prom_nbputchar(buf);
  46. if (!err)
  47. break;
  48. }
  49. }