early_printk.c 990 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * linux/arch/arm/kernel/early_printk.c
  3. *
  4. * Copyright (C) 2009 Sascha Hauer <s.hauer@pengutronix.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/console.h>
  12. #include <linux/init.h>
  13. extern void printch(int);
  14. static void early_write(const char *s, unsigned n)
  15. {
  16. while (n-- > 0) {
  17. if (*s == '\n')
  18. printch('\r');
  19. printch(*s);
  20. s++;
  21. }
  22. }
  23. static void early_console_write(struct console *con, const char *s, unsigned n)
  24. {
  25. early_write(s, n);
  26. }
  27. static struct console early_console_dev = {
  28. .name = "earlycon",
  29. .write = early_console_write,
  30. .flags = CON_PRINTBUFFER | CON_BOOT,
  31. .index = -1,
  32. };
  33. static int __init setup_early_printk(char *buf)
  34. {
  35. early_console = &early_console_dev;
  36. register_console(&early_console_dev);
  37. return 0;
  38. }
  39. early_param("earlyprintk", setup_early_printk);