libchardriver: full API rewrite

The new API now covers the entire character driver protocol, while
hiding all the message details. It should therefore be used by all
new character drivers. All existing drivers that already made use of
libchardriver have been changed to use the new API.

As one of the most important API changes, support for scatter and
gather transfers has been removed, as several key drivers already
did not support this, and it could be supported at the safecopy
level instead (for a future readv/writev).

Additional changes include:

- respond to block device open requests to avoid hanging VFS threads;
- add support for sef_cancel.

Change-Id: I1bab6c1cb66916c71b87aeb1db54a9bdf171fe6b
This commit is contained in:
David van Moolenbroek
2013-09-03 01:49:38 +02:00
committed by Lionel Sambuc
parent b0ea2920e6
commit 597151d963
14 changed files with 958 additions and 1198 deletions

View File

@@ -3,20 +3,23 @@
#include <minix/driver.h>
typedef unsigned int cdev_id_t;
/* Entry points into the device dependent code of character drivers. */
struct chardriver {
int(*cdr_open) (message *m_ptr);
int(*cdr_close) (message *m_ptr);
int(*cdr_ioctl) (message *m_ptr);
struct device *(*cdr_prepare)(dev_t device);
int(*cdr_transfer) (endpoint_t endpt, int opcode, u64_t position,
iovec_t *iov, unsigned int nr_req, endpoint_t user_endpt, unsigned int
flags);
void(*cdr_cleanup) (void);
void(*cdr_alarm) (message *m_ptr);
int(*cdr_cancel) (message *m_ptr);
int(*cdr_select) (message *m_ptr);
int(*cdr_other) (message *m_ptr);
int (*cdr_open)(devminor_t minor, int access, endpoint_t user_endpt);
int (*cdr_close)(devminor_t minor);
ssize_t (*cdr_read)(devminor_t minor, u64_t position, endpoint_t endpt,
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
ssize_t (*cdr_write)(devminor_t minor, u64_t position, endpoint_t endpt,
cp_grant_id_t grant, size_t size, int flags, cdev_id_t id);
int (*cdr_ioctl)(devminor_t minor, unsigned long request, endpoint_t endpt,
cp_grant_id_t grant, int flags, endpoint_t user_endpt, cdev_id_t id);
int (*cdr_cancel)(devminor_t minor, endpoint_t endpt, cdev_id_t id);
int (*cdr_select)(devminor_t minor, unsigned int ops, endpoint_t endpt);
void (*cdr_intr)(unsigned int mask);
void (*cdr_alarm)(clock_t stamp);
void (*cdr_other)(message *m_ptr, int ipc_status);
};
/* Functions defined by libchardriver. */
@@ -26,11 +29,7 @@ void chardriver_process(struct chardriver *cdp, message *m_ptr,
void chardriver_terminate(void);
void chardriver_task(struct chardriver *cdp);
int do_nop(message *m_ptr);
void nop_cleanup(void);
void nop_alarm(message *m_ptr);
int nop_cancel(message *m_ptr);
int nop_select(message *m_ptr);
int nop_ioctl(message *m_ptr);
void chardriver_reply_task(endpoint_t endpt, cdev_id_t id, int r);
void chardriver_reply_select(endpoint_t endpt, devminor_t minor, int ops);
#endif /* _MINIX_CHARDRIVER_H */