console.c 700 B

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