If a Darwin process using the framebuffer (e.g.: XDarwin) crashes without
restoring text mode, do the job ourselves. This avoids letting the user on an unusable console
This commit is contained in:
parent
553c82ed11
commit
ebd83433da
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: darwin_exec.c,v 1.17 2003/08/24 17:52:40 chs Exp $ */
|
||||
/* $NetBSD: darwin_exec.c,v 1.18 2003/08/29 23:11:40 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "opt_compat_darwin.h" /* For COMPAT_DARWIN in mach_port.h */
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: darwin_exec.c,v 1.17 2003/08/24 17:52:40 chs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: darwin_exec.c,v 1.18 2003/08/29 23:11:40 manu Exp $");
|
||||
|
||||
#include "opt_syscall_debug.h"
|
||||
|
||||
|
@ -49,11 +49,14 @@ __KERNEL_RCSID(0, "$NetBSD: darwin_exec.c,v 1.17 2003/08/24 17:52:40 chs Exp $")
|
|||
#include <sys/malloc.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/exec_macho.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
#include <uvm/uvm_param.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
|
||||
#include <compat/mach/mach_types.h>
|
||||
#include <compat/mach/mach_message.h>
|
||||
#include <compat/mach/mach_exec.h>
|
||||
|
@ -64,6 +67,9 @@ __KERNEL_RCSID(0, "$NetBSD: darwin_exec.c,v 1.17 2003/08/24 17:52:40 chs Exp $")
|
|||
#include <compat/darwin/darwin_syscall.h>
|
||||
#include <compat/darwin/darwin_sysctl.h>
|
||||
|
||||
/* Redefined from sys/dev/wscons/wsdisplay.c */
|
||||
extern const struct cdevsw wsdisplay_cdevsw;
|
||||
|
||||
static void darwin_e_proc_exec(struct proc *, struct exec_package *);
|
||||
static void darwin_e_proc_fork(struct proc *, struct proc *);
|
||||
static void darwin_e_proc_exit(struct proc *);
|
||||
|
@ -267,6 +273,7 @@ darwin_e_proc_init(p, vmspace)
|
|||
}
|
||||
ded = (struct darwin_emuldata *)p->p_emuldata;
|
||||
ded->ded_fakepid = 0;
|
||||
ded->ded_wsdev = NODEV;
|
||||
|
||||
mach_e_proc_init(p, vmspace);
|
||||
|
||||
|
@ -278,6 +285,7 @@ darwin_e_proc_exit(p)
|
|||
struct proc *p;
|
||||
{
|
||||
struct darwin_emuldata *ded;
|
||||
int error, mode;
|
||||
|
||||
ded = p->p_emuldata;
|
||||
|
||||
|
@ -289,6 +297,16 @@ darwin_e_proc_exit(p)
|
|||
if (ded->ded_fakepid == 2)
|
||||
mach_bootstrap_port = mach_saved_bootstrap_port;
|
||||
|
||||
if (ded->ded_wsdev != NODEV) {
|
||||
mode = WSDISPLAYIO_MODE_EMUL;
|
||||
error = (*wsdisplay_cdevsw.d_ioctl)(ded->ded_wsdev,
|
||||
WSDISPLAYIO_SMODE, (caddr_t)&mode, 0, p);
|
||||
#ifdef DEBUG_DARWIN
|
||||
if (error != 0)
|
||||
printf("Unable to switch back to text mode\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
mach_e_proc_exit(p);
|
||||
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: darwin_exec.h,v 1.6 2003/06/29 22:29:15 fvdl Exp $ */
|
||||
/* $NetBSD: darwin_exec.h,v 1.7 2003/08/29 23:11:40 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -48,6 +48,7 @@
|
|||
struct darwin_emuldata {
|
||||
struct mach_emuldata ded_mach_emuldata;
|
||||
pid_t ded_fakepid;
|
||||
dev_t ded_wsdev; /* display to restore on exit */
|
||||
};
|
||||
|
||||
int exec_darwin_copyargs(struct proc *, struct exec_package *,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: darwin_ioframebuffer.c,v 1.14 2003/08/29 22:03:13 manu Exp $ */
|
||||
/* $NetBSD: darwin_ioframebuffer.c,v 1.15 2003/08/29 23:11:40 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: darwin_ioframebuffer.c,v 1.14 2003/08/29 22:03:13 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: darwin_ioframebuffer.c,v 1.15 2003/08/29 23:11:40 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -59,11 +59,13 @@ __KERNEL_RCSID(0, "$NetBSD: darwin_ioframebuffer.c,v 1.14 2003/08/29 22:03:13 ma
|
|||
#include <dev/wscons/wsconsio.h>
|
||||
|
||||
#include <compat/mach/mach_types.h>
|
||||
#include <compat/mach/mach_exec.h>
|
||||
#include <compat/mach/mach_message.h>
|
||||
#include <compat/mach/mach_port.h>
|
||||
#include <compat/mach/mach_errno.h>
|
||||
#include <compat/mach/mach_iokit.h>
|
||||
|
||||
#include <compat/darwin/darwin_exec.h>
|
||||
#include <compat/darwin/darwin_iokit.h>
|
||||
#include <compat/darwin/darwin_ioframebuffer.h>
|
||||
|
||||
|
@ -480,6 +482,7 @@ darwin_ioframebuffer_connect_map_memory(args)
|
|||
int mode;
|
||||
struct uvm_object *udo;
|
||||
struct wsdisplay_fbinfo fbi;
|
||||
struct darwin_emuldata *ded;
|
||||
|
||||
/* Find the first wsdisplay available */
|
||||
TAILQ_FOREACH(dv, &alldevs, dv_list)
|
||||
|
@ -518,11 +521,36 @@ darwin_ioframebuffer_connect_map_memory(args)
|
|||
#endif
|
||||
len = round_page(fbi.height * fbi.width * fbi.depth / 8);
|
||||
|
||||
/*
|
||||
* The framebuffer cannot be mapped (ie: udv_attach will
|
||||
* fail) if the console is not in graphic mode. We will
|
||||
* do the switch, but it screws the console. Therefore
|
||||
* we attempt to restore its original state on process
|
||||
* exit. ded->ded_wsdev is used to remember the console
|
||||
* device. If it is not NODEV on process exit, we use
|
||||
* it to restore text mode.
|
||||
*/
|
||||
ded = (struct darwin_emuldata *)p->p_emuldata;
|
||||
if ((error = (*wsdisplay_cdevsw.d_ioctl)(device,
|
||||
WSDISPLAYIO_GMODE, (caddr_t)&mode, 0, p)) != 0) {
|
||||
#ifdef DEBUG_DARWIN
|
||||
printf("*** Cannot get console state ***\n");
|
||||
#endif
|
||||
return mach_msg_error(args, ENODEV);
|
||||
}
|
||||
if (mode == WSDISPLAYIO_MODE_EMUL)
|
||||
ded->ded_wsdev = device;
|
||||
|
||||
/* Switch to graphic mode */
|
||||
mode = WSDISPLAYIO_MODE_MAPPED;
|
||||
if ((error = (*wsdisplay_cdevsw.d_ioctl)(device,
|
||||
WSDISPLAYIO_SMODE, (caddr_t)&mode, 0, p)) != 0)
|
||||
WSDISPLAYIO_SMODE, (caddr_t)&mode, 0, p)) != 0) {
|
||||
#ifdef DEBUG_DARWIN
|
||||
printf("*** Cannot switch to graphic mode ***\n");
|
||||
#endif
|
||||
return mach_msg_error(args, ENODEV);
|
||||
}
|
||||
|
||||
|
||||
/* Create the uvm_object */
|
||||
udo = udv_attach(&device, UVM_PROT_RW, 0, len);
|
||||
|
|
Loading…
Reference in New Issue