From 960f1e30de219b04d48287a6fa6b932e2a724be4 Mon Sep 17 00:00:00 2001 From: jmcneill Date: Wed, 9 Feb 2011 13:24:23 +0000 Subject: [PATCH] if genfb is attached, hook into db_trap_callback to switch in and out of polling mode as necessary --- sys/arch/x86/include/genfb_machdep.h | 4 +++- sys/arch/x86/x86/genfb_machdep.c | 27 +++++++++++++++++++++++++-- sys/arch/x86/x86/x86_autoconf.c | 21 +++++++++++++++++++-- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/sys/arch/x86/include/genfb_machdep.h b/sys/arch/x86/include/genfb_machdep.h index 30a68ac0e1cb..02152083f5ed 100644 --- a/sys/arch/x86/include/genfb_machdep.h +++ b/sys/arch/x86/include/genfb_machdep.h @@ -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 @@ -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 */ diff --git a/sys/arch/x86/x86/genfb_machdep.c b/sys/arch/x86/x86/genfb_machdep.c index a36adfb0fe1a..60482e3294bb 100644 --- a/sys/arch/x86/x86/genfb_machdep.c +++ b/sys/arch/x86/x86/genfb_machdep.c @@ -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 @@ -31,7 +31,7 @@ */ #include -__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 #include +#include #include #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) { diff --git a/sys/arch/x86/x86/x86_autoconf.c b/sys/arch/x86/x86/x86_autoconf.c index fcc40da2fc1a..fb1cb3a02671 100644 --- a/sys/arch/x86/x86/x86_autoconf.c +++ b/sys/arch/x86/x86/x86_autoconf.c @@ -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 -__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 #include @@ -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 +#include +#include +#endif #if NACPICA > 0 #include @@ -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);