Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / ldi_add_event_handler.9f
blobdad442093454256bd8d260d0bf8a6d6ed5c012fe
1 '\" te
2 .\" Copyright (c) 2007, 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 LDI_ADD_EVENT_HANDLER 9F "April 9, 2016"
7 .SH NAME
8 ldi_add_event_handler \- add NDI event service callback handler
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/ddi_obsolete.h>
14 \fBint\fR \fBldi_add_event_handler\fR(\fBldi_handle_t\fR \fIlh\fR, \fIddi_eventcookie_t ec\fR,
15      \fBvoid (*handler)(\fR\fIldi_handle_t\fR, \fIddi_eventcookie_t\fR,
16      \fBvoid *, void *) void *arg,\fR \fIldi_callback_id_t *id\fR);
17 .fi
19 .SH INTERFACE LEVEL
20 .LP
21 Obsolete
22 .SH PARAMETERS
23 .ne 2
24 .na
25 \fB\fIldi_handle_t lh\fR\fR
26 .ad
27 .sp .6
28 .RS 4n
29 Layered handle representing event notification device.
30 .RE
32 .sp
33 .ne 2
34 .na
35 \fB\fIddi_eventcookie_t ec\fR\fR
36 .ad
37 .sp .6
38 .RS 4n
39 Cookie returned from call to \fBldi_get_eventcookie\fR(9F).
40 .RE
42 .sp
43 .ne 2
44 .na
45 \fB\fIvoid (*handler)(ldi_handle_t, ddi_eventcookie_t, void *, void *)\fR\fR
46 .ad
47 .sp .6
48 .RS 4n
49 Callback handler for NDI event service notification.
50 .RE
52 .sp
53 .ne 2
54 .na
55 \fB\fIvoid *arg\fR\fR
56 .ad
57 .sp .6
58 .RS 4n
59 Pointer to opaque data supplied by caller. Typically, this is a pointer to the
60 layered driver's softstate structure.
61 .RE
63 .sp
64 .ne 2
65 .na
66 \fB\fIldi_callback_id_t *id\fR\fR
67 .ad
68 .sp .6
69 .RS 4n
70 Pointer to registration id, where a unique registration id is returned.
71 Registration id must be saved and used when calling
72 \fBldi_remove_event_handler\fR(9F) to unregister a callback handler.
73 .RE
75 .SH DESCRIPTION
76 .LP
77 This function is obsolete and is only maintained for compatibility. Use of this
78 function is strongly discouraged. For equivalent functionality provided by new
79 interfaces, see \fBldi_ev_get_cookie\fR(9F) and
80 \fBldi_ev_register_callbacks\fR(9F).
81 .sp
82 .LP
83 The \fBldi_add_event_handler()\fR function adds a callback handler to be
84 invoked at the occurrence of the event specified by the cookie. Adding a
85 callback handler is also known as subscribing to an event. Upon successful
86 subscription, the handler is invoked when the event occurs. You can unregister
87 the handler by using \fBldi_remove_event_handler\fR(9F).
88 .sp
89 .LP
90 An instance of a layered driver can register multiple handlers for an event or
91 a single handler for multiple events. Callback order is not defined and should
92 be assumed to be random.
93 .sp
94 .LP
95 The routine handler is invoked with the following arguments:
96 .sp
97 .ne 2
98 .na
99 \fB\fBldi_handle_t\fR \fIlh\fR\fR
101 .RS 24n
102 Layered handle representing the device for which the event notification is
103 requested.
107 .ne 2
109 \fB\fBddi_eventcookie_t\fR \fIec\fR\fR
111 .RS 24n
112 Structure describing event that occurred.
116 .ne 2
118 \fB\fBvoid *\fR\fIarg\fR\fR
120 .RS 24n
121 Opaque data pointer provided by the driver during callback registration.
125 .ne 2
127 \fB\fBvoid *\fR\fIimpl_data\fR\fR
129 .RS 24n
130 Pointer to event specific data defined by the framework that invokes the
131 callback function.
134 .SH RETURN VALUES
135 .ne 2
137 \fB\fBDDI_SUCCESS\fR\fR
139 .RS 15n
140 Callback handler registered successfully.
144 .ne 2
146 \fB\fBDDI_FAILURE\fR\fR
148 .RS 15n
149 Failed to register callback handler. Possible reasons include lack of resources
150 or a bad cookie.
153 .SH CONTEXT
155 The \fBldi_add_event_handler()\fR function can be called from user and kernel
156 contexts only.
157 .SH SEE ALSO
159 \fBldi_ev_get_cookie\fR(9F), \fBldi_ev_register_callbacks\fR(9F),
160 \fBldi_get_eventcookie\fR(9F), \fBldi_remove_event_handler\fR(9F)
163 \fIWriting Device Drivers\fR
164 .SH NOTES
166 Layered drivers must remove all registered callback handlers for a device
167 instance, represented by the layered handle, by calling
168 \fBldi_remove_event_handler\fR(9F) before the layered driver's \fBdetach(9E)\fR
169 routine completes.