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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2014 Garrett D'Amore <garrett@damore.org> 24 * Copyright 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> 25 * 26 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 27 * Use is subject to license terms. 28 */ 29 30 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 31 /* All Rights Reserved */ 32 33 34 #ifndef _SYS_DDI_H 35 #define _SYS_DDI_H 36 37 #include <sys/types.h> 38 #include <sys/map.h> 39 #include <sys/buf.h> 40 #include <sys/uio.h> 41 #include <sys/stream.h> 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /* 48 * ddi.h -- the flag and function definitions needed by DDI-conforming 49 * drivers. This header file contains #undefs to undefine macros that 50 * drivers would otherwise pick up in order that function definitions 51 * may be used. Programmers should place the include of "sys/ddi.h" 52 * after any header files that define the macros #undef'ed or the code 53 * may compile incorrectly. 54 */ 55 56 /* 57 * define min() and max() as macros so that drivers will not pick up the 58 * min() and max() kernel functions since they do signed comparison only. 59 */ 60 #ifdef min 61 #undef min 62 #endif /* min */ 63 #define min(a, b) ((a) < (b) ? (a) : (b)) 64 65 #ifdef max 66 #undef max 67 #endif /* max */ 68 #define max(a, b) ((a) < (b) ? (b) : (a)) 69 70 #define TIME 1 71 #define UPROCP 2 72 #define PPGRP 3 73 #define LBOLT 4 74 #define SYSRINT 5 75 #define SYSXINT 6 76 #define SYSMINT 7 77 #define SYSRAWC 8 78 #define SYSCANC 9 79 #define SYSOUTC 10 80 #define PPID 11 81 #define PSID 12 82 #define UCRED 13 83 84 extern int drv_getparm(uint_t, void *); 85 extern int drv_setparm(uint_t, ulong_t); 86 extern void drv_usecwait(clock_t); 87 extern clock_t drv_hztousec(clock_t); 88 extern clock_t drv_usectohz(clock_t); 89 extern clock_t drv_sectohz(clock_t); 90 extern void delay(clock_t); 91 extern void time_to_wait(clock_t *, clock_t); 92 93 /* XXX -- should be changed to major_t */ 94 /* convert external to internal major number */ 95 96 extern int etoimajor(major_t); 97 /* convert internal to extern major number */ 98 extern int itoemajor(major_t, int); 99 extern int drv_priv(struct cred *); 100 101 /* 102 * The following declarations take the place of macros in 103 * sysmacros.h The undefs are for any case where a driver includes 104 * sysmacros.h, even though DDI conforming drivers must not. 105 */ 106 #undef getemajor 107 #undef geteminor 108 #undef getmajor 109 #undef getminor 110 #undef makedevice 111 #undef cmpdev 112 #undef expdev 113 114 115 extern major_t getemajor(dev_t); 116 extern minor_t geteminor(dev_t); 117 extern major_t getmajor(dev_t); 118 extern minor_t getminor(dev_t); 119 extern dev_t makedevice(major_t, minor_t); 120 extern o_dev_t cmpdev(dev_t); 121 extern dev_t expdev(dev_t); 122 123 /* 124 * The following macros from param.h are also being converted to 125 * functions and #undefs must be done here as well since param.h 126 * will be included by most if not every driver 127 */ 128 129 #undef btop 130 #undef btopr 131 #undef ptob 132 133 extern unsigned long btop(unsigned long); 134 extern unsigned long btopr(unsigned long); 135 extern unsigned long ptob(unsigned long); 136 137 138 /* STREAMS drivers and modules must include stream.h to pick up the */ 139 /* needed structure and flag definitions. As was the case with map.h, */ 140 /* macros used by both the kernel and drivers in times past now have */ 141 /* a macro definition for the kernel and a function definition for */ 142 /* drivers. The following #undefs allow drivers to include stream.h */ 143 /* but call the functions rather than macros. */ 144 145 #undef OTHERQ 146 #undef RD 147 #undef WR 148 #undef SAMESTR 149 #undef datamsg 150 151 extern struct queue *OTHERQ(queue_t *); /* stream.h */ 152 extern struct queue *RD(queue_t *); 153 extern struct queue *WR(queue_t *); 154 extern int SAMESTR(queue_t *); 155 extern int datamsg(unsigned char); 156 157 /* declarations of functions for allocating and deallocating the space */ 158 /* for a buffer header (just a header, not the associated buffer) */ 159 160 extern struct buf *getrbuf(int); 161 extern void freerbuf(struct buf *); 162 163 #ifdef _KERNEL 164 /* 165 * SVR4MP replacement for hat_getkpfnum() 166 */ 167 #define NOPAGE (-1) /* value returned for invalid addresses */ 168 169 typedef pfn_t ppid_t; /* a 'physical page identifier' - no math allowed! */ 170 171 extern ppid_t kvtoppid(caddr_t); 172 173 extern int qassociate(queue_t *, int); 174 175 #endif /* _KERNEL */ 176 177 #ifdef __cplusplus 178 } 179 #endif 180 181 #endif /* _SYS_DDI_H */