17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5e099bf07Scth * Common Development and Distribution License (the "License"). 6e099bf07Scth * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 22b4203d75SMarcel Telka /* All Rights Reserved */ 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate /* 25bbc000e5SAnders Persson * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 267c478bd9Sstevel@tonic-gate * Use is subject to license terms. 276cfa0a70SAndy Fiddaman * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifndef _SYS_CONF_H 317c478bd9Sstevel@tonic-gate #define _SYS_CONF_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 377c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 417c478bd9Sstevel@tonic-gate extern "C" { 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 44*8329232eSGordon Ross #define FMNAMESZ 8 /* used by struct fmodsw */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 477c478bd9Sstevel@tonic-gate 48*8329232eSGordon Ross #if defined(_KERNEL) || defined(_FAKE_KERNEL) 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * XXX Given that drivers need to include this file, 527c478bd9Sstevel@tonic-gate * <sys/systm.h> probably shouldn't be here, as 537c478bd9Sstevel@tonic-gate * it legitimizes (aka provides prototypes for) 547c478bd9Sstevel@tonic-gate * all sorts of functions that aren't in the DKI/SunDDI 557c478bd9Sstevel@tonic-gate */ 56*8329232eSGordon Ross #include <sys/types.h> 577c478bd9Sstevel@tonic-gate #include <sys/systm.h> 58*8329232eSGordon Ross 59*8329232eSGordon Ross #endif /* _KERNEL || _FAKE_KERNEL */ 60*8329232eSGordon Ross #ifdef _KERNEL 61*8329232eSGordon Ross 627c478bd9Sstevel@tonic-gate #include <sys/devops.h> 637c478bd9Sstevel@tonic-gate #include <sys/model.h> 647c478bd9Sstevel@tonic-gate #include <sys/buf.h> 657c478bd9Sstevel@tonic-gate #include <sys/cred.h> 667c478bd9Sstevel@tonic-gate #include <sys/uio.h> 677c478bd9Sstevel@tonic-gate #include <sys/poll.h> 687c478bd9Sstevel@tonic-gate #include <vm/as.h> 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate typedef struct fmodsw { 717c478bd9Sstevel@tonic-gate char f_name[FMNAMESZ + 1]; 727c478bd9Sstevel@tonic-gate struct streamtab *f_str; 737c478bd9Sstevel@tonic-gate int f_flag; 747c478bd9Sstevel@tonic-gate } fmodsw_t; 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate extern struct dev_ops **devopsp; 777c478bd9Sstevel@tonic-gate extern int devcnt; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* 807c478bd9Sstevel@tonic-gate * Return streams information for the driver specified by major number or 817c478bd9Sstevel@tonic-gate * NULL if device cb_ops structure is not present. 827c478bd9Sstevel@tonic-gate */ 837c478bd9Sstevel@tonic-gate #define STREAMSTAB(maj) (devopsp[(maj)] == NULL ? NULL : \ 847c478bd9Sstevel@tonic-gate (devopsp[(maj)]->devo_cb_ops == NULL ? \ 857c478bd9Sstevel@tonic-gate NULL : \ 867c478bd9Sstevel@tonic-gate devopsp[(maj)]->devo_cb_ops->cb_str)) 877c478bd9Sstevel@tonic-gate #define CBFLAG(maj) (devopsp[(maj)]->devo_cb_ops->cb_flag) 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate extern int devi_identify(dev_info_t *); 907c478bd9Sstevel@tonic-gate extern int devi_probe(dev_info_t *); 917c478bd9Sstevel@tonic-gate extern int devi_attach(dev_info_t *, ddi_attach_cmd_t); 927c478bd9Sstevel@tonic-gate extern int devi_detach(dev_info_t *, ddi_detach_cmd_t); 937c478bd9Sstevel@tonic-gate extern int devi_reset(dev_info_t *, ddi_reset_cmd_t); 9419397407SSherry Moore extern int devi_quiesce(dev_info_t *); 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * The following [cb]dev_* functions are not part of the DDI, use 987c478bd9Sstevel@tonic-gate * <sys/sunldi.h> defined interfaces instead. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate extern int dev_open(dev_t *, int, int, cred_t *); 1017c478bd9Sstevel@tonic-gate extern int dev_lopen(dev_t *, int, int, cred_t *); 1027c478bd9Sstevel@tonic-gate extern int dev_close(dev_t, int, int, cred_t *); 1037c478bd9Sstevel@tonic-gate extern int dev_lclose(dev_t, int, int, cred_t *); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate extern int dev_to_instance(dev_t); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate extern int bdev_strategy(struct buf *); 1087c478bd9Sstevel@tonic-gate extern int bdev_print(dev_t, caddr_t); 1097c478bd9Sstevel@tonic-gate extern int bdev_dump(dev_t, caddr_t, daddr_t, int); 1107c478bd9Sstevel@tonic-gate extern int bdev_size(dev_t); 1117c478bd9Sstevel@tonic-gate extern uint64_t bdev_Size(dev_t); 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate extern int cdev_read(dev_t, struct uio *, cred_t *); 1147c478bd9Sstevel@tonic-gate extern int cdev_write(dev_t, struct uio *, cred_t *); 1157c478bd9Sstevel@tonic-gate extern int cdev_size(dev_t); 1167c478bd9Sstevel@tonic-gate extern uint64_t cdev_Size(dev_t); 1177c478bd9Sstevel@tonic-gate extern int cdev_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); 1187c478bd9Sstevel@tonic-gate extern int cdev_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, 1197c478bd9Sstevel@tonic-gate size_t len, size_t *maplen, uint_t model); 1207c478bd9Sstevel@tonic-gate extern int cdev_mmap(int (*)(dev_t, off_t, int), 1217c478bd9Sstevel@tonic-gate dev_t, off_t, int); 1227c478bd9Sstevel@tonic-gate extern int cdev_segmap(dev_t, off_t, struct as *, caddr_t *, 1237c478bd9Sstevel@tonic-gate off_t, uint_t, uint_t, uint_t, cred_t *); 1247c478bd9Sstevel@tonic-gate extern int cdev_poll(dev_t, short, int, short *, struct pollhead **); 1257c478bd9Sstevel@tonic-gate extern int cdev_prop_op(dev_t, dev_info_t *, ddi_prop_op_t, 1267c478bd9Sstevel@tonic-gate int, char *, caddr_t, int *); 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 1327c478bd9Sstevel@tonic-gate * Device flags. 1337c478bd9Sstevel@tonic-gate * 1347c478bd9Sstevel@tonic-gate * Bit 0 to bit 15 are reserved for kernel. 1357c478bd9Sstevel@tonic-gate * Bit 16 to bit 31 are reserved for different machines. 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate #define D_NEW 0x00 /* new-style driver */ 1397c478bd9Sstevel@tonic-gate #define _D_OLD 0x01 /* old-style driver (obsolete) */ 1407c478bd9Sstevel@tonic-gate #define D_TAPE 0x08 /* Magtape device (no bdwrite when cooked) */ 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * MT-safety level (in DDI portion of flags). 1447c478bd9Sstevel@tonic-gate * 1457c478bd9Sstevel@tonic-gate * All drivers must be MT-safe, and must advertise this by specifying D_MP. 1467c478bd9Sstevel@tonic-gate * 1477c478bd9Sstevel@tonic-gate * The remainder of the flags apply only to STREAMS modules and drivers. 1487c478bd9Sstevel@tonic-gate * 1497c478bd9Sstevel@tonic-gate * A STREAMS driver or module can optionally select inner and outer perimeters. 1507c478bd9Sstevel@tonic-gate * The four mutually exclusive options that define the presence and scope 1517c478bd9Sstevel@tonic-gate * of the inner perimeter are: 1527c478bd9Sstevel@tonic-gate * D_MTPERMOD - per module single threaded. 1537c478bd9Sstevel@tonic-gate * D_MTQPAIR - per queue-pair single threaded. 1547c478bd9Sstevel@tonic-gate * D_MTPERQ - per queue instance single threaded. 1557c478bd9Sstevel@tonic-gate * (none of the above) - no inner perimeter restricting concurrency 1567c478bd9Sstevel@tonic-gate * 1577c478bd9Sstevel@tonic-gate * The presence of the outer perimeter is declared with: 1587c478bd9Sstevel@tonic-gate * D_MTOUTPERIM - a per-module outer perimeter. Can be combined with 1597c478bd9Sstevel@tonic-gate * D_MTPERQ, D_MTQPAIR, and D_MP. 1607c478bd9Sstevel@tonic-gate * 1617c478bd9Sstevel@tonic-gate * The concurrency when entering the different STREAMS entry points can be 1627c478bd9Sstevel@tonic-gate * modified with: 1637c478bd9Sstevel@tonic-gate * D_MTPUTSHARED - modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD 1647c478bd9Sstevel@tonic-gate * specifying that the put procedures should not be 1657c478bd9Sstevel@tonic-gate * single-threaded at the inner perimeter. 1667c478bd9Sstevel@tonic-gate * _D_MTOCSHARED - EXPERIMENTAL - will be removed in a future release. 1677c478bd9Sstevel@tonic-gate * Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD 1687c478bd9Sstevel@tonic-gate * specifying that the open and close procedures should not be 1697c478bd9Sstevel@tonic-gate * single-threaded at the inner perimeter. 1707c478bd9Sstevel@tonic-gate * _D_MTCBSHARED - EXPERIMENTAL - will be removed in a future release. 1717c478bd9Sstevel@tonic-gate * Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD 1727c478bd9Sstevel@tonic-gate * specifying that the callback i.e qtimeout() procedures should 1737c478bd9Sstevel@tonic-gate * not be single-threaded at the inner perimeter. 1747c478bd9Sstevel@tonic-gate * _D_MTSVCSHARED - EXPERIMENTAL - will be removed in a future release. 1757c478bd9Sstevel@tonic-gate * Modifier for D_MTPERMOD only. Specifies that the service 1767c478bd9Sstevel@tonic-gate * procedure should not be single-threaded at the inner perimeter. 1777c478bd9Sstevel@tonic-gate * However only a single instance of the service thread can run on 1787c478bd9Sstevel@tonic-gate * any given queue. 1797c478bd9Sstevel@tonic-gate * D_MTOCEXCL - modifier for D_MTOUTPERIM specifying that the open and 1807c478bd9Sstevel@tonic-gate * close procedures should be single-threaded at the outer 1817c478bd9Sstevel@tonic-gate * perimeter. 1827c478bd9Sstevel@tonic-gate */ 1837c478bd9Sstevel@tonic-gate #define D_MTSAFE 0x0020 /* multi-threaded module or driver */ 1847c478bd9Sstevel@tonic-gate #define _D_QNEXTLESS 0x0040 /* Unused, retained for source compatibility */ 1857c478bd9Sstevel@tonic-gate #define _D_MTOCSHARED 0x0080 /* modify: open/close procedures are hot */ 1867c478bd9Sstevel@tonic-gate /* 0x100 - see below */ 1877c478bd9Sstevel@tonic-gate /* 0x200 - see below */ 1887c478bd9Sstevel@tonic-gate /* 0x400 - see below */ 1897c478bd9Sstevel@tonic-gate #define D_MTOCEXCL 0x0800 /* modify: open/close are exclusive at outer */ 1907c478bd9Sstevel@tonic-gate #define D_MTPUTSHARED 0x1000 /* modify: put procedures are hot */ 1917c478bd9Sstevel@tonic-gate #define D_MTPERQ 0x2000 /* per queue instance single-threaded */ 1927c478bd9Sstevel@tonic-gate #define D_MTQPAIR 0x4000 /* per queue-pair instance single-threaded */ 1937c478bd9Sstevel@tonic-gate #define D_MTPERMOD 0x6000 /* per module single-threaded */ 1947c478bd9Sstevel@tonic-gate #define D_MTOUTPERIM 0x8000 /* r/w outer perimeter around whole modules */ 1957c478bd9Sstevel@tonic-gate #define _D_MTCBSHARED 0x10000 /* modify : callback procedures are hot */ 1967c478bd9Sstevel@tonic-gate #define _D_MTSVCSHARED 0x20000 /* modify : service procedures are hot */ 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate /* The inner perimeter scope bits */ 1997c478bd9Sstevel@tonic-gate #define D_MTINNER_MASK (D_MP|D_MTPERQ|D_MTQPAIR|D_MTPERMOD) 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate /* Inner perimeter modification bits */ 2027c478bd9Sstevel@tonic-gate #define D_MTINNER_MOD (D_MTPUTSHARED|_D_MTOCSHARED|_D_MTCBSHARED| \ 2037c478bd9Sstevel@tonic-gate _D_MTSVCSHARED) 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate /* Outer perimeter modification bits */ 2067c478bd9Sstevel@tonic-gate #define D_MTOUTER_MOD (D_MTOCEXCL) 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* All the MT flags */ 2097c478bd9Sstevel@tonic-gate #define D_MTSAFETY_MASK (D_MTINNER_MASK|D_MTOUTPERIM|D_MTPUTSHARED|\ 2107c478bd9Sstevel@tonic-gate D_MTINNER_MOD|D_MTOUTER_MOD) 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate #define D_MP D_MTSAFE /* ddi/dki approved flag */ 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate #define D_64BIT 0x200 /* Driver supports 64-bit offsets, blk nos. */ 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate #define D_SYNCSTR 0x400 /* Module or driver has Synchronous STREAMS */ 2177c478bd9Sstevel@tonic-gate /* extended qinit structure */ 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate #define D_DEVMAP 0x100 /* Use devmap framework to mmap device */ 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate #define D_HOTPLUG 0x4 /* Driver is hotplug capable */ 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate #define D_U64BIT 0x40000 /* Driver supports unsigned 64-bit uio offset */ 2247c478bd9Sstevel@tonic-gate 225ff550d0eSmasputra #define _D_DIRECT 0x80000 /* Private flag for transport modules */ 226ff550d0eSmasputra 227e099bf07Scth #define D_OPEN_RETURNS_EINTR 0x100000 /* EINTR expected from open(9E) */ 228e099bf07Scth 2296cfa0a70SAndy Fiddaman #define _D_SINGLE_INSTANCE 0x200000 /* Module may only be pushed once */ 2306cfa0a70SAndy Fiddaman 2317c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2347c478bd9Sstevel@tonic-gate } 2357c478bd9Sstevel@tonic-gate #endif 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate #endif /* _SYS_CONF_H */ 238