<sys/ioccom.h>, <sys/ioctl.h>
. use <sys/ioccom.h> to make ioctls . use netbsd <sys/ioctl.h>, include minix ioctls . convert to varargs ioctl() like netbsd Change-Id: Id5165780df48172b28bf0003603516d30d7c1abb
This commit is contained in:
parent
ad9df9a490
commit
aae07bc777
19 changed files with 203 additions and 109 deletions
|
@ -1,6 +1,10 @@
|
||||||
#ifndef __EEPROMREAD_H
|
#ifndef __EEPROMREAD_H
|
||||||
#define __EEPROMREAD_H
|
#define __EEPROMREAD_H
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <minix/i2cdriver.h>
|
||||||
|
#include <minix/i2c.h>
|
||||||
|
|
||||||
enum device_types { I2C_DEVICE, EEPROM_DEVICE };
|
enum device_types { I2C_DEVICE, EEPROM_DEVICE };
|
||||||
#define DEFAULT_DEVICE I2C_DEVICE
|
#define DEFAULT_DEVICE I2C_DEVICE
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
* ioctl(2) function will translate to/from the Minix version of the struct.
|
* 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 <dev/i2c/i2c_io.h>
|
||||||
|
#include <minix/ioctl.h>
|
||||||
|
|
||||||
typedef struct minix_i2c_ioctl_exec {
|
typedef struct minix_i2c_ioctl_exec {
|
||||||
i2c_op_t iie_op; /* operation to perform */
|
i2c_op_t iie_op; /* operation to perform */
|
||||||
|
@ -21,6 +22,6 @@ typedef struct minix_i2c_ioctl_exec {
|
||||||
size_t iie_buflen; /* length of data buffer */
|
size_t iie_buflen; /* length of data buffer */
|
||||||
} minix_i2c_ioctl_exec_t;
|
} 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 */
|
#endif /* __MINIX_I2C_H */
|
||||||
|
|
|
@ -1,60 +1 @@
|
||||||
/* minix/ioctl.h - Ioctl helper definitions. Author: Kees J. Bot
|
#include <sys/ioccom.h>
|
||||||
* 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 */
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#define DIOCSETP _IOW('d', 3, struct part_geom)
|
#define DIOCSETP _IOW('d', 3, struct part_geom)
|
||||||
#define DIOCGETP _IOR('d', 4, struct part_geom)
|
#define DIOCGETP _IOR('d', 4, struct part_geom)
|
||||||
#define DIOCEJECT _IO ('d', 5)
|
#define DIOCEJECT _IO ('d', 5)
|
||||||
#define DIOCTIMEOUT _IORW('d', 6, int)
|
#define DIOCTIMEOUT _IOWR('d', 6, int)
|
||||||
#define DIOCOPENCT _IOR('d', 7, int)
|
#define DIOCOPENCT _IOR('d', 7, int)
|
||||||
#define DIOCFLUSH _IO ('d', 8)
|
#define DIOCFLUSH _IO ('d', 8)
|
||||||
#define DIOCSETWC _IOW('d', 9, int)
|
#define DIOCSETWC _IOW('d', 9, int)
|
||||||
|
|
|
@ -61,6 +61,6 @@ enum {
|
||||||
/* The I/O control requests. */
|
/* The I/O control requests. */
|
||||||
#define FBDCADDRULE _IOW('B', 1, struct fbd_rule) /* add a rule */
|
#define FBDCADDRULE _IOW('B', 1, struct fbd_rule) /* add a rule */
|
||||||
#define FBDCDELRULE _IOW('B', 2, fbd_rulenum_t) /* delete 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 */
|
#endif /* _S_I_FBD_H */
|
||||||
|
|
|
@ -30,8 +30,8 @@ struct msg_control
|
||||||
#define NWIOGETHOPT _IOR('n', 17, struct nwio_ethopt)
|
#define NWIOGETHOPT _IOR('n', 17, struct nwio_ethopt)
|
||||||
#define NWIOGETHSTAT _IOR('n', 18, struct nwio_ethstat)
|
#define NWIOGETHSTAT _IOR('n', 18, struct nwio_ethstat)
|
||||||
|
|
||||||
#define NWIOARPGIP _IORW('n',20, struct nwio_arp)
|
#define NWIOARPGIP _IOWR('n',20, struct nwio_arp)
|
||||||
#define NWIOARPGNEXT _IORW('n',21, struct nwio_arp)
|
#define NWIOARPGNEXT _IOWR('n',21, struct nwio_arp)
|
||||||
#define NWIOARPSIP _IOW ('n',22, struct nwio_arp)
|
#define NWIOARPSIP _IOW ('n',22, struct nwio_arp)
|
||||||
#define NWIOARPDIP _IOW ('n',23, struct nwio_arp)
|
#define NWIOARPDIP _IOW ('n',23, struct nwio_arp)
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@ struct msg_control
|
||||||
#define NWIOSIPOPT _IOW('n', 34, struct nwio_ipopt)
|
#define NWIOSIPOPT _IOW('n', 34, struct nwio_ipopt)
|
||||||
#define NWIOGIPOPT _IOR('n', 35, 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 NWIOSIPOROUTE _IOW ('n', 41, struct nwio_route)
|
||||||
#define NWIODIPOROUTE _IOW ('n', 42, 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 NWIOSIPIROUTE _IOW ('n', 44, struct nwio_route)
|
||||||
#define NWIODIPIROUTE _IOW ('n', 45, struct nwio_route)
|
#define NWIODIPIROUTE _IOW ('n', 45, struct nwio_route)
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ struct msg_control
|
||||||
#define NWIOSUDSPAIR _IOW ('n', 76, dev_t) /* socketpair() */
|
#define NWIOSUDSPAIR _IOW ('n', 76, dev_t) /* socketpair() */
|
||||||
#define NWIOSUDSACCEPT _IOW ('n', 77, struct sockaddr_un) /* accept() */
|
#define NWIOSUDSACCEPT _IOW ('n', 77, struct sockaddr_un) /* accept() */
|
||||||
#define NWIOSUDSCTRL _IOW ('n', 78, struct msg_control) /* sendmsg() */
|
#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 NWIOSPSIPOPT _IOW('n', 80, struct nwio_psipopt)
|
||||||
#define NWIOGPSIPOPT _IOR('n', 81, struct nwio_psipopt)
|
#define NWIOGPSIPOPT _IOR('n', 81, struct nwio_psipopt)
|
||||||
|
|
|
@ -22,13 +22,13 @@
|
||||||
#define DSPIORESUME _IO ('s', 33)
|
#define DSPIORESUME _IO ('s', 33)
|
||||||
|
|
||||||
/* Soundcard mixer ioctls. */
|
/* Soundcard mixer ioctls. */
|
||||||
#define MIXIOGETVOLUME _IORW('s', 10, struct volume_level)
|
#define MIXIOGETVOLUME _IOWR('s', 10, struct volume_level)
|
||||||
#define MIXIOGETINPUTLEFT _IORW('s', 11, struct inout_ctrl)
|
#define MIXIOGETINPUTLEFT _IOWR('s', 11, struct inout_ctrl)
|
||||||
#define MIXIOGETINPUTRIGHT _IORW('s', 12, struct inout_ctrl)
|
#define MIXIOGETINPUTRIGHT _IOWR('s', 12, struct inout_ctrl)
|
||||||
#define MIXIOGETOUTPUT _IORW('s', 13, struct inout_ctrl)
|
#define MIXIOGETOUTPUT _IOWR('s', 13, struct inout_ctrl)
|
||||||
#define MIXIOSETVOLUME _IORW('s', 20, struct volume_level)
|
#define MIXIOSETVOLUME _IOWR('s', 20, struct volume_level)
|
||||||
#define MIXIOSETINPUTLEFT _IORW('s', 21, struct inout_ctrl)
|
#define MIXIOSETINPUTLEFT _IOWR('s', 21, struct inout_ctrl)
|
||||||
#define MIXIOSETINPUTRIGHT _IORW('s', 22, struct inout_ctrl)
|
#define MIXIOSETINPUTRIGHT _IOWR('s', 22, struct inout_ctrl)
|
||||||
#define MIXIOSETOUTPUT _IORW('s', 23, struct inout_ctrl)
|
#define MIXIOSETOUTPUT _IOWR('s', 23, struct inout_ctrl)
|
||||||
|
|
||||||
#endif /* _S_I_SOUND_H */
|
#endif /* _S_I_SOUND_H */
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <minix/audio_fw.h>
|
#include <minix/audio_fw.h>
|
||||||
#include <minix/endpoint.h>
|
#include <minix/endpoint.h>
|
||||||
#include <minix/ds.h>
|
#include <minix/ds.h>
|
||||||
|
#include <sys/ioccom.h>
|
||||||
|
|
||||||
|
|
||||||
static int msg_open(devminor_t minor_dev_nr, int access,
|
static int msg_open(devminor_t minor_dev_nr, int access,
|
||||||
|
@ -49,7 +50,7 @@ static special_file_t* get_special_file(int minor_dev_nr);
|
||||||
static void tell_dev(vir_bytes buf, size_t size, int pci_bus, int
|
static void tell_dev(vir_bytes buf, size_t size, int pci_bus, int
|
||||||
pci_dev, int pci_func);
|
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_id = 0; /* id of irq hook at the kernel */
|
||||||
static int irq_hook_set = FALSE;
|
static int irq_hook_set = FALSE;
|
||||||
|
|
||||||
|
@ -369,7 +370,7 @@ static int msg_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||||
return EIO;
|
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);
|
len = io_ctl_length(request);
|
||||||
|
|
||||||
if (sys_safecopyfrom(endpt, grant, 0, (vir_bytes)io_ctl_buf,
|
if (sys_safecopyfrom(endpt, grant, 0, (vir_bytes)io_ctl_buf,
|
||||||
|
@ -381,8 +382,8 @@ static int msg_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||||
/* all ioctl's are passed to the device specific part of the driver */
|
/* all ioctl's are passed to the device specific part of the driver */
|
||||||
status = drv_io_ctl(request, (void *)io_ctl_buf, &len, chan);
|
status = drv_io_ctl(request, (void *)io_ctl_buf, &len, chan);
|
||||||
|
|
||||||
/* _IOC_OUT bit -> user expects data */
|
/* IOC_OUT bit -> user expects data */
|
||||||
if (status == OK && request & _IOC_OUT) {
|
if (status == OK && request & IOC_OUT) {
|
||||||
/* copy result back to user */
|
/* copy result back to user */
|
||||||
|
|
||||||
if (sys_safecopyto(endpt, grant, 0, (vir_bytes)io_ctl_buf,
|
if (sys_safecopyto(endpt, grant, 0, (vir_bytes)io_ctl_buf,
|
||||||
|
@ -812,7 +813,7 @@ static int init_buffers(sub_dev_t *sub_dev_ptr)
|
||||||
|
|
||||||
static int io_ctl_length(int io_request) {
|
static int io_ctl_length(int io_request) {
|
||||||
io_request >>= 16;
|
io_request >>= 16;
|
||||||
return io_request & _IOCPARM_MASK;
|
return io_request & IOCPARM_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <minix/i2c.h>
|
#include <minix/i2c.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/ioccom.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef __weak_alias
|
#ifdef __weak_alias
|
||||||
__weak_alias(ioctl, _ioctl)
|
__weak_alias(ioctl, _ioctl)
|
||||||
|
@ -44,14 +47,16 @@ static void rewrite_i2c_minix_to_netbsd(i2c_ioctl_exec_t *out,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ioctl(fd, request, data)
|
int ioctl(int fd, unsigned long request, ...)
|
||||||
int fd;
|
|
||||||
unsigned long request;
|
|
||||||
void *data;
|
|
||||||
{
|
{
|
||||||
int r, request_save;
|
int r, request_save;
|
||||||
message m;
|
message m;
|
||||||
void *addr;
|
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
|
* To support compatibility with interfaces on other systems, certain
|
||||||
|
@ -90,5 +95,7 @@ void *data;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ static int sr_rwio(sr_req_t *req)
|
||||||
break;
|
break;
|
||||||
case SRR_IOCTL:
|
case SRR_IOCTL:
|
||||||
request= m->mq_req.srr_req;
|
request= m->mq_req.srr_req;
|
||||||
size= (request >> 16) & _IOCPARM_MASK;
|
size= _MINIX_IOCTL_SIZE(request);
|
||||||
if (size>MAX_IOCTL_S)
|
if (size>MAX_IOCTL_S)
|
||||||
{
|
{
|
||||||
DBLOCK(1, printf("replying EINVAL\n"));
|
DBLOCK(1, printf("replying EINVAL\n"));
|
||||||
|
|
|
@ -597,8 +597,7 @@ static int nic_do_ioctl(struct socket * sock, struct nic * nic,
|
||||||
debug_print("device /dev/%s req %c %ld %ld",
|
debug_print("device /dev/%s req %c %ld %ld",
|
||||||
nic->name,
|
nic->name,
|
||||||
(unsigned char) (req->req >> 8),
|
(unsigned char) (req->req >> 8),
|
||||||
req->req & 0xff,
|
req->req & 0xff, _MINIX_IOCTL_SIZE(req->req));
|
||||||
(req->req >> 16) & _IOCPARM_MASK);
|
|
||||||
|
|
||||||
debug_drv_print("socket %ld", sock ? get_sock_num(sock) : -1);
|
debug_drv_print("socket %ld", sock ? get_sock_num(sock) : -1);
|
||||||
|
|
||||||
|
|
|
@ -318,7 +318,7 @@ static int raw_ip_op_ioctl(struct socket * sock, struct sock_req * req,
|
||||||
get_sock_num(sock),
|
get_sock_num(sock),
|
||||||
(unsigned char) (req->req >> 8),
|
(unsigned char) (req->req >> 8),
|
||||||
req->req & 0xff,
|
req->req & 0xff,
|
||||||
(req->req >> 16) & _IOCPARM_MASK);
|
_MINIX_IOCTL_SIZE(req->req));
|
||||||
|
|
||||||
switch (req->req) {
|
switch (req->req) {
|
||||||
case NWIOSIPOPT:
|
case NWIOSIPOPT:
|
||||||
|
|
|
@ -1035,8 +1035,7 @@ static int tcp_op_ioctl(struct socket * sock, struct sock_req * req,
|
||||||
debug_tcp_print("socket num %ld req %c %ld %ld",
|
debug_tcp_print("socket num %ld req %c %ld %ld",
|
||||||
get_sock_num(sock),
|
get_sock_num(sock),
|
||||||
(unsigned char) (req->req >> 8),
|
(unsigned char) (req->req >> 8),
|
||||||
req->req & 0xff,
|
req->req & 0xff, _MINIX_IOCTL_SIZE(req->req));
|
||||||
(req->req >> 16) & _IOCPARM_MASK);
|
|
||||||
|
|
||||||
switch (req->req) {
|
switch (req->req) {
|
||||||
case NWIOGTCPCONF:
|
case NWIOGTCPCONF:
|
||||||
|
|
|
@ -376,8 +376,7 @@ static int udp_op_ioctl(struct socket * sock, struct sock_req * req,
|
||||||
debug_udp_print("socket num %ld req %c %ld %ld",
|
debug_udp_print("socket num %ld req %c %ld %ld",
|
||||||
get_sock_num(sock),
|
get_sock_num(sock),
|
||||||
(unsigned char) (req->req >> 8),
|
(unsigned char) (req->req >> 8),
|
||||||
req->req & 0xff,
|
req->req & 0xff, _MINIX_IOCTL_SIZE(req->req));
|
||||||
(req->req >> 16) & _IOCPARM_MASK);
|
|
||||||
|
|
||||||
switch (req->req) {
|
switch (req->req) {
|
||||||
case NWIOSUDPOPT:
|
case NWIOSUDPOPT:
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#ifndef _SYS_IOCCOM_H_
|
#ifndef _SYS_IOCCOM_H_
|
||||||
#define _SYS_IOCCOM_H_
|
#define _SYS_IOCCOM_H_
|
||||||
|
|
||||||
|
#ifndef __minix
|
||||||
/*
|
/*
|
||||||
* Ioctl's have the command encoded in the lower word, and the size of
|
* 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
|
* any in or out parameters in the upper word. The high 3 bits of the
|
||||||
|
@ -45,6 +46,21 @@
|
||||||
* +---------------------------------------------------------------+
|
* +---------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
|
#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 IOCPARM_SHIFT 16
|
||||||
#define IOCGROUP_SHIFT 8
|
#define IOCGROUP_SHIFT 8
|
||||||
#define IOCPARM_LEN(x) (((x) >> IOCPARM_SHIFT) & IOCPARM_MASK)
|
#define IOCPARM_LEN(x) (((x) >> IOCPARM_SHIFT) & IOCPARM_MASK)
|
||||||
|
@ -59,6 +75,7 @@
|
||||||
/* copy parameters in */
|
/* copy parameters in */
|
||||||
#define IOC_IN (unsigned long)0x80000000
|
#define IOC_IN (unsigned long)0x80000000
|
||||||
/* copy parameters in and out */
|
/* copy parameters in and out */
|
||||||
|
|
||||||
#define IOC_INOUT (IOC_IN|IOC_OUT)
|
#define IOC_INOUT (IOC_IN|IOC_OUT)
|
||||||
/* mask for IN/OUT/VOID */
|
/* mask for IN/OUT/VOID */
|
||||||
#define IOC_DIRMASK (unsigned long)0xe0000000
|
#define IOC_DIRMASK (unsigned long)0xe0000000
|
||||||
|
@ -72,4 +89,23 @@
|
||||||
/* this should be _IORW, but stdio got there first */
|
/* this should be _IORW, but stdio got there first */
|
||||||
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
|
#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_ */
|
#endif /* !_SYS_IOCCOM_H_ */
|
||||||
|
|
130
sys/sys/ioctl.h
130
sys/sys/ioctl.h
|
@ -1,19 +1,68 @@
|
||||||
/* sys/ioctl.h - All ioctl() command codes. Author: Kees J. Bot
|
/* $NetBSD: ioctl.h,v 1.36 2009/02/13 22:41:04 apb Exp $ */
|
||||||
* 23 Nov 2002
|
|
||||||
|
/*-
|
||||||
|
* 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.
|
||||||
*
|
*
|
||||||
* This header file includes all other ioctl command code headers.
|
* 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 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
|
#ifndef _SYS_IOCTL_H_
|
||||||
#define _S_IOCTL_H
|
#define _SYS_IOCTL_H_
|
||||||
|
|
||||||
/* A driver that uses ioctls claims a character for its series of commands.
|
#include <sys/ttycom.h>
|
||||||
* 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_net.h> /* 'n' */
|
||||||
#include <sys/ioc_disk.h> /* 'd' */
|
#include <sys/ioc_disk.h> /* 'd' */
|
||||||
#include <sys/ioc_file.h> /* 'f' */
|
#include <sys/ioc_file.h> /* 'f' */
|
||||||
|
@ -24,8 +73,63 @@
|
||||||
#include <sys/ioc_fbd.h> /* 'B' */
|
#include <sys/ioc_fbd.h> /* 'B' */
|
||||||
#include <sys/ioc_fb.h> /* 'V' */
|
#include <sys/ioc_fb.h> /* 'V' */
|
||||||
#include <dev/vndvar.h> /* 'F' */
|
#include <dev/vndvar.h> /* 'F' */
|
||||||
|
#include <dev/i2c/i2c_io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TIOCGSIZE TIOCGWINSZ
|
/*
|
||||||
#define TIOCSSIZE TIOCSWINSZ
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
#endif /* _S_IOCTL_H */
|
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 ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#ifndef __minix
|
||||||
/* $NetBSD: ioctl_compat.h,v 1.15 2005/12/03 17:10:46 christos Exp $ */
|
/* $NetBSD: ioctl_compat.h,v 1.15 2005/12/03 17:10:46 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -163,3 +164,4 @@ struct sgttyb {
|
||||||
#define NTTYDISC 2
|
#define NTTYDISC 2
|
||||||
|
|
||||||
#endif /* !_SYS_IOCTL_COMPAT_H_ */
|
#endif /* !_SYS_IOCTL_COMPAT_H_ */
|
||||||
|
#endif
|
||||||
|
|
|
@ -176,8 +176,8 @@ typedef char linedn_t[TTLINEDNAMELEN];
|
||||||
#define KIOCSMAP _IOW('k', 3, keymap_t)
|
#define KIOCSMAP _IOW('k', 3, keymap_t)
|
||||||
|
|
||||||
/* /dev/video ioctls. */
|
/* /dev/video ioctls. */
|
||||||
#define TIOCMAPMEM _IORW('v', 1, struct mapreqvm)
|
#define TIOCMAPMEM _IOWR('v', 1, struct mapreqvm)
|
||||||
#define TIOCUNMAPMEM _IORW('v', 2, struct mapreqvm)
|
#define TIOCUNMAPMEM _IOWR('v', 2, struct mapreqvm)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !_SYS_TTYCOM_H_ */
|
#endif /* !_SYS_TTYCOM_H_ */
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <sys/ttycom.h>
|
#include <sys/ttycom.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
Loading…
Reference in a new issue