Root/kernel/power/console.c

1/*
2 * drivers/power/process.c - Functions for saving/restoring console.
3 *
4 * Originally from swsusp.
5 */
6
7#include <linux/vt_kern.h>
8#include <linux/kbd_kern.h>
9#include <linux/vt.h>
10#include <linux/module.h>
11#include "power.h"
12
13#if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
14#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
15
16static int orig_fgconsole, orig_kmsg;
17
18int pm_prepare_console(void)
19{
20    orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1);
21    if (orig_fgconsole < 0)
22        return 1;
23
24    orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE);
25    return 0;
26}
27
28void pm_restore_console(void)
29{
30    if (orig_fgconsole >= 0) {
31        vt_move_to_console(orig_fgconsole, 0);
32        vt_kmsg_redirect(orig_kmsg);
33    }
34}
35#endif
36

Archive Download this file



interactive