From: Lionel Sambuc Date: Fri, 6 Jun 2014 11:00:39 +0000 (+0200) Subject: Message type for CDEV_{READ,WRITE,IOCTL} X-Git-Tag: v3.3.0~191 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch10.html?a=commitdiff_plain;h=b41d3ab74ede8c92aca77a2ca1310becb9327f30;p=minix.git Message type for CDEV_{READ,WRITE,IOCTL} Change-Id: Ia89c98410d3775fe3b6621576eadd186d60ec894 --- diff --git a/include/minix/com.h b/include/minix/com.h index 0ee25611c..324f82117 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -1009,16 +1009,6 @@ #define CDEV_SEL1_REPLY (CDEV_RS_BASE + 1) /* immediate select reply */ #define CDEV_SEL2_REPLY (CDEV_RS_BASE + 2) /* select notification reply */ -/* Field names for block device messages. */ -#define CDEV_MINOR m10_i1 /* minor device number */ -#define CDEV_GRANT m10_i2 /* grant ID of buffer */ -#define CDEV_COUNT m10_i3 /* number of bytes to transfer */ -#define CDEV_USER m10_i3 /* endpoint of user process */ -#define CDEV_FLAGS m10_i4 /* transfer flags */ -#define CDEV_ID m10_l1 /* opaque request ID */ -#define CDEV_REQUEST m10_l2 /* I/O control request */ -#define CDEV_POS m10_ull1 /* transfer position */ - /* Bits in 'CDEV_ACCESS' field of block device open requests. */ # define CDEV_R_BIT 0x01 /* open with read access */ # define CDEV_W_BIT 0x02 /* open with write access */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index a668079ab..59f19c4bb 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -1592,6 +1592,20 @@ typedef struct { } mess_vfs_lchardriver_openclose; _ASSERT_MSG_SIZE(mess_vfs_lchardriver_openclose); +typedef struct { + off_t pos; + cp_grant_id_t grant; + size_t count; + int request; + int flags; + endpoint_t id; + endpoint_t user; + devminor_t minor; + + uint8_t padding[20]; +} mess_vfs_lchardriver_readwrite; +_ASSERT_MSG_SIZE(mess_vfs_lchardriver_readwrite); + typedef struct { devminor_t minor; int ops; @@ -1889,6 +1903,7 @@ typedef struct { mess_vfs_lchardriver_cancel m_vfs_lchardriver_cancel; mess_vfs_lchardriver_openclose m_vfs_lchardriver_openclose; + mess_vfs_lchardriver_readwrite m_vfs_lchardriver_readwrite; mess_vfs_lchardriver_select m_vfs_lchardriver_select; mess_vfs_utimens m_vfs_utimens; diff --git a/lib/libchardriver/chardriver.c b/lib/libchardriver/chardriver.c index 586a9c656..0890d5bf8 100644 --- a/lib/libchardriver/chardriver.c +++ b/lib/libchardriver/chardriver.c @@ -205,13 +205,13 @@ static void chardriver_reply(message *mess, int ipc_status, int r) case CDEV_READ: case CDEV_WRITE: case CDEV_IOCTL: - /* FIXME: we should be able to check CDEV_FLAGS against + /* FIXME: we should be able to check FLAGS against * CDEV_NONBLOCK here, but in practice, several drivers do not * send a reply through this path (eg TTY) or simply do not * implement nonblocking calls properly (eg audio, LWIP). */ #if 0 - if (mess->CDEV_FLAGS & CDEV_NONBLOCK) + if (mess->m_vfs_lchardriver_readwrite.flags & CDEV_NONBLOCK) panic("chardriver: cannot suspend nonblocking I/O"); #endif /*fall-through*/ @@ -248,7 +248,8 @@ static void chardriver_reply(message *mess, int ipc_status, int r) case CDEV_IOCTL: reply_mess.m_type = CDEV_REPLY; reply_mess.m_lchardriver_vfs_reply.status = r; - reply_mess.m_lchardriver_vfs_reply.id = mess->CDEV_ID; + reply_mess.m_lchardriver_vfs_reply.id = + mess->m_vfs_lchardriver_readwrite.id; break; case CDEV_CANCEL: /* For cancel, this is a reply to the original request! */ @@ -328,7 +329,7 @@ static int do_transfer(struct chardriver *cdp, message *m_ptr, int do_write) { /* Carry out a read or write task request. */ devminor_t minor; - u64_t position; + off_t position; endpoint_t endpt; cp_grant_id_t grant; size_t size; @@ -336,13 +337,13 @@ static int do_transfer(struct chardriver *cdp, message *m_ptr, int do_write) cdev_id_t id; ssize_t r; - minor = m_ptr->CDEV_MINOR; - position = m_ptr->CDEV_POS; + minor = m_ptr->m_vfs_lchardriver_readwrite.minor; + position = m_ptr->m_vfs_lchardriver_readwrite.pos; endpt = m_ptr->m_source; - grant = (cp_grant_id_t) m_ptr->CDEV_GRANT; - size = m_ptr->CDEV_COUNT; - flags = m_ptr->CDEV_FLAGS; - id = m_ptr->CDEV_ID; + grant = m_ptr->m_vfs_lchardriver_readwrite.grant; + size = m_ptr->m_vfs_lchardriver_readwrite.count; + flags = m_ptr->m_vfs_lchardriver_readwrite.flags; + id = m_ptr->m_vfs_lchardriver_readwrite.id; /* Call the read/write hook, if the appropriate one is in place. */ if (!do_write && cdp->cdr_read != NULL) @@ -373,13 +374,13 @@ static int do_ioctl(struct chardriver *cdp, message *m_ptr) return ENOTTY; /* Call the ioctl hook. */ - minor = m_ptr->CDEV_MINOR; - request = m_ptr->CDEV_REQUEST; + minor = m_ptr->m_vfs_lchardriver_readwrite.minor; + request = m_ptr->m_vfs_lchardriver_readwrite.request; endpt = m_ptr->m_source; - grant = m_ptr->CDEV_GRANT; - flags = m_ptr->CDEV_FLAGS; - user_endpt = m_ptr->CDEV_USER; - id = m_ptr->CDEV_ID; + grant = m_ptr->m_vfs_lchardriver_readwrite.grant; + flags = m_ptr->m_vfs_lchardriver_readwrite.flags; + user_endpt = m_ptr->m_vfs_lchardriver_readwrite.user; + id = m_ptr->m_vfs_lchardriver_readwrite.id; return cdp->cdr_ioctl(minor, request, endpt, grant, flags, user_endpt, id); } @@ -589,7 +590,7 @@ int chardriver_get_minor(message *m, devminor_t *minor) case CDEV_READ: case CDEV_WRITE: case CDEV_IOCTL: - *minor = m->CDEV_MINOR; + *minor = m->m_vfs_lchardriver_readwrite.minor; return OK; default: return EINVAL; diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 56478944c..d9ea8f29d 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -281,19 +281,19 @@ int cdev_io( /* Set up the rest of the message that will be sent to the driver. */ memset(&dev_mess, 0, sizeof(dev_mess)); dev_mess.m_type = op; - dev_mess.CDEV_MINOR = minor_dev; + dev_mess.m_vfs_lchardriver_readwrite.minor = minor_dev; if (op == CDEV_IOCTL) { - dev_mess.CDEV_REQUEST = bytes; - dev_mess.CDEV_USER = proc_e; + dev_mess.m_vfs_lchardriver_readwrite.request = bytes; + dev_mess.m_vfs_lchardriver_readwrite.user = proc_e; } else { - dev_mess.CDEV_POS = pos; - dev_mess.CDEV_COUNT = (size_t) bytes; + dev_mess.m_vfs_lchardriver_readwrite.pos = pos; + dev_mess.m_vfs_lchardriver_readwrite.count = bytes; } - dev_mess.CDEV_ID = proc_e; - dev_mess.CDEV_GRANT = gid; - dev_mess.CDEV_FLAGS = 0; + dev_mess.m_vfs_lchardriver_readwrite.id = proc_e; + dev_mess.m_vfs_lchardriver_readwrite.grant = gid; + dev_mess.m_vfs_lchardriver_readwrite.flags = 0; if (flags & O_NONBLOCK) - dev_mess.CDEV_FLAGS |= CDEV_NONBLOCK; + dev_mess.m_vfs_lchardriver_readwrite.flags |= CDEV_NONBLOCK; /* Send the request to the driver. */ if ((r = asynsend3(dp->dmap_driver, &dev_mess, AMF_NOREPLY)) != OK)