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