mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-22 20:23:57 +08:00
5ada918b82
The kernel offers with TIOCL_GETKMSGREDIRECT ioctl() the possibility to redirect the kernel messages to a specific console. However, since it's not possible to switch to the kernel message console after a panic(), it would be nice if the kernel would print the panic message on the current console. This patch series adds a new interface to access the global kmsg_redirect variable by a function to be able to use it in code where CONFIG_VT_CONSOLE is not set (kernel/panic.c). This patch: Instead of using and exporting a global value kmsg_redirect, introduce a function vt_kmsg_redirect() that both can set and return the console where messages are printed. Change all users of kmsg_redirect (the VT code itself and kernel/power.c) to the new interface. The main advantage is that vt_kmsg_redirect() can also be used when CONFIG_VT_CONSOLE is not set. Signed-off-by: Bernhard Walle <bernhard@bwalle.de> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
36 lines
700 B
C
36 lines
700 B
C
/*
|
|
* drivers/power/process.c - Functions for saving/restoring console.
|
|
*
|
|
* Originally from swsusp.
|
|
*/
|
|
|
|
#include <linux/vt_kern.h>
|
|
#include <linux/kbd_kern.h>
|
|
#include <linux/vt.h>
|
|
#include <linux/module.h>
|
|
#include "power.h"
|
|
|
|
#if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
|
|
#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
|
|
|
|
static int orig_fgconsole, orig_kmsg;
|
|
|
|
int pm_prepare_console(void)
|
|
{
|
|
orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1);
|
|
if (orig_fgconsole < 0)
|
|
return 1;
|
|
|
|
orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE);
|
|
return 0;
|
|
}
|
|
|
|
void pm_restore_console(void)
|
|
{
|
|
if (orig_fgconsole >= 0) {
|
|
vt_move_to_console(orig_fgconsole, 0);
|
|
vt_kmsg_redirect(orig_kmsg);
|
|
}
|
|
}
|
|
#endif
|