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