early_printk.c 976 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 __init
  14. early_console_write(struct console *con, const char *s, unsigned n)
  15. {
  16. while (n-- && *s) {
  17. if (*s == '\n')
  18. prom_putchar('\r');
  19. prom_putchar(*s);
  20. s++;
  21. }
  22. }
  23. static struct console early_console __initdata = {
  24. .name = "early",
  25. .write = early_console_write,
  26. .flags = CON_PRINTBUFFER | CON_BOOT,
  27. .index = -1
  28. };
  29. static int early_console_initialized __initdata;
  30. void __init setup_early_printk(void)
  31. {
  32. if (early_console_initialized)
  33. return;
  34. early_console_initialized = 1;
  35. register_console(&early_console);
  36. }