xref: /titanic_44/usr/src/uts/common/sys/sunldi.h (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SUNLDI_H
28 #define	_SYS_SUNLDI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/modctl.h>
33 #include <sys/stream.h>
34 #include <sys/open.h>
35 
36 /*
37  * DDI interfaces for Layered driver support.
38  */
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 #ifdef	_KERNEL
45 
46 
47 /*
48  * Opaque layered driver data structures.
49  *
50  * The contents of these data structures are private to this
51  * implementation of Solaris and are subject to change at any
52  * time without notice.
53  *
54  * Applications and drivers accessing the contents of these structures
55  * directly will fail to run on future releases.
56  */
57 typedef struct __ldi_ident		*ldi_ident_t;
58 
59 typedef struct __ldi_handle		*ldi_handle_t;
60 
61 typedef struct __ldi_callback_id	*ldi_callback_id_t;
62 
63 /*
64  * LDI Ident manipulation functions
65  */
66 extern ldi_ident_t ldi_ident_from_anon(void);
67 
68 extern int ldi_ident_from_mod(struct modlinkage *, ldi_ident_t *);
69 extern int ldi_ident_from_major(major_t major, ldi_ident_t *);
70 extern int ldi_ident_from_dip(dev_info_t *dip, ldi_ident_t *);
71 extern int ldi_ident_from_dev(dev_t, ldi_ident_t *);
72 extern int ldi_ident_from_stream(struct queue *, ldi_ident_t *);
73 extern void ldi_ident_release(ldi_ident_t);
74 
75 
76 /*
77  * LDI Handle manipulation functions
78  */
79 extern int ldi_open_by_dev(dev_t *, int, int, cred_t *,
80     ldi_handle_t *, ldi_ident_t);
81 extern int ldi_open_by_name(char *, int, cred_t *,
82     ldi_handle_t *, ldi_ident_t);
83 extern int ldi_open_by_devid(ddi_devid_t, char *, int, cred_t *,
84     ldi_handle_t *, ldi_ident_t);
85 
86 extern int ldi_close(ldi_handle_t, int flag, cred_t *);
87 
88 extern int ldi_read(ldi_handle_t, struct uio *, cred_t *);
89 extern int ldi_write(ldi_handle_t, struct uio *, cred_t *);
90 extern int ldi_ioctl(ldi_handle_t, int, intptr_t, int, cred_t *, int *);
91 extern int ldi_poll(ldi_handle_t, short, int, short *, struct pollhead **);
92 extern int ldi_get_size(ldi_handle_t, uint64_t *);
93 extern int ldi_prop_op(ldi_handle_t, ddi_prop_op_t, int,
94     char *, caddr_t, int *);
95 
96 extern int ldi_get_eventcookie(ldi_handle_t, char *,
97     ddi_eventcookie_t *);
98 extern int ldi_add_event_handler(ldi_handle_t, ddi_eventcookie_t,
99     void (*handler)(ldi_handle_t, ddi_eventcookie_t, void *, void *),
100     void *, ldi_callback_id_t *);
101 extern int ldi_remove_event_handler(ldi_handle_t, ldi_callback_id_t);
102 
103 extern int ldi_strategy(ldi_handle_t, struct buf *);
104 extern int ldi_dump(ldi_handle_t, caddr_t, daddr_t, int);
105 extern int ldi_devmap(ldi_handle_t, devmap_cookie_t, offset_t,
106     size_t, size_t *, uint_t);
107 extern int ldi_aread(ldi_handle_t, struct aio_req *, cred_t *);
108 extern int ldi_awrite(ldi_handle_t, struct aio_req *, cred_t *);
109 
110 extern int ldi_putmsg(ldi_handle_t, mblk_t *);
111 extern int ldi_getmsg(ldi_handle_t, mblk_t **, timestruc_t *);
112 
113 extern int ldi_prop_lookup_int_array(ldi_handle_t lh,
114     uint_t flags, char *name, int **data, uint_t *nelements);
115 extern int ldi_prop_lookup_int64_array(ldi_handle_t lh,
116     uint_t flags, char *name, int64_t **data, uint_t *nelements);
117 extern int ldi_prop_lookup_string_array(ldi_handle_t lh,
118     uint_t flags, char *name, char ***data, uint_t *nelements);
119 extern int ldi_prop_lookup_string(ldi_handle_t lh,
120     uint_t flags, char *name, char **data);
121 extern int ldi_prop_lookup_byte_array(ldi_handle_t lh,
122     uint_t flags, char *name, uchar_t **data, uint_t *nelements);
123 extern int ldi_prop_get_int(ldi_handle_t lh,
124     uint_t flags, char *name, int defvalue);
125 extern int64_t ldi_prop_get_int64(ldi_handle_t lh,
126     uint_t flags, char *name, int64_t defvalue);
127 extern int ldi_prop_exists(ldi_handle_t lh,
128     uint_t flags, char *name);
129 
130 extern int ldi_get_dev(ldi_handle_t, dev_t *);
131 extern int ldi_get_otyp(ldi_handle_t, int *);
132 extern int ldi_get_devid(ldi_handle_t, ddi_devid_t *);
133 extern int ldi_get_minor_name(ldi_handle_t, char **);
134 
135 
136 #endif	/* _KERNEL */
137 
138 #ifdef	__cplusplus
139 }
140 #endif
141 
142 #endif	/* _SYS_SUNLDI_H */
143