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
|
'\" te
.\" Copyright (c) 2003, 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_ADD_EVENT_HANDLER 9F "Nov 26, 2017"
.SH NAME
ddi_add_event_handler \- add an NDI event service callback handler
.SH SYNOPSIS
.nf
#include <sys/dditypes.h>
#include <sys/sunddi.h>
\fBint\fR \fBddi_add_event_handler\fR(\fBdev_info_t *\fR\fIdip\fR, \fBddi_eventcookie_t\fR \fIcookie\fR,
\fBvoid (*\fR\fIhandler\fR)(dev_info_t *, ddi_eventcookie_t, void *, void *),
\fBvoid *\fR\fIarg\fR, \fBddi_registration_id_t *\fR\fIid\fR);
.fi
.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI).
.SH PARAMETERS
.ne 2
.na
\fB\fBdev_info_t *\fR\fIdip\fR\fR
.ad
.sp .6
.RS 4n
Device node registering the callback.
.RE
.sp
.ne 2
.na
\fB\fBddi_eventcookie_t\fR \fIcookie\fR\fR
.ad
.sp .6
.RS 4n
Cookie returned from call to \fBddi_get_eventcookie\fR(9F).
.RE
.sp
.ne 2
.na
\fB\fBvoid (*\fR\fIhandler\fR\fB)(dev_info_t *, ddi_eventcookie_t, void *, void
*)\fR\fR
.ad
.sp .6
.RS 4n
Callback handler responsible for handling an NDI event service notification.
.RE
.sp
.ne 2
.na
\fB\fBvoid *\fR\fIarg\fR\fR
.ad
.sp .6
.RS 4n
Pointer to opaque data supplied by the caller. Typically, this would be a
pointer to the driver's \fBsoftstate\fR structure.
.RE
.sp
.ne 2
.na
\fB\fBddi_registration_id_t *\fR\fIid\fR\fR
.ad
.sp .6
.RS 4n
Pointer to registration ID where a unique registration id will be returned.
Registration ID must be saved and used when calling
\fBddi_remove_event_handler\fR(9F) to unregister a callback.
.RE
.SH DESCRIPTION
The \fBddi_add_event_handler()\fR function adds a callback handler to be
invoked in the face of the event specified by \fIcookie\fR. The process of
adding a callback handler is also known as subscribing to an event. Upon
successful subscription, the handler will be invoked by the system when the
event occurs. The handler can be unregistered by using
\fBddi_remove_event_handler\fR(9F).
.sp
.LP
An instance of a driver can register multiple handlers for an event or a single
handler for multiple events. Callback order is not defined and should assumed
to be random.
.sp
.LP
The routine handler will be invoked with the following arguments:
.sp
.ne 2
.na
\fB\fBdev_info_t *\fR\fIdip\fR\fR
.ad
.RS 28n
Device node requesting the notification.
.RE
.sp
.ne 2
.na
\fB\fBddi_eventcookie_t\fR \fIcookie\fR\fR
.ad
.RS 28n
Structure describing event that occurred.
.RE
.sp
.ne 2
.na
\fB\fBvoid *\fR\fIarg\fR\fR
.ad
.RS 28n
Opaque data pointer provided, by the driver, during callback registration.
.RE
.sp
.ne 2
.na
\fB\fBvoid *\fR\fIimpl_data\fR\fR
.ad
.RS 28n
Pointer to event specific data defined by the framework which invokes the
callback function.
.RE
.SH RETURN VALUES
.ne 2
.na
\fB\fBDDI_SUCCESS\fR\fR
.ad
.RS 15n
Callback handler registered successfully.
.RE
.sp
.ne 2
.na
\fB\fBDDI_FAILURE\fR\fR
.ad
.RS 15n
Failed to register callback handler. Possible reasons include lack of resources
or a bad cookie.
.RE
.SH CONTEXT
The \fBddi_add_event_handler()\fR and \fBhandler()\fR function can be called
from user and kernel contexts only.
.SH ATTRIBUTES
See \fBattributes\fR(7) for a description of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Stability Level Committed
.TE
.SH SEE ALSO
.BR attributes (7),
.BR ddi_get_eventcookie (9F),
.BR ddi_remove_event_handler (9F)
.sp
.LP
\fIWriting Device Drivers\fR
.SH NOTES
Drivers must remove all registered callback handlers for a device instance by
calling \fBddi_remove_event_handler\fR(9F) before detach completes.
|