early_printk.c 988 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/kernel.h>
  11. #include <linux/console.h>
  12. #include <linux/printk.h>
  13. #include <linux/init.h>
  14. #include <asm/setup.h>
  15. extern void prom_putchar(char);
  16. static void early_console_write(struct console *con, const char *s, unsigned n)
  17. {
  18. while (n-- && *s) {
  19. if (*s == '\n')
  20. prom_putchar('\r');
  21. prom_putchar(*s);
  22. s++;
  23. }
  24. }
  25. static struct console early_console_prom = {
  26. .name = "early",
  27. .write = early_console_write,
  28. .flags = CON_PRINTBUFFER | CON_BOOT,
  29. .index = -1
  30. };
  31. void __init setup_early_printk(void)
  32. {
  33. if (early_console)
  34. return;
  35. early_console = &early_console_prom;
  36. register_console(&early_console_prom);
  37. }