console.c 614 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * 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/vt.h>
  9. #include <linux/module.h>
  10. #include "power.h"
  11. #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
  12. static int orig_fgconsole, orig_kmsg;
  13. int pm_prepare_console(void)
  14. {
  15. orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1);
  16. if (orig_fgconsole < 0)
  17. return 1;
  18. orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE);
  19. return 0;
  20. }
  21. void pm_restore_console(void)
  22. {
  23. if (orig_fgconsole >= 0) {
  24. vt_move_to_console(orig_fgconsole, 0);
  25. vt_kmsg_redirect(orig_kmsg);
  26. }
  27. }