minix/include/minix/blockdriver.h
David van Moolenbroek 6700874deb Block drivers: make IOCTL request unsigned long
The block driver protocol and libblockdriver's bdr_ioctl hook are
changed, as well as the users of this hook. Other parts of the system
are expected to change accordingly eventually, since the ioctl(2)
prototype has been aligned with NetBSD's.

Change-Id: Ide46245b22cfa89ed267a38088fb0ab7696eba92
2014-02-19 11:22:15 +01:00

63 lines
2.3 KiB
C

#ifndef _MINIX_BLOCKDRIVER_H
#define _MINIX_BLOCKDRIVER_H
#include <minix/driver.h>
typedef int device_id_t;
typedef int thread_id_t;
/* Types supported for the 'type' field of struct blockdriver. */
typedef enum {
BLOCKDRIVER_TYPE_DISK, /* handle partition requests */
BLOCKDRIVER_TYPE_OTHER /* do not handle partition requests */
} blockdriver_type_t;
/* Entry points into the device dependent code of block drivers. */
struct blockdriver {
blockdriver_type_t bdr_type;
int (*bdr_open)(devminor_t minor, int access);
int (*bdr_close)(devminor_t minor);
ssize_t (*bdr_transfer)(devminor_t minor, int do_write, u64_t pos,
endpoint_t endpt, iovec_t *iov, unsigned int count, int flags);
int (*bdr_ioctl)(devminor_t minor, unsigned long request, endpoint_t endpt,
cp_grant_id_t grant, endpoint_t user_endpt);
void (*bdr_cleanup)(void);
struct device *(*bdr_part)(devminor_t minor);
void (*bdr_geometry)(devminor_t minor, struct part_geom *part);
void (*bdr_intr)(unsigned int mask);
void (*bdr_alarm)(clock_t stamp);
void (*bdr_other)(message *m_ptr, int ipc_status);
int (*bdr_device)(devminor_t minor, device_id_t *id);
};
/* Functions defined by libblockdriver. These can be used for both
* singlethreaded and multithreaded drivers.
*/
void blockdriver_announce(int type);
#ifndef _BLOCKDRIVER_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.
*/
int blockdriver_receive_mq(message *m_ptr, int *status_ptr);
void blockdriver_process(struct blockdriver *dp, message *m_ptr, int
ipc_status);
void blockdriver_terminate(void);
void blockdriver_task(struct blockdriver *bdp);
int blockdriver_mq_queue(message *m_ptr, int status);
#endif /* !_BLOCKDRIVER_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 */