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"
8 ldi_add_event_handler \- add NDI event service callback handler
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);
25 \fB\fIldi_handle_t lh\fR\fR
29 Layered handle representing event notification device.
35 \fB\fIddi_eventcookie_t ec\fR\fR
39 Cookie returned from call to \fBldi_get_eventcookie\fR(9F).
45 \fB\fIvoid (*handler)(ldi_handle_t, ddi_eventcookie_t, void *, void *)\fR\fR
49 Callback handler for NDI event service notification.
59 Pointer to opaque data supplied by caller. Typically, this is a pointer to the
60 layered driver's softstate structure.
66 \fB\fIldi_callback_id_t *id\fR\fR
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.
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).
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).
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.
95 The routine handler is invoked with the following arguments:
99 \fB\fBldi_handle_t\fR \fIlh\fR\fR
102 Layered handle representing the device for which the event notification is
109 \fB\fBddi_eventcookie_t\fR \fIec\fR\fR
112 Structure describing event that occurred.
118 \fB\fBvoid *\fR\fIarg\fR\fR
121 Opaque data pointer provided by the driver during callback registration.
127 \fB\fBvoid *\fR\fIimpl_data\fR\fR
130 Pointer to event specific data defined by the framework that invokes the
137 \fB\fBDDI_SUCCESS\fR\fR
140 Callback handler registered successfully.
146 \fB\fBDDI_FAILURE\fR\fR
149 Failed to register callback handler. Possible reasons include lack of resources
155 The \fBldi_add_event_handler()\fR function can be called from user and kernel
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
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