Home | History | Annotate | Line # | Download | only in m68k
linux_ioctl.h revision 1.1
      1  1.1  itohy /*	$NetBSD: linux_ioctl.h,v 1.1 1998/12/15 19:25:40 itohy Exp $	*/
      2  1.1  itohy 
      3  1.1  itohy /*-
      4  1.1  itohy  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  1.1  itohy  * All rights reserved.
      6  1.1  itohy  *
      7  1.1  itohy  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  itohy  * by Eric Haszlakiewicz.
      9  1.1  itohy  *
     10  1.1  itohy  * Redistribution and use in source and binary forms, with or without
     11  1.1  itohy  * modification, are permitted provided that the following conditions
     12  1.1  itohy  * are met:
     13  1.1  itohy  * 1. Redistributions of source code must retain the above copyright
     14  1.1  itohy  *    notice, this list of conditions and the following disclaimer.
     15  1.1  itohy  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  itohy  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  itohy  *    documentation and/or other materials provided with the distribution.
     18  1.1  itohy  * 3. All advertising materials mentioning features or use of this software
     19  1.1  itohy  *    must display the following acknowledgement:
     20  1.1  itohy  *	This product includes software developed by the NetBSD
     21  1.1  itohy  *	Foundation, Inc. and its contributors.
     22  1.1  itohy  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1  itohy  *    contributors may be used to endorse or promote products derived
     24  1.1  itohy  *    from this software without specific prior written permission.
     25  1.1  itohy  *
     26  1.1  itohy  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1  itohy  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1  itohy  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1  itohy  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1  itohy  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1  itohy  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1  itohy  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1  itohy  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1  itohy  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1  itohy  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1  itohy  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1  itohy  */
     38  1.1  itohy 
     39  1.1  itohy #ifndef _M68K_LINUX_IOCTL_H
     40  1.1  itohy #define _M68K_LINUX_IOCTL_H
     41  1.1  itohy /* Note: Linux looks to have tried to switch to a structured way of defining
     42  1.1  itohy  *	ioctls.  Doesn't look like they finished.  Some ioctls use these
     43  1.1  itohy  *	defines.  Other are still just a number.  (But they could
     44  1.1  itohy  *	probably be encoded as _LINUX_IO('T', #) )
     45  1.1  itohy  */
     46  1.1  itohy #define	_LINUX_IOC_NRBITS	8
     47  1.1  itohy #define	_LINUX_IOC_TYPEBITS	8
     48  1.1  itohy #define	_LINUX_IOC_SIZEBITS	14
     49  1.1  itohy #define	_LINUX_IOC_DIRBITS	2
     50  1.1  itohy 
     51  1.1  itohy #define	_LINUX_IOC_NRMASK	((1 << _LINUX_IOC_NRBITS) - 1)
     52  1.1  itohy #define	_LINUX_IOC_TYPEMASK	((1 << _LINUX_IOC_TYPEBITS) - 1)
     53  1.1  itohy #define	_LINUX_IOC_SIZEMAEK	((1 << _LINUX_IOC_SIZEBITS) - 1)
     54  1.1  itohy #define _LINUX_IOC_DIRMASK	((1 << _LINUX_IOC_DIRBITS) - 1)
     55  1.1  itohy 
     56  1.1  itohy #define	_LINUX_IOC_NRSHIFT	0
     57  1.1  itohy #define	_LINUX_IOC_TYPESHIFT	(_LINUX_IOC_NRSHIFT + _LINUX_IOC_NRBITS)
     58  1.1  itohy #define	_LINUX_IOC_SIZESHIFT	(_LINUX_IOC_TYPESHIFT + _LINUX_IOC_TYPEBITS)
     59  1.1  itohy #define	_LINUX_IOC_DIRSHIFT	(_LINUX_IOC_SIZESHIFT + _LINUX_IOC_SIZEBITS)
     60  1.1  itohy 
     61  1.1  itohy #define	_LINUX_IOC_NONE		0U
     62  1.1  itohy #define	_LINUX_IOC_READ		1U
     63  1.1  itohy #define	_LINUX_IOC_WRITE	2U
     64  1.1  itohy 
     65  1.1  itohy #define	_LINUX_IOC(dir,type,nr,size)		\
     66  1.1  itohy 	(((nr)   << _LINUX_IOC_NRSHIFT) |	\
     67  1.1  itohy 	 ((type) << _LINUX_IOC_TYPESHIFT) |	\
     68  1.1  itohy 	 ((size) << _LINUX_IOC_SIZESHIFT) |	\
     69  1.1  itohy 	 ((dir)  << _LINUX_IOC_DIRSHIFT))
     70  1.1  itohy 
     71  1.1  itohy #define _LINUX_IO(type,nr)		\
     72  1.1  itohy 	_LINUX_IOC(_LINUX_IOC_NONE,(type),(nr),0)
     73  1.1  itohy #define	_LINUX_IOR(type,nr,size)	\
     74  1.1  itohy 	_LINUX_IOC(_LINUX_IOC_READ,(type),(nr),sizeof(size))
     75  1.1  itohy #define	_LINUX_IOW(type,nr,size)	\
     76  1.1  itohy 	_LINUX_IOC(_LINUX_IOC_WRITE,(type),(nr),sizeof(size))
     77  1.1  itohy #define	_LINUX_IOWR(type,nr,size)	\
     78  1.1  itohy 	_LINUX_IOC(_LINUX_IOC_READ|_LINUX_IOC_WRITE,(type),(nr),sizeof(size))
     79  1.1  itohy 
     80  1.1  itohy #define _LINUX_IOC_DIR(nr)	\
     81  1.1  itohy 	(((nr) >> _LINUX_IOC_DIRSHIFT) & _LINUX_IOC_DIRMASK)
     82  1.1  itohy #define _LINUX_IOC_TYPE(nr)	\
     83  1.1  itohy 	(((nr) >> _LINUX_IOC_TYPESHIFT) & _LINUX_IOC_TYPEMASK)
     84  1.1  itohy #define _LINUX_IOC_NR(nr)	\
     85  1.1  itohy 	(((nr) >> _LINUX_IOC_NRSHIFT) & _LINUX_IOC_NRMASK)
     86  1.1  itohy #define _LINUX_IOC_SIZE(nr)	\
     87  1.1  itohy 	(((nr) >> _LINUX_IOC_SIZESHIFT) & _LINUX_IOC_SIZEMASK)
     88  1.1  itohy 
     89  1.1  itohy #define LINUX_IOCGROUP(x)	_LINUX_IOC_TYPE(x)
     90  1.1  itohy 
     91  1.1  itohy #endif /* !_M68K_LINUX_IOCTL_H */
     92