10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*4845Svikram * Common Development and Distribution License (the "License"). 6*4845Svikram * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*4845Svikram * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_SUNLDI_IMPL_H 270Sstevel@tonic-gate #define _SYS_SUNLDI_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <sys/dditypes.h> 360Sstevel@tonic-gate #include <sys/vnode.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate /* 390Sstevel@tonic-gate * NOTE 400Sstevel@tonic-gate * 410Sstevel@tonic-gate * The contents of this file are private to this implementation 420Sstevel@tonic-gate * of Solaris and are subject to change at any time without notice. 430Sstevel@tonic-gate * 440Sstevel@tonic-gate * Applications and drivers using these interfaces will fail 450Sstevel@tonic-gate * to run on future releases. 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 490Sstevel@tonic-gate * LDI hash definitions 500Sstevel@tonic-gate */ 510Sstevel@tonic-gate #define LH_HASH_SZ 32 520Sstevel@tonic-gate #define LI_HASH_SZ 32 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* 55*4845Svikram * Obsolete LDI event interfaces are available for now but are deprecated and a 56*4845Svikram * warning will be issued to consumers. 57*4845Svikram */ 58*4845Svikram #define LDI_OBSOLETE_EVENT 1 59*4845Svikram 60*4845Svikram /* 61*4845Svikram * Flag for LDI handle's lh_flags field 62*4845Svikram */ 63*4845Svikram #define LH_FLAGS_NOTIFY 0x0001 /* invoked in context of a notify */ 64*4845Svikram 65*4845Svikram /* 660Sstevel@tonic-gate * LDI initialization function 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate void ldi_init(void); 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* 710Sstevel@tonic-gate * LDI streams linking interfaces 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate extern int ldi_mlink_lh(vnode_t *, int, intptr_t, cred_t *, int *); 740Sstevel@tonic-gate extern void ldi_mlink_fp(struct stdata *, struct file *, int, int); 750Sstevel@tonic-gate extern void ldi_munlink_fp(struct stdata *, struct file *, int); 760Sstevel@tonic-gate 770Sstevel@tonic-gate /* 780Sstevel@tonic-gate * LDI module identifier 790Sstevel@tonic-gate */ 800Sstevel@tonic-gate struct ldi_ident { 810Sstevel@tonic-gate /* protected by ldi_ident_hash_lock */ 820Sstevel@tonic-gate struct ldi_ident *li_next; 830Sstevel@tonic-gate uint_t li_ref; 840Sstevel@tonic-gate 850Sstevel@tonic-gate /* unique/static fields in the ident */ 860Sstevel@tonic-gate char li_modname[MODMAXNAMELEN]; 870Sstevel@tonic-gate modid_t li_modid; 880Sstevel@tonic-gate major_t li_major; 890Sstevel@tonic-gate dev_info_t *li_dip; 900Sstevel@tonic-gate dev_t li_dev; 910Sstevel@tonic-gate }; 920Sstevel@tonic-gate 930Sstevel@tonic-gate /* 940Sstevel@tonic-gate * LDI handle 950Sstevel@tonic-gate */ 960Sstevel@tonic-gate struct ldi_handle { 970Sstevel@tonic-gate /* protected by ldi_handle_hash_lock */ 980Sstevel@tonic-gate struct ldi_handle *lh_next; 990Sstevel@tonic-gate uint_t lh_ref; 100*4845Svikram uint_t lh_flags; 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* unique/static fields in the handle */ 1030Sstevel@tonic-gate uint_t lh_type; 1040Sstevel@tonic-gate struct ldi_ident *lh_ident; 1050Sstevel@tonic-gate vnode_t *lh_vp; 1060Sstevel@tonic-gate 107*4845Svikram #ifdef LDI_OBSOLETE_EVENT 1080Sstevel@tonic-gate /* fields protected by lh_lock */ 1090Sstevel@tonic-gate kmutex_t lh_lock[1]; 1100Sstevel@tonic-gate struct ldi_event *lh_events; 111*4845Svikram #endif 1120Sstevel@tonic-gate }; 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* 1150Sstevel@tonic-gate * LDI event information 1160Sstevel@tonic-gate */ 117*4845Svikram #ifdef LDI_OBSOLETE_EVENT 1180Sstevel@tonic-gate typedef struct ldi_event { 1190Sstevel@tonic-gate /* fields protected by le_lhp->lh_lock */ 1200Sstevel@tonic-gate struct ldi_event *le_next; 1210Sstevel@tonic-gate struct ldi_event *le_prev; 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate /* unique/static fields in the handle */ 1240Sstevel@tonic-gate struct ldi_handle *le_lhp; 1250Sstevel@tonic-gate void (*le_handler)(); 1260Sstevel@tonic-gate void *le_arg; 1270Sstevel@tonic-gate ddi_callback_id_t le_id; 1280Sstevel@tonic-gate } ldi_event_t; 129*4845Svikram #endif 130*4845Svikram 131*4845Svikram typedef struct ldi_ev_callback_impl { 132*4845Svikram struct ldi_handle *lec_lhp; 133*4845Svikram dev_info_t *lec_dip; 134*4845Svikram dev_t lec_dev; 135*4845Svikram int lec_spec; 136*4845Svikram int (*lec_notify)(); 137*4845Svikram void (*lec_finalize)(); 138*4845Svikram void *lec_arg; 139*4845Svikram void *lec_cookie; 140*4845Svikram void *lec_id; 141*4845Svikram list_node_t lec_list; 142*4845Svikram } ldi_ev_callback_impl_t; 143*4845Svikram 144*4845Svikram struct ldi_ev_callback_list { 145*4845Svikram kmutex_t le_lock; 146*4845Svikram kcondvar_t le_cv; 147*4845Svikram int le_busy; 148*4845Svikram void *le_thread; 149*4845Svikram list_t le_head; 150*4845Svikram }; 151*4845Svikram 152*4845Svikram int ldi_invoke_notify(dev_info_t *dip, dev_t dev, int spec_type, char *event, 153*4845Svikram void *ev_data); 154*4845Svikram void ldi_invoke_finalize(dev_info_t *dip, dev_t dev, int spec_type, char *event, 155*4845Svikram int ldi_result, void *ev_data); 156*4845Svikram int e_ddi_offline_notify(dev_info_t *dip); 157*4845Svikram void e_ddi_offline_finalize(dev_info_t *dip, int result); 158*4845Svikram 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate /* 1610Sstevel@tonic-gate * LDI device usage interfaces 1620Sstevel@tonic-gate * 1630Sstevel@tonic-gate * ldi_usage_count(), ldi_usage_walker(), and ldi_usage_t 1640Sstevel@tonic-gate * 1650Sstevel@tonic-gate * These functions are used by the devinfo driver and fuser to get a 1660Sstevel@tonic-gate * device usage information from the LDI. These functions along with 1670Sstevel@tonic-gate * the ldi_usage_t data structure allow these other subsystems to have 1680Sstevel@tonic-gate * no knowledge of how the LDI stores it's internal state. 1690Sstevel@tonic-gate * 1700Sstevel@tonic-gate * ldi_usage_count() provides an count of how many kernel 1710Sstevel@tonic-gate * device clients currently exist. 1720Sstevel@tonic-gate * 1730Sstevel@tonic-gate * ldi_usage_walker() reports all kernel device usage information. 1740Sstevel@tonic-gate */ 1750Sstevel@tonic-gate #define LDI_USAGE_CONTINUE 0 1760Sstevel@tonic-gate #define LDI_USAGE_TERMINATE 1 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate typedef struct ldi_usage { 1790Sstevel@tonic-gate /* 1800Sstevel@tonic-gate * information about the kernel subsystem that is accessing 1810Sstevel@tonic-gate * the target device 1820Sstevel@tonic-gate */ 1830Sstevel@tonic-gate modid_t src_modid; 1840Sstevel@tonic-gate char *src_name; 1850Sstevel@tonic-gate dev_info_t *src_dip; 1860Sstevel@tonic-gate dev_t src_devt; 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate /* 1890Sstevel@tonic-gate * information about the target device that is open 1900Sstevel@tonic-gate */ 1910Sstevel@tonic-gate modid_t tgt_modid; 1920Sstevel@tonic-gate char *tgt_name; 1930Sstevel@tonic-gate dev_info_t *tgt_dip; 1940Sstevel@tonic-gate dev_t tgt_devt; 1950Sstevel@tonic-gate int tgt_spec_type; 1960Sstevel@tonic-gate } ldi_usage_t; 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate int ldi_usage_count(); 1990Sstevel@tonic-gate void ldi_usage_walker(void *arg, 2000Sstevel@tonic-gate int (*callback)(const ldi_usage_t *ldi_usage, void *arg)); 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate #ifdef __cplusplus 2030Sstevel@tonic-gate } 2040Sstevel@tonic-gate #endif 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate #endif /* _SYS_SUNLDI_IMPL_H */ 207