xref: /titanic_51/usr/src/uts/common/sys/ddi.h (revision ba3594ba9b5dd4c846c472a8d657edcb7c8109ac)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24*ba3594baSGarrett D'Amore  *
257c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
267c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
307c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef _SYS_DDI_H
347c478bd9Sstevel@tonic-gate #define	_SYS_DDI_H
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate #include <sys/map.h>
387c478bd9Sstevel@tonic-gate #include <sys/buf.h>
397c478bd9Sstevel@tonic-gate #include <sys/uio.h>
407c478bd9Sstevel@tonic-gate #include <sys/stream.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * ddi.h -- the flag and function definitions needed by DDI-conforming
487c478bd9Sstevel@tonic-gate  * drivers.  This header file contains #undefs to undefine macros that
497c478bd9Sstevel@tonic-gate  * drivers would otherwise pick up in order that function definitions
507c478bd9Sstevel@tonic-gate  * may be used. Programmers should place the include of "sys/ddi.h"
517c478bd9Sstevel@tonic-gate  * after any header files that define the macros #undef'ed or the code
527c478bd9Sstevel@tonic-gate  * may compile incorrectly.
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate  * define min() and max() as macros so that drivers will not pick up the
577c478bd9Sstevel@tonic-gate  * min() and max() kernel functions since they do signed comparison only.
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate #ifdef	min
607c478bd9Sstevel@tonic-gate #undef	min
617c478bd9Sstevel@tonic-gate #endif	/* min */
627c478bd9Sstevel@tonic-gate #define	min(a, b)	((a) < (b) ? (a) : (b))
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate #ifdef	max
657c478bd9Sstevel@tonic-gate #undef	max
667c478bd9Sstevel@tonic-gate #endif	/* max */
677c478bd9Sstevel@tonic-gate #define	max(a, b)	((a) < (b) ? (b) : (a))
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #define	TIME	1
707c478bd9Sstevel@tonic-gate #define	UPROCP	2
717c478bd9Sstevel@tonic-gate #define	PPGRP	3
727c478bd9Sstevel@tonic-gate #define	LBOLT	4
737c478bd9Sstevel@tonic-gate #define	SYSRINT	5
747c478bd9Sstevel@tonic-gate #define	SYSXINT	6
757c478bd9Sstevel@tonic-gate #define	SYSMINT	7
767c478bd9Sstevel@tonic-gate #define	SYSRAWC	8
777c478bd9Sstevel@tonic-gate #define	SYSCANC	9
787c478bd9Sstevel@tonic-gate #define	SYSOUTC	10
797c478bd9Sstevel@tonic-gate #define	PPID	11
807c478bd9Sstevel@tonic-gate #define	PSID	12
817c478bd9Sstevel@tonic-gate #define	UCRED	13
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate extern int drv_getparm(uint_t, void *);
847c478bd9Sstevel@tonic-gate extern int drv_setparm(uint_t, ulong_t);
857c478bd9Sstevel@tonic-gate extern void drv_usecwait(clock_t);
867c478bd9Sstevel@tonic-gate extern clock_t drv_hztousec(clock_t);
877c478bd9Sstevel@tonic-gate extern clock_t drv_usectohz(clock_t);
887c478bd9Sstevel@tonic-gate extern void delay(clock_t);
897c478bd9Sstevel@tonic-gate extern void time_to_wait(clock_t *, clock_t);
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /* XXX -- should be changed to major_t */
927c478bd9Sstevel@tonic-gate /* convert external to internal major number */
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate extern int etoimajor(major_t);
957c478bd9Sstevel@tonic-gate /* convert internal to extern major number */
967c478bd9Sstevel@tonic-gate extern int itoemajor(major_t, int);
977c478bd9Sstevel@tonic-gate extern int drv_priv(struct cred *);
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate /*
1007c478bd9Sstevel@tonic-gate  * The following declarations take the place of macros in
1017c478bd9Sstevel@tonic-gate  * sysmacros.h The undefs are for any case where a driver includes
1027c478bd9Sstevel@tonic-gate  * sysmacros.h, even though DDI conforming drivers must not.
1037c478bd9Sstevel@tonic-gate  */
1047c478bd9Sstevel@tonic-gate #undef getemajor
1057c478bd9Sstevel@tonic-gate #undef geteminor
1067c478bd9Sstevel@tonic-gate #undef getmajor
1077c478bd9Sstevel@tonic-gate #undef getminor
1087c478bd9Sstevel@tonic-gate #undef makedevice
1097c478bd9Sstevel@tonic-gate #undef cmpdev
1107c478bd9Sstevel@tonic-gate #undef expdev
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate extern major_t getemajor(dev_t);
1147c478bd9Sstevel@tonic-gate extern minor_t geteminor(dev_t);
1157c478bd9Sstevel@tonic-gate extern major_t getmajor(dev_t);
1167c478bd9Sstevel@tonic-gate extern minor_t getminor(dev_t);
1177c478bd9Sstevel@tonic-gate extern dev_t makedevice(major_t, minor_t);
1187c478bd9Sstevel@tonic-gate extern o_dev_t cmpdev(dev_t);
1197c478bd9Sstevel@tonic-gate extern dev_t expdev(dev_t);
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * The following macros from param.h are also being converted to
1237c478bd9Sstevel@tonic-gate  * functions and #undefs must be done here as well since param.h
1247c478bd9Sstevel@tonic-gate  * will be included by most if not every driver
1257c478bd9Sstevel@tonic-gate  */
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate #undef btop
1287c478bd9Sstevel@tonic-gate #undef btopr
1297c478bd9Sstevel@tonic-gate #undef ptob
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate extern unsigned long btop(unsigned long);
1327c478bd9Sstevel@tonic-gate extern unsigned long btopr(unsigned long);
1337c478bd9Sstevel@tonic-gate extern unsigned long ptob(unsigned long);
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate /* STREAMS drivers and modules must include stream.h to pick up the */
1377c478bd9Sstevel@tonic-gate /* needed structure and flag definitions. As was the case with map.h, */
1387c478bd9Sstevel@tonic-gate /* macros used by both the kernel and drivers in times past now have */
1397c478bd9Sstevel@tonic-gate /* a macro definition for the kernel and a function definition for */
1407c478bd9Sstevel@tonic-gate /* drivers. The following #undefs allow drivers to include stream.h */
1417c478bd9Sstevel@tonic-gate /* but call the functions rather than macros. */
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate #undef OTHERQ
1447c478bd9Sstevel@tonic-gate #undef RD
1457c478bd9Sstevel@tonic-gate #undef WR
1467c478bd9Sstevel@tonic-gate #undef SAMESTR
1477c478bd9Sstevel@tonic-gate #undef datamsg
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate extern struct queue *OTHERQ(queue_t *);	/* stream.h */
1507c478bd9Sstevel@tonic-gate extern struct queue *RD(queue_t *);
1517c478bd9Sstevel@tonic-gate extern struct queue *WR(queue_t *);
1527c478bd9Sstevel@tonic-gate extern int SAMESTR(queue_t *);
1537c478bd9Sstevel@tonic-gate extern int datamsg(unsigned char);
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate /* declarations of functions for allocating and deallocating the space */
1567c478bd9Sstevel@tonic-gate /* for a buffer header (just a header, not the associated buffer) */
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate extern struct buf *getrbuf(int);
1597c478bd9Sstevel@tonic-gate extern void freerbuf(struct buf *);
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
1627c478bd9Sstevel@tonic-gate /*
1637c478bd9Sstevel@tonic-gate  * SVR4MP replacement for hat_getkpfnum()
1647c478bd9Sstevel@tonic-gate  */
1657c478bd9Sstevel@tonic-gate #define	NOPAGE	(-1)	/* value returned for invalid addresses */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate typedef pfn_t	ppid_t;	/* a 'physical page identifier' - no math allowed! */
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate extern ppid_t kvtoppid(caddr_t);
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate extern int qassociate(queue_t *, int);
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1767c478bd9Sstevel@tonic-gate }
1777c478bd9Sstevel@tonic-gate #endif
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate #endif	/* _SYS_DDI_H */
180