early_printk.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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) 2014 Finn Thain
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/console.h>
  10. #include <linux/init.h>
  11. #include <linux/string.h>
  12. #include <asm/setup.h>
  13. extern void mvme16x_cons_write(struct console *co,
  14. const char *str, unsigned count);
  15. asmlinkage void __init debug_cons_nputs(const char *s, unsigned n);
  16. static void __ref debug_cons_write(struct console *c,
  17. const char *s, unsigned n)
  18. {
  19. #if !(defined(CONFIG_SUN3) || defined(CONFIG_M68000) || \
  20. defined(CONFIG_COLDFIRE))
  21. if (MACH_IS_MVME16x)
  22. mvme16x_cons_write(c, s, n);
  23. else
  24. debug_cons_nputs(s, n);
  25. #endif
  26. }
  27. static struct console early_console_instance = {
  28. .name = "debug",
  29. .write = debug_cons_write,
  30. .flags = CON_PRINTBUFFER | CON_BOOT,
  31. .index = -1
  32. };
  33. static int __init setup_early_printk(char *buf)
  34. {
  35. if (early_console || buf)
  36. return 0;
  37. early_console = &early_console_instance;
  38. register_console(early_console);
  39. return 0;
  40. }
  41. early_param("earlyprintk", setup_early_printk);
  42. /*
  43. * debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be called
  44. * after init sections are discarded (for platforms that use it).
  45. */
  46. #if !(defined(CONFIG_SUN3) || defined(CONFIG_M68000) || \
  47. defined(CONFIG_COLDFIRE))
  48. static int __init unregister_early_console(void)
  49. {
  50. if (!early_console || MACH_IS_MVME16x)
  51. return 0;
  52. return unregister_console(early_console);
  53. }
  54. late_initcall(unregister_early_console);
  55. #endif