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