2 .\" Copyright (c) 2008, 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_ALLOC 9F "Apr 23, 2008"
8 ddi_intr_alloc, ddi_intr_free \- allocate or free interrupts for a given
13 #include <sys/types.h>
16 #include <sys/sunddi.h>
18 \fBint\fR \fBddi_intr_alloc\fR(\fBdev_info_t *\fR\fIdip\fR, \fBddi_intr_handle_t *\fR\fIh_array\fR, \fBint\fR \fItype\fR,
19 \fBint\fR \fIinum\fR, \fBint\fR \fIcount\fR, \fBint *\fR\fIactualp\fR, \fBint\fR \fIbehavior\fR);
24 \fBint\fR \fBddi_intr_free\fR(\fBddi_intr_handle_t\fR \fIh\fR);
30 Solaris DDI specific (Solaris DDI).
34 \fBddi_intr_alloc()\fR
41 Pointer to the \fBdev_info\fR structure
50 Pointer to an array of DDI interrupt handles
77 Number of interrupts requested. The \fIcount\fR should not exceed the total
78 number of interrupts supported by the device, as returned by a call to
79 \fBddi_intr_get_nintrs\fR(9F).
88 Pointer to the number of interrupts actually allocated
97 Flag to determine the allocation algorithm
102 \fBddi_intr_free()\fR
115 The \fBddi_intr_alloc()\fR function allocates interrupts of the interrupt type
116 given by the \fItype\fR argument beginning at the interrupt number \fIinum\fR.
117 If \fBddi_intr_alloc()\fR allocates any interrupts, it returns the actual
118 number of interrupts allocated in the integer pointed to by the \fIactualp\fR
119 argument and returns the number of interrupt handles in the interrupt handle
120 array pointed to by the \fIh_array\fR argument.
123 Specific interrupts are always specified by the combination of interrupt
124 \fItype\fR and \fIinum\fR. For legacy devices, \fIinum\fR refers to the nth
125 interrupt, typically as defined by the devices \fBinterrupts\fR property. For
126 PCI fixed interrupts, \fIinum\fR refers to the interrupt number. The \fIinum\fR
127 is the relative interrupt vector number, from \fB0\fR to \fB31\fR for MSI, from
128 \fB0\fR to \fB2047\fR for MSI-X. The first interrupt vector is \fB0\fR. The
129 last relative vector is \fB31\fR for MSI or \fB2047\fR for MSI-X.
132 The \fIh_array\fR must be pre-allocated by the caller as a \fIcount\fR sized
133 array of ddi_intr_handle_t's.
136 If MSI interrupts are being allocated, the \fIcount\fR argument passed should
137 be a number between \fB1\fR and \fB32\fR, specified as a power of two. If
138 \fIcount\fR is not specified as a power of two, the error \fBDDI_EINVAL\fR is
142 The behavior flag controls the interrupt allocation algorithm. It takes one of
143 two input values: \fBDDI_INTR_ALLOC_NORMAL\fR or \fBDDI_INTR_ALLOC_STRICT\fR.
144 If the \fIcount\fR value used is greater than \fBNINTRs\fR, then the call fails
145 with \fBDDI_EINVAL\fR unconditionally. When set to \fBDDI_INTR_ALLOC_STRICT\fR,
146 the call succeeds if and only if \fIcount\fR interrupts are allocated.
147 Otherwise, the call fails, and the number of available interrupts is returned
148 in \fIactualp\fR. When set to \fBDDI_INTR_ALLOC_NORMAL\fR, the call succeeds if
149 at least one interrupt is allocated, and the number of allocated interrupts is
153 The handle for each allocated interrupt, if any, is returned in the array of
154 handles given by the \fIh_array\fR argument.
157 The \fBddi_intr_free()\fR function releases the system resources and interrupt
158 vectors associated with the ddi_intr_handle_t \fIh\fR, including any resources
159 associated with the handle \fIh\fR itself. Once freed, the handle \fIh\fR
160 should not be used in any further calls.
163 The \fBddi_intr_free()\fR function should be called once for each handle in the
168 The \fBddi_intr_alloc()\fR and \fBddi_intr_free()\fR functions return:
172 \fB\fBDDI_SUCCESS\fR\fR
181 \fB\fBDDI_EAGAIN\fR\fR
184 Not enough interrupt resources.
190 \fB\fBDDI_EINVAL\fR\fR
193 On encountering invalid input parameters.
199 \fB\fBDDI_INTR_NOTFOUND\fR\fR
202 On failure to find the interrupt.
208 \fB\fBDDI_FAILURE\fR\fR
211 On any implementation specific failure.
217 The \fBddi_intr_alloc()\fR and \fBddi_intr_free()\fR functions can be called
218 from kernel non-interrupt context.
222 See \fBattributes\fR(5) for descriptions of the following attributes:
230 ATTRIBUTE TYPE ATTRIBUTE VALUE
232 Interface Stability Committed
238 \fBattributes\fR(5), \fBddi_intr_add_handler\fR(9F),
239 \fBddi_intr_block_enable\fR(9F), \fBddi_intr_disable\fR(9F),
240 \fBddi_intr_enable\fR(9F), \fBddi_intr_get_cap\fR(9F),
241 \fBddi_intr_get_nintrs\fR(9F), \fBddi_intr_get_pri\fR(9F),
242 \fBddi_intr_get_supported_types\fR(9F), \fBddi_intr_remove_handler\fR(9F)
245 \fIWriting Device Drivers\fR
249 Consumers of these interfaces should verify that the return value is not equal
250 to \fBDDI_SUCCESS\fR. Incomplete checking for failure codes could result in
251 inconsistent behavior among platforms.
254 If a device driver that uses \fBMSI\fR and \fBMSI-X\fR interrupts resets the
255 device, the device might reset its configuration space modifications. Such a
256 reset could cause a device driver to lose any \fBMSI\fR and \fBMSI-X\fR
257 interrupt usage settings that have been applied.