mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 03:44:06 +00:00
xfree86: os-support: bsd: factor out console close handling
* move console type specific close logic into separate functions * install them into xf86_console_proc_close on init Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
6e46e34801
commit
53a20908fa
@@ -47,7 +47,7 @@
|
||||
static Bool KeepTty = FALSE;
|
||||
|
||||
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
|
||||
static int initialVT = -1;
|
||||
int initialVT = -1;
|
||||
#endif
|
||||
|
||||
#ifdef SYSCONS_SUPPORT
|
||||
@@ -342,6 +342,7 @@ static bool xf86OpenSyscons(void)
|
||||
}
|
||||
xf86Info.consoleFd = fd;
|
||||
xf86_bsd_acquire_vt();
|
||||
xf86_console_proc_close = xf86_console_syscons_close;
|
||||
return (fd > 0);
|
||||
}
|
||||
|
||||
@@ -463,6 +464,7 @@ static bool xf86OpenPcvt(void)
|
||||
goto out;
|
||||
out:
|
||||
xf86_bsd_acquire_vt();
|
||||
xf86_console_proc_close = xf86_console_pcvt_close;
|
||||
return (fd > 0);
|
||||
}
|
||||
|
||||
@@ -497,6 +499,8 @@ static bool xf86OpenWScons(void)
|
||||
}
|
||||
xf86Info.consoleFd = fd;
|
||||
|
||||
xf86_console_proc_close = xf86_console_wscons_close;
|
||||
|
||||
/* nothing special to do for acquiring the VT */
|
||||
return (fd > 0);
|
||||
}
|
||||
@@ -506,45 +510,13 @@ static bool xf86OpenWScons(void)
|
||||
void
|
||||
xf86CloseConsole(void)
|
||||
{
|
||||
#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
|
||||
struct vt_mode VT;
|
||||
#endif
|
||||
|
||||
if (xf86Info.ShareVTs)
|
||||
return;
|
||||
|
||||
switch (xf86Info.consType) {
|
||||
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
|
||||
case SYSCONS:
|
||||
case PCVT:
|
||||
ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
|
||||
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) {
|
||||
VT.mode = VT_AUTO;
|
||||
ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
|
||||
}
|
||||
#if !defined(__OpenBSD__) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
|
||||
if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) {
|
||||
xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
|
||||
strerror(errno));
|
||||
}
|
||||
#endif
|
||||
if (xf86Info.autoVTSwitch && initialVT != -1)
|
||||
ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
|
||||
break;
|
||||
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
|
||||
#ifdef WSCONS_SUPPORT
|
||||
case WSCONS:
|
||||
{
|
||||
int mode = WSDISPLAYIO_MODE_EMUL;
|
||||
|
||||
ioctl(xf86Info.consoleFd, WSDISPLAYIO_SMODE, &mode);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
close(xf86Info.consoleFd);
|
||||
return;
|
||||
if (xf86_console_proc_close)
|
||||
xf86_console_proc_close();
|
||||
else
|
||||
LogMessageVerb(X_WARNING, 1, "no xf86_console_proc_close() installed\n");
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
43
hw/xfree86/os-support/bsd/console_pcvt.c
Normal file
43
hw/xfree86/os-support/bsd/console_pcvt.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <xorg-config.h>
|
||||
|
||||
#if defined(PCVT_SUPPORT)
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#include <dev/wscons/wsdisplay_usl_io.h>
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <sys/consio.h>
|
||||
#include <sys/kbio.h>
|
||||
#endif
|
||||
|
||||
#include "xf86Priv.h"
|
||||
#include "xf86_bsd_priv.h"
|
||||
#include "xf86_console_priv.h"
|
||||
|
||||
void xf86_console_pcvt_close(void)
|
||||
{
|
||||
struct vt_mode VT = { 0 };
|
||||
ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
|
||||
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) {
|
||||
VT.mode = VT_AUTO;
|
||||
ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
|
||||
}
|
||||
#if !defined(__OpenBSD__) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
|
||||
if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) {
|
||||
FatalError("xf86CloseConsole: KDDISABIO failed (%s)", strerror(errno));
|
||||
}
|
||||
#endif
|
||||
if (xf86Info.autoVTSwitch && initialVT != -1)
|
||||
ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
|
||||
|
||||
close(xf86Info.consoleFd);
|
||||
xf86Info.consoleFd = -1;
|
||||
}
|
||||
|
||||
#endif /* PCVT_SUPPORT */
|
||||
38
hw/xfree86/os-support/bsd/console_syscons.c
Normal file
38
hw/xfree86/os-support/bsd/console_syscons.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <xorg-config.h>
|
||||
|
||||
#if defined(SYSCONS_SUPPORT)
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <sys/consio.h>
|
||||
#include <sys/kbio.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "xf86Priv.h"
|
||||
#include "xf86_bsd_priv.h"
|
||||
|
||||
void xf86_console_syscons_close(void)
|
||||
{
|
||||
struct vt_mode VT = { 0 };
|
||||
ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
|
||||
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) {
|
||||
VT.mode = VT_AUTO;
|
||||
ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
|
||||
}
|
||||
#if !defined(__OpenBSD__) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
|
||||
if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) {
|
||||
xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
|
||||
strerror(errno));
|
||||
}
|
||||
#endif
|
||||
if (xf86Info.autoVTSwitch && initialVT != -1)
|
||||
ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
|
||||
|
||||
close(xf86Info.consoleFd);
|
||||
xf86Info.consoleFd = -1;
|
||||
}
|
||||
|
||||
#endif /* SYSCONS_SUPPORT */
|
||||
21
hw/xfree86/os-support/bsd/console_wscons.c
Normal file
21
hw/xfree86/os-support/bsd/console_wscons.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <xorg-config.h>
|
||||
|
||||
#if defined(WSCONS_SUPPORT)
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
|
||||
#include "xf86Priv.h"
|
||||
#include "xf86_bsd_priv.h"
|
||||
|
||||
void xf86_console_wscons_close(void)
|
||||
{
|
||||
int mode = WSDISPLAYIO_MODE_EMUL;
|
||||
ioctl(xf86Info.consoleFd, WSDISPLAYIO_SMODE, &mode);
|
||||
|
||||
close(xf86Info.consoleFd);
|
||||
xf86Info.consoleFd = -1;
|
||||
}
|
||||
|
||||
#endif /* WSCONS_SUPPORT */
|
||||
@@ -21,4 +21,15 @@
|
||||
|
||||
void xf86_bsd_acquire_vt(void);
|
||||
|
||||
/* PCVT console driver */
|
||||
void xf86_console_pcvt_close(void);
|
||||
|
||||
/* SYSCONS console driver */
|
||||
void xf86_console_syscons_close(void);
|
||||
|
||||
/* WSCONS console driver */
|
||||
void xf86_console_wscons_close(void);
|
||||
|
||||
extern int initialVT;
|
||||
|
||||
#endif /* _XSERVER_XFREE86_OS_SUPPORT_BSD_PRIV_H */
|
||||
|
||||
@@ -98,8 +98,11 @@ elif host_machine.system().endswith('bsd') or host_machine.system() == 'dragonfl
|
||||
'bsd/bsd_VTsw.c',
|
||||
'bsd/bsd_bell.c',
|
||||
'bsd/bsd_init.c',
|
||||
'bsd/console_pcvt.c',
|
||||
'bsd/console_syscons.c',
|
||||
'bsd/console_wscons.c',
|
||||
'shared/drm_platform.c',
|
||||
'shared/pm_noop.c'
|
||||
'shared/pm_noop.c'
|
||||
]
|
||||
|
||||
if host_machine.cpu_family() == 'x86_64'
|
||||
|
||||
Reference in New Issue
Block a user