1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
'\" te
.\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
.\" 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.
.\" 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.
.\" 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]
.TH DDI_INTR_ADD_HANDLER 9F "Apr 22, 2005"
.SH NAME
ddi_intr_add_handler, ddi_intr_remove_handler \- add or remove interrupt
handler
.SH SYNOPSIS
.nf
#include <sys/types.h>
#include <sys/conf.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
\fBint\fR \fBddi_intr_add_handler\fR(\fBddi_intr_handle_t *\fR\fIh\fR,
\fBddi_intr_handler_t\fR \fIinthandler\fR, \fBvoid *\fR\fIarg1\fR,
\fBvoid *\fR\fIarg2\fR);
.fi
.LP
.nf
\fBint\fR \fBddi_intr_remove_handler\fR(\fBddi_intr_handle_t\fR \fIh\fR);
.fi
.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI).
.SH PARAMETERS
\fBddi_intr_add_handler()\fR
.sp
.ne 2
.na
\fB\fIh\fR\fR
.ad
.RS 14n
Pointer to the DDI interrupt handle
.RE
.sp
.ne 2
.na
\fB\fIinthandler\fR\fR
.ad
.RS 14n
Pointer to interrupt handler
.RE
.sp
.ne 2
.na
\fB\fIarg1\fR\fR
.ad
.RS 14n
First argument for the interrupt handler
.RE
.sp
.ne 2
.na
\fB\fIarg2\fR\fR
.ad
.RS 14n
Second, optional, argument for the interrupt handler
.RE
.sp
.LP
\fBddi_intr_remove_handler()\fR
.sp
.ne 2
.na
\fB\fIh\fR\fR
.ad
.RS 5n
DDI interrupt handle
.RE
.SH DESCRIPTION
The \fBddi_intr_add_handler()\fR function adds an interrupt handler given by
the \fIinthandler\fR argument to the system with the handler arguments
\fIarg1\fR and \fIarg2\fR for the previously allocated interrupt handle
specified by the \fIh\fR pointer. The arguments \fIarg1\fR and \fIarg2\fR are
passed as the first and second arguments, respectively, to the interrupt
handler \fIinthandler\fR. See \fB<sys/ddi_intr.h>\fR for the definition of the
interrupt handler.
.sp
.LP
The routine \fIinthandler\fR with the arguments \fIarg1\fR and \fIarg2\fR is
called upon receipt of the appropriate interrupt. The interrupt handler should
return \fBDDI_INTR_CLAIMED\fR if the interrupt is claimed and
\fBDDI_INTR_UNCLAIMED\fR otherwise.
.sp
.LP
The \fBddi_intr_add_handler()\fR function must be called after
\fBddi_intr_alloc()\fR, but before \fBddi_intr_enable()\fR is called. The
interrupt must be enabled through \fBddi_intr_enable()\fR or
\fBddi_intr_block_enable()\fR before it can be used.
.sp
.LP
The \fBddi_intr_remove_handler()\fR function removes the handler association,
added previously with \fBddi_intr_add_handler()\fR, for the interrupt
identified by the interrupt handle \fIh\fR argument. Unloadable drivers should
call this routine during their \fBdetach\fR(9E) routine to remove the interrupt
handler from the system.
.sp
.LP
The \fBddi_intr_remove_handler()\fR function is used to disassociate the
handler after the interrupt is disabled to remove \fBdup-ed\fR interrupt
handles. See \fBddi_intr_dup_handler\fR(9F) for \fBdup-ed\fR interrupt handles.
If a handler is duplicated with the \fBddi_intr_dup_handler()\fR function, all
added and duplicated instances of the handler must be removed with
\fBddi_intr_remove_handler()\fR in order for the handler to be completely
removed.
.SH RETURN VALUES
The \fBddi_intr_add_handler()\fR and \fBddi_intr_remove_handler()\fR functions
return:
.sp
.ne 2
.na
\fB\fBDDI_SUCCESS\fR\fR
.ad
.RS 15n
On success.
.RE
.sp
.ne 2
.na
\fB\fBDDI_EINVAL\fR\fR
.ad
.RS 15n
On encountering invalid input parameters.
.RE
.sp
.ne 2
.na
\fB\fBDDI_FAILURE\fR\fR
.ad
.RS 15n
On any implementation specific failure.
.RE
.SH CONTEXT
The \fBddi_intr_add_handler()\fR and \fBddi_intr_remove_handler()\fR functions
can be called from kernel non-interrupt context.
.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Committed
.TE
.SH SEE ALSO
.BR attributes (7),
.BR attach (9E),
.BR detach (9E),
.BR ddi_intr_alloc (9F),
.BR ddi_intr_block_enable (9F),
.BR ddi_intr_disable (9F),
.BR ddi_intr_dup_handler (9F),
.BR ddi_intr_enable (9F),
.BR ddi_intr_free (9F),
.BR ddi_intr_get_supported_types (9F),
.BR mutex (9F),
.BR mutex_init (9F),
.BR rw_init (9F),
.BR rwlock (9F)
.sp
.LP
\fIWriting Device Drivers\fR
.SH NOTES
Consumers of these interfaces should verify that the return value is not equal
to \fBDDI_SUCCESS\fR. Incomplete checking for failure codes could result in
inconsistent behavior among platforms.
.sp
.LP
If a device driver that uses \fBMSI\fR and \fBMSI-X\fR interrupts resets the
device, the device might reset its configuration space modifications. Such a
reset could cause a device driver to lose any \fBMSI\fR and \fBMSI-X\fR
interrupt usage settings that have been applied.
.sp
.LP
The second argument, \fIarg2\fR, is optional. Device drivers are free to use
the two arguments however they see fit. There is no officially recommended
model or restrictions. For example, an interrupt handler may wish to use the
first argument as the pointer to its softstate and the second argument as the
value of the MSI vector.
|