ahci: link FIS receive mode to memory allocation
[minix.git] / drivers / filter / inc.h
blobc54a77e0ce04ae528ca1e652e927bd401dc8d705
1 /* Filter driver - general include file */
2 #define _MINIX 1
3 #define _SYSTEM 1
4 #include <minix/config.h>
5 #include <minix/const.h>
6 #include <minix/type.h>
7 #include <minix/com.h>
8 #include <minix/ipc.h>
9 #include <sys/ioc_disk.h>
10 #include <minix/sysutil.h>
11 #include <minix/syslib.h>
12 #include <minix/partition.h>
13 #include <minix/ds.h>
14 #include <minix/callnr.h>
15 #include <minix/blockdriver.h>
16 #include <minix/optset.h>
17 #include <unistd.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <errno.h>
21 #include <string.h>
23 #define SECTOR_SIZE 512
25 typedef enum {
26 ST_NIL, /* Zero checksums */
27 ST_XOR, /* XOR-based checksums */
28 ST_CRC, /* CRC32-based checksums */
29 ST_MD5 /* MD5-based checksums */
30 } checksum_type;
32 typedef enum {
33 FLT_WRITE, /* write to up to two disks */
34 FLT_READ, /* read from one disk */
35 FLT_READ2 /* read from both disks */
36 } disk_operation;
38 struct driverinfo {
39 char *label;
40 int minor;
41 endpoint_t endpt;
42 int up_event;
44 int problem; /* one of BD_* */
45 int error; /* one of E*, only relevant if problem>0 */
46 int retries;
47 int kills;
50 /* UP event characterization. */
51 #define UP_EXPECTED 0
52 #define UP_NONE 1
53 #define UP_PENDING 2
55 /* Something was wrong and the disk driver has been restarted/refreshed,
56 * so the request needs to be redone.
58 #define RET_REDO 1
60 /* The cases where the disk driver need to be restarted/refreshed by RS.
61 * BD_DEAD: the disk driver has died. Restart it.
62 * BD_PROTO: a protocol error has occurred. Refresh it.
63 * BD_DATA: a data error has occurred. Refresh it.
65 typedef enum {
66 BD_NONE,
67 BD_DEAD,
68 BD_PROTO,
69 BD_DATA,
70 BD_LAST
71 } driver_state;
73 #define DRIVER_MAIN 0
74 #define DRIVER_BACKUP 1
76 /* Requests for more than this many bytes will be allocated dynamically. */
77 #define BUF_SIZE (256 * 1024)
78 #define SBUF_SIZE (BUF_SIZE * 2)
80 #define LABEL_SIZE 32
82 typedef unsigned long sector_t;
84 /* main.c */
85 extern int USE_CHECKSUM;
86 extern int USE_MIRROR;
87 extern int BAD_SUM_ERROR;
88 extern int USE_SUM_LAYOUT;
89 extern int SUM_TYPE;
90 extern int SUM_SIZE;
91 extern int NR_SUM_SEC;
92 extern int NR_RETRIES;
93 extern int NR_RESTARTS;
94 extern int DRIVER_TIMEOUT;
95 extern int CHUNK_SIZE;
97 extern char MAIN_LABEL[LABEL_SIZE];
98 extern char BACKUP_LABEL[LABEL_SIZE];
99 extern int MAIN_MINOR;
100 extern int BACKUP_MINOR;
102 /* sum.c */
103 extern void sum_init(void);
104 extern int transfer(u64_t pos, char *buffer, size_t *sizep, int flag_rw);
105 extern u64_t convert(u64_t size);
107 /* driver.c */
108 extern void driver_init(void);
109 extern void driver_shutdown(void);
110 extern u64_t get_raw_size(void);
111 extern void reset_kills(void);
112 extern int check_driver(int which);
113 extern int bad_driver(int which, int type, int error);
114 extern int read_write(u64_t pos, char *bufa, char *bufb, size_t *sizep,
115 int flag_rw);
116 extern void ds_event(void);
118 /* util.c */
119 extern char *flt_malloc(size_t size, char *sbuf, size_t ssize);
120 extern void flt_free(char *buf, size_t size, const char *sbuf);
121 extern clock_t flt_alarm(clock_t dt);