console.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * drivers/power/process.c - Functions for saving/restoring console.
  3. *
  4. * Originally from swsusp.
  5. */
  6. #include <linux/vt_kern.h>
  7. #include <linux/kbd_kern.h>
  8. #include <linux/console.h>
  9. #include "power.h"
  10. static int new_loglevel = 10;
  11. static int orig_loglevel;
  12. #ifdef SUSPEND_CONSOLE
  13. static int orig_fgconsole, orig_kmsg;
  14. #endif
  15. int pm_prepare_console(void)
  16. {
  17. orig_loglevel = console_loglevel;
  18. console_loglevel = new_loglevel;
  19. #ifdef SUSPEND_CONSOLE
  20. acquire_console_sem();
  21. orig_fgconsole = fg_console;
  22. if (vc_allocate(SUSPEND_CONSOLE)) {
  23. /* we can't have a free VC for now. Too bad,
  24. * we don't want to mess the screen for now. */
  25. release_console_sem();
  26. return 1;
  27. }
  28. set_console(SUSPEND_CONSOLE);
  29. release_console_sem();
  30. if (vt_waitactive(SUSPEND_CONSOLE)) {
  31. pr_debug("Suspend: Can't switch VCs.");
  32. return 1;
  33. }
  34. orig_kmsg = kmsg_redirect;
  35. kmsg_redirect = SUSPEND_CONSOLE;
  36. #endif
  37. return 0;
  38. }
  39. void pm_restore_console(void)
  40. {
  41. console_loglevel = orig_loglevel;
  42. #ifdef SUSPEND_CONSOLE
  43. acquire_console_sem();
  44. set_console(orig_fgconsole);
  45. release_console_sem();
  46. kmsg_redirect = orig_kmsg;
  47. #endif
  48. return;
  49. }