diff --git a/hw/xfree86/common/console.c b/hw/xfree86/common/console.c new file mode 100644 index 0000000000..209abaca44 --- /dev/null +++ b/hw/xfree86/common/console.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * @copyright Enrico Weigelt, metux IT consult + * @brief console driver interface + */ +#include + +#include + +#include "xf86_console_priv.h" + +/* user requested VT number (-1 = unspecified) */ +int xf86_console_requested_vt = -1; + +/* close callback of current console backend - may be NULL */ +void (*xf86_console_proc_close)(void) = NULL; + +/* reactivation callback (eg. on server regeneration) - may be NULL */ +void (*xf86_console_proc_reactivate)(void) = NULL; + +/* ring the system bell */ +void (*xf86_console_proc_bell)(int loudness, int pitch, int duration) = NULL; + +/* switch away from VT */ +bool (*xf86_console_proc_switch_away)(void) = NULL; diff --git a/hw/xfree86/common/meson.build b/hw/xfree86/common/meson.build index 161e005f75..55798bdc77 100644 --- a/hw/xfree86/common/meson.build +++ b/hw/xfree86/common/meson.build @@ -1,4 +1,5 @@ srcs_xorg_common = [ + 'console.c', 'xf86fbBus.c', 'xf86noBus.c', 'xf86Configure.c', diff --git a/hw/xfree86/common/xf86_console_priv.h b/hw/xfree86/common/xf86_console_priv.h new file mode 100644 index 0000000000..e22429392e --- /dev/null +++ b/hw/xfree86/common/xf86_console_priv.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * @copyright Enrico Weigelt, metux IT consult + * @brief definitions for XF86 console driver interface + */ +#ifndef __XSERVER_XFREE86_XF86_CONSOLE_PRIV_H +#define __XSERVER_XFREE86_XF86_CONSOLE_PRIV_H + +#include + +/* user requested VT number (-1 = unspecified) */ +extern int xf86_console_requested_vt; + +/* close callback of current console backend - may be NULL */ +extern void (*xf86_console_proc_close)(void); + +/* reactivation callback (eg. on server regeneration) - may be NULL */ +extern void (*xf86_console_proc_reactivate)(void); + +/* ring the system bell */ +extern void (*xf86_console_proc_bell)(int loudness, int pitch, int duration); + +/* switch away from VT */ +extern bool (*xf86_console_proc_switch_away)(void); + +#endif /* __XSERVER_XFREE86_XF86_CONSOLE_PRIV_H */ diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index eebd585790..f0c5de8707 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -30,6 +30,7 @@ #include "compiler.h" #include "xf86.h" +#include "xf86_console_priv.h" #include "xf86Priv.h" #include "xf86_os_support.h" #include "xf86_OSlib.h" @@ -46,7 +47,6 @@ static Bool KeepTty = FALSE; #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) -static int VTnum = -1; static int initialVT = -1; #endif @@ -300,7 +300,7 @@ xf86OpenSyscons(void) syscons_version = 0; } - xf86Info.vtno = VTnum; + xf86Info.vtno = xf86_console_requested_vt; from = X_CMDLINE; #ifdef VT_GETACTIVE @@ -424,7 +424,7 @@ xf86OpenPcvt(void) " not supported.", CHECK_DRIVER_MSG); } - xf86Info.vtno = VTnum; + xf86Info.vtno = xf86_console_requested_vt; if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) initialVT = -1; @@ -577,11 +577,12 @@ xf86ProcessArgument(int argc, char *argv[], int i) } #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) if ((argv[i][0] == 'v') && (argv[i][1] == 't')) { + int VTnum = -1; if (sscanf(argv[i], "vt%2d", &VTnum) == 0 || VTnum < 1 || VTnum > 12) { UseMsg(); - VTnum = -1; return 0; } + xf86_console_requested_vt = VTnum; return 1; } #endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c index 9732b83520..779bd4f895 100644 --- a/hw/xfree86/os-support/solaris/sun_init.c +++ b/hw/xfree86/os-support/solaris/sun_init.c @@ -29,6 +29,7 @@ #include "../../../../os/cmdline.h" #include "xf86_priv.h" +#include "xf86_console_priv.h" #include "xf86Priv.h" #include "xf86_os_support.h" #include "xf86_OSlib.h" @@ -59,7 +60,6 @@ static Bool KeepTty = FALSE; static Bool UseConsole = FALSE; #ifdef HAS_USL_VTS -static int VTnum = -1; static int xf86StartVT = -1; static int vtEnabled = 0; #endif @@ -169,8 +169,8 @@ xf86OpenConsole(void) xf86StartVT = vtinfo.v_active; - if (VTnum != -1) { - xf86Info.vtno = VTnum; + if (xf86_console_requested_vt != -1) { + xf86Info.vtno = xf86_console_requested_vt; from = X_CMDLINE; } else if (xf86Info.ShareVTs) { @@ -377,12 +377,12 @@ xf86ProcessArgument(int argc, char **argv, int i) #ifdef HAS_USL_VTS if ((argv[i][0] == 'v') && (argv[i][1] == 't')) { + int VTnum; if (sscanf(argv[i], "vt%d", &VTnum) == 0) { UseMsg(); - VTnum = -1; return 0; } - + xf86_console_requested_vt = VTnum; return 1; }