if genfb is attached, hook into db_trap_callback to switch in and out of

polling mode as necessary
This commit is contained in:
jmcneill 2011-02-09 13:24:23 +00:00
parent 9204517c6d
commit 960f1e30de
3 changed files with 47 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: genfb_machdep.h,v 1.2 2011/02/08 20:55:51 ahoka Exp $ */
/* $NetBSD: genfb_machdep.h,v 1.3 2011/02/09 13:24:23 jmcneill Exp $ */
/*-
* Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca>
@ -31,5 +31,7 @@
int x86_genfb_cnattach(void);
void x86_genfb_mtrr_init(uint64_t, uint32_t);
void x86_genfb_set_console_dev(device_t);
void x86_genfb_ddb_trap_callback(int);
#endif /* !_X86_GENFB_MACHDEP_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: genfb_machdep.c,v 1.6 2011/02/09 02:30:09 jmcneill Exp $ */
/* $NetBSD: genfb_machdep.c,v 1.7 2011/02/09 13:24:24 jmcneill Exp $ */
/*-
* Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca>
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.6 2011/02/09 02:30:09 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.7 2011/02/09 13:24:24 jmcneill Exp $");
#include "opt_mtrr.h"
@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.6 2011/02/09 02:30:09 jmcneill E
#include <dev/wsfont/wsfont.h>
#include <dev/wscons/wsdisplay_vconsvar.h>
#include <dev/wsfb/genfbvar.h>
#include <arch/x86/include/genfb_machdep.h>
#include "wsdisplay.h"
@ -65,6 +66,8 @@ struct vcons_screen x86_genfb_console_screen;
extern int acpi_md_vesa_modenum;
#endif
static device_t x86_genfb_console_dev = NULL;
static struct wsscreen_descr x86_genfb_stdscreen = {
"std",
0, 0,
@ -74,6 +77,26 @@ static struct wsscreen_descr x86_genfb_stdscreen = {
NULL
};
void
x86_genfb_set_console_dev(device_t dev)
{
KASSERT(x86_genfb_console_dev != NULL);
x86_genfb_console_dev = dev;
}
void
x86_genfb_ddb_trap_callback(int where)
{
if (x86_genfb_console_dev == NULL)
return;
if (where) {
genfb_enable_polling(x86_genfb_console_dev);
} else {
genfb_disable_polling(x86_genfb_console_dev);
}
}
void
x86_genfb_mtrr_init(uint64_t physaddr, uint32_t size)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: x86_autoconf.c,v 1.54 2011/02/08 10:52:56 jmcneill Exp $ */
/* $NetBSD: x86_autoconf.c,v 1.55 2011/02/09 13:24:24 jmcneill Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.54 2011/02/08 10:52:56 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.55 2011/02/09 13:24:24 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -59,6 +59,13 @@ __KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.54 2011/02/08 10:52:56 jmcneill E
#include "genfb.h"
#include "wsdisplay.h"
#include "opt_vga.h"
#include "opt_ddb.h"
#ifdef DDB
#include <machine/db_machdep.h>
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
#endif
#if NACPICA > 0
#include <dev/acpi/acpivar.h>
@ -692,6 +699,16 @@ device_register(device_t dev, void *aux)
"mode_callback",
(uint64_t)&mode_cb);
}
#if NWSDISPLAY > 0 && NGENFB > 0
if (device_is_a(dev, "genfb")) {
x86_genfb_set_console_dev(dev);
#ifdef DDB
db_trap_callback =
x86_genfb_ddb_trap_callback;
#endif
}
#endif
}
prop_dictionary_set_bool(dict, "is_console", true);
prop_dictionary_set_bool(dict, "clear-screen", false);