Module Name: src Committed By: mlelstv Date: Sat Apr 4 07:33:18 UTC 2020
Modified Files: src/sys/dev/wscons: wsevent.c Log Message: Make default protocol version used by wscons selectable and default to the current version. Fixes PR 55103. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/dev/wscons/wsevent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/wscons/wsevent.c diff -u src/sys/dev/wscons/wsevent.c:1.42 src/sys/dev/wscons/wsevent.c:1.43 --- src/sys/dev/wscons/wsevent.c:1.42 Fri Mar 1 11:06:57 2019 +++ src/sys/dev/wscons/wsevent.c Sat Apr 4 07:33:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wsevent.c,v 1.42 2019/03/01 11:06:57 pgoyette Exp $ */ +/* $NetBSD: wsevent.c,v 1.43 2020/04/04 07:33:18 mlelstv Exp $ */ /*- * Copyright (c) 2006, 2008 The NetBSD Foundation, Inc. @@ -104,7 +104,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.42 2019/03/01 11:06:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.43 2020/04/04 07:33:18 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -121,6 +121,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsevent.c,v #include <sys/select.h> #include <sys/poll.h> #include <sys/compat_stub.h> +#include <sys/sysctl.h> #include <dev/wscons/wsconsio.h> #include <dev/wscons/wseventvar.h> @@ -138,6 +139,8 @@ __KERNEL_RCSID(0, "$NetBSD: wsevent.c,v sizeof(struct owscons_event)) #define EVARRAY(ev, idx) (&(ev)->q[(idx)]) +static int wsevent_default_version = WSEVENT_VERSION; + /* * Priority of code managing wsevent queues. PWSEVENT is set just above * PSOCK, which is just above TTIPRI, on the theory that mouse and keyboard @@ -161,8 +164,16 @@ wsevent_init(struct wseventvar *ev, stru #endif return; } - /* For binary compat. New code must call WSxxxIO_SETVERSION */ - ev->version = 0; + /* For binary compat set default version and either build with + * COMPAT_50 or load COMPAT_50 module to include the compatibility + * code. + */ + if (wsevent_default_version >= 0 && + wsevent_default_version < WSEVENT_VERSION) + ev->version = wsevent_default_version; + else + ev->version = WSEVENT_VERSION; + ev->get = ev->put = 0; ev->q = kmem_alloc(WSEVENT_QSIZE * sizeof(*ev->q), KM_SLEEP); selinit(&ev->sel); @@ -445,3 +456,22 @@ wsevent_setversion(struct wseventvar *ev ev->version = vers; return 0; } + +SYSCTL_SETUP(sysctl_wsevent_setup, "sysctl hw.wsevent subtree setup") +{ + const struct sysctlnode *node = NULL; + + if (sysctl_createv(clog, 0, NULL, &node, + CTLFLAG_PERMANENT, + CTLTYPE_NODE, "wsevent", NULL, + NULL, 0, NULL, 0, + CTL_HW, CTL_CREATE, CTL_EOL) != 0) + return; + + sysctl_createv(clog, 0, &node, NULL, + CTLFLAG_READWRITE, + CTLTYPE_INT, "default_version", + SYSCTL_DESCR("Set default event version for compatibility"), + NULL, 0, &wsevent_default_version, 0, + CTL_CREATE, CTL_EOL); +}