
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.
55 lines
2.2 KiB
C
55 lines
2.2 KiB
C
#ifndef _MINIX_BLOCKDRIVER_H
|
|
#define _MINIX_BLOCKDRIVER_H
|
|
|
|
#include <minix/driver.h>
|
|
|
|
typedef int thread_id_t;
|
|
|
|
/* Entry points into the device dependent code of block drivers. */
|
|
struct blockdriver {
|
|
_PROTOTYPE( int (*bdr_open), (dev_t minor, int access) );
|
|
_PROTOTYPE( int (*bdr_close), (dev_t minor) );
|
|
_PROTOTYPE( ssize_t (*bdr_transfer), (dev_t minor, int do_write, u64_t pos,
|
|
endpoint_t endpt, iovec_t *iov, unsigned count, int flags) );
|
|
_PROTOTYPE( int (*bdr_ioctl), (dev_t minor, unsigned int request,
|
|
endpoint_t endpt, cp_grant_id_t grant) );
|
|
_PROTOTYPE( void (*bdr_cleanup), (void) );
|
|
_PROTOTYPE( struct device *(*bdr_part), (dev_t minor) );
|
|
_PROTOTYPE( void (*bdr_geometry), (dev_t minor, struct partition *part) );
|
|
_PROTOTYPE( void (*bdr_intr), (unsigned int irqs) );
|
|
_PROTOTYPE( void (*bdr_alarm), (clock_t stamp) );
|
|
_PROTOTYPE( int (*bdr_other), (message *m_ptr) );
|
|
_PROTOTYPE( int (*bdr_thread), (dev_t minor, thread_id_t *threadp) );
|
|
};
|
|
|
|
/* Functions defined by libblockdriver. These can be used for both
|
|
* singlethreaded and multithreaded drivers.
|
|
*/
|
|
_PROTOTYPE( void blockdriver_announce, (void) );
|
|
|
|
#ifndef _DRIVER_MT_API
|
|
/* Additional functions for the singlethreaded version. These allow the driver
|
|
* to either use the stock driver_task(), or implement its own message loop.
|
|
* To avoid accidents, these functions are not exposed when minix/driver_mt.h
|
|
* has been included previously.
|
|
*/
|
|
_PROTOTYPE( int blockdriver_receive_mq, (message *m_ptr, int *status_ptr) );
|
|
_PROTOTYPE( void blockdriver_process, (struct blockdriver *dp, message *m_ptr,
|
|
int ipc_status) );
|
|
_PROTOTYPE( void blockdriver_terminate, (void) );
|
|
_PROTOTYPE( void blockdriver_task, (struct blockdriver *bdp) );
|
|
_PROTOTYPE( int blockdriver_mq_queue, (message *m_ptr, int status) );
|
|
#endif /* !_DRIVER_MT_API */
|
|
|
|
/* Parameters for the disk drive. */
|
|
#define SECTOR_SIZE 512 /* physical sector size in bytes */
|
|
#define SECTOR_SHIFT 9 /* for division */
|
|
#define SECTOR_MASK 511 /* and remainder */
|
|
|
|
#define CD_SECTOR_SIZE 2048 /* sector size of a CD-ROM in bytes */
|
|
|
|
/* Size of the DMA buffer buffer in bytes. */
|
|
#define DMA_BUF_SIZE (DMA_SECTORS * SECTOR_SIZE)
|
|
|
|
#endif /* _MINIX_BLOCKDRIVER_H */
|