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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 22 /* All Rights Reserved */ 23 24 /* 25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. 28 */ 29 30 #ifndef _SYS_CONF_H 31 #define _SYS_CONF_H 32 33 34 #include <sys/feature_tests.h> 35 36 #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 37 #include <sys/t_lock.h> 38 #endif 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #define FMNAMESZ 8 /* used by struct fmodsw */ 45 46 #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 47 48 #ifdef _KERNEL 49 50 /* 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 55 */ 56 #include <sys/systm.h> 57 #include <sys/devops.h> 58 #include <sys/model.h> 59 #include <sys/types.h> 60 #include <sys/buf.h> 61 #include <sys/cred.h> 62 #include <sys/uio.h> 63 #include <sys/poll.h> 64 #include <vm/as.h> 65 66 typedef struct fmodsw { 67 char f_name[FMNAMESZ + 1]; 68 struct streamtab *f_str; 69 int f_flag; 70 } fmodsw_t; 71 72 extern struct dev_ops **devopsp; 73 extern int devcnt; 74 75 /* 76 * Return streams information for the driver specified by major number or 77 * NULL if device cb_ops structure is not present. 78 */ 79 #define STREAMSTAB(maj) (devopsp[(maj)] == NULL ? NULL : \ 80 (devopsp[(maj)]->devo_cb_ops == NULL ? \ 81 NULL : \ 82 devopsp[(maj)]->devo_cb_ops->cb_str)) 83 #define CBFLAG(maj) (devopsp[(maj)]->devo_cb_ops->cb_flag) 84 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 *); 91 92 /* 93 * The following [cb]dev_* functions are not part of the DDI, use 94 * <sys/sunldi.h> defined interfaces instead. 95 */ 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 *); 100 101 extern int dev_to_instance(dev_t); 102 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); 108 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), 117 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 *); 123 124 #endif /* _KERNEL */ 125 126 127 /* 128 * Device flags. 129 * 130 * Bit 0 to bit 15 are reserved for kernel. 131 * Bit 16 to bit 31 are reserved for different machines. 132 */ 133 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) */ 137 138 /* 139 * MT-safety level (in DDI portion of flags). 140 * 141 * All drivers must be MT-safe, and must advertise this by specifying D_MP. 142 * 143 * The remainder of the flags apply only to STREAMS modules and drivers. 144 * 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 152 * 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. 156 * 157 * The concurrency when entering the different STREAMS entry points can be 158 * modified with: 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 174 * any given queue. 175 * D_MTOCEXCL - modifier for D_MTOUTPERIM specifying that the open and 176 * close procedures should be single-threaded at the outer 177 * perimeter. 178 */ 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 */ 193 194 /* The inner perimeter scope bits */ 195 #define D_MTINNER_MASK (D_MP|D_MTPERQ|D_MTQPAIR|D_MTPERMOD) 196 197 /* Inner perimeter modification bits */ 198 #define D_MTINNER_MOD (D_MTPUTSHARED|_D_MTOCSHARED|_D_MTCBSHARED| \ 199 _D_MTSVCSHARED) 200 201 /* Outer perimeter modification bits */ 202 #define D_MTOUTER_MOD (D_MTOCEXCL) 203 204 /* All the MT flags */ 205 #define D_MTSAFETY_MASK (D_MTINNER_MASK|D_MTOUTPERIM|D_MTPUTSHARED|\ 206 D_MTINNER_MOD|D_MTOUTER_MOD) 207 208 #define D_MP D_MTSAFE /* ddi/dki approved flag */ 209 210 #define D_64BIT 0x200 /* Driver supports 64-bit offsets, blk nos. */ 211 212 #define D_SYNCSTR 0x400 /* Module or driver has Synchronous STREAMS */ 213 /* extended qinit structure */ 214 215 #define D_DEVMAP 0x100 /* Use devmap framework to mmap device */ 216 217 #define D_HOTPLUG 0x4 /* Driver is hotplug capable */ 218 219 #define D_U64BIT 0x40000 /* Driver supports unsigned 64-bit uio offset */ 220 221 #define _D_DIRECT 0x80000 /* Private flag for transport modules */ 222 223 #define D_OPEN_RETURNS_EINTR 0x100000 /* EINTR expected from open(9E) */ 224 225 #define _D_SINGLE_INSTANCE 0x200000 /* Module may only be pushed once */ 226 227 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 228 229 #ifdef __cplusplus 230 } 231 #endif 232 233 #endif /* _SYS_CONF_H */ 234