diff options
author | Adam Wolk <awolk@cvs.openbsd.org> | 2016-09-15 17:53:39 +0000 |
---|---|---|
committer | Adam Wolk <awolk@cvs.openbsd.org> | 2016-09-15 17:53:39 +0000 |
commit | bfc46a5fe7a0833e1612d28e4f30a157ac901514 (patch) | |
tree | d65f1ae2831fdc17dbcfcef185662d231060e095 /share/man/man9 | |
parent | d0358eaed149ae3570cb03167b58d4cdc90698eb (diff) |
Document the USB task API
OK mpi@
change post OK:
- long lines in the source file wrapped
- added note about USB_TASK_TYPE_ABORT from mpi@
Diffstat (limited to 'share/man/man9')
-rw-r--r-- | share/man/man9/Makefile | 6 | ||||
-rw-r--r-- | share/man/man9/usb_add_task.9 | 117 |
2 files changed, 120 insertions, 3 deletions
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index a9a83b2f0e5..de8cf732dde 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.280 2016/09/05 07:22:29 dlg Exp $ +# $OpenBSD: Makefile,v 1.281 2016/09/15 17:53:38 awolk Exp $ # $NetBSD: Makefile,v 1.4 1996/01/09 03:23:01 thorpej Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -33,8 +33,8 @@ MAN= aml_evalnode.9 atomic_add_int.9 atomic_cas_uint.9 \ spl.9 srp_enter.9 srpl_rc_init.9 startuphook_establish.9 \ socreate.9 sosplice.9 style.9 syscall.9 sysctl_int.9 \ task_add.9 tc_init.9 time_second.9 timeout.9 tsleep.9 tvtohz.9 \ - uiomove.9 uvm.9 usbd_close_pipe.9 usbd_open_pipe.9 usbd_ref_wait.9 \ - usbd_transfer.9 vfs.9 vfs_busy.9 \ + uiomove.9 uvm.9 usb_add_task.9 usbd_close_pipe.9 usbd_open_pipe.9 \ + usbd_ref_wait.9 usbd_transfer.9 vfs.9 vfs_busy.9 \ vfs_cache.9 vaccess.9 vclean.9 vcount.9 vdevgone.9 vfinddev.9 vflush.9 \ vflushbuf.9 vget.9 vgone.9 vhold.9 vinvalbuf.9 vnode.9 vnsubr.9 \ VOP_LOOKUP.9 vput.9 vrecycle.9 vref.9 vrele.9 \ diff --git a/share/man/man9/usb_add_task.9 b/share/man/man9/usb_add_task.9 new file mode 100644 index 00000000000..861651d79b0 --- /dev/null +++ b/share/man/man9/usb_add_task.9 @@ -0,0 +1,117 @@ +.\" $OpenBSD: usb_add_task.9,v 1.1 2016/09/15 17:53:38 awolk Exp $ +.\" +.\" Copyright (c) 2016 Adam Wolk <awolk@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: September 15 2016 $ +.Dt USB_ADD_TASK 9 +.Os +.Sh NAME +.Nm usb_add_task , +.Nm usb_rem_task , +.Nm usb_wait_task , +.Nm usb_rem_wait_task , +.Nm usb_init_task +.Nd USB task queues +.Sh SYNOPSIS +.In dev/usb/usbdi.h +.Ft void +.Fn usb_add_task "struct usbd_device *dev" "struct usb_task *task" +.Ft void +.Fn usb_rem_task "struct usbd_device *dev" "struct usb_task *task" +.Ft void +.Fn usb_wait_task "struct usbd_device *dev" "struct usb_task *task" +.Ft void +.Fn usb_rem_wait_task "struct usbd_device *dev" "struct usb_task *task" +.Ft void +.Fn usb_init_task "struct usbd_device *dev" "void (*fn)(void *)" "void *arg" "char type" +.Sh DESCRIPTION +The USB stack provides an API to manage task execution in a thread context at +the soonest opportunity. There are three different task queues that are +executed on two separate threads. All tasks executed via the USB task API are +serialized with USB events such as device detachments. +.Pp +The +.Fn usb_add_task +function enqueues a task to be executed by the task thread. +Subsequent calls to +.Fn usb_add_task +will not result in multiple executions being scheduled. +The task structure must already be initialised by +.Fn usb_init_task . +.Pp +The +.Fn usb_rem_task +function removes a scheduled task from its queue. +If the work was already executed or has not been added to the task queue, +the call will have no effect. +Calling +.Fn usb_rem_task +while the task is executing will not abort it. +.Pp +The +.Fn usb_wait_task +function sleeps until the given task is neither queued for execution +nor currently running. +.Pp +The +.Fn usb_rem_wait_task +function is the equivalent of calling +.Fn usb_rem_task +followed by +.Fn usb_wait_task . +.Pp +The +.Fn usb_init_task +macro prepares the task structure +.Fa task +to be used in future calls to +.Fn usb_add_task , +.Fn usb_rem_task , +.Fn usb_wait_task , +and +.Fn usb_rem_wait_task . +.Fa task +will be prepared to call the function +.Fa fn +with the argument specified by +.Fa arg . +The +.Fa type +of the task determines the queue and thread that will be used for its execution: +.Bl -tag -width "USB_TASK_TYPE_EXPLORE" -offset indent +.It Dv USB_TASK_TYPE_GENERIC +Tasks used for general work that needs to happen in a process context. +.It Dv USB_TASK_TYPE_EXPLORE +Device discovery tasks exploring the tree from the root. +.It Dv USB_TASK_TYPE_ABORT +Tasks of this type execute on a dedicated thread +not shared with other USB task types. +.El +.Pp +Most drivers will only define tasks of type +.Dv USB_TASK_TYPE_GENERIC . +Note that +.Dv USB_TASK_TYPE_ABORT +tasks are only used by Host Controller Drivers and should never be used by +drivers. Once initialised, the +.Fa task +can be used repeatedly in the API functions listed above and does not need to be +reinitialised unless the function called and/or its argument must change. +.Sh CONTEXT +.Fn usb_task_add +can be called from any context. +.Sh SEE ALSO +.Xr usb 4 , +.Xr task_add 9 |