From 6e46e34801c643df86f8c52526d4b76dfcf9f468 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 13 Jan 2026 18:47:17 +0100 Subject: [PATCH] xfree86: os-support: bsd: move console post-open steps into open procs Moving the console post-open steps (eg. acquire_vt()) into the indivual console driver's open proc, so we don't need the extra switch() and related #ifdef zoo anymore. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/os-support/bsd/bsd_init.c | 61 +++++++++++----------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index c462420d9..e18a42828 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -226,44 +226,6 @@ xf86OpenConsole(void) ("%s: No console driver found\n\tSupported drivers: %s\n\t%s", "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG); } - - switch (xf86Info.consType) { -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) - case SYSCONS: - /* - * As of FreeBSD 2.2.8, syscons driver does not need the #1 vt - * switching anymore. - */ - xf86_bsd_acquire_vt(); - return; - - case PCVT: -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) - xf86_bsd_acquire_vt(); - return; -#endif -#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000)) - /* - * First activate the #1 VT. This is a hack to allow a server - * to be started while another one is active. There should be - * a better way. - */ - if (initialVT != 1) { - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0) { - LogMessageVerb(X_WARNING, 1, "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - sleep(1); - } -#endif - xf86_bsd_acquire_vt(); - return; -#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ -#ifdef WSCONS_SUPPORT - case WSCONS: - /* Nothing to do */ - break; -#endif - } } else { /* serverGeneration != 1 */ @@ -379,6 +341,7 @@ static bool xf86OpenSyscons(void) } } xf86Info.consoleFd = fd; + xf86_bsd_acquire_vt(); return (fd > 0); } @@ -480,6 +443,26 @@ static bool xf86OpenPcvt(void) #endif } xf86Info.consoleFd = fd; + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + goto out; +#endif +#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000)) + /* + * First activate the #1 VT. This is a hack to allow a server + * to be started while another one is active. There should be + * a better way. + */ + if (initialVT != 1) { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0) { + LogMessageVerb(X_WARNING, 1, "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + sleep(1); + } +#endif + goto out; +out: + xf86_bsd_acquire_vt(); return (fd > 0); } @@ -513,6 +496,8 @@ static bool xf86OpenWScons(void) LogMessageVerb(X_PROBED, 1, "Using wscons driver\n"); } xf86Info.consoleFd = fd; + + /* nothing special to do for acquiring the VT */ return (fd > 0); }