-add a function to vga_post which can be called from DDB to get a

usable VGA console ("call ddb_vgapost")
-allow to switch from/to screens occupied by an X server if the graphics
 device is console and in polling mode (ie DDB)
This together allows to get a DDB session on a VGA console if the
system crashed while X11 was running.
As long as the protocol to tell X servers about virtual screen switches
is as primitive as it is, it is unsafe to restart an X session afterwards.
So this is basically for crash analysis.
This commit is contained in:
drochner 2008-03-12 23:26:18 +00:00
parent e8401439ac
commit 3678498d59
2 changed files with 31 additions and 8 deletions

View File

@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vga_post.c,v 1.6 2008/01/15 22:15:13 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: vga_post.c,v 1.7 2008/03/12 23:26:18 drochner Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -44,6 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: vga_post.c,v 1.6 2008/01/15 22:15:13 drochner Exp $"
#include <x86emu/x86emu_i8254.h>
#include <x86emu/x86emu_regs.h>
#include "opt_ddb.h"
struct vga_post {
struct X86EMU emu;
vaddr_t sys_image;
@ -53,6 +55,11 @@ struct vga_post {
struct pglist ram_backing;
};
#ifdef DDB
static struct vga_post *ddb_vgapostp;
void ddb_vgapost(void);
#endif
static uint8_t
vm86_emu_inb(struct X86EMU *emu, uint16_t port)
{
@ -189,7 +196,9 @@ vga_post_init(int bus, int device, int function)
sc->emu.mem_size = 1024 * 1024;
sc->initial_eax = bus * 256 + device * 8 + function;
#ifdef DDB
ddb_vgapostp = sc;
#endif
return sc;
}
@ -222,3 +231,13 @@ vga_post_free(struct vga_post *sc)
pmap_update(pmap_kernel());
kmem_free(sc, sizeof(*sc));
}
#ifdef DDB
void
ddb_vgapost()
{
if (ddb_vgapostp)
vga_post_call(ddb_vgapostp);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsdisplay.c,v 1.118 2008/02/29 06:18:13 dyoung Exp $ */
/* $NetBSD: wsdisplay.c,v 1.119 2008/03/12 23:26:18 drochner Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.118 2008/02/29 06:18:13 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.119 2008/03/12 23:26:18 drochner Exp $");
#include "opt_wsdisplay_compat.h"
#include "opt_wsmsgattrs.h"
@ -1817,9 +1817,10 @@ wsdisplay_switch2(device_t dv, int error, int waitok)
#endif
/* keyboard map??? */
if (scr->scr_syncops) {
if (scr->scr_syncops &&
!(sc->sc_isconsole && wsdisplay_cons_pollmode)) {
error = (*scr->scr_syncops->attach)(scr->scr_synccookie, waitok,
sc->sc_isconsole && wsdisplay_cons_pollmode ? 0 : wsdisplay_switch3_cb, dv);
wsdisplay_switch3_cb, dv);
if (error == EAGAIN) {
/* switch will be done asynchronously */
return (0);
@ -1928,10 +1929,13 @@ wsdisplay_switch(device_t dv, int no, int waitok)
sc->sc_oldscreen = sc->sc_focusidx;
if (scr->scr_syncops) {
if (!(sc->sc_flags & SC_XATTACHED)) /* nothing to do here */
if (!(sc->sc_flags & SC_XATTACHED) ||
(sc->sc_isconsole && wsdisplay_cons_pollmode)) {
/* nothing to do here */
return (wsdisplay_switch1(dv, 0, waitok));
}
res = (*scr->scr_syncops->detach)(scr->scr_synccookie, waitok,
sc->sc_isconsole && wsdisplay_cons_pollmode ? 0 : wsdisplay_switch1_cb, dv);
wsdisplay_switch1_cb, dv);
if (res == EAGAIN) {
/* switch will be done asynchronously */
return (0);