console.c 815 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * DECstation PROM-based early console support.
  4. *
  5. * Copyright (C) 2004, 2007 Maciej W. Rozycki
  6. */
  7. #include <linux/console.h>
  8. #include <linux/init.h>
  9. #include <linux/kernel.h>
  10. #include <linux/string.h>
  11. #include <asm/dec/prom.h>
  12. static void __init prom_console_write(struct console *con, const char *s,
  13. unsigned int c)
  14. {
  15. char buf[81];
  16. unsigned int chunk = sizeof(buf) - 1;
  17. while (c > 0) {
  18. if (chunk > c)
  19. chunk = c;
  20. memcpy(buf, s, chunk);
  21. buf[chunk] = '\0';
  22. prom_printf("%s", buf);
  23. s += chunk;
  24. c -= chunk;
  25. }
  26. }
  27. static struct console promcons __initdata = {
  28. .name = "prom",
  29. .write = prom_console_write,
  30. .flags = CON_BOOT | CON_PRINTBUFFER,
  31. .index = -1,
  32. };
  33. void __init register_prom_console(void)
  34. {
  35. register_console(&promcons);
  36. }