early_printk.c 833 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2002, 2003, 06, 07 Ralf Baechle (ralf@linux-mips.org)
  7. * Copyright (C) 2007 MIPS Technologies, Inc.
  8. * written by Ralf Baechle (ralf@linux-mips.org)
  9. */
  10. #include <linux/console.h>
  11. #include <linux/init.h>
  12. extern void prom_putchar(char);
  13. static void early_console_write(struct console *con, const char *s, unsigned n)
  14. {
  15. while (n-- && *s) {
  16. if (*s == '\n')
  17. prom_putchar('\r');
  18. prom_putchar(*s);
  19. s++;
  20. }
  21. }
  22. static struct console early_console = {
  23. .name = "early",
  24. .write = early_console_write,
  25. .flags = CON_PRINTBUFFER | CON_BOOT,
  26. .index = -1
  27. };
  28. void __init setup_early_printk(void)
  29. {
  30. register_console(&early_console);
  31. }