console.c 994 B

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