early_printk.c 955 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 ([email protected])
  7. * Copyright (C) 2007 MIPS Technologies, Inc.
  8. * written by Ralf Baechle ([email protected])
  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. static void early_console_write(struct console *con, const char *s, unsigned n)
  16. {
  17. while (n-- && *s) {
  18. if (*s == '\n')
  19. prom_putchar('\r');
  20. prom_putchar(*s);
  21. s++;
  22. }
  23. }
  24. static struct console early_console_prom = {
  25. .name = "early",
  26. .write = early_console_write,
  27. .flags = CON_PRINTBUFFER | CON_BOOT,
  28. .index = -1
  29. };
  30. void __init setup_early_printk(void)
  31. {
  32. if (early_console)
  33. return;
  34. early_console = &early_console_prom;
  35. register_console(&early_console_prom);
  36. }