4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/modctl.h>
32 #include <sys/stream.h>
36 * DDI interfaces for Layered driver support.
47 * Opaque layered driver data structures.
49 * The contents of these data structures are private to this
50 * implementation of Solaris and are subject to change at any
51 * time without notice.
53 * Applications and drivers accessing the contents of these structures
54 * directly will fail to run on future releases.
56 typedef struct __ldi_ident
*ldi_ident_t
;
58 typedef struct __ldi_handle
*ldi_handle_t
;
60 typedef struct __ldi_callback_id
*ldi_callback_id_t
;
62 typedef struct __ldi_ev_cookie
*ldi_ev_cookie_t
;
65 * LDI event interface related
67 #define LDI_EV_SUCCESS 0
68 #define LDI_EV_FAILURE (-1)
69 #define LDI_EV_NONE (-2) /* no matching callbacks registered */
70 #define LDI_EV_OFFLINE "LDI:EVENT:OFFLINE"
71 #define LDI_EV_DEGRADE "LDI:EVENT:DEGRADE"
73 #define LDI_EV_CB_VERS_1 1
74 #define LDI_EV_CB_VERS LDI_EV_CB_VERS_1
76 typedef struct ldi_ev_callback
{
78 int (*cb_notify
)(ldi_handle_t
, ldi_ev_cookie_t
, void *, void *);
79 void (*cb_finalize
)(ldi_handle_t
, ldi_ev_cookie_t
, int, void *, void *);
83 * LDI Ident manipulation functions
85 extern ldi_ident_t
ldi_ident_from_anon(void);
87 extern int ldi_ident_from_mod(struct modlinkage
*, ldi_ident_t
*);
88 extern int ldi_ident_from_major(major_t major
, ldi_ident_t
*);
89 extern int ldi_ident_from_dip(dev_info_t
*dip
, ldi_ident_t
*);
90 extern int ldi_ident_from_dev(dev_t
, ldi_ident_t
*);
91 extern int ldi_ident_from_stream(struct queue
*, ldi_ident_t
*);
92 extern void ldi_ident_release(ldi_ident_t
);
96 * LDI Handle manipulation functions
98 extern int ldi_open_by_dev(dev_t
*, int, int, cred_t
*,
99 ldi_handle_t
*, ldi_ident_t
);
100 extern int ldi_open_by_name(char *, int, cred_t
*,
101 ldi_handle_t
*, ldi_ident_t
);
102 extern int ldi_open_by_devid(ddi_devid_t
, char *, int, cred_t
*,
103 ldi_handle_t
*, ldi_ident_t
);
105 extern int ldi_close(ldi_handle_t
, int flag
, cred_t
*);
107 extern int ldi_read(ldi_handle_t
, struct uio
*, cred_t
*);
108 extern int ldi_write(ldi_handle_t
, struct uio
*, cred_t
*);
109 extern int ldi_ioctl(ldi_handle_t
, int, intptr_t, int, cred_t
*, int *);
110 extern int ldi_poll(ldi_handle_t
, short, int, short *, struct pollhead
**);
111 extern int ldi_get_size(ldi_handle_t
, uint64_t *);
112 extern int ldi_prop_op(ldi_handle_t
, ddi_prop_op_t
, int,
113 char *, caddr_t
, int *);
115 extern int ldi_strategy(ldi_handle_t
, struct buf
*);
116 extern int ldi_dump(ldi_handle_t
, caddr_t
, daddr_t
, int);
117 extern int ldi_devmap(ldi_handle_t
, devmap_cookie_t
, offset_t
,
118 size_t, size_t *, uint_t
);
119 extern int ldi_aread(ldi_handle_t
, struct aio_req
*, cred_t
*);
120 extern int ldi_awrite(ldi_handle_t
, struct aio_req
*, cred_t
*);
122 extern int ldi_putmsg(ldi_handle_t
, mblk_t
*);
123 extern int ldi_getmsg(ldi_handle_t
, mblk_t
**, timestruc_t
*);
125 extern int ldi_prop_lookup_int_array(ldi_handle_t lh
,
126 uint_t flags
, char *name
, int **data
, uint_t
*nelements
);
127 extern int ldi_prop_lookup_int64_array(ldi_handle_t lh
,
128 uint_t flags
, char *name
, int64_t **data
, uint_t
*nelements
);
129 extern int ldi_prop_lookup_string_array(ldi_handle_t lh
,
130 uint_t flags
, char *name
, char ***data
, uint_t
*nelements
);
131 extern int ldi_prop_lookup_string(ldi_handle_t lh
,
132 uint_t flags
, char *name
, char **data
);
133 extern int ldi_prop_lookup_byte_array(ldi_handle_t lh
,
134 uint_t flags
, char *name
, uchar_t
**data
, uint_t
*nelements
);
135 extern int ldi_prop_get_int(ldi_handle_t lh
,
136 uint_t flags
, char *name
, int defvalue
);
137 extern int64_t ldi_prop_get_int64(ldi_handle_t lh
,
138 uint_t flags
, char *name
, int64_t defvalue
);
139 extern int ldi_prop_exists(ldi_handle_t lh
,
140 uint_t flags
, char *name
);
142 extern int ldi_get_dev(ldi_handle_t
, dev_t
*);
143 extern int ldi_get_otyp(ldi_handle_t
, int *);
144 extern int ldi_get_devid(ldi_handle_t
, ddi_devid_t
*);
145 extern int ldi_get_minor_name(ldi_handle_t
, char **);
148 * LDI events related declarations
150 extern int ldi_ev_get_cookie(ldi_handle_t lh
, char *evname
,
151 ldi_ev_cookie_t
*cookiep
);
152 extern char *ldi_ev_get_type(ldi_ev_cookie_t cookie
);
153 extern int ldi_ev_register_callbacks(ldi_handle_t lh
,
154 ldi_ev_cookie_t cookie
, ldi_ev_callback_t
*callb
,
155 void *arg
, ldi_callback_id_t
*id
);
156 extern int ldi_ev_notify(dev_info_t
*dip
, minor_t minor
, int spec_type
,
157 ldi_ev_cookie_t cookie
, void *ev_data
);
158 extern void ldi_ev_finalize(dev_info_t
*dip
, minor_t minor
, int spec_type
,
159 int ldi_result
, ldi_ev_cookie_t cookie
, void *ev_data
);
160 extern int ldi_ev_remove_callbacks(ldi_callback_id_t id
);
168 #endif /* _SYS_SUNLDI_H */