early_printk.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #include "../mvme147/mvme147.h"
  14. #include "../mvme16x/mvme16x.h"
  15. asmlinkage void __init debug_cons_nputs(struct console *c, const char *s, unsigned int n);
  16. static struct console early_console_instance = {
  17. .name = "debug",
  18. .flags = CON_PRINTBUFFER | CON_BOOT,
  19. .index = -1
  20. };
  21. static int __init setup_early_printk(char *buf)
  22. {
  23. if (early_console || buf)
  24. return 0;
  25. if (MACH_IS_MVME147)
  26. early_console_instance.write = mvme147_scc_write;
  27. else if (MACH_IS_MVME16x)
  28. early_console_instance.write = mvme16x_cons_write;
  29. else
  30. early_console_instance.write = debug_cons_nputs;
  31. early_console = &early_console_instance;
  32. register_console(early_console);
  33. return 0;
  34. }
  35. early_param("earlyprintk", setup_early_printk);
  36. static int __init unregister_early_console(void)
  37. {
  38. /*
  39. * debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be
  40. * called after init sections are discarded (for platforms that use it).
  41. */
  42. if (early_console && early_console->write == debug_cons_nputs)
  43. return unregister_console(early_console);
  44. return 0;
  45. }
  46. late_initcall(unregister_early_console);