2 .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH DDI_INTR_ADD_HANDLER 9F "Apr 22, 2005"
8 ddi_intr_add_handler, ddi_intr_remove_handler \- add or remove interrupt
13 #include <sys/types.h>
16 #include <sys/sunddi.h>
20 \fBint\fR \fBddi_intr_add_handler\fR(\fBddi_intr_handle_t *\fR\fIh\fR,
21 \fBddi_intr_handler_t\fR \fIinthandler\fR, \fBvoid *\fR\fIarg1\fR,
22 \fBvoid *\fR\fIarg2\fR);
27 \fBint\fR \fBddi_intr_remove_handler\fR(\fBddi_intr_handle_t\fR \fIh\fR);
33 Solaris DDI specific (Solaris DDI).
37 \fBddi_intr_add_handler()\fR
44 Pointer to the DDI interrupt handle
50 \fB\fIinthandler\fR\fR
53 Pointer to interrupt handler
62 First argument for the interrupt handler
71 Second, optional, argument for the interrupt handler
76 \fBddi_intr_remove_handler()\fR
89 The \fBddi_intr_add_handler()\fR function adds an interrupt handler given by
90 the \fIinthandler\fR argument to the system with the handler arguments
91 \fIarg1\fR and \fIarg2\fR for the previously allocated interrupt handle
92 specified by the \fIh\fR pointer. The arguments \fIarg1\fR and \fIarg2\fR are
93 passed as the first and second arguments, respectively, to the interrupt
94 handler \fIinthandler\fR. See \fB<sys/ddi_intr.h>\fR for the definition of the
98 The routine \fIinthandler\fR with the arguments \fIarg1\fR and \fIarg2\fR is
99 called upon receipt of the appropriate interrupt. The interrupt handler should
100 return \fBDDI_INTR_CLAIMED\fR if the interrupt is claimed and
101 \fBDDI_INTR_UNCLAIMED\fR otherwise.
104 The \fBddi_intr_add_handler()\fR function must be called after
105 \fBddi_intr_alloc()\fR, but before \fBddi_intr_enable()\fR is called. The
106 interrupt must be enabled through \fBddi_intr_enable()\fR or
107 \fBddi_intr_block_enable()\fR before it can be used.
110 The \fBddi_intr_remove_handler()\fR function removes the handler association,
111 added previously with \fBddi_intr_add_handler()\fR, for the interrupt
112 identified by the interrupt handle \fIh\fR argument. Unloadable drivers should
113 call this routine during their \fBdetach\fR(9E) routine to remove the interrupt
114 handler from the system.
117 The \fBddi_intr_remove_handler()\fR function is used to disassociate the
118 handler after the interrupt is disabled to remove \fBdup-ed\fR interrupt
119 handles. See \fBddi_intr_dup_handler\fR(9F) for \fBdup-ed\fR interrupt handles.
120 If a handler is duplicated with the \fBddi_intr_dup_handler()\fR function, all
121 added and duplicated instances of the handler must be removed with
122 \fBddi_intr_remove_handler()\fR in order for the handler to be completely
127 The \fBddi_intr_add_handler()\fR and \fBddi_intr_remove_handler()\fR functions
132 \fB\fBDDI_SUCCESS\fR\fR
141 \fB\fBDDI_EINVAL\fR\fR
144 On encountering invalid input parameters.
150 \fB\fBDDI_FAILURE\fR\fR
153 On any implementation specific failure.
159 The \fBddi_intr_add_handler()\fR and \fBddi_intr_remove_handler()\fR functions
160 can be called from kernel non-interrupt context.
164 See \fBattributes\fR(5) for descriptions of the following attributes:
172 ATTRIBUTE TYPE ATTRIBUTE VALUE
174 Interface Stability Committed
180 \fBattributes\fR(5), \fBattach\fR(9E), \fBdetach\fR(9E),
181 \fBddi_intr_alloc\fR(9F), \fBddi_intr_block_enable\fR(9F),
182 \fBddi_intr_disable\fR(9F), \fBddi_intr_dup_handler\fR(9F),
183 \fBddi_intr_enable\fR(9F), \fBddi_intr_free\fR(9F),
184 \fBddi_intr_get_supported_types\fR(9F), \fBmutex\fR(9F), \fBmutex_init\fR(9F),
185 \fBrw_init\fR(9F), \fBrwlock\fR(9F)
188 \fIWriting Device Drivers\fR
192 Consumers of these interfaces should verify that the return value is not equal
193 to \fBDDI_SUCCESS\fR. Incomplete checking for failure codes could result in
194 inconsistent behavior among platforms.
197 If a device driver that uses \fBMSI\fR and \fBMSI-X\fR interrupts resets the
198 device, the device might reset its configuration space modifications. Such a
199 reset could cause a device driver to lose any \fBMSI\fR and \fBMSI-X\fR
200 interrupt usage settings that have been applied.
203 The second argument, \fIarg2\fR, is optional. Device drivers are free to use
204 the two arguments however they see fit. There is no officially recommended
205 model or restrictions. For example, an interrupt handler may wish to use the
206 first argument as the pointer to its softstate and the second argument as the
207 value of the MSI vector.