13cdbaee3SMitchell Horne.\" Copyright (c) 2001 John H. Baldwin <jhb@FreeBSD.org> 22af741fcSMitchell Horne.\" Copyright (c) 2006 Tom Rhodes <trhodes@FreeBSD.org> 32af741fcSMitchell Horne.\" Copyright (c) 2021 Mitchell Horne <mhorne@FreeBSD.org> 42af741fcSMitchell Horne.\" Copyright (c) 2022 The FreeBSD Foundation 52af741fcSMitchell Horne.\" 62af741fcSMitchell Horne.\" Portions of this documentation were written by Mitchell Horne 72af741fcSMitchell Horne.\" under sponsorship from the FreeBSD Foundation. 83cdbaee3SMitchell Horne.\" 93cdbaee3SMitchell Horne.\" Redistribution and use in source and binary forms, with or without 103cdbaee3SMitchell Horne.\" modification, are permitted provided that the following conditions 113cdbaee3SMitchell Horne.\" are met: 123cdbaee3SMitchell Horne.\" 1. Redistributions of source code must retain the above copyright 133cdbaee3SMitchell Horne.\" notice, this list of conditions and the following disclaimer. 143cdbaee3SMitchell Horne.\" 2. Redistributions in binary form must reproduce the above copyright 153cdbaee3SMitchell Horne.\" notice, this list of conditions and the following disclaimer in the 163cdbaee3SMitchell Horne.\" documentation and/or other materials provided with the distribution. 173cdbaee3SMitchell Horne.\" 183cdbaee3SMitchell Horne.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 193cdbaee3SMitchell Horne.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 203cdbaee3SMitchell Horne.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 213cdbaee3SMitchell Horne.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 223cdbaee3SMitchell Horne.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 233cdbaee3SMitchell Horne.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 243cdbaee3SMitchell Horne.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 253cdbaee3SMitchell Horne.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 263cdbaee3SMitchell Horne.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 273cdbaee3SMitchell Horne.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 283cdbaee3SMitchell Horne.\" SUCH DAMAGE. 293cdbaee3SMitchell Horne.\" 30334fc46fSMitchell Horne.Dd October 30, 2022 313cdbaee3SMitchell Horne.Dt INTR_EVENT 9 323cdbaee3SMitchell Horne.Os 333cdbaee3SMitchell Horne.Sh NAME 343cdbaee3SMitchell Horne.Nm intr_event_add_handler , 353cdbaee3SMitchell Horne.Nm intr_event_create , 363cdbaee3SMitchell Horne.Nm intr_event_destroy , 37a4532c4cSMitchell Horne.Nm intr_event_handle , 383cdbaee3SMitchell Horne.Nm intr_event_remove_handler , 393cdbaee3SMitchell Horne.Nm intr_priority 403cdbaee3SMitchell Horne.Nd "kernel interrupt handler and thread API" 413cdbaee3SMitchell Horne.Sh SYNOPSIS 423cdbaee3SMitchell Horne.In sys/param.h 433cdbaee3SMitchell Horne.In sys/bus.h 443cdbaee3SMitchell Horne.In sys/interrupt.h 453cdbaee3SMitchell Horne.Ft int 463cdbaee3SMitchell Horne.Fo intr_event_add_handler 473cdbaee3SMitchell Horne.Fa "struct intr_event *ie" 483cdbaee3SMitchell Horne.Fa "const char *name" 493cdbaee3SMitchell Horne.Fa "driver_filter_t filter" 503cdbaee3SMitchell Horne.Fa "driver_intr_t handler" 513cdbaee3SMitchell Horne.Fa "void *arg" 523cdbaee3SMitchell Horne.Fa "u_char pri" 533cdbaee3SMitchell Horne.Fa "enum intr_type flags" 543cdbaee3SMitchell Horne.Fa "void **cookiep" 553cdbaee3SMitchell Horne.Fc 563cdbaee3SMitchell Horne.Ft int 573cdbaee3SMitchell Horne.Fo intr_event_create 583cdbaee3SMitchell Horne.Fa "struct intr_event **event" 593cdbaee3SMitchell Horne.Fa "void *source" 603cdbaee3SMitchell Horne.Fa "int flags" 613cdbaee3SMitchell Horne.Fa "int irq" 623cdbaee3SMitchell Horne.Fa "void (*pre_ithread)(void *)" 633cdbaee3SMitchell Horne.Fa "void (*post_ithread)(void *)" 643cdbaee3SMitchell Horne.Fa "void (*post_filter)(void *)" 653cdbaee3SMitchell Horne.Fa "int (*assign_cpu)(void *, int)" 663cdbaee3SMitchell Horne.Fa "const char *fmt" 673cdbaee3SMitchell Horne.Fa "..." 683cdbaee3SMitchell Horne.Fc 693cdbaee3SMitchell Horne.Ft int 703cdbaee3SMitchell Horne.Fn intr_event_destroy "struct intr_event *ie" 713cdbaee3SMitchell Horne.Ft int 72334fc46fSMitchell Horne.Fn intr_event_handle "struct intr_event *ie" "struct trapframe *frame" 73334fc46fSMitchell Horne.Ft int 743cdbaee3SMitchell Horne.Fn intr_event_remove_handler "void *cookie" 753cdbaee3SMitchell Horne.Ft u_char 763cdbaee3SMitchell Horne.Fn intr_priority "enum intr_type flags" 773cdbaee3SMitchell Horne.Sh DESCRIPTION 78dfc91493SMitchell HorneThe interrupt event API provides methods to manage the registration and 79dfc91493SMitchell Horneexecution of interrupt handlers and their associated thread contexts. 803cdbaee3SMitchell Horne.Pp 81dfc91493SMitchell HorneEach interrupt event in the system corresponds to a single hardware or software 82dfc91493SMitchell Horneinterrupt source. 83dfc91493SMitchell HorneEach interrupt event maintains a list of interrupt handlers, sorted by 84dfc91493SMitchell Hornepriority, which will be invoked when handling the event. 85dfc91493SMitchell HorneAn interrupt event will typically, but not always, have an associated 86dfc91493SMitchell Horne.Xr kthread 9 , 87dfc91493SMitchell Horneknown as the interrupt thread. 88dfc91493SMitchell HorneFinally, each event contains optional callback functions which will be 89dfc91493SMitchell Horneinvoked before and after the handler functions themselves. 90dfc91493SMitchell Horne.Pp 91dfc91493SMitchell HorneAn interrupt handler contains two distinct handler functions: 92dfc91493SMitchell Hornethe 93dfc91493SMitchell Horne.Em filter 94dfc91493SMitchell Horneand the thread 95dfc91493SMitchell Horne.Em handler . 96dfc91493SMitchell HorneThe 97dfc91493SMitchell Horne.Em filter 98dfc91493SMitchell Hornefunction is run from interrupt context and is intended to perform quick 99dfc91493SMitchell Hornehandling such as acknowledging or masking a hardware interrupt, 100dfc91493SMitchell Horneand queueing work for the ensuing thread 101dfc91493SMitchell Horne.Em handler . 102dfc91493SMitchell HorneBoth functions are optional; each interrupt handler may choose to register a 103dfc91493SMitchell Hornefilter, a thread handler, or both. 104dfc91493SMitchell HorneEach interrupt handler also consists of a name, 105dfc91493SMitchell Hornea set of flags, 106dfc91493SMitchell Horneand an opaque argument which will be passed to both the 107dfc91493SMitchell Horne.Em filter 108dfc91493SMitchell Horneand 109dfc91493SMitchell Horne.Em handler 110dfc91493SMitchell Hornefunctions. 111dfc91493SMitchell Horne.Ss Handler Constraints 112dfc91493SMitchell HorneThe 113dfc91493SMitchell Horne.Em filter 114dfc91493SMitchell Hornefunction is executed inside a 115dfc91493SMitchell Horne.Xr critical 9 116dfc91493SMitchell Hornesection. 117dfc91493SMitchell HorneTherefore, filters may not yield the CPU for any reason, and may only use spin 118dfc91493SMitchell Hornelocks to access shared data. 119dfc91493SMitchell HorneAllocating memory within a filter is not permitted. 120dfc91493SMitchell Horne.Pp 121dfc91493SMitchell HorneThe 122dfc91493SMitchell Horne.Em handler 123dfc91493SMitchell Hornefunction executes from the context of the associated interrupt kernel thread. 124dfc91493SMitchell HorneSleeping is not permitted, but the interrupt thread may be preempted by higher 125dfc91493SMitchell Hornepriority threads. 126dfc91493SMitchell HorneThus, threaded handler functions may obtain non-sleepable locks, as described 127dfc91493SMitchell Hornein 128dfc91493SMitchell Horne.Xr locking 9 . 129dfc91493SMitchell HorneAny memory or zone allocations in an interrupt thread must specify the 130dfc91493SMitchell Horne.Dv M_NOWAIT 131dfc91493SMitchell Horneflag, and any allocation errors must be handled. 132dfc91493SMitchell Horne.Pp 133dfc91493SMitchell HorneThe exception to these constraints is software interrupt threads, which are 134dfc91493SMitchell Horneallowed to sleep but should be allocated and scheduled using the 135dfc91493SMitchell Horne.Xr swi 9 136dfc91493SMitchell Horneinterface. 137dfc91493SMitchell Horne.Ss Function Descriptions 1383cdbaee3SMitchell HorneThe 1393cdbaee3SMitchell Horne.Fn intr_event_create 140cb9425e2SMitchell Hornefunction creates a new interrupt event. 141cb9425e2SMitchell HorneThe 142cb9425e2SMitchell Horne.Fa event 143cb9425e2SMitchell Horneargument points to a 144cb9425e2SMitchell Horne.Vt struct intr_event 145cb9425e2SMitchell Hornepointer that will reference the newly created event upon success. 1463cdbaee3SMitchell HorneThe 1473cdbaee3SMitchell Horne.Fa source 148cb9425e2SMitchell Horneargument is an opaque pointer which will be passed to the 149cb9425e2SMitchell Horne.Fa pre_ithread , 150cb9425e2SMitchell Horne.Fa post_ithread , 151cb9425e2SMitchell Horneand 152cb9425e2SMitchell Horne.Fa post_filter 153cb9425e2SMitchell Hornecallbacks. 1543cdbaee3SMitchell HorneThe 1553cdbaee3SMitchell Horne.Fa flags 1563cdbaee3SMitchell Horneargument is a mask of properties of this thread. 1573cdbaee3SMitchell HorneThe only valid flag currently for 1583cdbaee3SMitchell Horne.Fn intr_event_create 1593cdbaee3SMitchell Horneis 1603cdbaee3SMitchell Horne.Dv IE_SOFT 1613cdbaee3SMitchell Horneto specify that this interrupt thread is a software interrupt. 1623cdbaee3SMitchell HorneThe 1633cdbaee3SMitchell Horne.Fa enable 1643cdbaee3SMitchell Horneand 1653cdbaee3SMitchell Horne.Fa disable 1663cdbaee3SMitchell Hornearguments specify optional functions used to enable and disable this 1673cdbaee3SMitchell Horneinterrupt thread's interrupt source. 168cb9425e2SMitchell HorneThe 169cb9425e2SMitchell Horne.Fa irq 170cb9425e2SMitchell Horneargument is the unique interrupt vector number corresponding to the event. 171cb9425e2SMitchell HorneThe 172cb9425e2SMitchell Horne.Fa pre_ithread , 173cb9425e2SMitchell Horne.Fa post_ithread , 174cb9425e2SMitchell Horneand 175cb9425e2SMitchell Horne.Fa post_filter 176cb9425e2SMitchell Hornearguments are callback functions that are invoked at different 177cb9425e2SMitchell Hornepoints while handling an interrupt. 178cb9425e2SMitchell HorneThis is described in more detail in the 179cb9425e2SMitchell Horne.Sx Handler Callbacks 180cb9425e2SMitchell Hornesection, below. 181cb9425e2SMitchell HorneThey may be 182cb9425e2SMitchell Horne.Va NULL 183cb9425e2SMitchell Horneto specify no callback. 184cb9425e2SMitchell HorneThe 185cb9425e2SMitchell Horne.Fa assign_cpu 186cb9425e2SMitchell Horneargument points to a callback function that will be invoked when binding 187cb9425e2SMitchell Hornean interrupt to a particular CPU. 188cb9425e2SMitchell HorneIt may be 189cb9425e2SMitchell Horne.Va NULL 190cb9425e2SMitchell Horneif binding is unsupported. 191cb9425e2SMitchell HorneThe 192cb9425e2SMitchell Horneremaining arguments form a 1933cdbaee3SMitchell Horne.Xr printf 9 1943cdbaee3SMitchell Horneargument list that is used to build the base name of the new interrupt thread. 1953cdbaee3SMitchell HorneThe full name of an interrupt thread is formed by concatenating the base 1963cdbaee3SMitchell Hornename of the interrupt thread with the names of all of its interrupt handlers. 1973cdbaee3SMitchell Horne.Pp 1983cdbaee3SMitchell HorneThe 1993cdbaee3SMitchell Horne.Fn intr_event_destroy 200cb9425e2SMitchell Hornefunction destroys a previously created interrupt event by releasing its 201cb9425e2SMitchell Horneresources. 202cb9425e2SMitchell Horne.\" The following is not true (yet): 203cb9425e2SMitchell Horne.\"and arranging for the backing kernel thread to terminate. 204cb9425e2SMitchell HorneAn interrupt event can only be destroyed if it has no handlers remaining. 2053cdbaee3SMitchell Horne.Pp 2063cdbaee3SMitchell HorneThe 2073cdbaee3SMitchell Horne.Fn intr_event_add_handler 208cb9425e2SMitchell Hornefunction adds a new handler to an existing interrupt event specified by 209cb9425e2SMitchell Horne.Fa ie . 2103cdbaee3SMitchell HorneThe 2113cdbaee3SMitchell Horne.Fa name 2123cdbaee3SMitchell Horneargument specifies a name for this handler. 2133cdbaee3SMitchell HorneThe 214cb9425e2SMitchell Horne.Fa filter 215cb9425e2SMitchell Horneargument provide the filter function to execute. 216cb9425e2SMitchell HorneThe 2173cdbaee3SMitchell Horne.Fa handler 218cb9425e2SMitchell Horneargument provides the handler function to be executed from the 219cb9425e2SMitchell Horneevent's interrupt thread. 220cb9425e2SMitchell HorneThe 2213cdbaee3SMitchell Horne.Fa arg 222cb9425e2SMitchell Horneargument will be passed to the 223cb9425e2SMitchell Horne.Fa filter 224cb9425e2SMitchell Horneand 225cb9425e2SMitchell Horne.Fa handler 226cb9425e2SMitchell Hornefunctions when they are invoked. 2273cdbaee3SMitchell HorneThe 2283cdbaee3SMitchell Horne.Fa pri 229cb9425e2SMitchell Horneargument specifies the priority of this handler, 230cb9425e2SMitchell Hornecorresponding to the values defined in 231cb9425e2SMitchell Horne.In sys/priority.h . 232cb9425e2SMitchell HorneIt determines the order this handler is called relative to the other handlers 233*2c346617SGordon Berglingfor this event, as well as the scheduling priority of the backing kernel 234cb9425e2SMitchell Hornethread. 2353cdbaee3SMitchell Horne.Fa flags 2363cdbaee3SMitchell Horneargument can be used to specify properties of this handler as defined in 2373cdbaee3SMitchell Horne.In sys/bus.h . 2383cdbaee3SMitchell HorneIf 2393cdbaee3SMitchell Horne.Fa cookiep 2403cdbaee3SMitchell Horneis not 2413cdbaee3SMitchell Horne.Dv NULL , 2423cdbaee3SMitchell Hornethen it will be assigned a cookie that can be used later to remove this 2433cdbaee3SMitchell Hornehandler. 2443cdbaee3SMitchell Horne.Pp 2453cdbaee3SMitchell HorneThe 246334fc46fSMitchell Horne.Fn intr_event_handle 247334fc46fSMitchell Hornefunction is the main entry point into the interrupt handling code. 248334fc46fSMitchell HorneIt must be called from an interrupt context. 249334fc46fSMitchell HorneThe function will execute all filter handlers associated with the interrupt 250334fc46fSMitchell Horneevent 251334fc46fSMitchell Horne.Fa ie , 252334fc46fSMitchell Horneand schedule the associated interrupt thread to run, if applicable. 253334fc46fSMitchell HorneThe 254334fc46fSMitchell Horne.Fa frame 255334fc46fSMitchell Horneargument is used to pass a pointer to the 256334fc46fSMitchell Horne.Vt struct trapframe 257334fc46fSMitchell Hornecontaining the machine state at the time of the interrupt. 258334fc46fSMitchell HorneThe main body of this function runs within a 259334fc46fSMitchell Horne.Xr critical 9 260334fc46fSMitchell Hornesection. 261334fc46fSMitchell Horne.Pp 262334fc46fSMitchell HorneThe 2633cdbaee3SMitchell Horne.Fn intr_event_remove_handler 264cb9425e2SMitchell Hornefunction removes an interrupt handler from the interrupt event specified by 265cb9425e2SMitchell Horne.Fa ie . 2663cdbaee3SMitchell HorneThe 2673cdbaee3SMitchell Horne.Fa cookie 268cb9425e2SMitchell Horneargument, obtained from 269cb9425e2SMitchell Horne.Fn intr_event_add_handler , 270cb9425e2SMitchell Horneidentifies the handler to remove. 2713cdbaee3SMitchell Horne.Pp 2723cdbaee3SMitchell HorneThe 2733cdbaee3SMitchell Horne.Fn intr_priority 2743cdbaee3SMitchell Hornefunction translates the 2753cdbaee3SMitchell Horne.Dv INTR_TYPE_* 2763cdbaee3SMitchell Horneinterrupt flags into interrupt thread scheduling priorities. 2773cdbaee3SMitchell Horne.Pp 2783cdbaee3SMitchell HorneThe interrupt flags not related to the type of a particular interrupt 2793cdbaee3SMitchell Horne.Pq Dv INTR_TYPE_* 2803cdbaee3SMitchell Hornecan be used to specify additional properties of both hardware and software 2813cdbaee3SMitchell Horneinterrupt handlers. 2823cdbaee3SMitchell HorneThe 2833cdbaee3SMitchell Horne.Dv INTR_EXCL 2843cdbaee3SMitchell Horneflag specifies that this handler cannot share an interrupt thread with 2853cdbaee3SMitchell Horneanother handler. 2863cdbaee3SMitchell HorneThe 2873cdbaee3SMitchell Horne.Dv INTR_MPSAFE 2883cdbaee3SMitchell Horneflag specifies that this handler is MP safe in that it does not need the 2893cdbaee3SMitchell HorneGiant mutex to be held while it is executed. 2903cdbaee3SMitchell HorneThe 2913cdbaee3SMitchell Horne.Dv INTR_ENTROPY 2923cdbaee3SMitchell Horneflag specifies that the interrupt source this handler is tied to is a good 2933cdbaee3SMitchell Hornesource of entropy, and thus that entropy should be gathered when an interrupt 2943cdbaee3SMitchell Hornefrom the handler's source triggers. 2953cdbaee3SMitchell HornePresently, the 2963cdbaee3SMitchell Horne.Dv INTR_ENTROPY 2973cdbaee3SMitchell Horneflag is not valid for software interrupt handlers. 298cb9425e2SMitchell Horne.Ss Handler Callbacks 299cb9425e2SMitchell HorneEach 300cb9425e2SMitchell Horne.Vt struct intr_event 301cb9425e2SMitchell Horneis assigned three optional callback functions when it is created: 302cb9425e2SMitchell Horne.Fa pre_ithread , 303cb9425e2SMitchell Horne.Fa post_ithread , 304cb9425e2SMitchell Horneand 305cb9425e2SMitchell Horne.Fa post_filter . 306cb9425e2SMitchell HorneThese callbacks are intended to be defined by the interrupt controller driver, 307cb9425e2SMitchell Horneto allow for actions such as masking and unmasking hardware interrupt signals. 308cb9425e2SMitchell Horne.Pp 309cb9425e2SMitchell HorneWhen an interrupt is triggered, all filters are run to determine if any 310cb9425e2SMitchell Hornethreaded interrupt handlers should be scheduled for execution by the associated 311cb9425e2SMitchell Horneinterrupt thread. If no threaded handlers are scheduled, the 312cb9425e2SMitchell Horne.Fa post_filter 313cb9425e2SMitchell Hornecallback is invoked which should acknowledge the interrupt and permit it to 314cb9425e2SMitchell Hornetrigger in the future. 315cb9425e2SMitchell HorneIf any threaded handlers are scheduled, the 316cb9425e2SMitchell Horne.Fa pre_ithread 317cb9425e2SMitchell Hornecallback is invoked instead. 318cb9425e2SMitchell HorneThis handler should acknowledge the interrupt, but it should also ensure that 319cb9425e2SMitchell Hornethe interrupt will not fire continuously until after the threaded handlers have 320cb9425e2SMitchell Horneexecuted. 321cb9425e2SMitchell HorneTypically this callback masks level-triggered interrupts in an interrupt 322cb9425e2SMitchell Hornecontroller while leaving edge-triggered interrupts alone. 323cb9425e2SMitchell HorneOnce all threaded handlers have executed, 324cb9425e2SMitchell Hornethe 325cb9425e2SMitchell Horne.Fa post_ithread 326cb9425e2SMitchell Hornecallback is invoked from the interrupt thread to enable future interrupts. 327cb9425e2SMitchell HorneTypically this callback unmasks level-triggered interrupts in an interrupt 328cb9425e2SMitchell Hornecontroller. 3293cdbaee3SMitchell Horne.Sh RETURN VALUES 3303cdbaee3SMitchell HorneThe 3313cdbaee3SMitchell Horne.Fn intr_event_add_handler , 3323cdbaee3SMitchell Horne.Fn intr_event_create , 3333cdbaee3SMitchell Horne.Fn intr_event_destroy , 334334fc46fSMitchell Horne.Fn intr_event_handle , 3353cdbaee3SMitchell Horneand 3363cdbaee3SMitchell Horne.Fn intr_event_remove_handler 3373cdbaee3SMitchell Hornefunctions return zero on success and non-zero on failure. 3383cdbaee3SMitchell HorneThe 3393cdbaee3SMitchell Horne.Fn intr_priority 3403cdbaee3SMitchell Hornefunction returns a process priority corresponding to the passed in interrupt 3413cdbaee3SMitchell Horneflags. 3423cdbaee3SMitchell Horne.Sh EXAMPLES 3433cdbaee3SMitchell HorneThe 3440cec1648SMitchell Horne.Xr swi_add 9 3453cdbaee3SMitchell Hornefunction demonstrates the use of 3463cdbaee3SMitchell Horne.Fn intr_event_create 3473cdbaee3SMitchell Horneand 3483cdbaee3SMitchell Horne.Fn intr_event_add_handler . 3493cdbaee3SMitchell Horne.Bd -literal -offset indent 3503cdbaee3SMitchell Horneint 3510cec1648SMitchell Horneswi_add(struct intr_event **eventp, const char *name, driver_intr_t handler, 3523cdbaee3SMitchell Horne void *arg, int pri, enum intr_type flags, void **cookiep) 3533cdbaee3SMitchell Horne{ 3540cec1648SMitchell Horne struct intr_event *ie; 3550cec1648SMitchell Horne int error = 0; 3563cdbaee3SMitchell Horne 3573cdbaee3SMitchell Horne if (flags & INTR_ENTROPY) 3583cdbaee3SMitchell Horne return (EINVAL); 3593cdbaee3SMitchell Horne 3600cec1648SMitchell Horne ie = (eventp != NULL) ? *eventp : NULL; 3613cdbaee3SMitchell Horne 3620cec1648SMitchell Horne if (ie != NULL) { 3630cec1648SMitchell Horne if (!(ie->ie_flags & IE_SOFT)) 3643cdbaee3SMitchell Horne return (EINVAL); 3653cdbaee3SMitchell Horne } else { 3660cec1648SMitchell Horne error = intr_event_create(&ie, NULL, IE_SOFT, 0, 3670cec1648SMitchell Horne NULL, NULL, NULL, swi_assign_cpu, "swi%d:", pri); 3683cdbaee3SMitchell Horne if (error) 3693cdbaee3SMitchell Horne return (error); 3700cec1648SMitchell Horne if (eventp != NULL) 3710cec1648SMitchell Horne *eventp = ie; 3723cdbaee3SMitchell Horne } 3730cec1648SMitchell Horne if (handler != NULL) { 3740cec1648SMitchell Horne error = intr_event_add_handler(ie, name, NULL, handler, arg, 3750cec1648SMitchell Horne PI_SWI(pri), flags, cookiep); 3760cec1648SMitchell Horne } 3770cec1648SMitchell Horne return (error); 3783cdbaee3SMitchell Horne} 3793cdbaee3SMitchell Horne.Ed 3803cdbaee3SMitchell Horne.Sh ERRORS 3813cdbaee3SMitchell HorneThe 3823cdbaee3SMitchell Horne.Fn intr_event_add_handler 3833cdbaee3SMitchell Hornefunction will fail if: 3843cdbaee3SMitchell Horne.Bl -tag -width Er 3853cdbaee3SMitchell Horne.It Bq Er EINVAL 3863cdbaee3SMitchell HorneThe 3873cdbaee3SMitchell Horne.Fa ie 3883cdbaee3SMitchell Horneor 3893cdbaee3SMitchell Horne.Fa name 3903cdbaee3SMitchell Hornearguments are 3913cdbaee3SMitchell Horne.Dv NULL . 3923cdbaee3SMitchell Horne.It Bq Er EINVAL 3933cdbaee3SMitchell HorneThe 3943cdbaee3SMitchell Horne.Fa handler 3953cdbaee3SMitchell Horneand 3963cdbaee3SMitchell Horne.Fa filter 3973cdbaee3SMitchell Hornearguments are both 3983cdbaee3SMitchell Horne.Dv NULL . 3993cdbaee3SMitchell Horne.It Bq Er EINVAL 4003cdbaee3SMitchell HorneThe 4013cdbaee3SMitchell Horne.Dv IH_EXCLUSIVE 4023cdbaee3SMitchell Horneflag is specified and the interrupt thread 4033cdbaee3SMitchell Horne.Fa ie 4043cdbaee3SMitchell Hornealready has at least one handler, or the interrupt thread 4053cdbaee3SMitchell Horne.Fa ie 4063cdbaee3SMitchell Hornealready has an exclusive handler. 4073cdbaee3SMitchell Horne.El 4083cdbaee3SMitchell Horne.Pp 4093cdbaee3SMitchell HorneThe 4103cdbaee3SMitchell Horne.Fn intr_event_create 4113cdbaee3SMitchell Hornefunction will fail if: 4123cdbaee3SMitchell Horne.Bl -tag -width Er 4133cdbaee3SMitchell Horne.It Bq Er EINVAL 4143cdbaee3SMitchell HorneA flag other than 4153cdbaee3SMitchell Horne.Dv IE_SOFT 4163cdbaee3SMitchell Hornewas specified in the 4173cdbaee3SMitchell Horne.Fa flags 4183cdbaee3SMitchell Horneparameter. 4193cdbaee3SMitchell Horne.El 4203cdbaee3SMitchell Horne.Pp 4213cdbaee3SMitchell HorneThe 4223cdbaee3SMitchell Horne.Fn intr_event_destroy 4233cdbaee3SMitchell Hornefunction will fail if: 4243cdbaee3SMitchell Horne.Bl -tag -width Er 4253cdbaee3SMitchell Horne.It Bq Er EINVAL 4263cdbaee3SMitchell HorneThe 4273cdbaee3SMitchell Horne.Fa ie 4283cdbaee3SMitchell Horneargument is 4293cdbaee3SMitchell Horne.Dv NULL . 4303cdbaee3SMitchell Horne.It Bq Er EBUSY 4313cdbaee3SMitchell HorneThe interrupt event pointed to by 4323cdbaee3SMitchell Horne.Fa ie 4333cdbaee3SMitchell Hornehas at least one handler which has not been removed with 4343cdbaee3SMitchell Horne.Fn intr_event_remove_handler . 4353cdbaee3SMitchell Horne.El 4363cdbaee3SMitchell Horne.Pp 4373cdbaee3SMitchell HorneThe 438334fc46fSMitchell Horne.Fn intr_event_handle 439334fc46fSMitchell Hornefunction will fail if: 440334fc46fSMitchell Horne.Bl -tag -width Er 441334fc46fSMitchell Horne.It Bq Er EINVAL 442334fc46fSMitchell HorneThe 443334fc46fSMitchell Horne.Fa ie 444334fc46fSMitchell Horneargument is 445334fc46fSMitchell Horne.Dv NULL . 446334fc46fSMitchell Horne.It Bq Er EINVAL 447334fc46fSMitchell HorneThere are no interrupt handlers assigned to 448334fc46fSMitchell Horne.Fa ie . 449334fc46fSMitchell Horne.It Bq Er EINVAL 450334fc46fSMitchell HorneThe interrupt was not acknowledged by any filter and has no associated thread 451334fc46fSMitchell Hornehandler. 452334fc46fSMitchell Horne.El 453334fc46fSMitchell Horne.Pp 454334fc46fSMitchell HorneThe 4553cdbaee3SMitchell Horne.Fn intr_event_remove_handler 4563cdbaee3SMitchell Hornefunction will fail if: 4573cdbaee3SMitchell Horne.Bl -tag -width Er 4583cdbaee3SMitchell Horne.It Bq Er EINVAL 4593cdbaee3SMitchell HorneThe 4603cdbaee3SMitchell Horne.Fa cookie 4613cdbaee3SMitchell Horneargument is 4623cdbaee3SMitchell Horne.Dv NULL . 4633cdbaee3SMitchell Horne.El 4643cdbaee3SMitchell Horne.Sh SEE ALSO 465334fc46fSMitchell Horne.Xr critical 9 , 4663cdbaee3SMitchell Horne.Xr kthread 9 , 467dfc91493SMitchell Horne.Xr locking 9 , 4683cdbaee3SMitchell Horne.Xr malloc 9 , 4693cdbaee3SMitchell Horne.Xr swi 9 , 4703cdbaee3SMitchell Horne.Xr uma 9 4713cdbaee3SMitchell Horne.Sh HISTORY 4723cdbaee3SMitchell HorneInterrupt threads and their corresponding API first appeared in 4733cdbaee3SMitchell Horne.Fx 5.0 . 474