early_printk.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * arch/sh/kernel/early_printk.c
  3. *
  4. * Copyright (C) 1999, 2000 Niibe Yutaka
  5. * Copyright (C) 2002 M. R. Brown
  6. * Copyright (C) 2004 - 2007 Paul Mundt
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/console.h>
  13. #include <linux/tty.h>
  14. #include <linux/init.h>
  15. #include <linux/io.h>
  16. #include <linux/delay.h>
  17. #include <asm/sh_bios.h>
  18. /*
  19. * Print a string through the BIOS
  20. */
  21. static void sh_console_write(struct console *co, const char *s,
  22. unsigned count)
  23. {
  24. sh_bios_console_write(s, count);
  25. }
  26. /*
  27. * Setup initial baud/bits/parity. We do two things here:
  28. * - construct a cflag setting for the first rs_open()
  29. * - initialize the serial port
  30. * Return non-zero if we didn't find a serial port.
  31. */
  32. static int __init sh_console_setup(struct console *co, char *options)
  33. {
  34. int cflag = CREAD | HUPCL | CLOCAL;
  35. /*
  36. * Now construct a cflag setting.
  37. * TODO: this is a totally bogus cflag, as we have
  38. * no idea what serial settings the BIOS is using, or
  39. * even if its using the serial port at all.
  40. */
  41. cflag |= B115200 | CS8 | /*no parity*/0;
  42. co->cflag = cflag;
  43. return 0;
  44. }
  45. static struct console bios_console = {
  46. .name = "bios",
  47. .write = sh_console_write,
  48. .setup = sh_console_setup,
  49. .flags = CON_PRINTBUFFER,
  50. .index = -1,
  51. };
  52. static struct console *early_console;
  53. static int __init setup_early_printk(char *buf)
  54. {
  55. int keep_early = 0;
  56. if (!buf)
  57. return 0;
  58. if (strstr(buf, "keep"))
  59. keep_early = 1;
  60. if (!strncmp(buf, "bios", 4))
  61. early_console = &bios_console;
  62. if (likely(early_console)) {
  63. if (keep_early)
  64. early_console->flags &= ~CON_BOOT;
  65. else
  66. early_console->flags |= CON_BOOT;
  67. register_console(early_console);
  68. }
  69. return 0;
  70. }
  71. early_param("earlyprintk", setup_early_printk);