#ifndef __EEPROMREAD_H
#define __EEPROMREAD_H
+#include <sys/ioctl.h>
+#include <minix/i2cdriver.h>
+#include <minix/i2c.h>
+
enum device_types { I2C_DEVICE, EEPROM_DEVICE };
#define DEFAULT_DEVICE I2C_DEVICE
* ioctl(2) function will translate to/from the Minix version of the struct.
*/
-#include <minix/ioctl.h>
+#include <sys/types.h>
#include <dev/i2c/i2c_io.h>
+#include <minix/ioctl.h>
typedef struct minix_i2c_ioctl_exec {
i2c_op_t iie_op; /* operation to perform */
size_t iie_buflen; /* length of data buffer */
} minix_i2c_ioctl_exec_t;
-#define MINIX_I2C_IOCTL_EXEC _IORW('I', 1, minix_i2c_ioctl_exec_t)
+#define MINIX_I2C_IOCTL_EXEC _IOWR('I', 1, minix_i2c_ioctl_exec_t)
#endif /* __MINIX_I2C_H */
-/* minix/ioctl.h - Ioctl helper definitions. Author: Kees J. Bot
- * 23 Nov 2002
- *
- * This file is included by every header file that defines ioctl codes.
- */
-
-#ifndef _M_IOCTL_H
-#define _M_IOCTL_H
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-/* Ioctls have the command encoded in the low-order word, and the size
- * of the parameter in the high-order word. The 3 high bits of the high-
- * order word are used to encode the in/out/void status of the parameter.
- */
-#define _IOCPARM_MASK 0x0FFF
-#define _IOCPARM_MASK_BIG 0x0FFFFF
-#define _IOC_VOID 0x20000000
-#define _IOCTYPE_MASK 0xFFFF
-#define _IOC_IN 0x40000000
-#define _IOC_OUT 0x80000000
-#define _IOC_INOUT (_IOC_IN | _IOC_OUT)
-
-/* Flag indicating ioctl format with only one type field, and more bits
- * for the size field (using mask _IOCPARM_MASK_BIG).
- */
-#define _IOC_BIG 0x10000000
-
-#define _IO(x,y) ((x << 8) | y | _IOC_VOID)
-#define _IOR(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\
- _IOC_OUT)
-#define _IOW(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\
- _IOC_IN)
-#define _IORW(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\
- _IOC_INOUT)
-#define _IOWR(x,y,t) _IORW(x,y,t) /* NetBSD compatibility */
-
-#define _IOW_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \
- | _IOC_IN | _IOC_BIG)
-#define _IOR_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \
- | _IOC_OUT | _IOC_BIG)
-#define _IORW_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \
- | _IOC_INOUT | _IOC_BIG)
-
-/* Decode an ioctl call. */
-#define _MINIX_IOCTL_SIZE(i) (((i) >> 16) & _IOCPARM_MASK)
-#define _MINIX_IOCTL_IOR(i) ((i) & _IOC_OUT)
-#define _MINIX_IOCTL_IORW(i) ((i) & _IOC_INOUT)
-#define _MINIX_IOCTL_IOW(i) ((i) & _IOC_IN)
-
-/* Recognize and decode size of a 'big' ioctl call. */
-#define _MINIX_IOCTL_BIG(i) ((i) & _IOC_BIG)
-#define _MINIX_IOCTL_SIZE_BIG(i) (((i) >> 8) & _IOCPARM_MASK_BIG)
-
-__BEGIN_DECLS
-int ioctl(int _fd, unsigned long _request, void *_data);
-__END_DECLS
-
-#endif /* _M_IOCTL_H */
+#include <sys/ioccom.h>
#define DIOCSETP _IOW('d', 3, struct part_geom)
#define DIOCGETP _IOR('d', 4, struct part_geom)
#define DIOCEJECT _IO ('d', 5)
-#define DIOCTIMEOUT _IORW('d', 6, int)
+#define DIOCTIMEOUT _IOWR('d', 6, int)
#define DIOCOPENCT _IOR('d', 7, int)
#define DIOCFLUSH _IO ('d', 8)
#define DIOCSETWC _IOW('d', 9, int)
/* The I/O control requests. */
#define FBDCADDRULE _IOW('B', 1, struct fbd_rule) /* add a rule */
#define FBDCDELRULE _IOW('B', 2, fbd_rulenum_t) /* delete a rule */
-#define FBDCGETRULE _IORW('B', 3, struct fbd_rule) /* retrieve a rule */
+#define FBDCGETRULE _IOWR('B', 3, struct fbd_rule) /* retrieve a rule */
#endif /* _S_I_FBD_H */
#define NWIOGETHOPT _IOR('n', 17, struct nwio_ethopt)
#define NWIOGETHSTAT _IOR('n', 18, struct nwio_ethstat)
-#define NWIOARPGIP _IORW('n',20, struct nwio_arp)
-#define NWIOARPGNEXT _IORW('n',21, struct nwio_arp)
+#define NWIOARPGIP _IOWR('n',20, struct nwio_arp)
+#define NWIOARPGNEXT _IOWR('n',21, struct nwio_arp)
#define NWIOARPSIP _IOW ('n',22, struct nwio_arp)
#define NWIOARPDIP _IOW ('n',23, struct nwio_arp)
#define NWIOSIPOPT _IOW('n', 34, struct nwio_ipopt)
#define NWIOGIPOPT _IOR('n', 35, struct nwio_ipopt)
-#define NWIOGIPOROUTE _IORW('n', 40, struct nwio_route)
+#define NWIOGIPOROUTE _IOWR('n', 40, struct nwio_route)
#define NWIOSIPOROUTE _IOW ('n', 41, struct nwio_route)
#define NWIODIPOROUTE _IOW ('n', 42, struct nwio_route)
-#define NWIOGIPIROUTE _IORW('n', 43, struct nwio_route)
+#define NWIOGIPIROUTE _IOWR('n', 43, struct nwio_route)
#define NWIOSIPIROUTE _IOW ('n', 44, struct nwio_route)
#define NWIODIPIROUTE _IOW ('n', 45, struct nwio_route)
#define NWIOSUDSPAIR _IOW ('n', 76, dev_t) /* socketpair() */
#define NWIOSUDSACCEPT _IOW ('n', 77, struct sockaddr_un) /* accept() */
#define NWIOSUDSCTRL _IOW ('n', 78, struct msg_control) /* sendmsg() */
-#define NWIOGUDSCTRL _IORW('n', 79, struct msg_control) /* recvmsg() */
+#define NWIOGUDSCTRL _IOWR('n', 79, struct msg_control) /* recvmsg() */
#define NWIOSPSIPOPT _IOW('n', 80, struct nwio_psipopt)
#define NWIOGPSIPOPT _IOR('n', 81, struct nwio_psipopt)
#define DSPIORESUME _IO ('s', 33)
/* Soundcard mixer ioctls. */
-#define MIXIOGETVOLUME _IORW('s', 10, struct volume_level)
-#define MIXIOGETINPUTLEFT _IORW('s', 11, struct inout_ctrl)
-#define MIXIOGETINPUTRIGHT _IORW('s', 12, struct inout_ctrl)
-#define MIXIOGETOUTPUT _IORW('s', 13, struct inout_ctrl)
-#define MIXIOSETVOLUME _IORW('s', 20, struct volume_level)
-#define MIXIOSETINPUTLEFT _IORW('s', 21, struct inout_ctrl)
-#define MIXIOSETINPUTRIGHT _IORW('s', 22, struct inout_ctrl)
-#define MIXIOSETOUTPUT _IORW('s', 23, struct inout_ctrl)
+#define MIXIOGETVOLUME _IOWR('s', 10, struct volume_level)
+#define MIXIOGETINPUTLEFT _IOWR('s', 11, struct inout_ctrl)
+#define MIXIOGETINPUTRIGHT _IOWR('s', 12, struct inout_ctrl)
+#define MIXIOGETOUTPUT _IOWR('s', 13, struct inout_ctrl)
+#define MIXIOSETVOLUME _IOWR('s', 20, struct volume_level)
+#define MIXIOSETINPUTLEFT _IOWR('s', 21, struct inout_ctrl)
+#define MIXIOSETINPUTRIGHT _IOWR('s', 22, struct inout_ctrl)
+#define MIXIOSETOUTPUT _IOWR('s', 23, struct inout_ctrl)
#endif /* _S_I_SOUND_H */
#include <minix/audio_fw.h>
#include <minix/endpoint.h>
#include <minix/ds.h>
+#include <sys/ioccom.h>
static int msg_open(devminor_t minor_dev_nr, int access,
static void tell_dev(vir_bytes buf, size_t size, int pci_bus, int
pci_dev, int pci_func);
-static char io_ctl_buf[_IOCPARM_MASK];
+static char io_ctl_buf[IOCPARM_MASK];
static int irq_hook_id = 0; /* id of irq hook at the kernel */
static int irq_hook_set = FALSE;
return EIO;
}
- if (request & _IOC_IN) { /* if there is data for us, copy it */
+ if (request & IOC_IN) { /* if there is data for us, copy it */
len = io_ctl_length(request);
if (sys_safecopyfrom(endpt, grant, 0, (vir_bytes)io_ctl_buf,
/* all ioctl's are passed to the device specific part of the driver */
status = drv_io_ctl(request, (void *)io_ctl_buf, &len, chan);
- /* _IOC_OUT bit -> user expects data */
- if (status == OK && request & _IOC_OUT) {
+ /* IOC_OUT bit -> user expects data */
+ if (status == OK && request & IOC_OUT) {
/* copy result back to user */
if (sys_safecopyto(endpt, grant, 0, (vir_bytes)io_ctl_buf,
static int io_ctl_length(int io_request) {
io_request >>= 16;
- return io_request & _IOCPARM_MASK;
+ return io_request & IOCPARM_MASK;
}
#include <sys/ioctl.h>
#include <minix/i2c.h>
+#include <string.h>
+#include <sys/ioccom.h>
+#include <stdarg.h>
#ifdef __weak_alias
__weak_alias(ioctl, _ioctl)
}
}
-int ioctl(fd, request, data)
-int fd;
-unsigned long request;
-void *data;
+int ioctl(int fd, unsigned long request, ...)
{
int r, request_save;
message m;
void *addr;
+ void *data;
+ va_list ap;
+
+ va_start(ap, request);
+ data = va_arg(ap, void *);
/*
* To support compatibility with interfaces on other systems, certain
break;
}
+ va_end(ap);
+
return r;
}
break;
case SRR_IOCTL:
request= m->mq_req.srr_req;
- size= (request >> 16) & _IOCPARM_MASK;
+ size= _MINIX_IOCTL_SIZE(request);
if (size>MAX_IOCTL_S)
{
DBLOCK(1, printf("replying EINVAL\n"));
debug_print("device /dev/%s req %c %ld %ld",
nic->name,
(unsigned char) (req->req >> 8),
- req->req & 0xff,
- (req->req >> 16) & _IOCPARM_MASK);
+ req->req & 0xff, _MINIX_IOCTL_SIZE(req->req));
debug_drv_print("socket %ld", sock ? get_sock_num(sock) : -1);
get_sock_num(sock),
(unsigned char) (req->req >> 8),
req->req & 0xff,
- (req->req >> 16) & _IOCPARM_MASK);
+ _MINIX_IOCTL_SIZE(req->req));
switch (req->req) {
case NWIOSIPOPT:
debug_tcp_print("socket num %ld req %c %ld %ld",
get_sock_num(sock),
(unsigned char) (req->req >> 8),
- req->req & 0xff,
- (req->req >> 16) & _IOCPARM_MASK);
+ req->req & 0xff, _MINIX_IOCTL_SIZE(req->req));
switch (req->req) {
case NWIOGTCPCONF:
debug_udp_print("socket num %ld req %c %ld %ld",
get_sock_num(sock),
(unsigned char) (req->req >> 8),
- req->req & 0xff,
- (req->req >> 16) & _IOCPARM_MASK);
+ req->req & 0xff, _MINIX_IOCTL_SIZE(req->req));
switch (req->req) {
case NWIOSUDPOPT:
#ifndef _SYS_IOCCOM_H_
#define _SYS_IOCCOM_H_
+#ifndef __minix
/*
* Ioctl's have the command encoded in the lower word, and the size of
* any in or out parameters in the upper word. The high 3 bits of the
* +---------------------------------------------------------------+
*/
#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
+#else
+/* For Minix, reserve one extra flag bit: the 'big' size flag.
+ * We have big ioctls and can't help it.
+ *
+ * 31 28 27 16 15 8 7 0
+ * +----------------------------------------------------------------+
+ * | I/O/B | Parameter Length | Command Group | Command |
+ * +----------------------------------------------------------------+
+ */
+#define IOC_BIG (unsigned long)0x10000000
+#define IOCPARM_MASK 0xfff /* parameter length, at most 12 bits */
+#define IOCPARM_MASK_BIG 0xFFFFF /* or 20 bits, if IOC_BIG is set */
+#define IOCPARM_SHIFT_BIG 8
+#endif
+
#define IOCPARM_SHIFT 16
#define IOCGROUP_SHIFT 8
#define IOCPARM_LEN(x) (((x) >> IOCPARM_SHIFT) & IOCPARM_MASK)
/* copy parameters in */
#define IOC_IN (unsigned long)0x80000000
/* copy parameters in and out */
+
#define IOC_INOUT (IOC_IN|IOC_OUT)
/* mask for IN/OUT/VOID */
#define IOC_DIRMASK (unsigned long)0xe0000000
/* this should be _IORW, but stdio got there first */
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
+#ifdef __minix
+#define _IOW_BIG(y,t) (y | ((sizeof(t) & IOCPARM_MASK_BIG) << IOCPARM_SHIFT_BIG) \
+ | IOC_IN | IOC_BIG)
+#define _IOR_BIG(y,t) (y | ((sizeof(t) & IOCPARM_MASK_BIG) << IOCPARM_SHIFT_BIG) \
+ | IOC_OUT | IOC_BIG)
+#define _IORW_BIG(y,t) (y | ((sizeof(t) & IOCPARM_MASK_BIG) << IOCPARM_SHIFT_BIG) \
+ | IOC_INOUT | IOC_BIG)
+
+/* Decode an ioctl call. */
+#define _MINIX_IOCTL_SIZE(i) (((i) >> IOCPARM_SHIFT) & IOCPARM_MASK)
+#define _MINIX_IOCTL_IOR(i) ((i) & IOC_OUT)
+#define _MINIX_IOCTL_IORW(i) ((i) & IOC_INOUT)
+#define _MINIX_IOCTL_IOW(i) ((i) & IOC_IN)
+
+/* Recognize and decode size of a 'big' ioctl call. */
+#define _MINIX_IOCTL_BIG(i) ((i) & IOC_BIG)
+#define _MINIX_IOCTL_SIZE_BIG(i) (((i) >> IOCPARM_SHIFT_BIG) & IOCPARM_MASK_BIG)
+#endif
+
#endif /* !_SYS_IOCCOM_H_ */
-/* sys/ioctl.h - All ioctl() command codes. Author: Kees J. Bot
- * 23 Nov 2002
+/* $NetBSD: ioctl.h,v 1.36 2009/02/13 22:41:04 apb Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
- * This header file includes all other ioctl command code headers.
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ioctl.h 8.6 (Berkeley) 3/28/94
*/
-#ifndef _S_IOCTL_H
-#define _S_IOCTL_H
+#ifndef _SYS_IOCTL_H_
+#define _SYS_IOCTL_H_
+
+#include <sys/ttycom.h>
-/* A driver that uses ioctls claims a character for its series of commands.
- * For instance: #define TCGETS _IOR('T', 8, struct termios)
- * This is a terminal ioctl that uses the character 'T'. The character(s)
- * used in each header file are shown in the comment following.
+/*
+ * Pun for SunOS prior to 3.2. SunOS 3.2 and later support TIOCGWINSZ
+ * and TIOCSWINSZ (yes, even 3.2-3.5, the fact that it wasn't documented
+ * nonwithstanding).
*/
+struct ttysize {
+ unsigned short ts_lines;
+ unsigned short ts_cols;
+ unsigned short ts_xxx;
+ unsigned short ts_yyy;
+};
+#define TIOCGSIZE TIOCGWINSZ
+#define TIOCSSIZE TIOCSWINSZ
-#include <sys/ttycom.h> /* 't' */
+#include <sys/ioccom.h>
+
+#include <sys/dkio.h>
+#include <sys/filio.h>
+#include <sys/sockio.h>
+
+#ifdef __minix
+/* ioctls */
#include <sys/ioc_net.h> /* 'n' */
#include <sys/ioc_disk.h> /* 'd' */
#include <sys/ioc_file.h> /* 'f' */
#include <sys/ioc_fbd.h> /* 'B' */
#include <sys/ioc_fb.h> /* 'V' */
#include <dev/vndvar.h> /* 'F' */
+#include <dev/i2c/i2c_io.h>
+#endif
+
+/*
+ * Passthrough ioctl commands. These are passed through to devices
+ * as they are, it is expected that the device (a module, for example),
+ * will know how to deal with them. One for each emulation, so that
+ * no namespace clashes will occur between them, for devices that
+ * may be dealing with specific ioctls for multiple emulations.
+ */
+
+struct ioctl_pt {
+ unsigned long com;
+ void *data;
+};
+
+#define PTIOCNETBSD _IOW('Z', 0, struct ioctl_pt)
+#define PTIOCSUNOS _IOW('Z', 1, struct ioctl_pt)
+#define PTIOCSVR4 _IOW('Z', 2, struct ioctl_pt)
+#define PTIOCLINUX _IOW('Z', 3, struct ioctl_pt)
+#define PTIOCFREEBSD _IOW('Z', 4, struct ioctl_pt)
+#define PTIOCOSF1 _IOW('Z', 5, struct ioctl_pt)
+#define PTIOCULTRIX _IOW('Z', 6, struct ioctl_pt)
+#define PTIOCWIN32 _IOW('Z', 7, struct ioctl_pt)
+
+#ifndef _KERNEL
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int ioctl(int, unsigned long, ...);
+__END_DECLS
+#endif /* !_KERNEL */
+#endif /* !_SYS_IOCTL_H_ */
+
+#ifndef __minix
+/*
+ * Keep outside _SYS_IOCTL_H_
+ * Compatibility with old terminal driver
+ *
+ * Source level -> #define USE_OLD_TTY
+ * Kernel level -> options COMPAT_43 or COMPAT_SUNOS or ...
+ */
-#define TIOCGSIZE TIOCGWINSZ
-#define TIOCSSIZE TIOCSWINSZ
+#if defined(_KERNEL_OPT)
+#include "opt_compat_freebsd.h"
+#include "opt_compat_sunos.h"
+#include "opt_compat_svr4.h"
+#include "opt_compat_43.h"
+#include "opt_compat_osf1.h"
+#include "opt_compat_ibcs2.h"
+#include "opt_modular.h"
+#endif
-#endif /* _S_IOCTL_H */
+#if defined(USE_OLD_TTY) || defined(COMPAT_43) || defined(COMPAT_SUNOS) || \
+ defined(COMPAT_SVR4) || defined(COMPAT_FREEBSD) || defined(COMPAT_OSF1) || \
+ defined(COMPAT_IBCS2) || defined(MODULAR)
+#include <sys/ioctl_compat.h>
+#endif
+#endif
+#ifndef __minix
/* $NetBSD: ioctl_compat.h,v 1.15 2005/12/03 17:10:46 christos Exp $ */
/*
#define NTTYDISC 2
#endif /* !_SYS_IOCTL_COMPAT_H_ */
+#endif
#define KIOCSMAP _IOW('k', 3, keymap_t)
/* /dev/video ioctls. */
-#define TIOCMAPMEM _IORW('v', 1, struct mapreqvm)
-#define TIOCUNMAPMEM _IORW('v', 2, struct mapreqvm)
+#define TIOCMAPMEM _IOWR('v', 1, struct mapreqvm)
+#define TIOCUNMAPMEM _IOWR('v', 2, struct mapreqvm)
#endif
#endif /* !_SYS_TTYCOM_H_ */
#include <assert.h>
#include <sys/ttycom.h>
+#include <sys/ioctl.h>
#include <sys/times.h>
#include <sys/types.h>
#include <sys/time.h>