console.c 919 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifdef SUSPEND_CONSOLE
  11. static int orig_fgconsole, orig_kmsg;
  12. int pm_prepare_console(void)
  13. {
  14. acquire_console_sem();
  15. orig_fgconsole = fg_console;
  16. if (vc_allocate(SUSPEND_CONSOLE)) {
  17. /* we can't have a free VC for now. Too bad,
  18. * we don't want to mess the screen for now. */
  19. release_console_sem();
  20. return 1;
  21. }
  22. set_console(SUSPEND_CONSOLE);
  23. release_console_sem();
  24. if (vt_waitactive(SUSPEND_CONSOLE)) {
  25. pr_debug("Suspend: Can't switch VCs.");
  26. return 1;
  27. }
  28. orig_kmsg = kmsg_redirect;
  29. kmsg_redirect = SUSPEND_CONSOLE;
  30. return 0;
  31. }
  32. void pm_restore_console(void)
  33. {
  34. acquire_console_sem();
  35. set_console(orig_fgconsole);
  36. release_console_sem();
  37. kmsg_redirect = orig_kmsg;
  38. return;
  39. }
  40. #endif