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