early_printk.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include <linux/string.h>
  14. extern void printascii(const char *);
  15. static void early_write(const char *s, unsigned n)
  16. {
  17. char buf[128];
  18. while (n) {
  19. unsigned l = min(n, sizeof(buf)-1);
  20. memcpy(buf, s, l);
  21. buf[l] = 0;
  22. s += l;
  23. n -= l;
  24. printascii(buf);
  25. }
  26. }
  27. static void early_console_write(struct console *con, const char *s, unsigned n)
  28. {
  29. early_write(s, n);
  30. }
  31. static struct console early_console_dev = {
  32. .name = "earlycon",
  33. .write = early_console_write,
  34. .flags = CON_PRINTBUFFER | CON_BOOT,
  35. .index = -1,
  36. };
  37. static int __init setup_early_printk(char *buf)
  38. {
  39. early_console = &early_console_dev;
  40. register_console(&early_console_dev);
  41. return 0;
  42. }
  43. early_param("earlyprintk", setup_early_printk);