Commit graph

50 commits

Author SHA1 Message Date
Warner Losh 2ff63af9b8 sys: Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:18 -06:00
Michael 971bac5ace kbd: consolidate kb interfaces (phase one)
Refactor to eliminate duplicated rate and delay tables, with minor style
tweaks for changed lines.  Remove an obsolete comment about needing to
convert from microseconds to ticks (that's done elsewhere). Remove
traiing whitespace in kbdcontrol.c.

Except for the new warning, no change in behavior

Sponsored by: 		DSS GmbH
Reviewed by:		imp [minor style tweaks as well]
Pull Request:		https://github.com/freebsd/pull/683
Differential Revision: 	https://reviews.freebsd.org/D38818
2023-07-06 23:10:18 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Stefan Eßer f20058955c sys/kbio.h: make pre-unicode keymap support optional
FreeBSD-9 had introduced support for the full set of Unicode
characters to the parsing and processing of keymap character tables.

This support has been extended to cover the table for accented
characters that are reached via dead key combinations in FreeBSD-13.2.

New ioctls have been introduced to support both the pre-Unicode and
the Unicode formats and keyboard drivers have been extended to support
those ioctls.

This commit makes the ABI compatibility functions in the kernel
optional and dependent on COMPAT_FREEBSD13 in -CURRENT.

The kbdcontrol command in -CURRENT and 13-STABLE (before 13.2) has
been made ABI compatible with old kernels to allow a new world to be
run on an old kernel (that does not have full Unicode support for
keymaps).

This commit is not to merged back to 12-STABLE or 13-STABLE. It is
part of review D38465, which has been split into 3 separate commits
due to different MFC and life-time requirements of either commit.

Approved by:	imp
Differential Revision:	https://reviews.freebsd.org/D38465
2023-02-14 14:03:28 +01:00
Stefan Eßer 4972fb9276 Support Unicode characters in keymap dead key tables
Support for Unicode characters had been added to the keyboard code,
but there are keymaps that have accented characters accessed via dead
key combinations, and those were still restricted to 8 bit codes.

This update to kbd.c adds support for Unicode characters and
compatibility code that allows a kbdcontrol command built from kbio.h
without these patches to work on a new kernel.

Compatibility code that allows a new kbdcontrol binary running on an
old kernel to load and display the dead key map will be committed in a
separate commit.

Reviewed by:	imp, brooks
Approved by:	brooks
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38381
2023-02-06 23:48:47 +01:00
Vladimir Kondratyev 183088934a evdev: Extend EVIOCGRAB ioctl scope to cover kbd interface
of various keyboard drivers.
EVIOCGRAB ioctl execution on /dev/input/event# device node gains
exclusive access to this device to caller. It is used mostly for
development purposes and remote control software. See e.g.
https://reviews.freebsd.org/D30020 which is the reason of creation
of this change.
Keyboard grabbing is disabled in KDB and during panics.

MFC with:	4a0db5e292
Tested by:	corvink
Differential revision:	https://reviews.freebsd.org/D30542
2022-11-19 02:54:46 +03:00
Alexander Motin e5018628e7 kbdmux(4): Make callout handler mpsafe.
Both callout and taskqueue now have drain() routines not requiring
external locking.  It allows to remove TASK flag and manual drain,
so the only thing remaining for lock to protect inside the callout
handler is ks_inq_length zero comparison, that can be lockless.

MFC after:	2 weeks
2021-08-08 18:29:48 -04:00
Kyle Evans 94551ceb0a kbdmux: simplify modevent handler
In the event of a MOD_LOAD failure, MOD_UNLOAD will be invoked to unwind
module load. Most of the reversion in MOD_LOAD can just be deferred to
normal MOD_UNLOAD cleanup, rather than duplicating the effort.

A NULL return of kbd_get_switch in the MOD_UNLOAD handler has been
downgraded from a panic to a successful return, as that certainly just means
that kbd_add_driver failed (not possible at the moment) and we have no work
to do.
2019-12-26 17:25:51 +00:00
Kyle Evans 2899979df9 Revert r355806: kbd drivers: don't double register keyboard drivers
r356087 made it rather innocuous to double-register built-in keyboard
drivers; we now set a flag to indicate that it's been registered and only
act once on a registration anyways. There is no misleading here, as the
follow-up kbd_delete_driver will actually remove the driver as needed now
that the linker set isn't also consulted after kbdinit.
2019-12-26 17:09:36 +00:00
Kyle Evans 5a7a578be9 kbd drivers: don't double register keyboard drivers
Keyboard drivers are generally registered via linker set. In these cases,
they're also available as kmods which use KPI for registering/unregistering
keyboard drivers outside of the linker set.

For built-in modules, we still fire off MOD_LOAD and maybe even MOD_UNLOAD
if an error occurs, leading to registration via linker set and at MOD_LOAD
time.

This is a minor optimization at best, but it keeps the internal kbd driver
tidy as a future change will merge the linker set driver list into its
internal keyboard_drivers list via SYSINIT and simplify driver lookup by
removing the need to consult the linker set.
2019-12-16 16:41:24 +00:00
Kyle Evans eefc662f0b kbd: provide default implementations of get_fkeystr/diag
Most keyboard drivers are using the genkbd implementations as it is;
formally use them for any that aren't set and make
genkbd_get_fkeystr/genkbd_diag private.
2019-12-16 02:44:56 +00:00
John Baldwin 5773ac113c Use callout_func_t instead of the deprecated timeout_t.
Reviewed by:	kib, imp
Differential Revision:	https://reviews.freebsd.org/D22752
2019-12-10 22:06:53 +00:00
Vladimir Kondratyev f86e7267f5 evdev: Use console lock as evdev lock for all supported keyboard drivers.
Now evdev part of keyboard drivers does not take any locks if corresponding
input/eventN device node is not opened by userland consumers.

Do not assert console lock inside evdev to handle the cases when keyboard
driver is called from some special single-threaded context like shutdown
thread.
2018-10-27 20:22:41 +00:00
Vladimir Kondratyev 48f2b00648 evdev: Remove evdev.ko linkage dependency on kbd driver
Move evdev_ev_kbd_event() helper from evdev to kbd.c as otherwise evdev
unconditionally requires all keyboard and console stuff to be compiled
into the kernel. This dependency happens as evdev_ev_kbd_event() helper
references kbdsw global variable defined in kbd.c through use of
kbdd_ioctl() macro.

While here make all keyboard drivers respect evdev_rcpt_mask while setting
typematic rate and LEDs with evdev interface.

Requested by:	Milan Obuch <bsd@dino.sk>
Reviewed by:	hselasky, gonzo
Differential Revision:	https://reviews.freebsd.org/D16614
2018-08-13 19:05:53 +00:00
Brooks Davis 6469bdcdb6 Move most of the contents of opt_compat.h to opt_global.h.
opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by:	kib, cem, jhb, jtl
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14941
2018-04-06 17:35:35 +00:00
Pedro F. Giffuni 718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Oleksandr Tymoshenko 97fc5dbe89 [evdev] Add evdev support to kbdmux(4) driver
To enable event sourcing from kbdmux(4) kern.evdev.rcpt_mask value
should have bit 1 set (this is default)

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D8437
2016-11-15 04:12:19 +00:00
Bruce Evans cc43fd1ab5 Fix keyboard polling "on/off" to support recursion. vt depends on
this, and sc will soon depend on it again.

The on/off request is passed without modification to lower layers,
so the bug was smaller in this layer than in in lower layers (the
sequence on;on;off left polling off when it should be on, but the
sequence on;on;off;on;off...  doesn't allow the interrupt handler
to eat the input after an "off" that should't turn off polled mode,
provided lower layers don't have the bug, since this layer is virtual.

The bug was small in lower layers too.  Normally everything is Giant
locked for keyboards, and this locks out the interrupt handler in
on;on;off;on;off... sequences.  However, PR 211884 says that fixing
this bug in ukbd in r303765 apparently causes the eating-by-interrupt
behaviour that the fix is to prevent.

Discussed with: emax
2016-08-30 12:36:14 +00:00
Ed Maste 46360281f0 Add option to specify built-in keymap for kbdmux
PR:		153459
Submitted by:	swell.k@gmail.com
2016-04-07 20:12:45 +00:00
Pedro F. Giffuni 1faac5bc09 Revert r281889:
The change would appease the static analyzers but it is pretty much a
no-op. I need to trust static analyzers much less, especially for the
kernel.

Requested by:	jkim
2015-04-29 20:08:03 +00:00
Pedro F. Giffuni 3b7176c90a Plug memory leaks in kbdmux(4) (take 2)
This is a fix to the previous attempt in r281889, which some (most?)
keyboards.

Discussed with:	emaste, jkim

Found by:	clang static analyzer
CID:		1007072
CID:		1007073
CID:		1007074
2015-04-29 15:41:19 +00:00
Ed Maste 2a4b3913bb Revert r281889, it broke keyboard input 2015-04-23 20:26:22 +00:00
Pedro F. Giffuni 77990dfda9 Plug memory leaks in kbdmux(4)
Al kudos here for the Clang static analyzer which, unlike Coverity,
failed to flag a false positive.

Found by:	clang static analyzer
CID:		1007072
CID:		1007073
CID:		1007074

MFC after:	1 week
2015-04-23 14:53:45 +00:00
Eitan Adler a8de37b024 This isn't functionally identical. In some cases a hint to disable
unit 0 would in fact disable all units.

This reverts r241856

Approved by: cperciva (implicit)
2012-10-22 13:06:09 +00:00
Eitan Adler 76b7512247 Now that device disabling is generic, remove extraneous code from the
device drivers that used to provide this feature.

Reviewed by:	des
Approved by:	cperciva
MFC after:	1 week
2012-10-22 03:41:14 +00:00
Ed Schouten 78d4d8eeb2 Restore binary compatibility for GIO_KEYMAP and PIO_KEYMAP.
Back in 2009 I changed the ABI of the GIO_KEYMAP and PIO_KEYMAP ioctls
to support wide characters. I created a patch to add ABI compatibility
for the old calls, but I didn't get any feedback to that.

It seems now people are upgrading from 8 to 9 they experience this
issue, so add it anyway.
2011-07-17 08:19:19 +00:00
Rui Paulo cd1fa5bd4d Explicitly tell the compiler that we don't care about the return value
of kbdd_ioctl().
2010-10-13 11:37:12 +00:00
Ed Schouten 417635733e Use proper types in kbdmux_kbd_getc():
- The return value should be a signed integer, because -1 means failure.
- The c variable should be unsigned, to force it to be zero-extended
  when returned.

Reported by:	Andreas Tobler <andreast-list fgznet ch>
2009-06-08 20:24:29 +00:00
Ed Schouten 5f46eda1fd Move buffer management into kbd and kbdmux drivers.
These two drivers seem to be the last consumers of clists. clists are
quite overengineered for simple circular buffers, so I'm adding similar
buffer management routines to the kbd and kbdmux drivers. The input
buffer is now part of the softc structures, instead of having
dynamically allocated cblocks.
2009-06-05 15:19:05 +00:00
Maksim Yevmenkin ed382753a7 Undo SVN rev 183283
Do not use Giant for kbdmux(4) locking. This is wrong and apparently
causing more problems than it solves. This will re-open the issue
where interrupt handlers may race with kbdmux(4) in polling mode.
Typical symptoms include (but not limited to) duplicated and/or
missing characters when low level console functions (such as gets)
are used while interrupts are enabled (for example geli password
prompt, mountroot prompt etc.)

MFC after:	3 days
2009-04-08 20:52:30 +00:00
Andrew Thompson fd66bfec7f Since r188030 the error value for attach is returned, this means if kbdmux
fails to attach (possibly due to disable hints) then we get called back for
unload. Correctly handle the case where the keyboard isnt found rather than
calling panic.
2009-02-13 23:36:08 +00:00
Maksim Yevmenkin 8de7d5083c Properly retun error core from kbdmux_modevent()
Reported by:	Christoph Mallon < christoph -dot- mallon -at- gmx -dot- de >
MFC after:	1 week
2009-02-02 21:34:04 +00:00
Maksim Yevmenkin 352d011bcc Use Giant for kbdmux(4) locking. This is to workaround the problem
where interrupt handlers may race with kbdmux(4) in polling mode.

PR:		kern/127446
Reported by:	Eygene Ryabinkin rea-fbsd at codelabs dot ru
Tested by:	Eygene Ryabinkin rea-fbsd at codelabs dot ru
MFC after:	1 week
2008-09-22 22:08:43 +00:00
Ed Schouten 75ec42320d Don't include <sys/tty.h> in non-TTY drivers.
The kbd, kbdmux, ugen and uhid drivers included <sys/tty.h>, because
they needed clists, which have been moved to <sys/clist.h> some time
ago. In the MPSAFE TTY branch, <sys/tty.h> does not include
<sys/clist.h>, which means we have to teach these drivers to include
this header file directly.

Approved by:	philip (mentor, implicit)
2008-07-24 09:54:10 +00:00
Wojciech A. Koszek 259699b294 Remove explicit calls to keyboard methods with their respective variants
implemented with macros. This patch improves code readability. Reasoning
behind kbdd_* is a "keyboard discipline".

List of macros is supposed to be complete--all methods of keyboard_switch
should have their respective macros from now on.

Functionally, this code should be no-op. My intention is to leave current
behaviour of code as is.

Glanced at by:	rwatson
Reviewed by:	emax, marcel
Approved by:	cognet
2007-12-29 21:55:25 +00:00
Maksim Yevmenkin 190fa66b39 Fix kbdmux(4) issue with backslash/underscore key not working on
Japanese 106/109 keyboard.

PR:		kern/112214, kern/99090
Submitted by:	TOMITA Yoshinori, TAKAHASHI Yoshihiro
Approved by:	re (hrs)
MFC after:	3 days
2007-07-11 18:57:15 +00:00
Ruslan Ermilov 9fddcc6661 Fix our ioctl(2) implementation when the argument is "int". New
ioctls passing integer arguments should use the _IOWINT() macro.
This fixes a lot of ioctl's not working on sparc64, most notable
being keyboard/syscons ioctls.

Full ABI compatibility is provided, with the bonus of fixing the
handling of old ioctls on sparc64.

Reviewed by:	bde (with contributions)
Tested by:	emax, marius
MFC after:	1 week
2006-09-27 19:57:02 +00:00
Ruslan Ermilov 8ad58ac6ee Revert back to always using *(int *)arg for now. While this
is incorrect, and causes endianness bugs on 64-bit big-endian
machines (sparc64), it's the best choice for now, as many of
these IOCTLs are used inside the kernel, and bogusly pass an
argument as "int *" which results in unaligned access panics
on sparc64 when attempting to dereference them via *(intptr_t *).

(Several of us are working on a real fix, which is uneasy.)
2006-09-20 11:43:36 +00:00
Ruslan Ermilov 9e24e7f60b Make typecast expressions comply with style(9). 2006-09-19 13:03:09 +00:00
Ruslan Ermilov 9cd96497d6 This time, really fix endian bugs accessing ioctl arguments that
are passed by value.  These are KDSKBMODE, KDSETLED, KDSKBSTATE,
and KDSETRAD.

Tested on:	amd64, sparc64 (demo code)
2006-09-19 13:01:20 +00:00
Ruslan Ermilov 225fcb2690 Back out revision 1.8. The only thing it did was to break LEDs (and
some other less noticeable things) on little-endian 64-bit platforms
such as amd64.

PR:		kern/101931
Discussed with:	emax, marius
MFC after:	1 day
2006-09-19 09:34:25 +00:00
Maksim Yevmenkin 04c1ba9b05 Add extra code into kbdmux(4)s read_char() method to
poll (i.e. call read_char() method) slave keyboards.

This workaround should fix problem with kbdmux(4) and
atkbd(4) not working in ddb(4) and mid-boot.

MFC after:	1 week
2006-07-27 20:33:48 +00:00
Maksim Yevmenkin af0618e9d4 Fix endian bugs accessing ioctl arguments that are passed by value.
Pointed out by:	marius
MFC after:	1 day
2006-03-03 00:46:28 +00:00
Maksim Yevmenkin b569776d07 Provide ability to disable kbdmux(4) with the hint.kbdmux.0.disabled="1" hint.
Document hint in the kbdmux(4) man page.

Requested by:	scottl
MFC after:	1 day
2006-03-01 18:34:48 +00:00
Maksim Yevmenkin 40a3c5ea70 Plug memory leak
MFC after:	1 day
2006-02-27 21:47:38 +00:00
Maksim Yevmenkin 65b70c1dfd Put a comment, explaining why kbdmux(4) had to be fixed.
While I'm here fix a couple of whitespaces.

Requested by:	netchild
MFC after:	1 day
2006-02-25 22:59:01 +00:00
Maksim Yevmenkin fd4df69975 Fix hard lockup caused by kbdmux(4) when kbdmux(4), PS/2 keyboard
(atkbd(4)) and PS/2 mouse (psm(4)) are used together.

Turns out that atkbd(4) check_char() method may return "true" while
read_char() method returns NOKEY. When this happens kbdmux(4) was
simply stuck in the dead loop. Avoid dead loop in kbdmux(4) by breaking
out of the loop if read_char() method returns NOKEY.

It almost seems like a bug in atkkbd(4), atkbd_check_char() calls
kbdc_data_ready(), and, the later will return "true" if there are
pending data in either kbd or aux queue. However, because both aux
and kbd are on the same controller, I'm not sure if this is a bug
or feature.

Tested by:	markus
MFC after:	1 day
2006-02-25 21:59:29 +00:00
Yaroslav Tykhiy 3423126960 Spotted a call to a cdev-related function not wrapped
in "#ifdef KBD_INSTALL_CDEV".

Noticed by:	glebius
Uncovered by:	recent change to modules' Makefiles
2005-10-18 06:38:14 +00:00
Maksim Yevmenkin 4673ea01e3 kbdmux(4) keyboard multiplexer integration
o Slightly change KBADDKBD and KBRELKBD ioctl() interface. Instead of passing
  keyboard index pass keyboard_info_t structure with populated 'kb_unit' and
  'kb_name' fields. Keyboard index is not very user-friendly and is not very
  easy to obtain. Keyboard driver name and unit, on the other hand, is much
  more user friendly and known almost all the time;

o Move definition of keyboard_info_t structure up;

o Teach kbdcontrol(1) how to attach/detach keyboards to/from the keyboard
  multiplexor;

o Update kbdcontrol(1) man page and document new functionality.

To attach/detach keyboard to/from keyboard multiplexor one needs to use
keyboard device name (i.e. ukbd0).

MFC after:	1 week
2005-07-14 22:43:20 +00:00
Maksim Yevmenkin dfa494399b kbdmux(4) keyboard multiplexer integration
o Add sys/dev/kbdmux/kbdmux.c to the source tree

o Add sys/modules/kbdmux/Makefile to the source tree

These are not yet connected to the build. Man page and other changes to follow.

MFC after:	1 week
2005-07-14 17:48:04 +00:00