early_printk.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * linux/arch/unicore32/kernel/early_printk.c
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/console.h>
  13. #include <linux/init.h>
  14. #include <linux/string.h>
  15. #include <mach/ocd.h>
  16. /* On-Chip-Debugger functions */
  17. static void early_ocd_write(struct console *con, const char *s, unsigned n)
  18. {
  19. while (*s && n-- > 0) {
  20. if (*s == '\n')
  21. ocd_putc((int)'\r');
  22. ocd_putc((int)*s);
  23. s++;
  24. }
  25. }
  26. static struct console early_ocd_console = {
  27. .name = "earlyocd",
  28. .write = early_ocd_write,
  29. .flags = CON_PRINTBUFFER,
  30. .index = -1,
  31. };
  32. static int __init setup_early_printk(char *buf)
  33. {
  34. if (!buf || early_console)
  35. return 0;
  36. early_console = &early_ocd_console;
  37. if (strstr(buf, "keep"))
  38. early_console->flags &= ~CON_BOOT;
  39. else
  40. early_console->flags |= CON_BOOT;
  41. register_console(early_console);
  42. return 0;
  43. }
  44. early_param("earlyprintk", setup_early_printk);