xref: /onnv-gate/usr/src/uts/common/sys/conf.h (revision 9491:2a8ac51063ac)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
54452Scth  * Common Development and Distribution License (the "License").
64452Scth  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
220Sstevel@tonic-gate /*	  All Rights Reserved  	*/
230Sstevel@tonic-gate 
240Sstevel@tonic-gate /*
25*9491SAnders.Persson@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
260Sstevel@tonic-gate  * Use is subject to license terms.
270Sstevel@tonic-gate  */
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifndef _SYS_CONF_H
300Sstevel@tonic-gate #define	_SYS_CONF_H
310Sstevel@tonic-gate 
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <sys/feature_tests.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
360Sstevel@tonic-gate #include <sys/t_lock.h>
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifdef	__cplusplus
400Sstevel@tonic-gate extern "C" {
410Sstevel@tonic-gate #endif
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #define	FMNAMESZ	8 		/* used by struct fmodsw */
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
460Sstevel@tonic-gate 
470Sstevel@tonic-gate #ifdef _KERNEL
480Sstevel@tonic-gate 
490Sstevel@tonic-gate /*
500Sstevel@tonic-gate  * XXX  Given that drivers need to include this file,
510Sstevel@tonic-gate  *	<sys/systm.h> probably shouldn't be here, as
520Sstevel@tonic-gate  *	it legitimizes (aka provides prototypes for)
530Sstevel@tonic-gate  *	all sorts of functions that aren't in the DKI/SunDDI
540Sstevel@tonic-gate  */
550Sstevel@tonic-gate #include <sys/systm.h>
560Sstevel@tonic-gate #include <sys/devops.h>
570Sstevel@tonic-gate #include <sys/model.h>
580Sstevel@tonic-gate #include <sys/types.h>
590Sstevel@tonic-gate #include <sys/buf.h>
600Sstevel@tonic-gate #include <sys/cred.h>
610Sstevel@tonic-gate #include <sys/uio.h>
620Sstevel@tonic-gate #include <sys/poll.h>
630Sstevel@tonic-gate #include <vm/as.h>
640Sstevel@tonic-gate 
650Sstevel@tonic-gate typedef struct fmodsw {
660Sstevel@tonic-gate 	char			f_name[FMNAMESZ + 1];
670Sstevel@tonic-gate 	struct streamtab	*f_str;
680Sstevel@tonic-gate 	int			f_flag;
690Sstevel@tonic-gate } fmodsw_t;
700Sstevel@tonic-gate 
710Sstevel@tonic-gate extern struct dev_ops **devopsp;
720Sstevel@tonic-gate extern int devcnt;
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /*
750Sstevel@tonic-gate  * Return streams information for the driver specified by major number or
760Sstevel@tonic-gate  *   NULL if device cb_ops structure is not present.
770Sstevel@tonic-gate  */
780Sstevel@tonic-gate #define	STREAMSTAB(maj)	(devopsp[(maj)] == NULL ? NULL : \
790Sstevel@tonic-gate 	(devopsp[(maj)]->devo_cb_ops == NULL ? \
800Sstevel@tonic-gate 	NULL : \
810Sstevel@tonic-gate 	devopsp[(maj)]->devo_cb_ops->cb_str))
820Sstevel@tonic-gate #define	CBFLAG(maj)	(devopsp[(maj)]->devo_cb_ops->cb_flag)
830Sstevel@tonic-gate 
840Sstevel@tonic-gate extern int devi_identify(dev_info_t *);
850Sstevel@tonic-gate extern int devi_probe(dev_info_t *);
860Sstevel@tonic-gate extern int devi_attach(dev_info_t *, ddi_attach_cmd_t);
870Sstevel@tonic-gate extern int devi_detach(dev_info_t *, ddi_detach_cmd_t);
880Sstevel@tonic-gate extern int devi_reset(dev_info_t *, ddi_reset_cmd_t);
897656SSherry.Moore@Sun.COM extern int devi_quiesce(dev_info_t *);
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  * The following [cb]dev_* functions are not part of the DDI, use
930Sstevel@tonic-gate  * <sys/sunldi.h> defined interfaces instead.
940Sstevel@tonic-gate  */
950Sstevel@tonic-gate extern int dev_open(dev_t *, int, int, cred_t *);
960Sstevel@tonic-gate extern int dev_lopen(dev_t *, int, int, cred_t *);
970Sstevel@tonic-gate extern int dev_close(dev_t, int, int, cred_t *);
980Sstevel@tonic-gate extern int dev_lclose(dev_t, int, int, cred_t *);
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate extern int dev_to_instance(dev_t);
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate extern int bdev_strategy(struct buf *);
1030Sstevel@tonic-gate extern int bdev_print(dev_t, caddr_t);
1040Sstevel@tonic-gate extern int bdev_dump(dev_t, caddr_t, daddr_t, int);
1050Sstevel@tonic-gate extern int bdev_size(dev_t);
1060Sstevel@tonic-gate extern uint64_t bdev_Size(dev_t);
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate extern int cdev_read(dev_t, struct uio *, cred_t *);
1090Sstevel@tonic-gate extern int cdev_write(dev_t, struct uio *, cred_t *);
1100Sstevel@tonic-gate extern int cdev_size(dev_t);
1110Sstevel@tonic-gate extern uint64_t cdev_Size(dev_t);
1120Sstevel@tonic-gate extern int cdev_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
1130Sstevel@tonic-gate extern int cdev_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off,
1140Sstevel@tonic-gate 	size_t len, size_t *maplen, uint_t model);
1150Sstevel@tonic-gate extern int cdev_mmap(int (*)(dev_t, off_t, int),
1160Sstevel@tonic-gate     dev_t, off_t, int);
1170Sstevel@tonic-gate extern int cdev_segmap(dev_t, off_t, struct as *, caddr_t *,
1180Sstevel@tonic-gate     off_t, uint_t, uint_t, uint_t, cred_t *);
1190Sstevel@tonic-gate extern int cdev_poll(dev_t, short, int, short *, struct pollhead **);
1200Sstevel@tonic-gate extern int cdev_prop_op(dev_t, dev_info_t *, ddi_prop_op_t,
1210Sstevel@tonic-gate     int, char *, caddr_t, int *);
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate #endif /* _KERNEL */
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate /*
1270Sstevel@tonic-gate  * Device flags.
1280Sstevel@tonic-gate  *
1290Sstevel@tonic-gate  * Bit 0 to bit 15 are reserved for kernel.
1300Sstevel@tonic-gate  * Bit 16 to bit 31 are reserved for different machines.
1310Sstevel@tonic-gate  */
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate #define	D_NEW		0x00	/* new-style driver */
1340Sstevel@tonic-gate #define	_D_OLD		0x01	/* old-style driver (obsolete) */
1350Sstevel@tonic-gate #define	D_TAPE		0x08	/* Magtape device (no bdwrite when cooked) */
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate /*
1380Sstevel@tonic-gate  * MT-safety level (in DDI portion of flags).
1390Sstevel@tonic-gate  *
1400Sstevel@tonic-gate  * All drivers must be MT-safe, and must advertise this by specifying D_MP.
1410Sstevel@tonic-gate  *
1420Sstevel@tonic-gate  * The remainder of the flags apply only to STREAMS modules and drivers.
1430Sstevel@tonic-gate  *
1440Sstevel@tonic-gate  * A STREAMS driver or module can optionally select inner and outer perimeters.
1450Sstevel@tonic-gate  * The four mutually exclusive options that define the presence and scope
1460Sstevel@tonic-gate  * of the inner perimeter are:
1470Sstevel@tonic-gate  *	D_MTPERMOD - per module single threaded.
1480Sstevel@tonic-gate  *	D_MTQPAIR - per queue-pair single threaded.
1490Sstevel@tonic-gate  *	D_MTPERQ - per queue instance single threaded.
1500Sstevel@tonic-gate  *	(none of the above) - no inner perimeter restricting concurrency
1510Sstevel@tonic-gate  *
1520Sstevel@tonic-gate  * The presence	of the outer perimeter is declared with:
1530Sstevel@tonic-gate  *	D_MTOUTPERIM - a per-module outer perimeter. Can be combined with
1540Sstevel@tonic-gate  *		D_MTPERQ, D_MTQPAIR, and D_MP.
1550Sstevel@tonic-gate  *
1560Sstevel@tonic-gate  * The concurrency when entering the different STREAMS entry points can be
1570Sstevel@tonic-gate  * modified with:
1580Sstevel@tonic-gate  *	D_MTPUTSHARED - modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD
1590Sstevel@tonic-gate  *		specifying that the put procedures should not be
1600Sstevel@tonic-gate  *		single-threaded at the inner perimeter.
1610Sstevel@tonic-gate  *	_D_MTOCSHARED - EXPERIMENTAL - will be removed in a future release.
1620Sstevel@tonic-gate  *		Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD
1630Sstevel@tonic-gate  *		specifying that the open and close procedures should not be
1640Sstevel@tonic-gate  *		single-threaded at the inner perimeter.
1650Sstevel@tonic-gate  *	_D_MTCBSHARED - EXPERIMENTAL - will be removed in a future release.
1660Sstevel@tonic-gate  *		Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD
1670Sstevel@tonic-gate  *		specifying that the callback i.e qtimeout() procedures should
1680Sstevel@tonic-gate  *		not be single-threaded at the inner perimeter.
1690Sstevel@tonic-gate  *	_D_MTSVCSHARED - EXPERIMENTAL - will be removed in a future release.
1700Sstevel@tonic-gate  *		Modifier for D_MTPERMOD only. Specifies that the service
1710Sstevel@tonic-gate  *		procedure should not be single-threaded at the inner perimeter.
1720Sstevel@tonic-gate  *		However only a single instance of the service thread can run on
1730Sstevel@tonic-gate  *		any given queue.
1740Sstevel@tonic-gate  *	D_MTOCEXCL - modifier for D_MTOUTPERIM specifying that the open and
1750Sstevel@tonic-gate  *		close procedures should be single-threaded at the outer
1760Sstevel@tonic-gate  *		perimeter.
1770Sstevel@tonic-gate  */
1780Sstevel@tonic-gate #define	D_MTSAFE	0x0020	/* multi-threaded module or driver */
1790Sstevel@tonic-gate #define	_D_QNEXTLESS	0x0040	/* Unused, retained for source compatibility */
1800Sstevel@tonic-gate #define	_D_MTOCSHARED	0x0080	/* modify: open/close procedures are hot */
1810Sstevel@tonic-gate /* 0x100 - see below */
1820Sstevel@tonic-gate /* 0x200 - see below */
1830Sstevel@tonic-gate /* 0x400 - see below */
1840Sstevel@tonic-gate #define	D_MTOCEXCL	0x0800	/* modify: open/close are exclusive at outer */
1850Sstevel@tonic-gate #define	D_MTPUTSHARED	0x1000	/* modify: put procedures are hot */
1860Sstevel@tonic-gate #define	D_MTPERQ	0x2000	/* per queue instance single-threaded */
1870Sstevel@tonic-gate #define	D_MTQPAIR	0x4000	/* per queue-pair instance single-threaded */
1880Sstevel@tonic-gate #define	D_MTPERMOD	0x6000	/* per module single-threaded */
1890Sstevel@tonic-gate #define	D_MTOUTPERIM	0x8000	/* r/w outer perimeter around whole modules */
1900Sstevel@tonic-gate #define	_D_MTCBSHARED	0x10000	/* modify : callback procedures are hot */
1910Sstevel@tonic-gate #define	_D_MTSVCSHARED	0x20000	/* modify : service procedures are hot */
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate /* The inner perimeter scope bits */
1940Sstevel@tonic-gate #define	D_MTINNER_MASK	(D_MP|D_MTPERQ|D_MTQPAIR|D_MTPERMOD)
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate /* Inner perimeter modification bits */
1970Sstevel@tonic-gate #define	D_MTINNER_MOD	(D_MTPUTSHARED|_D_MTOCSHARED|_D_MTCBSHARED| \
1980Sstevel@tonic-gate     _D_MTSVCSHARED)
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate /* Outer perimeter modification bits */
2010Sstevel@tonic-gate #define	D_MTOUTER_MOD	(D_MTOCEXCL)
2020Sstevel@tonic-gate 
2030Sstevel@tonic-gate /* All the MT flags */
2040Sstevel@tonic-gate #define	D_MTSAFETY_MASK (D_MTINNER_MASK|D_MTOUTPERIM|D_MTPUTSHARED|\
2050Sstevel@tonic-gate 			D_MTINNER_MOD|D_MTOUTER_MOD)
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate #define	D_MP		D_MTSAFE /* ddi/dki approved flag */
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate #define	D_64BIT		0x200	/* Driver supports 64-bit offsets, blk nos. */
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate #define	D_SYNCSTR	0x400	/* Module or driver has Synchronous STREAMS */
2120Sstevel@tonic-gate 				/* extended qinit structure */
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate #define	D_DEVMAP	0x100	/* Use devmap framework to mmap device */
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate #define	D_HOTPLUG	0x4	/* Driver is hotplug capable */
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate #define	D_U64BIT	0x40000	/* Driver supports unsigned 64-bit uio offset */
2190Sstevel@tonic-gate 
220741Smasputra #define	_D_DIRECT	0x80000	/* Private flag for transport modules */
221741Smasputra 
2224452Scth #define	D_OPEN_RETURNS_EINTR	0x100000 /* EINTR expected from open(9E) */
2234452Scth 
2240Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
2250Sstevel@tonic-gate 
2260Sstevel@tonic-gate #ifdef	__cplusplus
2270Sstevel@tonic-gate }
2280Sstevel@tonic-gate #endif
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate #endif	/* _SYS_CONF_H */
231