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.
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.
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]
21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 /* All Rights Reserved */
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
34 #include <sys/feature_tests.h>
36 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
37 #include <sys/t_lock.h>
44 #define FMNAMESZ 8 /* used by struct fmodsw */
46 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
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
56 #include <sys/systm.h>
57 #include <sys/devops.h>
58 #include <sys/model.h>
59 #include <sys/types.h>
66 typedef struct fmodsw
{
67 char f_name
[FMNAMESZ
+ 1];
68 struct streamtab
*f_str
;
72 extern struct dev_ops
**devopsp
;
76 * Return streams information for the driver specified by major number or
77 * NULL if device cb_ops structure is not present.
79 #define STREAMSTAB(maj) (devopsp[(maj)] == NULL ? NULL : \
80 (devopsp[(maj)]->devo_cb_ops == NULL ? \
82 devopsp[(maj)]->devo_cb_ops->cb_str))
83 #define CBFLAG(maj) (devopsp[(maj)]->devo_cb_ops->cb_flag)
85 extern int devi_identify(dev_info_t
*);
86 extern int devi_probe(dev_info_t
*);
87 extern int devi_attach(dev_info_t
*, ddi_attach_cmd_t
);
88 extern int devi_detach(dev_info_t
*, ddi_detach_cmd_t
);
89 extern int devi_reset(dev_info_t
*, ddi_reset_cmd_t
);
90 extern int devi_quiesce(dev_info_t
*);
93 * The following [cb]dev_* functions are not part of the DDI, use
94 * <sys/sunldi.h> defined interfaces instead.
96 extern int dev_open(dev_t
*, int, int, cred_t
*);
97 extern int dev_lopen(dev_t
*, int, int, cred_t
*);
98 extern int dev_close(dev_t
, int, int, cred_t
*);
99 extern int dev_lclose(dev_t
, int, int, cred_t
*);
101 extern int dev_to_instance(dev_t
);
103 extern int bdev_strategy(struct buf
*);
104 extern int bdev_print(dev_t
, caddr_t
);
105 extern int bdev_dump(dev_t
, caddr_t
, daddr_t
, int);
106 extern int bdev_size(dev_t
);
107 extern uint64_t bdev_Size(dev_t
);
109 extern int cdev_read(dev_t
, struct uio
*, cred_t
*);
110 extern int cdev_write(dev_t
, struct uio
*, cred_t
*);
111 extern int cdev_size(dev_t
);
112 extern uint64_t cdev_Size(dev_t
);
113 extern int cdev_ioctl(dev_t
, int, intptr_t, int, cred_t
*, int *);
114 extern int cdev_devmap(dev_t dev
, devmap_cookie_t dhp
, offset_t off
,
115 size_t len
, size_t *maplen
, uint_t model
);
116 extern int cdev_mmap(int (*)(dev_t
, off_t
, int),
118 extern int cdev_segmap(dev_t
, off_t
, struct as
*, caddr_t
*,
119 off_t
, uint_t
, uint_t
, uint_t
, cred_t
*);
120 extern int cdev_poll(dev_t
, short, int, short *, struct pollhead
**);
121 extern int cdev_prop_op(dev_t
, dev_info_t
*, ddi_prop_op_t
,
122 int, char *, caddr_t
, int *);
130 * Bit 0 to bit 15 are reserved for kernel.
131 * Bit 16 to bit 31 are reserved for different machines.
134 #define D_NEW 0x00 /* new-style driver */
135 #define _D_OLD 0x01 /* old-style driver (obsolete) */
136 #define D_TAPE 0x08 /* Magtape device (no bdwrite when cooked) */
139 * MT-safety level (in DDI portion of flags).
141 * All drivers must be MT-safe, and must advertise this by specifying D_MP.
143 * The remainder of the flags apply only to STREAMS modules and drivers.
145 * A STREAMS driver or module can optionally select inner and outer perimeters.
146 * The four mutually exclusive options that define the presence and scope
147 * of the inner perimeter are:
148 * D_MTPERMOD - per module single threaded.
149 * D_MTQPAIR - per queue-pair single threaded.
150 * D_MTPERQ - per queue instance single threaded.
151 * (none of the above) - no inner perimeter restricting concurrency
153 * The presence of the outer perimeter is declared with:
154 * D_MTOUTPERIM - a per-module outer perimeter. Can be combined with
155 * D_MTPERQ, D_MTQPAIR, and D_MP.
157 * The concurrency when entering the different STREAMS entry points can be
159 * D_MTPUTSHARED - modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD
160 * specifying that the put procedures should not be
161 * single-threaded at the inner perimeter.
162 * _D_MTOCSHARED - EXPERIMENTAL - will be removed in a future release.
163 * Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD
164 * specifying that the open and close procedures should not be
165 * single-threaded at the inner perimeter.
166 * _D_MTCBSHARED - EXPERIMENTAL - will be removed in a future release.
167 * Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD
168 * specifying that the callback i.e qtimeout() procedures should
169 * not be single-threaded at the inner perimeter.
170 * _D_MTSVCSHARED - EXPERIMENTAL - will be removed in a future release.
171 * Modifier for D_MTPERMOD only. Specifies that the service
172 * procedure should not be single-threaded at the inner perimeter.
173 * However only a single instance of the service thread can run on
175 * D_MTOCEXCL - modifier for D_MTOUTPERIM specifying that the open and
176 * close procedures should be single-threaded at the outer
179 #define D_MTSAFE 0x0020 /* multi-threaded module or driver */
180 #define _D_QNEXTLESS 0x0040 /* Unused, retained for source compatibility */
181 #define _D_MTOCSHARED 0x0080 /* modify: open/close procedures are hot */
182 /* 0x100 - see below */
183 /* 0x200 - see below */
184 /* 0x400 - see below */
185 #define D_MTOCEXCL 0x0800 /* modify: open/close are exclusive at outer */
186 #define D_MTPUTSHARED 0x1000 /* modify: put procedures are hot */
187 #define D_MTPERQ 0x2000 /* per queue instance single-threaded */
188 #define D_MTQPAIR 0x4000 /* per queue-pair instance single-threaded */
189 #define D_MTPERMOD 0x6000 /* per module single-threaded */
190 #define D_MTOUTPERIM 0x8000 /* r/w outer perimeter around whole modules */
191 #define _D_MTCBSHARED 0x10000 /* modify : callback procedures are hot */
192 #define _D_MTSVCSHARED 0x20000 /* modify : service procedures are hot */
194 /* The inner perimeter scope bits */
195 #define D_MTINNER_MASK (D_MP|D_MTPERQ|D_MTQPAIR|D_MTPERMOD)
197 /* Inner perimeter modification bits */
198 #define D_MTINNER_MOD (D_MTPUTSHARED|_D_MTOCSHARED|_D_MTCBSHARED| \
201 /* Outer perimeter modification bits */
202 #define D_MTOUTER_MOD (D_MTOCEXCL)
204 /* All the MT flags */
205 #define D_MTSAFETY_MASK (D_MTINNER_MASK|D_MTOUTPERIM|D_MTPUTSHARED|\
206 D_MTINNER_MOD|D_MTOUTER_MOD)
208 #define D_MP D_MTSAFE /* ddi/dki approved flag */
210 #define D_64BIT 0x200 /* Driver supports 64-bit offsets, blk nos. */
212 #define D_SYNCSTR 0x400 /* Module or driver has Synchronous STREAMS */
213 /* extended qinit structure */
215 #define D_DEVMAP 0x100 /* Use devmap framework to mmap device */
217 #define D_HOTPLUG 0x4 /* Driver is hotplug capable */
219 #define D_U64BIT 0x40000 /* Driver supports unsigned 64-bit uio offset */
221 #define _D_DIRECT 0x80000 /* Private flag for transport modules */
223 #define D_OPEN_RETURNS_EINTR 0x100000 /* EINTR expected from open(9E) */
225 #define _D_SINGLE_INSTANCE 0x200000 /* Module may only be pushed once */
227 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
233 #endif /* _SYS_CONF_H */