console_32.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * console.c: Routines that deal with sending and receiving IO
  4. * to/from the current console device using the PROM.
  5. *
  6. * Copyright (C) 1995 David S. Miller ([email protected])
  7. * Copyright (C) 1998 Pete Zaitcev <[email protected]>
  8. */
  9. #include <linux/types.h>
  10. #include <linux/kernel.h>
  11. #include <linux/sched.h>
  12. #include <asm/openprom.h>
  13. #include <asm/oplib.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. if ((*(romvec->pv_nbputchar))(*buf))
  27. i = 1;
  28. break;
  29. case PROM_V2:
  30. case PROM_V3:
  31. if ((*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout,
  32. buf, 0x1) == 1)
  33. i = 1;
  34. break;
  35. default:
  36. break;
  37. }
  38. restore_current();
  39. spin_unlock_irqrestore(&prom_lock, flags);
  40. return i; /* Ugh, we could spin forever on unsupported proms ;( */
  41. }
  42. void prom_console_write_buf(const char *buf, int len)
  43. {
  44. while (len) {
  45. int n = prom_nbputchar(buf);
  46. if (n < 0)
  47. continue;
  48. len--;
  49. buf++;
  50. }
  51. }