console.c 717 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/console.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 = kmsg_redirect;
  20. kmsg_redirect = SUSPEND_CONSOLE;
  21. return 0;
  22. }
  23. void pm_restore_console(void)
  24. {
  25. if (orig_fgconsole >= 0) {
  26. vt_move_to_console(orig_fgconsole, 0);
  27. kmsg_redirect = orig_kmsg;
  28. }
  29. }
  30. #endif