console_32.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <linux/string.h>
  14. extern void restore_current(void);
  15. /* Non blocking put character to console device, returns -1 if
  16. * unsuccessful.
  17. */
  18. static int prom_nbputchar(const char *buf)
  19. {
  20. unsigned long flags;
  21. int i = -1;
  22. spin_lock_irqsave(&prom_lock, flags);
  23. switch(prom_vers) {
  24. case PROM_V0:
  25. if ((*(romvec->pv_nbputchar))(*buf))
  26. i = 1;
  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 = 1;
  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. void prom_console_write_buf(const char *buf, int len)
  42. {
  43. while (len) {
  44. int n = prom_nbputchar(buf);
  45. if (n < 0)
  46. continue;
  47. len--;
  48. buf++;
  49. }
  50. }