1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_SUNLDI_IMPL_H 28*0Sstevel@tonic-gate #define _SYS_SUNLDI_IMPL_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <sys/dditypes.h> 37*0Sstevel@tonic-gate #include <sys/vnode.h> 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate /* 40*0Sstevel@tonic-gate * NOTE 41*0Sstevel@tonic-gate * 42*0Sstevel@tonic-gate * The contents of this file are private to this implementation 43*0Sstevel@tonic-gate * of Solaris and are subject to change at any time without notice. 44*0Sstevel@tonic-gate * 45*0Sstevel@tonic-gate * Applications and drivers using these interfaces will fail 46*0Sstevel@tonic-gate * to run on future releases. 47*0Sstevel@tonic-gate */ 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate /* 50*0Sstevel@tonic-gate * LDI hash definitions 51*0Sstevel@tonic-gate */ 52*0Sstevel@tonic-gate #define LH_HASH_SZ 32 53*0Sstevel@tonic-gate #define LI_HASH_SZ 32 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate /* 56*0Sstevel@tonic-gate * LDI initialization function 57*0Sstevel@tonic-gate */ 58*0Sstevel@tonic-gate void ldi_init(void); 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate /* 61*0Sstevel@tonic-gate * LDI streams linking interfaces 62*0Sstevel@tonic-gate */ 63*0Sstevel@tonic-gate extern int ldi_mlink_lh(vnode_t *, int, intptr_t, cred_t *, int *); 64*0Sstevel@tonic-gate extern void ldi_mlink_fp(struct stdata *, struct file *, int, int); 65*0Sstevel@tonic-gate extern void ldi_munlink_fp(struct stdata *, struct file *, int); 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate /* 68*0Sstevel@tonic-gate * LDI module identifier 69*0Sstevel@tonic-gate */ 70*0Sstevel@tonic-gate struct ldi_ident { 71*0Sstevel@tonic-gate /* protected by ldi_ident_hash_lock */ 72*0Sstevel@tonic-gate struct ldi_ident *li_next; 73*0Sstevel@tonic-gate uint_t li_ref; 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* unique/static fields in the ident */ 76*0Sstevel@tonic-gate char li_modname[MODMAXNAMELEN]; 77*0Sstevel@tonic-gate modid_t li_modid; 78*0Sstevel@tonic-gate major_t li_major; 79*0Sstevel@tonic-gate dev_info_t *li_dip; 80*0Sstevel@tonic-gate dev_t li_dev; 81*0Sstevel@tonic-gate }; 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate /* 84*0Sstevel@tonic-gate * LDI handle 85*0Sstevel@tonic-gate */ 86*0Sstevel@tonic-gate struct ldi_handle { 87*0Sstevel@tonic-gate /* protected by ldi_handle_hash_lock */ 88*0Sstevel@tonic-gate struct ldi_handle *lh_next; 89*0Sstevel@tonic-gate uint_t lh_ref; 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate /* unique/static fields in the handle */ 92*0Sstevel@tonic-gate uint_t lh_type; 93*0Sstevel@tonic-gate struct ldi_ident *lh_ident; 94*0Sstevel@tonic-gate vnode_t *lh_vp; 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate /* fields protected by lh_lock */ 97*0Sstevel@tonic-gate kmutex_t lh_lock[1]; 98*0Sstevel@tonic-gate struct ldi_event *lh_events; 99*0Sstevel@tonic-gate }; 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate /* 102*0Sstevel@tonic-gate * LDI event information 103*0Sstevel@tonic-gate */ 104*0Sstevel@tonic-gate typedef struct ldi_event { 105*0Sstevel@tonic-gate /* fields protected by le_lhp->lh_lock */ 106*0Sstevel@tonic-gate struct ldi_event *le_next; 107*0Sstevel@tonic-gate struct ldi_event *le_prev; 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate /* unique/static fields in the handle */ 110*0Sstevel@tonic-gate struct ldi_handle *le_lhp; 111*0Sstevel@tonic-gate void (*le_handler)(); 112*0Sstevel@tonic-gate void *le_arg; 113*0Sstevel@tonic-gate ddi_callback_id_t le_id; 114*0Sstevel@tonic-gate } ldi_event_t; 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate /* 117*0Sstevel@tonic-gate * LDI device usage interfaces 118*0Sstevel@tonic-gate * 119*0Sstevel@tonic-gate * ldi_usage_count(), ldi_usage_walker(), and ldi_usage_t 120*0Sstevel@tonic-gate * 121*0Sstevel@tonic-gate * These functions are used by the devinfo driver and fuser to get a 122*0Sstevel@tonic-gate * device usage information from the LDI. These functions along with 123*0Sstevel@tonic-gate * the ldi_usage_t data structure allow these other subsystems to have 124*0Sstevel@tonic-gate * no knowledge of how the LDI stores it's internal state. 125*0Sstevel@tonic-gate * 126*0Sstevel@tonic-gate * ldi_usage_count() provides an count of how many kernel 127*0Sstevel@tonic-gate * device clients currently exist. 128*0Sstevel@tonic-gate * 129*0Sstevel@tonic-gate * ldi_usage_walker() reports all kernel device usage information. 130*0Sstevel@tonic-gate */ 131*0Sstevel@tonic-gate #define LDI_USAGE_CONTINUE 0 132*0Sstevel@tonic-gate #define LDI_USAGE_TERMINATE 1 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate typedef struct ldi_usage { 135*0Sstevel@tonic-gate /* 136*0Sstevel@tonic-gate * information about the kernel subsystem that is accessing 137*0Sstevel@tonic-gate * the target device 138*0Sstevel@tonic-gate */ 139*0Sstevel@tonic-gate modid_t src_modid; 140*0Sstevel@tonic-gate char *src_name; 141*0Sstevel@tonic-gate dev_info_t *src_dip; 142*0Sstevel@tonic-gate dev_t src_devt; 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate /* 145*0Sstevel@tonic-gate * information about the target device that is open 146*0Sstevel@tonic-gate */ 147*0Sstevel@tonic-gate modid_t tgt_modid; 148*0Sstevel@tonic-gate char *tgt_name; 149*0Sstevel@tonic-gate dev_info_t *tgt_dip; 150*0Sstevel@tonic-gate dev_t tgt_devt; 151*0Sstevel@tonic-gate int tgt_spec_type; 152*0Sstevel@tonic-gate } ldi_usage_t; 153*0Sstevel@tonic-gate 154*0Sstevel@tonic-gate int ldi_usage_count(); 155*0Sstevel@tonic-gate void ldi_usage_walker(void *arg, 156*0Sstevel@tonic-gate int (*callback)(const ldi_usage_t *ldi_usage, void *arg)); 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate #ifdef __cplusplus 159*0Sstevel@tonic-gate } 160*0Sstevel@tonic-gate #endif 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate #endif /* _SYS_SUNLDI_IMPL_H */ 163