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 */ 227c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate /* 25*bbc000e5SAnders Persson * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 267c478bd9Sstevel@tonic-gate * Use is subject to license terms. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _SYS_CONF_H 307c478bd9Sstevel@tonic-gate #define _SYS_CONF_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 367c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #define FMNAMESZ 8 /* used by struct fmodsw */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #ifdef _KERNEL 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * XXX Given that drivers need to include this file, 517c478bd9Sstevel@tonic-gate * <sys/systm.h> probably shouldn't be here, as 527c478bd9Sstevel@tonic-gate * it legitimizes (aka provides prototypes for) 537c478bd9Sstevel@tonic-gate * all sorts of functions that aren't in the DKI/SunDDI 547c478bd9Sstevel@tonic-gate */ 557c478bd9Sstevel@tonic-gate #include <sys/systm.h> 567c478bd9Sstevel@tonic-gate #include <sys/devops.h> 577c478bd9Sstevel@tonic-gate #include <sys/model.h> 587c478bd9Sstevel@tonic-gate #include <sys/types.h> 597c478bd9Sstevel@tonic-gate #include <sys/buf.h> 607c478bd9Sstevel@tonic-gate #include <sys/cred.h> 617c478bd9Sstevel@tonic-gate #include <sys/uio.h> 627c478bd9Sstevel@tonic-gate #include <sys/poll.h> 637c478bd9Sstevel@tonic-gate #include <vm/as.h> 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate typedef struct fmodsw { 667c478bd9Sstevel@tonic-gate char f_name[FMNAMESZ + 1]; 677c478bd9Sstevel@tonic-gate struct streamtab *f_str; 687c478bd9Sstevel@tonic-gate int f_flag; 697c478bd9Sstevel@tonic-gate } fmodsw_t; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate extern struct dev_ops **devopsp; 727c478bd9Sstevel@tonic-gate extern int devcnt; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * Return streams information for the driver specified by major number or 767c478bd9Sstevel@tonic-gate * NULL if device cb_ops structure is not present. 777c478bd9Sstevel@tonic-gate */ 787c478bd9Sstevel@tonic-gate #define STREAMSTAB(maj) (devopsp[(maj)] == NULL ? NULL : \ 797c478bd9Sstevel@tonic-gate (devopsp[(maj)]->devo_cb_ops == NULL ? \ 807c478bd9Sstevel@tonic-gate NULL : \ 817c478bd9Sstevel@tonic-gate devopsp[(maj)]->devo_cb_ops->cb_str)) 827c478bd9Sstevel@tonic-gate #define CBFLAG(maj) (devopsp[(maj)]->devo_cb_ops->cb_flag) 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate extern int devi_identify(dev_info_t *); 857c478bd9Sstevel@tonic-gate extern int devi_probe(dev_info_t *); 867c478bd9Sstevel@tonic-gate extern int devi_attach(dev_info_t *, ddi_attach_cmd_t); 877c478bd9Sstevel@tonic-gate extern int devi_detach(dev_info_t *, ddi_detach_cmd_t); 887c478bd9Sstevel@tonic-gate extern int devi_reset(dev_info_t *, ddi_reset_cmd_t); 8919397407SSherry Moore extern int devi_quiesce(dev_info_t *); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * The following [cb]dev_* functions are not part of the DDI, use 937c478bd9Sstevel@tonic-gate * <sys/sunldi.h> defined interfaces instead. 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate extern int dev_open(dev_t *, int, int, cred_t *); 967c478bd9Sstevel@tonic-gate extern int dev_lopen(dev_t *, int, int, cred_t *); 977c478bd9Sstevel@tonic-gate extern int dev_close(dev_t, int, int, cred_t *); 987c478bd9Sstevel@tonic-gate extern int dev_lclose(dev_t, int, int, cred_t *); 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate extern int dev_to_instance(dev_t); 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate extern int bdev_strategy(struct buf *); 1037c478bd9Sstevel@tonic-gate extern int bdev_print(dev_t, caddr_t); 1047c478bd9Sstevel@tonic-gate extern int bdev_dump(dev_t, caddr_t, daddr_t, int); 1057c478bd9Sstevel@tonic-gate extern int bdev_size(dev_t); 1067c478bd9Sstevel@tonic-gate extern uint64_t bdev_Size(dev_t); 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate extern int cdev_read(dev_t, struct uio *, cred_t *); 1097c478bd9Sstevel@tonic-gate extern int cdev_write(dev_t, struct uio *, cred_t *); 1107c478bd9Sstevel@tonic-gate extern int cdev_size(dev_t); 1117c478bd9Sstevel@tonic-gate extern uint64_t cdev_Size(dev_t); 1127c478bd9Sstevel@tonic-gate extern int cdev_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); 1137c478bd9Sstevel@tonic-gate extern int cdev_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, 1147c478bd9Sstevel@tonic-gate size_t len, size_t *maplen, uint_t model); 1157c478bd9Sstevel@tonic-gate extern int cdev_mmap(int (*)(dev_t, off_t, int), 1167c478bd9Sstevel@tonic-gate dev_t, off_t, int); 1177c478bd9Sstevel@tonic-gate extern int cdev_segmap(dev_t, off_t, struct as *, caddr_t *, 1187c478bd9Sstevel@tonic-gate off_t, uint_t, uint_t, uint_t, cred_t *); 1197c478bd9Sstevel@tonic-gate extern int cdev_poll(dev_t, short, int, short *, struct pollhead **); 1207c478bd9Sstevel@tonic-gate extern int cdev_prop_op(dev_t, dev_info_t *, ddi_prop_op_t, 1217c478bd9Sstevel@tonic-gate int, char *, caddr_t, int *); 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * Device flags. 1287c478bd9Sstevel@tonic-gate * 1297c478bd9Sstevel@tonic-gate * Bit 0 to bit 15 are reserved for kernel. 1307c478bd9Sstevel@tonic-gate * Bit 16 to bit 31 are reserved for different machines. 1317c478bd9Sstevel@tonic-gate */ 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #define D_NEW 0x00 /* new-style driver */ 1347c478bd9Sstevel@tonic-gate #define _D_OLD 0x01 /* old-style driver (obsolete) */ 1357c478bd9Sstevel@tonic-gate #define D_TAPE 0x08 /* Magtape device (no bdwrite when cooked) */ 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* 1387c478bd9Sstevel@tonic-gate * MT-safety level (in DDI portion of flags). 1397c478bd9Sstevel@tonic-gate * 1407c478bd9Sstevel@tonic-gate * All drivers must be MT-safe, and must advertise this by specifying D_MP. 1417c478bd9Sstevel@tonic-gate * 1427c478bd9Sstevel@tonic-gate * The remainder of the flags apply only to STREAMS modules and drivers. 1437c478bd9Sstevel@tonic-gate * 1447c478bd9Sstevel@tonic-gate * A STREAMS driver or module can optionally select inner and outer perimeters. 1457c478bd9Sstevel@tonic-gate * The four mutually exclusive options that define the presence and scope 1467c478bd9Sstevel@tonic-gate * of the inner perimeter are: 1477c478bd9Sstevel@tonic-gate * D_MTPERMOD - per module single threaded. 1487c478bd9Sstevel@tonic-gate * D_MTQPAIR - per queue-pair single threaded. 1497c478bd9Sstevel@tonic-gate * D_MTPERQ - per queue instance single threaded. 1507c478bd9Sstevel@tonic-gate * (none of the above) - no inner perimeter restricting concurrency 1517c478bd9Sstevel@tonic-gate * 1527c478bd9Sstevel@tonic-gate * The presence of the outer perimeter is declared with: 1537c478bd9Sstevel@tonic-gate * D_MTOUTPERIM - a per-module outer perimeter. Can be combined with 1547c478bd9Sstevel@tonic-gate * D_MTPERQ, D_MTQPAIR, and D_MP. 1557c478bd9Sstevel@tonic-gate * 1567c478bd9Sstevel@tonic-gate * The concurrency when entering the different STREAMS entry points can be 1577c478bd9Sstevel@tonic-gate * modified with: 1587c478bd9Sstevel@tonic-gate * D_MTPUTSHARED - modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD 1597c478bd9Sstevel@tonic-gate * specifying that the put procedures should not be 1607c478bd9Sstevel@tonic-gate * single-threaded at the inner perimeter. 1617c478bd9Sstevel@tonic-gate * _D_MTOCSHARED - EXPERIMENTAL - will be removed in a future release. 1627c478bd9Sstevel@tonic-gate * Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD 1637c478bd9Sstevel@tonic-gate * specifying that the open and close procedures should not be 1647c478bd9Sstevel@tonic-gate * single-threaded at the inner perimeter. 1657c478bd9Sstevel@tonic-gate * _D_MTCBSHARED - EXPERIMENTAL - will be removed in a future release. 1667c478bd9Sstevel@tonic-gate * Modifier for D_MTPERQ, D_MTQPAIR, and D_MTPERMOD 1677c478bd9Sstevel@tonic-gate * specifying that the callback i.e qtimeout() procedures should 1687c478bd9Sstevel@tonic-gate * not be single-threaded at the inner perimeter. 1697c478bd9Sstevel@tonic-gate * _D_MTSVCSHARED - EXPERIMENTAL - will be removed in a future release. 1707c478bd9Sstevel@tonic-gate * Modifier for D_MTPERMOD only. Specifies that the service 1717c478bd9Sstevel@tonic-gate * procedure should not be single-threaded at the inner perimeter. 1727c478bd9Sstevel@tonic-gate * However only a single instance of the service thread can run on 1737c478bd9Sstevel@tonic-gate * any given queue. 1747c478bd9Sstevel@tonic-gate * D_MTOCEXCL - modifier for D_MTOUTPERIM specifying that the open and 1757c478bd9Sstevel@tonic-gate * close procedures should be single-threaded at the outer 1767c478bd9Sstevel@tonic-gate * perimeter. 1777c478bd9Sstevel@tonic-gate */ 1787c478bd9Sstevel@tonic-gate #define D_MTSAFE 0x0020 /* multi-threaded module or driver */ 1797c478bd9Sstevel@tonic-gate #define _D_QNEXTLESS 0x0040 /* Unused, retained for source compatibility */ 1807c478bd9Sstevel@tonic-gate #define _D_MTOCSHARED 0x0080 /* modify: open/close procedures are hot */ 1817c478bd9Sstevel@tonic-gate /* 0x100 - see below */ 1827c478bd9Sstevel@tonic-gate /* 0x200 - see below */ 1837c478bd9Sstevel@tonic-gate /* 0x400 - see below */ 1847c478bd9Sstevel@tonic-gate #define D_MTOCEXCL 0x0800 /* modify: open/close are exclusive at outer */ 1857c478bd9Sstevel@tonic-gate #define D_MTPUTSHARED 0x1000 /* modify: put procedures are hot */ 1867c478bd9Sstevel@tonic-gate #define D_MTPERQ 0x2000 /* per queue instance single-threaded */ 1877c478bd9Sstevel@tonic-gate #define D_MTQPAIR 0x4000 /* per queue-pair instance single-threaded */ 1887c478bd9Sstevel@tonic-gate #define D_MTPERMOD 0x6000 /* per module single-threaded */ 1897c478bd9Sstevel@tonic-gate #define D_MTOUTPERIM 0x8000 /* r/w outer perimeter around whole modules */ 1907c478bd9Sstevel@tonic-gate #define _D_MTCBSHARED 0x10000 /* modify : callback procedures are hot */ 1917c478bd9Sstevel@tonic-gate #define _D_MTSVCSHARED 0x20000 /* modify : service procedures are hot */ 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate /* The inner perimeter scope bits */ 1947c478bd9Sstevel@tonic-gate #define D_MTINNER_MASK (D_MP|D_MTPERQ|D_MTQPAIR|D_MTPERMOD) 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* Inner perimeter modification bits */ 1977c478bd9Sstevel@tonic-gate #define D_MTINNER_MOD (D_MTPUTSHARED|_D_MTOCSHARED|_D_MTCBSHARED| \ 1987c478bd9Sstevel@tonic-gate _D_MTSVCSHARED) 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* Outer perimeter modification bits */ 2017c478bd9Sstevel@tonic-gate #define D_MTOUTER_MOD (D_MTOCEXCL) 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate /* All the MT flags */ 2047c478bd9Sstevel@tonic-gate #define D_MTSAFETY_MASK (D_MTINNER_MASK|D_MTOUTPERIM|D_MTPUTSHARED|\ 2057c478bd9Sstevel@tonic-gate D_MTINNER_MOD|D_MTOUTER_MOD) 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate #define D_MP D_MTSAFE /* ddi/dki approved flag */ 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate #define D_64BIT 0x200 /* Driver supports 64-bit offsets, blk nos. */ 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate #define D_SYNCSTR 0x400 /* Module or driver has Synchronous STREAMS */ 2127c478bd9Sstevel@tonic-gate /* extended qinit structure */ 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate #define D_DEVMAP 0x100 /* Use devmap framework to mmap device */ 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate #define D_HOTPLUG 0x4 /* Driver is hotplug capable */ 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate #define D_U64BIT 0x40000 /* Driver supports unsigned 64-bit uio offset */ 2197c478bd9Sstevel@tonic-gate 220ff550d0eSmasputra #define _D_DIRECT 0x80000 /* Private flag for transport modules */ 221ff550d0eSmasputra 222e099bf07Scth #define D_OPEN_RETURNS_EINTR 0x100000 /* EINTR expected from open(9E) */ 223e099bf07Scth 2247c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2277c478bd9Sstevel@tonic-gate } 2287c478bd9Sstevel@tonic-gate #endif 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate #endif /* _SYS_CONF_H */ 231