summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/uhid.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* update some usb.org URLs following reorganisation, add a new one for updsthen2021-01-291-2/+2
| | | | partly from Alessandro Ricci
* introduce ujoy(4), a restricted subset of uhid(4) for gamecontrollers.thfr2021-01-231-1/+6
| | | | | | | | This includes ujoy_hid_is_collection() to work around limitations of hid_is_collection() until this can be combined without fallout. input, testing with 8bitdo controller, and ok brynet@ PS4 controller testing, fix for hid_is_collection, and ok mglocker@
* Refactor klist insertion and removalvisa2020-12-251-3/+3
| | | | | | | | | | | | Rename klist_{insert,remove}() to klist_{insert,remove}_locked(). These functions assume that the caller has locked the klist. The current state of locking remains intact because the kernel lock is still used with all klists. Add new functions klist_insert() and klist_remove() that lock the klist internally. This allows some code simplification. OK mpi@
* Use seltrue_kqfilter() instead of hand-rolling it in multiple drivers.mpi2020-05-131-11/+2
| | | | ok visa@
* Abstract the head of knote lists. This allows extending the lists,visa2020-04-071-3/+3
| | | | | | for example, with locking assertions. OK mpi@, anton@
* Fix incoherencies of errors returned by various *kqfilter routines.mpi2020-04-031-2/+2
| | | | | | | | EOPNOTSUPP is returned when there's no "filterops" for a given fd. EINVAL when the requested filter isn't supported by the "filterops". ENXIO means the underlying device is no longer valid/present. ok visa@
* Replace field f_isfd with field f_flags in struct filterops to allowvisa2020-02-201-3/+3
| | | | | | adding more filter properties without cluttering the struct. OK mpi@, anton@
* Invalidate knote list of uhid(4) after device detach. This preventsvisa2020-01-181-1/+5
| | | | | | | | | | | | a crash that can happen if a uhid(4) device is detached while kqueue still holds references to knotes that point to the device. The invalidation has to be done after vdevgone(). This order ensures that the file descriptors return an error or EOF when kevent(2) returns the EOF events. Crash reported and fix tested by Greg Steuck OK mpi@
* Use C99 designated initializers with struct filterops. In addition,visa2019-12-311-5/+13
| | | | | | make the structs const so that the data are put in .rodata. OK mpi@, deraadt@, anton@, bluhm@
* poll handlers must return a poll(2) revents value, not errno(2) values.reyk2019-12-191-3/+3
| | | | | | | | | Some drivers have returned ENXIO (6) if the device is not available which incorrectly translates into POLLPRI|POLLOUT (2|4) in userland. Change it to POLLERR for now, but it might as well be POLLHUP. OK mpi@
* Add fido(4), a HID driver for FIDO/U2F security keysreyk2019-12-171-41/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | While FIDO/U2F keys were already supported by the generic uhid(4) driver, this driver adds the first step to tighten the security of FIDO/U2F access. Specifically, users don't need read/write access to all USB/HID devices anymore and the driver also improves integration with pledge(2) and unveil(2): It is pledge-friendly because it doesn't require any ioctls to discover the device and unveil-friendly because it uses a single /dev/fido/* directory for its device nodes. It also allows to support FIDO/U2F in firefox without further weakening the "sandbox" of the browser. Firefox does not have a proper privsep design and many operations, such as U2F access, are handled directly by the main process. This means that the browser's "fat" main process needs direct read/write access to all USB HID devices, at least on other operating systems. With fido(4) we can support security keys in Firefox under OpenBSD without such a compromise. With this change, libfido2 stops using the ioctl to query the device vendor/product and just assumes "OpenBSD" "fido(4)" instead. The ioctl is still supported but there was no benefit in obtaining the vendor product or name; it also allows to use libfido2 under pledge. With feedback from deraadt@ and many others OK kettenis@ djm@ and jmc@ for the manpage bits
* Convert infinite sleeps to tsleep_nsec(9).mpi2019-11-271-2/+2
| | | | ok bluhm@
* Simplify/refactor the way vendor/product/serial informations arelandry2018-05-011-2/+2
| | | | | | | | | | | | | | | | | | gathered from usb devices. Cache them early in usbd_new_device() instead of querying the device several times (the content wont change anyway) and uselessly generating usb traffic (which could conflict with other access..) The heuristic stays the same, first look in the device descriptor, then try to match against usb_known_vendors/usb_known_products, then fallback to use the idVendor/idProduct codes. Remove the now useless 'usedev' parameter from usbd_fill_deviceinfo(). Tested from bsd & bsd.rd. suggested by and ok mpi@
* Delete unnecessary <sys/file.h> includesguenther2017-12-301-2/+1
| | | | ok millert@ krw@
* Add dummy FIOASYNC handler.mpi2017-09-231-1/+2
| | | | | | | | | Without it uhid_do_ioctl() will return EINVAL which will make the upper layer assume that uhid node do not support non-blocking reads. Fix a regression introduced by the removal of SIGIO support. Reported by many, fix tested by Bryan Linton, Micah Muer and Nam Nguyen.
* Remove SIGIO support. Base tools do not implement it and ports relyingmpi2017-07-201-26/+1
| | | | | | | | | | on libusbhid, generally via SDL, shouldn't do it either since it's not portable. Suggested by deraadt@ after Ilja van Sprundel reported an issue with a stale struct proc pointer in similar code. ok kettenis@, deraadt@
* A pile of sizes to free(9). In test for a few days in snapshots.deraadt2017-04-081-2/+2
| | | | | Errors will result in nice clean panic messages so we know what's wrong. Reviewed by dhill visa natano jsg.
* Kill unused ioctl(2)s.mpi2016-05-241-14/+2
| | | | ok deraadt@
* Convert uiomovei to uiomove. Fixes a few integer truncations along thestefan2016-03-031-5/+5
| | | | | | way. ok natano@
* Remove USB_SET_IMMED ioctl and corresponding code and manpage bits.stefan2016-02-281-24/+1
| | | | | | Nothing uses it. suggested by and ok mpi@
* revert manual additions of hid.h now that usbhid.h brings it injcs2016-01-091-3/+1
|
* Move HID support files out of dev/usb into new dev/hid directoryjcs2016-01-081-2/+3
| | | | | | | | | These files aren't USB-specific and were used by the previous Bluetooth implementation, and will be used by the upcoming HID-over-i2C implementation ok deraadt previous version ok kettenis and mpi
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-2/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* First step towards making uiomove() take a size_t size argument:miod2015-02-101-4/+4
| | | | | | | - rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
* Change uhidev(4) set/get report functions in various way.mpi2014-12-111-20/+12
| | | | | | | | | | | | | | Always pass the parent uhidev(4) descriptor corresponding to the single USB device with multiple reportIDs instead of a child. Make uhidev_get_report() aware of non NUL reportID by prepending a byte to the given buffer, just like uhidev_set_report{,async}() already do. Return the number of bytes written or read upon success and -1 otherwise. This allow callers to deal with short reads without having do mess with xfer error codes madness. Reviewed and tested by David Higgs.
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-2/+2
| | | | after discussions with beck deraadt kettenis.
* Modify the uhidev_*_report() methods to always take a report ID argumentmpi2014-04-151-4/+6
| | | | | | | | instead of using the default, per-driver, one. This is a step to move away from the 1 report ID <-> 1 driver design which is no longer true since the addition of upd(4). ok andre@
* Add a temporary hack to let a subdriver claim all the reportIDs ofmpi2014-03-191-5/+4
| | | | | | | a device. This should be removed once all the drivers attaching to uhidev(4) are converted. ok andre@, sthen@
* Kill matchlvl usage throughout the usb stack.pirofti2013-11-191-3/+3
| | | | | | Allows us to move forward on cleaning. Okay mpi@
* Clean-up the HID environment.pirofti2013-11-151-29/+12
| | | | | | | | | | | | | | | | | | | | | This set of drivers were very very dirty. i/ Clean-up the match/attach multi-casting hackjob - stop casting aux to every attach arg in existance - be consistent about casting it only to uhidev_attach_arg - fetch the usb_attach_arg from above where needed ii/ Sort out the activate routines - leave the deactivation to the parent (uhidev(4)) - ditch the sc_dying flag in favour of usbd_is_dying() iii/ Get closer to keeping all the usb hid information in the uhidev structure (one uhidev per reportID) - store the usbd_device in the uhidev - use it consistently instead of always peaking at the parent's soft state Okay mpi@
* Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thingmatthew2011-07-031-4/+1
| | | | | | | | that's ever used it, and it's long since been changed to use DVACT_{QUIESCE,SUSPEND,RESUME} instead. ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it up a few weeks ago
* kqueue attach functions should return an errno or 0, not a plain 1. Fixnicm2011-07-021-2/+2
| | | | | | the obvious cases to return EINVAL and ENXIO. ok tedu deraadt
* garbage collect "usb events". without /dev/usb there is no way to accessjakemsr2011-01-251-7/+1
| | | | | | them from userland, and nothing in the kernel uses them. ok krw@, miod@
* remove dying flag in detach() function.yuo2010-09-241-3/+1
| | | | | | The dying flag will be set in activate()/DEACTIVATE. ok deraadt@
* Handle USB_GET_REPORT, USB_GET_REPORT_DESC, USB_GET_REPORT_ID andmiod2010-08-021-75/+19
| | | | | | | USB_SET_REPORT ioctls in ukbd and ums. This allows usbhidctl to be used on these devices e.g. to dump the report descriptor of troublesome models. ok deraadt@
* Correct the links between threads, processes, pgrps, and sessions,guenther2010-07-261-8/+8
| | | | | | | | | so that the process-level stuff is to/from struct process and not struct proc. This fixes a bunch of problem cases in rthreads. Based on earlier work by blambert and myself, but mostly written at c2k10. Tested by many: deraadt, sthen, krw, ray, and in snapshots
* add USB_GET_DEVICEINFO and USB_GET_STRING_DESC ioctl to the uhid(4).yuo2009-11-231-1/+17
| | | | ok jsg@ deraadt@
* Every selwakeup() should have a matching KNOTE() (even if kqueue isn'tnicm2009-11-091-2/+1
| | | | | | | | | | supported it doesn't do any harm), so put the KNOTE() in selwakeup() itself and remove it from any occurences where both are used, except one for kqueue itself and one in sys_pipe.c (where the selwakeup is under a PIPE_SEL flag). Based on a diff from tedu. ok deraadt
* Add missing KNOTE() calls after selwakeup(), until we decide if the KNOTE()deraadt2009-10-311-1/+2
| | | | | | | calls can go directly into selwakeup() safely long discussion with nicm, murmers of consent from tedu and miod, noone else seems to care of kqueue is busted as long as it makes their sockets move data fast... pretty sad.
* Get rid of devact enum, substitute it with an int and coresponding defines.pirofti2009-10-131-3/+3
| | | | | | This is needed for the addition of further suspend/resume actions. Okay deraadt@, marco@.
* clalloc() can't fail, so there's no need to handle failure cases.blambert2009-07-191-5/+3
| | | | | | | | Change to void function. Also, no need to have global tty stats pointer, so just return it from clalloc, as the caller frees it immediately anyway. ok miod@
* First pass at removing clauses 3 and 4 from NetBSD licenses.ray2008-06-261-8/+1
| | | | | | | | | Not sure what's more surprising: how long it took for NetBSD to catch up to the rest of the BSDs (including UCB), or the amount of code that NetBSD has claimed for itself without attributing to the actual authors. OK deraadt@
* Remove the definition and usage of the USB_DECLARE_DRIVER_CLASS andmbalmer2007-06-141-2/+17
| | | | | | | | USB_DECLARE_DRIVER macros. No binary change. ok dlg.
* Remove the definition and use of the device_ptr_t which was a struct device *.mbalmer2007-06-121-2/+2
| | | | | | No binary change. ok mk.
* Remove the usb_proc_ptr type definition, which was really a 'struct proc *'mbalmer2007-06-111-8/+8
| | | | | | | | only. No binary change. ok mk.
* Remove the USB_GET_SC_OPEN macro. There is a double check for sc == NULL inmbalmer2007-06-111-2/+6
| | | | | | | | ulpt.c, I am aware of that and it will be changed later. No binary change. ok mk.
* Remove the definition and use of the USB_GET_SC macro, no binary change.mbalmer2007-06-111-7/+7
| | | | ok mk.
* More USB cleanup: In usb_port.h, get rid of the sel_klist #definemk2007-06-111-4/+4
| | | | | | | (which was there twice without gcc complaining) and update all uses of it. ok jsg mbalmer
* Remove the definition and use of the USBDEV macro. It only created confusionmbalmer2007-06-101-6/+6
| | | | | | | | and the address of it's argument: USBDEV(sc->sc_dev) yields &sc->sc_dev. No binary changes. ok jsg.
* Remove the "Static" declaration of many functions. It was defined to be emptymbalmer2007-06-051-11/+11
| | | | | | | and it was not consistently used. It was confusing as it suggested these functions were static, which they were not. discussed with dlg and jsg, ok jsg.