2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/include/linux/console.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993 Hamish Macdonald
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file COPYING in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Changed:
|
|
|
|
* 10-Mar-94: Arno Griffioen: Conversion for vt100 emulator port from PC LINUX
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_CONSOLE_H_
|
|
|
|
#define _LINUX_CONSOLE_H_ 1
|
|
|
|
|
2018-07-31 19:06:57 +08:00
|
|
|
#include <linux/atomic.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
struct vc_data;
|
|
|
|
struct console_font_op;
|
|
|
|
struct console_font;
|
|
|
|
struct module;
|
2007-02-10 17:45:02 +08:00
|
|
|
struct tty_struct;
|
2018-06-28 21:20:30 +08:00
|
|
|
struct notifier_block;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* this is what the terminal answers to a ESC-Z or csi0c query.
|
|
|
|
*/
|
|
|
|
#define VT100ID "\033[?1;2c"
|
|
|
|
#define VT102ID "\033[?6c"
|
|
|
|
|
2016-10-03 17:18:33 +08:00
|
|
|
enum con_scroll {
|
|
|
|
SM_UP,
|
|
|
|
SM_DOWN,
|
|
|
|
};
|
|
|
|
|
2016-06-23 19:34:26 +08:00
|
|
|
/**
|
|
|
|
* struct consw - callbacks for consoles
|
|
|
|
*
|
2016-10-03 17:18:33 +08:00
|
|
|
* @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
|
|
|
|
* Return true if no generic handling should be done.
|
|
|
|
* Invoked by csi_M and printing to the console.
|
2016-06-23 19:34:27 +08:00
|
|
|
* @con_set_palette: sets the palette of the console to @table (optional)
|
2016-06-23 19:34:26 +08:00
|
|
|
* @con_scrolldelta: the contents of the console should be scrolled by @lines.
|
|
|
|
* Invoked by user. (optional)
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
struct consw {
|
|
|
|
struct module *owner;
|
|
|
|
const char *(*con_startup)(void);
|
2018-02-27 08:04:19 +08:00
|
|
|
void (*con_init)(struct vc_data *vc, int init);
|
|
|
|
void (*con_deinit)(struct vc_data *vc);
|
|
|
|
void (*con_clear)(struct vc_data *vc, int sy, int sx, int height,
|
|
|
|
int width);
|
|
|
|
void (*con_putc)(struct vc_data *vc, int c, int ypos, int xpos);
|
|
|
|
void (*con_putcs)(struct vc_data *vc, const unsigned short *s,
|
|
|
|
int count, int ypos, int xpos);
|
|
|
|
void (*con_cursor)(struct vc_data *vc, int mode);
|
|
|
|
bool (*con_scroll)(struct vc_data *vc, unsigned int top,
|
2016-10-03 17:18:33 +08:00
|
|
|
unsigned int bottom, enum con_scroll dir,
|
|
|
|
unsigned int lines);
|
2018-02-27 08:04:19 +08:00
|
|
|
int (*con_switch)(struct vc_data *vc);
|
|
|
|
int (*con_blank)(struct vc_data *vc, int blank, int mode_switch);
|
|
|
|
int (*con_font_set)(struct vc_data *vc, struct console_font *font,
|
|
|
|
unsigned int flags);
|
|
|
|
int (*con_font_get)(struct vc_data *vc, struct console_font *font);
|
|
|
|
int (*con_font_default)(struct vc_data *vc,
|
|
|
|
struct console_font *font, char *name);
|
|
|
|
int (*con_font_copy)(struct vc_data *vc, int con);
|
|
|
|
int (*con_resize)(struct vc_data *vc, unsigned int width,
|
|
|
|
unsigned int height, unsigned int user);
|
|
|
|
void (*con_set_palette)(struct vc_data *vc,
|
2016-06-23 19:34:27 +08:00
|
|
|
const unsigned char *table);
|
2018-02-27 08:04:19 +08:00
|
|
|
void (*con_scrolldelta)(struct vc_data *vc, int lines);
|
|
|
|
int (*con_set_origin)(struct vc_data *vc);
|
|
|
|
void (*con_save_screen)(struct vc_data *vc);
|
|
|
|
u8 (*con_build_attr)(struct vc_data *vc, u8 color, u8 intensity,
|
|
|
|
u8 blink, u8 underline, u8 reverse, u8 italic);
|
|
|
|
void (*con_invert_region)(struct vc_data *vc, u16 *p, int count);
|
|
|
|
u16 *(*con_screen_pos)(struct vc_data *vc, int offset);
|
|
|
|
unsigned long (*con_getxy)(struct vc_data *vc, unsigned long position,
|
|
|
|
int *px, int *py);
|
2017-01-14 04:07:56 +08:00
|
|
|
/*
|
|
|
|
* Flush the video console driver's scrollback buffer
|
|
|
|
*/
|
2018-02-27 08:04:19 +08:00
|
|
|
void (*con_flush_scrollback)(struct vc_data *vc);
|
2010-08-05 22:22:30 +08:00
|
|
|
/*
|
|
|
|
* Prepare the console for the debugger. This includes, but is not
|
|
|
|
* limited to, unblanking the console, loading an appropriate
|
|
|
|
* palette, and allowing debugger generated output.
|
|
|
|
*/
|
2018-02-27 08:04:19 +08:00
|
|
|
int (*con_debug_enter)(struct vc_data *vc);
|
2010-08-05 22:22:30 +08:00
|
|
|
/*
|
|
|
|
* Restore the console to its pre-debug state as closely as possible.
|
|
|
|
*/
|
2018-02-27 08:04:19 +08:00
|
|
|
int (*con_debug_leave)(struct vc_data *vc);
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct consw *conswitchp;
|
|
|
|
|
|
|
|
extern const struct consw dummy_con; /* dummy console buffer */
|
|
|
|
extern const struct consw vga_con; /* VGA text console */
|
|
|
|
extern const struct consw newport_con; /* SGI Newport console */
|
|
|
|
|
[PATCH] VT binding: Add binding/unbinding support for the VT console
The framebuffer console is now able to dynamically bind and unbind from the VT
console layer. Due to the way the VT console layer works, the drivers
themselves decide when to bind or unbind. However, it was decided that
binding must be controlled, not by the drivers themselves, but by the VT
console layer. With this, dynamic binding is possible for all VT console
drivers, not just fbcon.
Thus, the VT console layer will impose the following to all VT console
drivers:
- all registered VT console drivers will be entered in a private list
- drivers can register themselves to the VT console layer, but they cannot
decide when to bind or unbind. (Exception: To maintain backwards
compatibility, take_over_console() will automatically bind the driver after
registration.)
- drivers can remove themselves from the list by unregistering from the VT
console layer. A prerequisite for unregistration is that the driver must not
be bound.
The following functions are new in the vt.c:
register_con_driver() - public function, this function adds the VT console
driver to an internal list maintained by the VT console
bind_con_driver() - private function, it binds the driver to the console
take_over_console() is changed to call register_con_driver() followed by a
bind_con_driver(). This is the only time drivers can decide when to bind to
the VT layer. This is to maintain backwards compatibility.
unbind_con_driver() - private function, it unbinds the driver from its
console. The vacated consoles will be taken over by the default boot console
driver.
unregister_con_driver() - public function, removes the driver from the
internal list maintained by the VT console. It will only succeed if the
driver is currently unbound.
con_is_bound() checks if the driver is currently bound or not
give_up_console() is just a wrapper to unregister_con_driver().
There are also 3 additional functions meant to be called only by the tty layer
for sysfs control:
vt_bind() - calls bind_con_driver()
vt_unbind() - calls unbind_con_driver()
vt_show_drivers() - shows the list of registered drivers
Most VT console drivers will continue to work as is, but might have problems
when unbinding or binding which should be fixable with minimal changes.
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-26 15:27:08 +08:00
|
|
|
int con_is_bound(const struct consw *csw);
|
2013-01-25 08:28:18 +08:00
|
|
|
int do_unregister_con_driver(const struct consw *csw);
|
2013-01-25 08:28:15 +08:00
|
|
|
int do_take_over_console(const struct consw *sw, int first, int last, int deflt);
|
2005-04-17 06:20:36 +08:00
|
|
|
void give_up_console(const struct consw *sw);
|
2010-08-07 04:36:47 +08:00
|
|
|
#ifdef CONFIG_HW_CONSOLE
|
2010-08-05 22:22:30 +08:00
|
|
|
int con_debug_enter(struct vc_data *vc);
|
|
|
|
int con_debug_leave(void);
|
2010-08-07 04:36:47 +08:00
|
|
|
#else
|
2012-09-29 05:36:14 +08:00
|
|
|
static inline int con_debug_enter(struct vc_data *vc)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline int con_debug_leave(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2010-08-07 04:36:47 +08:00
|
|
|
#endif
|
2010-08-05 22:22:30 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* cursor */
|
|
|
|
#define CM_DRAW (1)
|
|
|
|
#define CM_ERASE (2)
|
|
|
|
#define CM_MOVE (3)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The interface for a console, or any other device that wants to capture
|
|
|
|
* console messages (printer driver?)
|
|
|
|
*
|
|
|
|
* If a console driver is marked CON_BOOT then it will be auto-unregistered
|
|
|
|
* when the first real console is registered. This is for early-printk drivers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define CON_PRINTBUFFER (1)
|
2020-02-13 17:51:33 +08:00
|
|
|
#define CON_CONSDEV (2) /* Preferred console, /dev/console */
|
2005-04-17 06:20:36 +08:00
|
|
|
#define CON_ENABLED (4)
|
|
|
|
#define CON_BOOT (8)
|
2006-06-25 20:47:40 +08:00
|
|
|
#define CON_ANYTIME (16) /* Safe to call when cpu is offline */
|
2008-04-30 15:54:51 +08:00
|
|
|
#define CON_BRL (32) /* Used for a braille device */
|
2015-06-26 06:01:30 +08:00
|
|
|
#define CON_EXTENDED (64) /* Use the extended output format a la /dev/kmsg */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-08 15:26:47 +08:00
|
|
|
struct console {
|
|
|
|
char name[16];
|
2005-04-17 06:20:36 +08:00
|
|
|
void (*write)(struct console *, const char *, unsigned);
|
|
|
|
int (*read)(struct console *, char *, unsigned);
|
|
|
|
struct tty_driver *(*device)(struct console *, int *);
|
|
|
|
void (*unblank)(void);
|
|
|
|
int (*setup)(struct console *, char *);
|
2020-02-03 21:31:30 +08:00
|
|
|
int (*exit)(struct console *);
|
2015-03-10 04:27:12 +08:00
|
|
|
int (*match)(struct console *, char *name, int idx, char *options);
|
2005-04-17 06:20:36 +08:00
|
|
|
short flags;
|
|
|
|
short index;
|
|
|
|
int cflag;
|
|
|
|
void *data;
|
|
|
|
struct console *next;
|
|
|
|
};
|
|
|
|
|
2010-11-04 23:20:20 +08:00
|
|
|
/*
|
|
|
|
* for_each_console() allows you to iterate on each console
|
|
|
|
*/
|
|
|
|
#define for_each_console(con) \
|
|
|
|
for (con = console_drivers; con != NULL; con = con->next)
|
|
|
|
|
xen: Enable console tty by default in domU if it's not a dummy
Without console= arguments on the kernel command line, the first
console to register becomes enabled and the preferred console (the one
behind /dev/console). This is normally tty (assuming
CONFIG_VT_CONSOLE is enabled, which it commonly is).
This is okay as long tty is a useful console. But unless we have the
PV framebuffer, and it is enabled for this domain, tty0 in domU is
merely a dummy. In that case, we want the preferred console to be the
Xen console hvc0, and we want it without having to fiddle with the
kernel command line. Commit b8c2d3dfbc117dff26058fbac316b8acfc2cb5f7
did that for us.
Since we now have the PV framebuffer, we want to enable and prefer tty
again, but only when PVFB is enabled. But even then we still want to
enable the Xen console as well.
Problem: when tty registers, we can't yet know whether the PVFB is
enabled. By the time we can know (xenstore is up), the console setup
game is over.
Solution: enable console tty by default, but keep hvc as the preferred
console. Change the preferred console to tty when PVFB probes
successfully, unless we've been given console kernel parameters.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-27 06:31:07 +08:00
|
|
|
extern int console_set_on_cmdline;
|
2013-04-30 07:17:18 +08:00
|
|
|
extern struct console *early_console;
|
xen: Enable console tty by default in domU if it's not a dummy
Without console= arguments on the kernel command line, the first
console to register becomes enabled and the preferred console (the one
behind /dev/console). This is normally tty (assuming
CONFIG_VT_CONSOLE is enabled, which it commonly is).
This is okay as long tty is a useful console. But unless we have the
PV framebuffer, and it is enabled for this domain, tty0 in domU is
merely a dummy. In that case, we want the preferred console to be the
Xen console hvc0, and we want it without having to fiddle with the
kernel command line. Commit b8c2d3dfbc117dff26058fbac316b8acfc2cb5f7
did that for us.
Since we now have the PV framebuffer, we want to enable and prefer tty
again, but only when PVFB is enabled. But even then we still want to
enable the Xen console as well.
Problem: when tty registers, we can't yet know whether the PVFB is
enabled. By the time we can know (xenstore is up), the console setup
game is over.
Solution: enable console tty by default, but keep hvc as the preferred
console. Change the preferred console to tty when PVFB probes
successfully, unless we've been given console kernel parameters.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-27 06:31:07 +08:00
|
|
|
|
2019-05-18 05:31:50 +08:00
|
|
|
enum con_flush_mode {
|
|
|
|
CONSOLE_FLUSH_PENDING,
|
|
|
|
CONSOLE_REPLAY_ALL,
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
extern int add_preferred_console(char *name, int idx, char *options);
|
|
|
|
extern void register_console(struct console *);
|
|
|
|
extern int unregister_console(struct console *);
|
|
|
|
extern struct console *console_drivers;
|
2011-01-26 07:07:35 +08:00
|
|
|
extern void console_lock(void);
|
|
|
|
extern int console_trylock(void);
|
|
|
|
extern void console_unlock(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
extern void console_conditional_schedule(void);
|
|
|
|
extern void console_unblank(void);
|
2019-05-18 05:31:50 +08:00
|
|
|
extern void console_flush_on_panic(enum con_flush_mode mode);
|
2005-04-17 06:20:36 +08:00
|
|
|
extern struct tty_driver *console_device(int *);
|
|
|
|
extern void console_stop(struct console *);
|
|
|
|
extern void console_start(struct console *);
|
|
|
|
extern int is_console_locked(void);
|
2008-04-30 15:54:51 +08:00
|
|
|
extern int braille_register_console(struct console *, int index,
|
|
|
|
char *console_options, char *braille_options);
|
|
|
|
extern int braille_unregister_console(struct console *);
|
2013-01-18 14:44:22 +08:00
|
|
|
#ifdef CONFIG_TTY
|
2010-12-02 01:51:05 +08:00
|
|
|
extern void console_sysfs_notify(void);
|
2013-01-18 14:44:22 +08:00
|
|
|
#else
|
|
|
|
static inline void console_sysfs_notify(void)
|
|
|
|
{ }
|
|
|
|
#endif
|
2012-01-13 07:02:20 +08:00
|
|
|
extern bool console_suspend_enabled;
|
2007-10-18 18:04:50 +08:00
|
|
|
|
2006-06-20 09:16:01 +08:00
|
|
|
/* Suspend and resume console messages over PM events */
|
|
|
|
extern void suspend_console(void);
|
|
|
|
extern void resume_console(void);
|
|
|
|
|
2006-10-03 16:15:06 +08:00
|
|
|
int mda_console_init(void);
|
|
|
|
|
2009-03-09 21:18:52 +08:00
|
|
|
void vcs_make_sysfs(int index);
|
|
|
|
void vcs_remove_sysfs(int index);
|
2007-02-10 17:45:02 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Some debug stub to catch some of the obvious races in the VT code */
|
2018-07-31 19:06:57 +08:00
|
|
|
#define WARN_CONSOLE_UNLOCKED() \
|
|
|
|
WARN_ON(!atomic_read(&ignore_console_lock_warning) && \
|
|
|
|
!is_console_locked() && !oops_in_progress)
|
|
|
|
/*
|
|
|
|
* Increment ignore_console_lock_warning if you need to quiet
|
|
|
|
* WARN_CONSOLE_UNLOCKED() for debugging purposes.
|
|
|
|
*/
|
|
|
|
extern atomic_t ignore_console_lock_warning;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* VESA Blanking Levels */
|
|
|
|
#define VESA_NO_BLANKING 0
|
|
|
|
#define VESA_VSYNC_SUSPEND 1
|
|
|
|
#define VESA_HSYNC_SUSPEND 2
|
|
|
|
#define VESA_POWERDOWN 3
|
|
|
|
|
2008-11-08 06:05:41 +08:00
|
|
|
#ifdef CONFIG_VGA_CONSOLE
|
|
|
|
extern bool vgacon_text_force(void);
|
2016-03-30 17:26:35 +08:00
|
|
|
#else
|
|
|
|
static inline bool vgacon_text_force(void) { return false; }
|
2008-11-08 06:05:41 +08:00
|
|
|
#endif
|
|
|
|
|
2017-04-13 06:37:14 +08:00
|
|
|
extern void console_init(void);
|
|
|
|
|
2018-06-28 21:20:30 +08:00
|
|
|
/* For deferred console takeover */
|
|
|
|
void dummycon_register_output_notifier(struct notifier_block *nb);
|
|
|
|
void dummycon_unregister_output_notifier(struct notifier_block *nb);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _LINUX_CONSOLE_H */
|