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