early_printk.c 824 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright IBM Corp. 2017
  4. */
  5. #include <linux/console.h>
  6. #include <linux/kernel.h>
  7. #include <linux/init.h>
  8. #include <asm/sclp.h>
  9. static void sclp_early_write(struct console *con, const char *s, unsigned int len)
  10. {
  11. __sclp_early_printk(s, len, 0);
  12. }
  13. static struct console sclp_early_console = {
  14. .name = "earlysclp",
  15. .write = sclp_early_write,
  16. .flags = CON_PRINTBUFFER | CON_BOOT,
  17. .index = -1,
  18. };
  19. static int __init setup_early_printk(char *buf)
  20. {
  21. if (early_console)
  22. return 0;
  23. /* Accept only "earlyprintk" and "earlyprintk=sclp" */
  24. if (buf && strncmp(buf, "sclp", 4))
  25. return 0;
  26. if (!sclp.has_linemode && !sclp.has_vt220)
  27. return 0;
  28. early_console = &sclp_early_console;
  29. register_console(early_console);
  30. return 0;
  31. }
  32. early_param("earlyprintk", setup_early_printk);