Skip to content

Commit

Permalink
fb: add hooks to handle KDB enter/exit
Browse files Browse the repository at this point in the history
Add fb ops to handle enter/exit of the kernel debugger.  If present, the
fb core will register them with KGDB and they'll be called when the
debugger is entered and exited.  The new functions are responsible for
switching to an appropriate debug framebuffer and restoring the
interrupted state at exit time.

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
  • Loading branch information
Jesse Barnes authored and Jason Wessel committed Aug 5, 2010
1 parent 408a4be commit d219adc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions drivers/video/console/fbcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2342,6 +2342,30 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
return 0;
}

static int fbcon_debug_enter(struct vc_data *vc)
{
struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
struct fbcon_ops *ops = info->fbcon_par;

ops->save_graphics = ops->graphics;
ops->graphics = 0;
if (info->fbops->fb_debug_enter)
info->fbops->fb_debug_enter(info);
fbcon_set_palette(vc, color_table);
return 0;
}

static int fbcon_debug_leave(struct vc_data *vc)
{
struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
struct fbcon_ops *ops = info->fbcon_par;

ops->graphics = ops->save_graphics;
if (info->fbops->fb_debug_leave)
info->fbops->fb_debug_leave(info);
return 0;
}

static int fbcon_get_font(struct vc_data *vc, struct console_font *font)
{
u8 *fontdata = vc->vc_font.data;
Expand Down Expand Up @@ -3276,6 +3300,8 @@ static const struct consw fb_con = {
.con_screen_pos = fbcon_screen_pos,
.con_getxy = fbcon_getxy,
.con_resize = fbcon_resize,
.con_debug_enter = fbcon_debug_enter,
.con_debug_leave = fbcon_debug_leave,
};

static struct notifier_block fbcon_event_notifier = {
Expand Down
1 change: 1 addition & 0 deletions drivers/video/console/fbcon.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct fbcon_ops {
int cursor_reset;
int blank_state;
int graphics;
int save_graphics; /* for debug enter/leave */
int flags;
int rotate;
int cur_rotate;
Expand Down
13 changes: 13 additions & 0 deletions include/linux/fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

#include <linux/types.h>
#include <linux/i2c.h>
#ifdef __KERNEL__
#include <linux/kgdb.h>
#endif /* __KERNEL__ */

/* Definitions of frame buffers */

Expand Down Expand Up @@ -607,6 +610,12 @@ struct fb_deferred_io {
* LOCKING NOTE: those functions must _ALL_ be called with the console
* semaphore held, this is the only suitable locking mechanism we have
* in 2.6. Some may be called at interrupt time at this point though.
*
* The exception to this is the debug related hooks. Putting the fb
* into a debug state (e.g. flipping to the kernel console) and restoring
* it must be done in a lock-free manner, so low level drivers should
* keep track of the initial console (if applicable) and may need to
* perform direct, unlocked hardware writes in these hooks.
*/

struct fb_ops {
Expand Down Expand Up @@ -676,6 +685,10 @@ struct fb_ops {

/* teardown any resources to do with this framebuffer */
void (*fb_destroy)(struct fb_info *info);

/* called at KDB enter and leave time to prepare the console */
int (*fb_debug_enter)(struct fb_info *info);
int (*fb_debug_leave)(struct fb_info *info);
};

#ifdef CONFIG_FB_TILEBLITTING
Expand Down

0 comments on commit d219adc

Please sign in to comment.