2011-12-05 10:53:57 +01:00
|
|
|
#ifndef _MINIX_BDEV_H
|
|
|
|
#define _MINIX_BDEV_H
|
2011-11-09 14:29:12 +01:00
|
|
|
|
2011-12-05 10:53:57 +01:00
|
|
|
/* Common API. */
|
2011-11-30 19:05:26 +01:00
|
|
|
extern void bdev_driver(dev_t dev, char *label);
|
2011-11-09 14:29:12 +01:00
|
|
|
|
2011-12-05 10:53:57 +01:00
|
|
|
/* Synchronous API. */
|
2011-11-09 14:29:12 +01:00
|
|
|
extern int bdev_open(dev_t dev, int access);
|
|
|
|
extern int bdev_close(dev_t dev);
|
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
extern ssize_t bdev_read(dev_t dev, u64_t pos, char *buf, size_t count,
|
|
|
|
int flags);
|
|
|
|
extern ssize_t bdev_write(dev_t dev, u64_t pos, char *buf, size_t count,
|
|
|
|
int flags);
|
|
|
|
extern ssize_t bdev_gather(dev_t dev, u64_t pos, iovec_t *vec, int count,
|
|
|
|
int flags);
|
|
|
|
extern ssize_t bdev_scatter(dev_t dev, u64_t pos, iovec_t *vec, int count,
|
|
|
|
int flags);
|
2011-11-09 14:29:12 +01:00
|
|
|
extern int bdev_ioctl(dev_t dev, int request, void *buf);
|
|
|
|
|
2011-12-05 10:53:57 +01:00
|
|
|
/* Asynchronous API. */
|
|
|
|
typedef int bdev_id_t;
|
|
|
|
typedef void *bdev_param_t;
|
|
|
|
|
|
|
|
typedef void (*bdev_callback_t)(dev_t dev, bdev_id_t id, bdev_param_t param,
|
|
|
|
int result);
|
|
|
|
|
|
|
|
extern void bdev_flush_asyn(dev_t dev);
|
|
|
|
|
|
|
|
extern bdev_id_t bdev_read_asyn(dev_t dev, u64_t pos, char *buf, size_t count,
|
|
|
|
int flags, bdev_callback_t callback, bdev_param_t param);
|
|
|
|
extern bdev_id_t bdev_write_asyn(dev_t dev, u64_t pos, char *buf, size_t count,
|
|
|
|
int flags, bdev_callback_t callback, bdev_param_t param);
|
|
|
|
extern bdev_id_t bdev_gather_asyn(dev_t dev, u64_t pos, iovec_t *vec,
|
|
|
|
int count, int flags, bdev_callback_t callback, bdev_param_t param);
|
|
|
|
extern bdev_id_t bdev_scatter_asyn(dev_t dev, u64_t pos, iovec_t *vec,
|
|
|
|
int count, int flags, bdev_callback_t callback, bdev_param_t param);
|
|
|
|
extern bdev_id_t bdev_ioctl_asyn(dev_t dev, int request, void *buf,
|
|
|
|
bdev_callback_t callback, bdev_param_t param);
|
|
|
|
|
|
|
|
extern int bdev_wait_asyn(bdev_id_t id);
|
|
|
|
|
|
|
|
extern void bdev_reply_asyn(message *m);
|
|
|
|
|
|
|
|
#endif /* _MINIX_BDEV_H */
|