aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/os-support/bsd/bsd_init.c')
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_init.c107
1 files changed, 64 insertions, 43 deletions
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
index 83583d5b9..7698084ee 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
@@ -45,6 +45,7 @@ static int devConsoleFd = -1;
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
static int VTnum = -1;
static int initialVT = -1;
+static Bool ShareVTs = FALSE;
#endif
#ifdef PCCONS_SUPPORT
@@ -269,49 +270,52 @@ xf86OpenConsole()
}
#endif
acquire_vt:
- /*
- * now get the VT
- */
- SYSCALL(result =
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
- if (result != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- SYSCALL(result =
+ if (!ShareVTs) {
+ /*
+ * now get the VT
+ */
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ SYSCALL(result =
ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
- if (result != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
- }
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
- signal(SIGUSR1, xf86VTRequest);
+ signal(SIGUSR1, xf86VTRequest);
- vtmode.mode = VT_PROCESS;
- vtmode.relsig = SIGUSR1;
- vtmode.acqsig = SIGUSR1;
- vtmode.frsig = SIGUSR1;
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
- }
-#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
- if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
- {
- FatalError("xf86OpenConsole: KDENABIO failed (%s)",
- strerror(errno));
- }
-#endif
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
- {
- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
- }
- break;
+ vtmode.mode = VT_PROCESS;
+ vtmode.relsig = SIGUSR1;
+ vtmode.acqsig = SIGUSR1;
+ vtmode.frsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
+ }
+ #if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+ if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
+ {
+ FatalError("xf86OpenConsole: KDENABIO failed (%s)",
+ strerror(errno));
+ }
+ #endif
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
+ }
+ } else { /* ShareVTs */
+ close(xf86Info.consoleFd);
+ }
+ break;
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
#ifdef WSCONS_SUPPORT
case WSCONS:
- fprintf(stderr, "xf86OpenConsole\n");
- /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */
+ /* Nothing to do */
break;
#endif
}
@@ -320,7 +324,7 @@ acquire_vt:
{
/* serverGeneration != 1 */
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+ if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
{
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
@@ -393,6 +397,9 @@ xf86OpenSyscons()
if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
initialVT = -1;
#endif
+ if (ShareVTs)
+ xf86Info.vtno = initialVT;
+
if (xf86Info.vtno == -1)
{
/*
@@ -575,8 +582,14 @@ xf86OpenPcvt()
sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
{
- FatalError("xf86OpenPcvt: Cannot open %s (%s)",
+ ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
vtname, strerror(errno));
+ xf86Info.vtno = initialVT;
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
+ FatalError("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
}
if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
{
@@ -585,8 +598,8 @@ xf86OpenPcvt()
xf86Info.consType = PCVT;
#ifdef WSCONS_SUPPORT
xf86Msg(X_PROBED,
- "Using wscons driver in pcvt compatibility mode "
- "(version %d.%d)\n",
+ "Using wscons driver on %s in pcvt compatibility mode "
+ "(version %d.%d)\n", vtname,
pcvt_version.rmajor, pcvt_version.rminor);
#else
xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
@@ -620,7 +633,7 @@ xf86OpenWScons()
#if defined(__NetBSD__)
sprintf(ttyname, "/dev/ttyE%d", i);
#elif defined(__OpenBSD__)
- sprintf(ttyname, "/dev/ttyC%d", i);
+ sprintf(ttyname, "/dev/ttyC%x", i);
#endif
if ((fd = open(ttyname, 2)) != -1)
break;
@@ -646,6 +659,8 @@ xf86CloseConsole()
struct vt_mode VT;
#endif
+ if (ShareVTs) return;
+
switch (xf86Info.consType)
{
#ifdef PCCONS_SUPPORT
@@ -662,7 +677,7 @@ xf86CloseConsole()
VT.mode = VT_AUTO;
ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
}
-#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
{
xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
@@ -712,6 +727,11 @@ xf86ProcessArgument(int argc, char *argv[], int i)
return(1);
}
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (!strcmp(argv[i], "-sharevts"))
+ {
+ ShareVTs = TRUE;
+ return(1);
+ }
if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
{
if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
@@ -732,6 +752,7 @@ xf86UseMsg()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
ErrorF("vtXX use the specified VT number (1-12)\n");
+ ErrorF("-sharevts share VTs with another X server\n");
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
ErrorF("-keeptty ");
ErrorF("don't detach controlling tty (for debugging only)\n");