Copyright (c) 2007, 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]
#include <sys/ddi_obsolete.h> int ldi_add_event_handler(ldi_handle_t lh, ddi_eventcookie_t ec, void (*handler)(ldi_handle_t, ddi_eventcookie_t, void *, void *) void *arg, ldi_callback_id_t *id);
Obsolete
Layered handle representing event notification device.
Cookie returned from call to ldi_get_eventcookie(9F).
Callback handler for NDI event service notification.
Pointer to opaque data supplied by caller. Typically, this is a pointer to the layered driver's softstate structure.
Pointer to registration id, where a unique registration id is returned. Registration id must be saved and used when calling ldi_remove_event_handler(9F) to unregister a callback handler.
This function is obsolete and is only maintained for compatibility. Use of this function is strongly discouraged. For equivalent functionality provided by new interfaces, see ldi_ev_get_cookie(9F) and ldi_ev_register_callbacks(9F).
The ldi_add_event_handler() function adds a callback handler to be invoked at the occurrence of the event specified by the cookie. Adding a callback handler is also known as subscribing to an event. Upon successful subscription, the handler is invoked when the event occurs. You can unregister the handler by using ldi_remove_event_handler(9F).
An instance of a layered driver can register multiple handlers for an event or a single handler for multiple events. Callback order is not defined and should be assumed to be random.
The routine handler is invoked with the following arguments: ldi_handle_t lh
Layered handle representing the device for which the event notification is requested.
Structure describing event that occurred.
Opaque data pointer provided by the driver during callback registration.
Pointer to event specific data defined by the framework that invokes the callback function.
Callback handler registered successfully.
Failed to register callback handler. Possible reasons include lack of resources or a bad cookie.
The ldi_add_event_handler() function can be called from user and kernel contexts only.
ldi_ev_get_cookie (9F), ldi_ev_register_callbacks (9F), ldi_get_eventcookie (9F), ldi_remove_event_handler (9F)
Writing Device Drivers
Layered drivers must remove all registered callback handlers for a device instance, represented by the layered handle, by calling ldi_remove_event_handler(9F) before the layered driver's detach(9E) routine completes.