Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / minix / blockdriver.h @ 14

History | View | Annotate | Download (2.28 KB)

1
#ifndef _MINIX_BLOCKDRIVER_H
2
#define _MINIX_BLOCKDRIVER_H
3

    
4
#include <minix/driver.h>
5

    
6
typedef int device_id_t;
7
typedef int thread_id_t;
8

    
9
/* Types supported for the 'type' field of struct blockdriver. */
10
typedef enum {
11
  BLOCKDRIVER_TYPE_DISK,                /* handle partition requests */
12
  BLOCKDRIVER_TYPE_OTHER                /* do not handle partition requests */
13
} blockdriver_type_t;
14

    
15
/* Entry points into the device dependent code of block drivers. */
16
struct blockdriver {
17
  blockdriver_type_t bdr_type;
18
  int (*bdr_open)(devminor_t minor, int access);
19
  int (*bdr_close)(devminor_t minor);
20
  ssize_t (*bdr_transfer)(devminor_t minor, int do_write, u64_t pos,
21
          endpoint_t endpt, iovec_t *iov, unsigned int count, int flags);
22
  int (*bdr_ioctl)(devminor_t minor, unsigned long request, endpoint_t endpt,
23
          cp_grant_id_t grant, endpoint_t user_endpt);
24
  void (*bdr_cleanup)(void);
25
  struct device *(*bdr_part)(devminor_t minor);
26
  void (*bdr_geometry)(devminor_t minor, struct part_geom *part);
27
  void (*bdr_intr)(unsigned int mask);
28
  void (*bdr_alarm)(clock_t stamp);
29
  void (*bdr_other)(message *m_ptr, int ipc_status);
30
  int (*bdr_device)(devminor_t minor, device_id_t *id);
31
};
32

    
33
/* Functions defined by libblockdriver. These can be used for both
34
 * singlethreaded and multithreaded drivers.
35
 */
36
void blockdriver_announce(int type);
37

    
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.
43
 */
44
int blockdriver_receive_mq(message *m_ptr, int *status_ptr);
45
void blockdriver_process(struct blockdriver *dp, message *m_ptr, int
46
        ipc_status);
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 */
51

    
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 */
56

    
57
#define CD_SECTOR_SIZE  2048        /* sector size of a CD-ROM in bytes */
58

    
59
/* Size of the DMA buffer buffer in bytes. */
60
#define DMA_BUF_SIZE        (DMA_SECTORS * SECTOR_SIZE)
61

    
62
#endif /* _MINIX_BLOCKDRIVER_H */