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 <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. void prom_console_write_buf(const char *buf, int len)
  42. {
  43. while (len) {
  44. int n = prom_nbputchar(buf);
  45. if (n)
  46. continue;
  47. len--;
  48. buf++;
  49. }
  50. }