2 .\" Copyright (c) 2003, 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_ADD_EVENT_HANDLER 9F "Nov 2, 2003"
8 ddi_add_event_handler \- add an NDI event service callback handler
12 #include <sys/dditypes.h>
13 #include <sys/sunddi.h>
15 \fBint\fR \fBddi_add_event_handler\fR(\fBdev_info_t *\fR\fIdip\fR, \fBddi_eventcookie_t\fR \fIcookie\fR,
16 \fBvoid (*\fR\fIhandler\fR)(dev_info_t *, ddi_eventcookie_t, void *, void *),
17 \fBvoid *\fR\fIarg\fR, \fBddi_registration_id_t *\fR\fIid\fR);
23 Solaris DDI specific (Solaris DDI).
28 \fB\fBdev_info_t *\fR\fIdip\fR\fR
32 Device node registering the callback.
38 \fB\fBddi_eventcookie_t\fR \fIcookie\fR\fR
42 Cookie returned from call to \fBddi_get_eventcookie\fR(9F).
48 \fB\fBvoid (*\fR\fIhandler\fR\fB)(dev_info_t *, ddi_eventcookie_t, void *, void
53 Callback handler responsible for handling an NDI event service notification.
59 \fB\fBvoid *\fR\fIarg\fR\fR
63 Pointer to opaque data supplied by the caller. Typically, this would be a
64 pointer to the driver's \fBsoftstate\fR structure.
70 \fB\fBddi_registration_id_t *\fR\fIid\fR\fR
74 Pointer to registration ID where a unique registration id will be returned.
75 Registration ID must be saved and used when calling
76 \fBddi_remove_event_handler\fR(9F) to unregister a callback.
82 The \fBddi_add_event_handler()\fR function adds a callback handler to be
83 invoked in the face of the event specifed by \fIcookie\fR. The process of
84 adding a callback handler is also known as subscribing to an event. Upon
85 successful subscription, the handler will be invoked by the system when the
86 event occurs. The handler can be unregistered by using
87 \fBddi_remove_event_handler\fR(9F).
90 An instance of a driver can register multiple handlers for an event or a single
91 handler for multiple events. Callback order is not defined and should assumed
95 The routine handler will be invoked with the following arguments:
99 \fB\fBdev_info_t *\fR\fIdip\fR\fR
102 Device node requesting the notification.
108 \fB\fBddi_eventcookie_t\fR \fIcookie\fR\fR
111 Structure describing event that occurred.
117 \fB\fBvoid *\fR\fIarg\fR\fR
120 Opaque data pointer provided, by the driver, during callback registration.
126 \fB\fBvoid *\fR\fIimpl_data\fR\fR
129 Pointer to event specific data defined by the framework which 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
156 The \fBddi_add_event_handler()\fR and \fBhandler()\fR function can be called
157 from user and kernel contexts only.
161 See \fBattributes\fR(5) for a description of the following attributes:
169 ATTRIBUTE TYPE ATTRIBUTE VALUE
171 Stability Level Committed
177 \fBattributes\fR(5), \fBddi_get_eventcookie\fR(9F),
178 \fBddi_remove_event_handler\fR(9F)
181 \fIWriting Device Drivers\fR
185 Drivers must remove all registered callback handlers for a device instance by
186 calling \fBddi_remove_event_handler\fR(9F) before detach completes.