xref: /illumos-gate/usr/src/uts/common/sys/conf.h (revision 5422785d352a2bb398daceab3d1898a8aa64d006)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
22 /*	  All Rights Reserved  	*/
23 
24 /*
25  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 #ifndef _SYS_CONF_H
30 #define	_SYS_CONF_H
31 
32 
33 #include <sys/feature_tests.h>
34 
35 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
36 #include <sys/t_lock.h>
37 #endif
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 #define	FMNAMESZ	8 		/* used by struct fmodsw */
44 
45 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
46 
47 #ifdef _KERNEL
48 
49 /*
50  * XXX  Given that drivers need to include this file,
51  *	<sys/systm.h> probably shouldn't be here, as
52  *	it legitimizes (aka provides prototypes for)
53  *	all sorts of functions that aren't in the DKI/SunDDI
54  */
55 #include <sys/systm.h>
56 #include <sys/devops.h>
57 #include <sys/model.h>
58 #include <sys/types.h>
59 #include <sys/buf.h>
60 #include <sys/cred.h>
61 #include <sys/uio.h>
62 #include <sys/poll.h>
63 #include <vm/as.h>
64 
65 typedef struct fmodsw {
66 	char			f_name[FMNAMESZ + 1];
67 	struct streamtab	*f_str;
68 	int			f_flag;
69 } fmodsw_t;
70 
71 extern struct dev_ops **devopsp;
72 extern int devcnt;
73 
74 /*
75  * Return streams information for the driver specified by major number or
76  *   NULL if device cb_ops structure is not present.
77  */
78 #define	STREAMSTAB(maj)	(devopsp[(maj)] == NULL ? NULL : \
79 	(devopsp[(maj)]->devo_cb_ops == NULL ? \
80 	NULL : \
81 	devopsp[(maj)]->devo_cb_ops->cb_str))
82 #define	CBFLAG(maj)	(devopsp[(maj)]->devo_cb_ops->cb_flag)
83 
84 extern int devi_identify(dev_info_t *);
85 extern int devi_probe(dev_info_t *);
86 extern int devi_attach(dev_info_t *, ddi_attach_cmd_t);
87 extern int devi_detach(dev_info_t *, ddi_detach_cmd_t);
88 extern int devi_reset(dev_info_t *, ddi_reset_cmd_t);
89 extern int devi_quiesce(dev_info_t *);
90 
91 /*
92  * The following [cb]dev_* functions are not part of the DDI, use
93  * <sys/sunldi.h> defined interfaces instead.
94  */
95 extern int dev_open(dev_t *, int, int, cred_t *);
96 extern int dev_lopen(dev_t *, int, int, cred_t *);
97 extern int dev_close(dev_t, int, int, cred_t *);
98 extern int dev_lclose(dev_t, int, int, cred_t *);
99 
100 extern int dev_to_instance(dev_t);
101 
102 extern int bdev_strategy(struct buf *);
103 extern int bdev_print(dev_t, caddr_t);
104 extern int bdev_dump(dev_t, caddr_t, daddr_t, int);
105 extern int bdev_size(dev_t);
106 extern uint64_t bdev_Size(dev_t);
107 
108 extern int cdev_read(dev_t, struct uio *, cred_t *);
109 extern int cdev_write(dev_t, struct uio *, cred_t *);
110 extern int cdev_size(dev_t);
111 extern uint64_t cdev_Size(dev_t);
112 extern int cdev_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
113 extern int cdev_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off,
114 	size_t len, size_t *maplen, uint_t model);
115 extern int cdev_mmap(int (*)(dev_t, off_t, int),
116     dev_t, off_t, int);
117 extern int cdev_segmap(dev_t, off_t, struct as *, caddr_t *,
118     off_t, uint_t, uint_t, uint_t, cred_t *);
119 extern int cdev_poll(dev_t, short, int, short *, struct pollhead **);
120 extern int cdev_prop_op(dev_t, dev_info_t *, ddi_prop_op_t,
121     int, char *, caddr_t, int *);
122 
123 #endif /* _KERNEL */
124 
125 
126 /*
127  * Device flags.
128  *
129  * Bit 0 to bit 15 are reserved for kernel.
130  * Bit 16 to bit 31 are reserved for different machines.
131  */
132 
133 #define	D_NEW		0x00	/* new-style driver */
134 #define	_D_OLD		0x01	/* old-style driver (obsolete) */
135 #define	D_TAPE		0x08	/* Magtape device (no bdwrite when cooked) */
136 
137 /*
138  * MT-safety level (in DDI portion of flags).
139  *
140  * All drivers must be MT-safe, and must advertise this by specifying D_MP.
141  *
142  * The remainder of the flags apply only to STREAMS modules and drivers.
143  *
144  * A STREAMS driver or module can optionally select inner and outer perimeters.
145  * The four mutually exclusive options that define the presence and scope
146  * of the inner perimeter are:
147  *	D_MTPERMOD - per module single threaded.
148  *	D_MTQPAIR - per queue-pair single threaded.
149  *	D_MTPERQ - per queue instance single threaded.
150  *	(none of the above) - no inner perimeter restricting concurrency
151  *
152  * The presence	of the outer perimeter is declared with:
153  *	D_MTOUTPERIM - a per-module outer perimeter. Can be combined with
154  *		D_MTPERQ, D_MTQPAIR, and D_MP.
155  *
156  * The concurrency when entering the different STREAMS entry points can be
157  * modified with:
158  *	D_MTPUTSHARED - modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD
159  *		specifying that the put procedures should not be
160  *		single-threaded at the inner perimeter.
161  *	_D_MTOCSHARED - EXPERIMENTAL - will be removed in a future release.
162  *		Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD
163  *		specifying that the open and close procedures should not be
164  *		single-threaded at the inner perimeter.
165  *	_D_MTCBSHARED - EXPERIMENTAL - will be removed in a future release.
166  *		Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD
167  *		specifying that the callback i.e qtimeout() procedures should
168  *		not be single-threaded at the inner perimeter.
169  *	_D_MTSVCSHARED - EXPERIMENTAL - will be removed in a future release.
170  *		Modifier for D_MTPERMOD only. Specifies that the service
171  *		procedure should not be single-threaded at the inner perimeter.
172  *		However only a single instance of the service thread can run on
173  *		any given queue.
174  *	D_MTOCEXCL - modifier for D_MTOUTPERIM specifying that the open and
175  *		close procedures should be single-threaded at the outer
176  *		perimeter.
177  */
178 #define	D_MTSAFE	0x0020	/* multi-threaded module or driver */
179 #define	_D_QNEXTLESS	0x0040	/* Unused, retained for source compatibility */
180 #define	_D_MTOCSHARED	0x0080	/* modify: open/close procedures are hot */
181 /* 0x100 - see below */
182 /* 0x200 - see below */
183 /* 0x400 - see below */
184 #define	D_MTOCEXCL	0x0800	/* modify: open/close are exclusive at outer */
185 #define	D_MTPUTSHARED	0x1000	/* modify: put procedures are hot */
186 #define	D_MTPERQ	0x2000	/* per queue instance single-threaded */
187 #define	D_MTQPAIR	0x4000	/* per queue-pair instance single-threaded */
188 #define	D_MTPERMOD	0x6000	/* per module single-threaded */
189 #define	D_MTOUTPERIM	0x8000	/* r/w outer perimeter around whole modules */
190 #define	_D_MTCBSHARED	0x10000	/* modify : callback procedures are hot */
191 #define	_D_MTSVCSHARED	0x20000	/* modify : service procedures are hot */
192 
193 /* The inner perimeter scope bits */
194 #define	D_MTINNER_MASK	(D_MP|D_MTPERQ|D_MTQPAIR|D_MTPERMOD)
195 
196 /* Inner perimeter modification bits */
197 #define	D_MTINNER_MOD	(D_MTPUTSHARED|_D_MTOCSHARED|_D_MTCBSHARED| \
198     _D_MTSVCSHARED)
199 
200 /* Outer perimeter modification bits */
201 #define	D_MTOUTER_MOD	(D_MTOCEXCL)
202 
203 /* All the MT flags */
204 #define	D_MTSAFETY_MASK (D_MTINNER_MASK|D_MTOUTPERIM|D_MTPUTSHARED|\
205 			D_MTINNER_MOD|D_MTOUTER_MOD)
206 
207 #define	D_MP		D_MTSAFE /* ddi/dki approved flag */
208 
209 #define	D_64BIT		0x200	/* Driver supports 64-bit offsets, blk nos. */
210 
211 #define	D_SYNCSTR	0x400	/* Module or driver has Synchronous STREAMS */
212 				/* extended qinit structure */
213 
214 #define	D_DEVMAP	0x100	/* Use devmap framework to mmap device */
215 
216 #define	D_HOTPLUG	0x4	/* Driver is hotplug capable */
217 
218 #define	D_U64BIT	0x40000	/* Driver supports unsigned 64-bit uio offset */
219 
220 #define	_D_DIRECT	0x80000	/* Private flag for transport modules */
221 
222 #define	D_OPEN_RETURNS_EINTR	0x100000 /* EINTR expected from open(9E) */
223 
224 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
225 
226 #ifdef	__cplusplus
227 }
228 #endif
229 
230 #endif	/* _SYS_CONF_H */
231