]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/tdfx/tdfx_io.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
[FreeBSD/FreeBSD.git] / sys / dev / tdfx / tdfx_io.h
1 /*-
2  * SPDX-License-Identifier: BSD-4-Clause
3  *
4  * Copyright (c) 2000-2001 by Coleman Kane <cokane@FreeBSD.org>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Gardner Buchanan.
18  * 4. The name of Gardner Buchanan may not be used to endorse or promote
19  *    products derived from this software without specific prior written
20  *    permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  *   $FreeBSD$
34  */
35
36 /* This code originally came from <shocking@prth.pgs.com>
37  * it is basically a derivative of some sys/dhio.h file to work with the 3dfx
38  * cards 
39  */
40 #ifndef TDFX_IO_H
41 #define TDFX_IO_H
42
43 #ifndef KERNEL
44 #include <sys/types.h>
45 #endif
46
47 /*
48  * define an ioctl here
49  */
50 #define DHIOCRESET _IO('D', 0)   /* reset the voodoo device */
51 #define GETVOODOO 0x3302
52 #define SETVOODOO 0x3303
53 #define MOREVOODOO 0x3300
54 #define _IOC_NRBITS     8
55 #define _IOC_TYPEBITS   8
56 #define _IOC_SIZEBITS   14
57 #define _IOC_DIRBITS    2
58
59 #define _IOC_NRMASK     ((1 << _IOC_NRBITS)-1)
60 #define _IOC_TYPEMASK   ((1 << _IOC_TYPEBITS)-1)
61 #define _IOC_SIZEMASK   ((1 << _IOC_SIZEBITS)-1)
62 #define _IOC_DIRMASK    ((1 << _IOC_DIRBITS)-1)
63
64 #define _IOC_NRSHIFT    0
65 #define _IOC_TYPESHIFT  (_IOC_NRSHIFT+_IOC_NRBITS)
66 #define _IOC_SIZESHIFT  (_IOC_TYPESHIFT+_IOC_TYPEBITS)
67 #define _IOC_DIRSHIFT   (_IOC_SIZESHIFT+_IOC_SIZEBITS)
68
69 /*
70  * Direction bits.
71  */
72 #define _IOC_NONE       0U
73 #define _IOC_WRITE      1U
74 #define _IOC_READ       2U
75
76 #define _IOCV(dir,type,nr,size) \
77         (((dir)  << _IOC_DIRSHIFT) | \
78          ((type) << _IOC_TYPESHIFT) | \
79          ((nr)   << _IOC_NRSHIFT) | \
80          ((size) << _IOC_SIZESHIFT))
81
82 /* used to create numbers */
83 #define _IOV(type,nr)           _IOCV(_IOC_NONE,(type),(nr),0)
84 #define _IORV(type,nr,size)     _IOCV(_IOC_READ,(type),(nr),sizeof(size))
85 #define _IOWV(type,nr,size)     _IOCV(_IOC_WRITE,(type),(nr),sizeof(size))
86 #define _IOWRV(type,nr,size)    _IOCV(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
87
88 /* used to decode ioctl numbers.. */
89 #define _IOC_DIR(nr)            (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
90 #define _IOC_TYPE(nr)           (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
91 #define _IOC_NR(nr)             (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
92 #define _IOC_SIZE(nr)           (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
93
94 /* ...and for the drivers/sound files... */
95
96 #define IOCV_IN         (_IOC_WRITE << _IOC_DIRSHIFT)
97 #define IOCV_OUT        (_IOC_READ << _IOC_DIRSHIFT)
98 #define IOCV_INOUT      ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
99 #define IOCSIZE_MASK    (_IOC_SIZEMASK << _IOC_SIZESHIFT)
100 #define IOCSIZE_SHIFT   (_IOC_SIZESHIFT)
101
102 #endif