1 #ifndef _MINIX_BLOCKDRIVER_H
2 #define _MINIX_BLOCKDRIVER_H
4 #include <minix/driver.h>
6 typedef int device_id_t
;
7 typedef int thread_id_t
;
9 /* Types supported for the 'type' field of struct blockdriver. */
11 BLOCKDRIVER_TYPE_DISK
, /* handle partition requests */
12 BLOCKDRIVER_TYPE_OTHER
/* do not handle partition requests */
15 /* Entry points into the device dependent code of block drivers. */
17 blockdriver_type_t bdr_type
;
18 int(*bdr_open
) (dev_t minor
, int access
);
19 int(*bdr_close
) (dev_t minor
);
20 ssize_t(*bdr_transfer
) (dev_t minor
, int do_write
, u64_t pos
,
21 endpoint_t endpt
, iovec_t
*iov
, unsigned count
, int flags
);
22 int(*bdr_ioctl
) (dev_t minor
, unsigned int request
, endpoint_t endpt
,
24 void(*bdr_cleanup
) (void);
25 struct device
*(*bdr_part
)(dev_t minor
);
26 void(*bdr_geometry
) (dev_t minor
, struct partition
*part
);
27 void(*bdr_intr
) (unsigned int irqs
);
28 void(*bdr_alarm
) (clock_t stamp
);
29 int(*bdr_other
) (message
*m_ptr
);
30 int(*bdr_device
) (dev_t minor
, device_id_t
*id
);
33 /* Functions defined by libblockdriver. These can be used for both
34 * singlethreaded and multithreaded drivers.
36 void blockdriver_announce(int type
);
38 #ifndef _BLOCKDRIVER_MT_API
39 /* Additional functions for the singlethreaded version. These allow the driver
40 * to either use the stock driver_task(), or implement its own message loop.
41 * To avoid accidents, these functions are not exposed when minix/driver_mt.h
42 * has been included previously.
44 int blockdriver_receive_mq(message
*m_ptr
, int *status_ptr
);
45 void blockdriver_process(struct blockdriver
*dp
, message
*m_ptr
, int
47 void blockdriver_terminate(void);
48 void blockdriver_task(struct blockdriver
*bdp
);
49 int blockdriver_mq_queue(message
*m_ptr
, int status
);
50 #endif /* !_BLOCKDRIVER_MT_API */
52 /* Parameters for the disk drive. */
53 #define SECTOR_SIZE 512 /* physical sector size in bytes */
54 #define SECTOR_SHIFT 9 /* for division */
55 #define SECTOR_MASK 511 /* and remainder */
57 #define CD_SECTOR_SIZE 2048 /* sector size of a CD-ROM in bytes */
59 /* Size of the DMA buffer buffer in bytes. */
60 #define DMA_BUF_SIZE (DMA_SECTORS * SECTOR_SIZE)
62 #endif /* _MINIX_BLOCKDRIVER_H */