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