Commit bcd375f7 authored by Manuel Schölling's avatar Manuel Schölling Committed by Greg Kroah-Hartman

console: Add callback to flush scrollback buffer to consw struct

This new callback is in preparation for persistent scrollback buffer
support for VGA consoles.
With a single scrollback buffer for all consoles, we could flush the
buffer just by invocating consw->con_switch(). But when each VGA console
has its own scrollback buffer, we need a new callback to tell the
video console driver which buffer to flush.
Signed-off-by: default avatarManuel Schölling <manuel.schoelling@gmx.de>
Reviewed-by: default avatarAndrey Utkin <andrey_utkin@fastmail.com>
Tested-by: default avatarAndrey Utkin <andrey_utkin@fastmail.com>
Tested-by: default avatarAdam Borowski <kilobyte@angband.pl>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 66da39eb
...@@ -625,6 +625,14 @@ static void save_screen(struct vc_data *vc) ...@@ -625,6 +625,14 @@ static void save_screen(struct vc_data *vc)
vc->vc_sw->con_save_screen(vc); vc->vc_sw->con_save_screen(vc);
} }
static void flush_scrollback(struct vc_data *vc)
{
WARN_CONSOLE_UNLOCKED();
if (vc->vc_sw->con_flush_scrollback)
vc->vc_sw->con_flush_scrollback(vc);
}
/* /*
* Redrawing of screen * Redrawing of screen
*/ */
...@@ -1171,6 +1179,7 @@ static void csi_J(struct vc_data *vc, int vpar) ...@@ -1171,6 +1179,7 @@ static void csi_J(struct vc_data *vc, int vpar)
case 3: /* erase scroll-back buffer (and whole display) */ case 3: /* erase scroll-back buffer (and whole display) */
scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char, scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char,
vc->vc_screenbuf_size); vc->vc_screenbuf_size);
flush_scrollback(vc);
set_origin(vc); set_origin(vc);
if (con_is_visible(vc)) if (con_is_visible(vc))
update_screen(vc); update_screen(vc);
......
...@@ -173,6 +173,16 @@ static struct vgacon_scrollback_info { ...@@ -173,6 +173,16 @@ static struct vgacon_scrollback_info {
int restore; int restore;
} vgacon_scrollback; } vgacon_scrollback;
static void vgacon_scrollback_reset(size_t reset_size)
{
if (vgacon_scrollback.data && reset_size > 0)
memset(vgacon_scrollback.data, 0, reset_size);
vgacon_scrollback.cnt = 0;
vgacon_scrollback.tail = 0;
vgacon_scrollback.cur = 0;
}
static void vgacon_scrollback_init(int pitch) static void vgacon_scrollback_init(int pitch)
{ {
int rows = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024/pitch; int rows = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024/pitch;
...@@ -305,6 +315,14 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) ...@@ -305,6 +315,14 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
} else } else
vgacon_cursor(c, CM_MOVE); vgacon_cursor(c, CM_MOVE);
} }
static void vgacon_flush_scrollback(struct vc_data *c)
{
size_t size = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024;
if (c->vc_num == fg_console)
vgacon_scrollback_reset(size);
}
#else #else
#define vgacon_scrollback_startup(...) do { } while (0) #define vgacon_scrollback_startup(...) do { } while (0)
#define vgacon_scrollback_init(...) do { } while (0) #define vgacon_scrollback_init(...) do { } while (0)
...@@ -322,6 +340,10 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) ...@@ -322,6 +340,10 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
vga_vram_size); vga_vram_size);
vga_set_mem_top(c); vga_set_mem_top(c);
} }
static void vgacon_flush_scrollback(struct vc_data *c)
{
}
#endif /* CONFIG_VGACON_SOFT_SCROLLBACK */ #endif /* CONFIG_VGACON_SOFT_SCROLLBACK */
static const char *vgacon_startup(void) static const char *vgacon_startup(void)
...@@ -1329,7 +1351,6 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b, ...@@ -1329,7 +1351,6 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b,
return true; return true;
} }
/* /*
* The console `switch' structure for the VGA based console * The console `switch' structure for the VGA based console
*/ */
...@@ -1362,6 +1383,7 @@ const struct consw vga_con = { ...@@ -1362,6 +1383,7 @@ const struct consw vga_con = {
.con_save_screen = vgacon_save_screen, .con_save_screen = vgacon_save_screen,
.con_build_attr = vgacon_build_attr, .con_build_attr = vgacon_build_attr,
.con_invert_region = vgacon_invert_region, .con_invert_region = vgacon_invert_region,
.con_flush_scrollback = vgacon_flush_scrollback,
}; };
EXPORT_SYMBOL(vga_con); EXPORT_SYMBOL(vga_con);
......
...@@ -72,6 +72,10 @@ struct consw { ...@@ -72,6 +72,10 @@ struct consw {
void (*con_invert_region)(struct vc_data *, u16 *, int); void (*con_invert_region)(struct vc_data *, u16 *, int);
u16 *(*con_screen_pos)(struct vc_data *, int); u16 *(*con_screen_pos)(struct vc_data *, int);
unsigned long (*con_getxy)(struct vc_data *, unsigned long, int *, int *); unsigned long (*con_getxy)(struct vc_data *, unsigned long, int *, int *);
/*
* Flush the video console driver's scrollback buffer
*/
void (*con_flush_scrollback)(struct vc_data *);
/* /*
* Prepare the console for the debugger. This includes, but is not * Prepare the console for the debugger. This includes, but is not
* limited to, unblanking the console, loading an appropriate * limited to, unblanking the console, loading an appropriate
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment