2001-03-05 23:47:34 +00:00
|
|
|
.\" Copyright (c) 2000-2001 John H. Baldwin <jhb@FreeBSD.org>
|
2000-11-13 20:18:42 +00:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2012-04-19 15:29:09 +00:00
|
|
|
.Dd April 19, 2012
|
2000-11-13 20:18:42 +00:00
|
|
|
.Dt SWI 9
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
2001-03-05 23:47:34 +00:00
|
|
|
.Nm swi_add ,
|
2012-04-19 15:29:09 +00:00
|
|
|
.Nm swi_remove ,
|
2001-03-05 23:47:34 +00:00
|
|
|
.Nm swi_sched
|
2000-11-13 20:18:42 +00:00
|
|
|
.Nd register and schedule software interrupt handlers
|
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/param.h
|
|
|
|
.In sys/bus.h
|
|
|
|
.In sys/interrupt.h
|
2012-04-19 16:13:15 +00:00
|
|
|
.Vt "extern struct intr_event *tty_intr_event" ;
|
|
|
|
.Vt "extern struct intr_event *clk_intr_event" ;
|
2004-07-07 07:56:36 +00:00
|
|
|
.Vt "extern void *vm_ih" ;
|
2001-03-05 23:47:34 +00:00
|
|
|
.Ft int
|
|
|
|
.Fo swi_add
|
2012-04-12 16:02:45 +00:00
|
|
|
.Fa "struct intr_event **eventp"
|
2000-11-13 20:18:42 +00:00
|
|
|
.Fa "const char *name"
|
|
|
|
.Fa "driver_intr_t handler"
|
|
|
|
.Fa "void *arg"
|
|
|
|
.Fa "int pri"
|
2001-03-05 23:47:34 +00:00
|
|
|
.Fa "enum intr_type flags"
|
|
|
|
.Fa "void **cookiep"
|
2000-11-13 20:18:42 +00:00
|
|
|
.Fc
|
2012-04-19 15:29:09 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn swi_remove "void *cookie"
|
2001-03-05 23:47:34 +00:00
|
|
|
.Ft void
|
2004-12-29 04:29:06 +00:00
|
|
|
.Fn swi_sched "void *cookie" "int flags"
|
2000-11-13 20:18:42 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
These functions are used to register and schedule software interrupt handlers.
|
|
|
|
Software interrupt handlers are attached to a software interrupt thread, just
|
|
|
|
as hardware interrupt handlers are attached to a hardware interrupt thread.
|
2001-03-05 23:47:34 +00:00
|
|
|
Multiple handlers can be attached to the same thread.
|
2000-11-13 20:18:42 +00:00
|
|
|
Software interrupt handlers can be used to queue up less critical processing
|
|
|
|
inside of hardware interrupt handlers so that the work can be done at a later
|
|
|
|
time.
|
|
|
|
Software interrupt threads are different from other kernel threads in that they
|
|
|
|
are treated as an interrupt thread.
|
|
|
|
This means that time spent executing these threads is counted as interrupt
|
2001-03-05 23:47:34 +00:00
|
|
|
time, and that they can be run via a lightweight context switch.
|
2000-11-13 20:18:42 +00:00
|
|
|
.Pp
|
|
|
|
The
|
2001-03-05 23:47:34 +00:00
|
|
|
.Fn swi_add
|
2012-04-12 16:02:45 +00:00
|
|
|
function is used to add a new software interrupt handler to a specified
|
|
|
|
interrupt event.
|
2000-11-13 20:18:42 +00:00
|
|
|
The
|
2012-04-12 16:02:45 +00:00
|
|
|
.Fa eventp
|
2000-11-13 20:18:42 +00:00
|
|
|
argument is an optional pointer to a
|
2012-04-12 16:02:45 +00:00
|
|
|
.Vt struct intr_event
|
2000-11-13 20:18:42 +00:00
|
|
|
pointer.
|
2012-04-12 16:02:45 +00:00
|
|
|
If this argument points to an existing event that holds a list of
|
|
|
|
interrupt handlers, then this handler will be attached to that event.
|
|
|
|
Otherwise a new event will be created, and if
|
|
|
|
.Fa eventp
|
2000-11-13 20:18:42 +00:00
|
|
|
is not
|
|
|
|
.Dv NULL ,
|
|
|
|
then the pointer at that address to will be modified to point to the
|
2012-04-12 16:02:45 +00:00
|
|
|
newly created event.
|
2000-11-13 20:18:42 +00:00
|
|
|
The
|
2001-03-05 23:47:34 +00:00
|
|
|
.Fa name
|
|
|
|
argument is used to associate a name with a specific handler.
|
|
|
|
This name is appended to the name of the software interrupt thread that this
|
|
|
|
handler is attached to.
|
|
|
|
The
|
2000-11-13 20:18:42 +00:00
|
|
|
.Fa handler
|
2001-03-05 23:47:34 +00:00
|
|
|
argument is the function that will be executed when the handler is scheduled
|
|
|
|
to run.
|
2000-11-13 20:18:42 +00:00
|
|
|
The
|
|
|
|
.Fa arg
|
|
|
|
parameter will be passed in as the only parameter to
|
|
|
|
.Fa handler
|
|
|
|
when the function is executed.
|
|
|
|
The
|
|
|
|
.Fa pri
|
2001-03-05 23:47:34 +00:00
|
|
|
value specifies the priority of this interrupt handler relative to other
|
|
|
|
software interrupt handlers.
|
2012-04-12 16:02:45 +00:00
|
|
|
If an interrupt event is created, then this value is used as the vector,
|
2000-11-13 20:18:42 +00:00
|
|
|
and the
|
|
|
|
.Fa flags
|
|
|
|
argument is used to specify the attributes of a handler such as
|
|
|
|
.Dv INTR_MPSAFE .
|
2001-03-05 23:47:34 +00:00
|
|
|
The
|
2004-12-29 04:29:06 +00:00
|
|
|
.Fa cookiep
|
2001-03-05 23:47:34 +00:00
|
|
|
argument points to a
|
2001-03-06 08:22:10 +00:00
|
|
|
.Vt void *
|
2001-03-05 23:47:34 +00:00
|
|
|
cookie.
|
|
|
|
This cookie will be set to a value that uniquely identifies this handler,
|
|
|
|
and is used to schedule the handler for execution later on.
|
2000-11-13 20:18:42 +00:00
|
|
|
.Pp
|
|
|
|
The
|
2012-04-19 15:29:09 +00:00
|
|
|
.Fn swi_remove
|
|
|
|
function is used to teardown an interrupt handler pointed to by the
|
|
|
|
.Fa cookie
|
|
|
|
argument.
|
|
|
|
It detaches the interrupt handler from the associated interrupt event
|
|
|
|
and frees its memory.
|
|
|
|
.Pp
|
|
|
|
The
|
2001-03-05 23:47:34 +00:00
|
|
|
.Fn swi_sched
|
2000-11-13 20:18:42 +00:00
|
|
|
function is used to schedule an interrupt handler and its associated thread to
|
|
|
|
run.
|
|
|
|
The
|
2001-03-05 23:47:34 +00:00
|
|
|
.Fa cookie
|
2000-11-13 20:18:42 +00:00
|
|
|
argument specifies which software interrupt handler should be scheduled to run.
|
|
|
|
The
|
|
|
|
.Fa flags
|
|
|
|
argument specifies how and when the handler should be run and is a mask of one
|
|
|
|
or more of the following flags:
|
2002-10-11 19:45:19 +00:00
|
|
|
.Bl -tag -width SWI_DELAY
|
2000-11-13 20:18:42 +00:00
|
|
|
.It Dv SWI_DELAY
|
|
|
|
Specifies that the kernel should mark the specified handler as needing to run,
|
|
|
|
but the kernel should not schedule the software interrupt thread to run.
|
|
|
|
Instead,
|
|
|
|
.Fa handler
|
|
|
|
will be executed the next time that the software interrupt thread runs after
|
|
|
|
being scheduled by another event.
|
|
|
|
Attaching a handler to the clock software interrupt thread and using this flag
|
|
|
|
when scheduling a software interrupt handler can be used to implement the
|
2002-10-11 19:45:19 +00:00
|
|
|
functionality performed by
|
|
|
|
.Fn setdelayed
|
|
|
|
in earlier versions of
|
2002-11-29 11:39:20 +00:00
|
|
|
.Fx .
|
2000-11-13 20:18:42 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The
|
2012-04-19 16:13:15 +00:00
|
|
|
.Va tty_intr_event
|
2000-11-13 20:18:42 +00:00
|
|
|
and
|
2012-04-19 16:13:15 +00:00
|
|
|
.Va clk_intr_event
|
|
|
|
variables contain pointers to the software interrupt handlers for the tty and
|
2000-11-13 20:18:42 +00:00
|
|
|
clock software interrupts, respectively.
|
2012-04-19 16:13:15 +00:00
|
|
|
.Va tty_intr_event
|
2000-11-13 20:18:42 +00:00
|
|
|
is used to hang tty software interrupt handlers off of the same thread.
|
2012-04-19 16:13:15 +00:00
|
|
|
.Va clk_intr_event
|
2000-11-13 20:18:42 +00:00
|
|
|
is used to hang delayed handlers off of the clock software interrupt thread so
|
|
|
|
that the functionality of
|
|
|
|
.Fn setdelayed
|
2002-03-16 18:10:40 +00:00
|
|
|
can be obtained in conjunction with
|
2000-11-13 20:18:42 +00:00
|
|
|
.Dv SWI_DELAY .
|
|
|
|
The
|
|
|
|
.Va vm_ih
|
2012-04-19 16:13:15 +00:00
|
|
|
handler cookie is used to schedule software interrupt threads to run for the
|
|
|
|
VM subsystem.
|
2000-11-13 20:18:42 +00:00
|
|
|
.Sh RETURN VALUES
|
|
|
|
The
|
2001-03-05 23:47:34 +00:00
|
|
|
.Fn swi_add
|
2012-04-19 15:29:09 +00:00
|
|
|
and
|
|
|
|
.Fn swi_remove
|
|
|
|
functions return zero on success and non-zero on failure.
|
2001-03-05 23:47:34 +00:00
|
|
|
.Sh ERRORS
|
|
|
|
The
|
|
|
|
.Fn swi_add
|
|
|
|
function will fail if:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EAGAIN
|
|
|
|
The system-imposed limit on the total
|
|
|
|
number of processes under execution would be exceeded.
|
|
|
|
The limit is given by the
|
|
|
|
.Xr sysctl 3
|
|
|
|
MIB variable
|
|
|
|
.Dv KERN_MAXPROC .
|
|
|
|
.It Bq Er EINVAL
|
|
|
|
The
|
|
|
|
.Fa flags
|
2011-01-06 21:14:34 +00:00
|
|
|
argument specifies
|
|
|
|
.Dv INTR_ENTROPY .
|
2001-03-05 23:47:34 +00:00
|
|
|
.It Bq Er EINVAL
|
|
|
|
The
|
2012-04-12 16:02:45 +00:00
|
|
|
.Fa eventp
|
2001-03-05 23:47:34 +00:00
|
|
|
argument points to a hardware interrupt thread.
|
|
|
|
.It Bq Er EINVAL
|
|
|
|
Either of the
|
|
|
|
.Fa name
|
|
|
|
or
|
|
|
|
.Fa handler
|
|
|
|
arguments are
|
|
|
|
.Dv NULL .
|
|
|
|
.It Bq Er EINVAL
|
|
|
|
The
|
|
|
|
.Dv INTR_EXCL
|
2012-04-12 16:02:45 +00:00
|
|
|
flag is specified and the interrupt event pointed to by
|
|
|
|
.Fa eventp
|
|
|
|
already has at least one handler, or the interrupt event already has an
|
2001-03-05 23:47:34 +00:00
|
|
|
exclusive handler.
|
|
|
|
.El
|
2012-04-19 15:29:09 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn swi_remove
|
|
|
|
function will fail if:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EINVAL
|
|
|
|
A software interrupt handler pointed to by
|
|
|
|
.Fa cookie
|
|
|
|
is
|
|
|
|
.Dv NULL .
|
|
|
|
.El
|
2000-11-13 20:18:42 +00:00
|
|
|
.Sh SEE ALSO
|
2001-03-05 23:47:34 +00:00
|
|
|
.Xr ithread 9 ,
|
2000-11-13 20:18:42 +00:00
|
|
|
.Xr taskqueue 9
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
2001-03-05 23:47:34 +00:00
|
|
|
.Fn swi_add
|
|
|
|
and
|
|
|
|
.Fn swi_sched
|
2000-11-13 20:18:42 +00:00
|
|
|
functions first appeared in
|
|
|
|
.Fx 5.0 .
|
2001-03-05 23:47:34 +00:00
|
|
|
They replaced the
|
|
|
|
.Fn register_swi
|
|
|
|
function which appeared in
|
|
|
|
.Fx 3.0
|
|
|
|
and the
|
|
|
|
.Fn setsoft* ,
|
|
|
|
and
|
|
|
|
.Fn schedsoft*
|
|
|
|
functions which date back to at least
|
|
|
|
.Bx 4.4 .
|
2012-04-19 15:29:09 +00:00
|
|
|
The
|
|
|
|
.Fn swi_remove
|
|
|
|
function first appeared in
|
|
|
|
.Fx 6.1 .
|
2000-11-13 20:18:42 +00:00
|
|
|
.Sh BUGS
|
|
|
|
Most of the global variables described in this manual page should not be
|
|
|
|
global, or at the very least should not be declared in
|
2003-09-08 19:57:22 +00:00
|
|
|
.In sys/interrupt.h .
|