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