This source file includes following definitions.
- end_request
1 #ifndef _BLK_H
2 #define _BLK_H
3
4 #include <linux/major.h>
5 #include <linux/sched.h>
6 #include <linux/locks.h>
7 #include <linux/genhd.h>
8
9
10
11
12
13
14
15
16
17
18
19 #define NR_REQUEST 64
20
21
22
23
24
25
26
27 struct request {
28 int dev;
29 int cmd;
30 int errors;
31 unsigned long sector;
32 unsigned long nr_sectors;
33 unsigned long current_nr_sectors;
34 char * buffer;
35 struct task_struct * waiting;
36 struct buffer_head * bh;
37 struct buffer_head * bhtail;
38 struct request * next;
39 };
40
41
42
43
44
45
46 #define IN_ORDER(s1,s2) \
47 ((s1)->cmd < (s2)->cmd || ((s1)->cmd == (s2)->cmd && \
48 ((s1)->dev < (s2)->dev || (((s1)->dev == (s2)->dev && \
49 (s1)->sector < (s2)->sector)))))
50
51 struct blk_dev_struct {
52 void (*request_fn)(void);
53 struct request * current_request;
54 };
55
56
57 struct sec_size {
58 unsigned block_size;
59 unsigned block_size_bits;
60 };
61
62
63
64
65
66 #define SECTOR_MASK (blksize_size[MAJOR_NR] && \
67 blksize_size[MAJOR_NR][MINOR(CURRENT->dev)] ? \
68 ((blksize_size[MAJOR_NR][MINOR(CURRENT->dev)] >> 9) - 1) : \
69 ((BLOCK_SIZE >> 9) - 1))
70
71 #define SUBSECTOR(block) (CURRENT->current_nr_sectors > 0)
72
73 extern struct sec_size * blk_sec[MAX_BLKDEV];
74 extern struct blk_dev_struct blk_dev[MAX_BLKDEV];
75 extern struct wait_queue * wait_for_request;
76 extern void resetup_one_dev(struct gendisk *dev, int drive);
77
78 extern int * blk_size[MAX_BLKDEV];
79
80 extern int * blksize_size[MAX_BLKDEV];
81
82 extern unsigned long hd_init(unsigned long mem_start, unsigned long mem_end);
83 extern unsigned long cdu31a_init(unsigned long mem_start, unsigned long mem_end);
84 extern unsigned long mcd_init(unsigned long mem_start, unsigned long mem_end);
85 extern int is_read_only(int dev);
86 extern void set_device_ro(int dev,int flag);
87
88 extern void rd_load(void);
89 extern long rd_init(long mem_start, int length);
90 extern int ramdisk_size;
91
92 extern unsigned long xd_init(unsigned long mem_start, unsigned long mem_end);
93
94 #define RO_IOCTLS(dev,where) \
95 case BLKROSET: if (!suser()) return -EPERM; \
96 set_device_ro((dev),get_fs_long((long *) (where))); return 0; \
97 case BLKROGET: { int __err = verify_area(VERIFY_WRITE, (void *) (where), sizeof(long)); \
98 if (!__err) put_fs_long(is_read_only(dev),(long *) (where)); return __err; }
99
100 #ifdef MAJOR_NR
101
102
103
104
105
106
107 #if (MAJOR_NR == MEM_MAJOR)
108
109
110 #define DEVICE_NAME "ramdisk"
111 #define DEVICE_REQUEST do_rd_request
112 #define DEVICE_NR(device) ((device) & 7)
113 #define DEVICE_ON(device)
114 #define DEVICE_OFF(device)
115
116 #elif (MAJOR_NR == FLOPPY_MAJOR)
117
118 static void floppy_on(unsigned int nr);
119 static void floppy_off(unsigned int nr);
120
121 #define DEVICE_NAME "floppy"
122 #define DEVICE_INTR do_floppy
123 #define DEVICE_REQUEST do_fd_request
124 #define DEVICE_NR(device) ((device) & 3)
125 #define DEVICE_ON(device) floppy_on(DEVICE_NR(device))
126 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
127
128 #elif (MAJOR_NR == HD_MAJOR)
129
130
131 #define DEVICE_NAME "harddisk"
132 #define DEVICE_INTR do_hd
133 #define DEVICE_TIMEOUT HD_TIMER
134 #define TIMEOUT_VALUE 600
135 #define DEVICE_REQUEST do_hd_request
136 #define DEVICE_NR(device) (MINOR(device)>>6)
137 #define DEVICE_ON(device)
138 #define DEVICE_OFF(device)
139
140 #elif (MAJOR_NR == SCSI_DISK_MAJOR)
141
142 #define DEVICE_NAME "scsidisk"
143 #define DEVICE_INTR do_sd
144 #define TIMEOUT_VALUE 200
145 #define DEVICE_REQUEST do_sd_request
146 #define DEVICE_NR(device) (MINOR(device) >> 4)
147 #define DEVICE_ON(device)
148 #define DEVICE_OFF(device)
149
150 #elif (MAJOR_NR == SCSI_TAPE_MAJOR)
151
152 #define DEVICE_NAME "scsitape"
153 #define DEVICE_INTR do_st
154 #define DEVICE_NR(device) (MINOR(device))
155 #define DEVICE_ON(device)
156 #define DEVICE_OFF(device)
157
158 #elif (MAJOR_NR == SCSI_CDROM_MAJOR)
159
160 #define DEVICE_NAME "CD-ROM"
161 #define DEVICE_INTR do_sr
162 #define DEVICE_REQUEST do_sr_request
163 #define DEVICE_NR(device) (MINOR(device))
164 #define DEVICE_ON(device)
165 #define DEVICE_OFF(device)
166
167 #elif (MAJOR_NR == XT_DISK_MAJOR)
168
169 #define DEVICE_NAME "xt disk"
170 #define DEVICE_REQUEST do_xd_request
171 #define DEVICE_NR(device) (MINOR(device) >> 6)
172 #define DEVICE_ON(device)
173 #define DEVICE_OFF(device)
174
175 #elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
176
177 #define DEVICE_NAME "CDU31A"
178 #define DEVICE_REQUEST do_cdu31a_request
179 #define DEVICE_NR(device) (MINOR(device))
180 #define DEVICE_ON(device)
181 #define DEVICE_OFF(device)
182
183 #elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
184
185 #define DEVICE_NAME "Mitsumi CD-ROM"
186
187 #define DEVICE_REQUEST do_mcd_request
188 #define DEVICE_NR(device) (MINOR(device))
189 #define DEVICE_ON(device)
190 #define DEVICE_OFF(device)
191
192 #else
193
194 #error "unknown blk device"
195
196 #endif
197
198 #if (MAJOR_NR != SCSI_TAPE_MAJOR)
199
200 #ifndef CURRENT
201 #define CURRENT (blk_dev[MAJOR_NR].current_request)
202 #endif
203
204 #define CURRENT_DEV DEVICE_NR(CURRENT->dev)
205
206 #ifdef DEVICE_INTR
207 void (*DEVICE_INTR)(void) = NULL;
208 #endif
209 #ifdef DEVICE_TIMEOUT
210
211 #define SET_TIMER \
212 ((timer_table[DEVICE_TIMEOUT].expires = jiffies + TIMEOUT_VALUE), \
213 (timer_active |= 1<<DEVICE_TIMEOUT))
214
215 #define CLEAR_TIMER \
216 timer_active &= ~(1<<DEVICE_TIMEOUT)
217
218 #define SET_INTR(x) \
219 if ((DEVICE_INTR = (x)) != NULL) \
220 SET_TIMER; \
221 else \
222 CLEAR_TIMER;
223
224 #else
225
226 #define SET_INTR(x) (DEVICE_INTR = (x))
227
228 #endif
229 static void (DEVICE_REQUEST)(void);
230
231
232
233 #if ! SCSI_MAJOR(MAJOR_NR)
234
235 static void end_request(int uptodate)
236 {
237 struct request * req;
238 struct buffer_head * bh;
239 struct task_struct * p;
240
241 req = CURRENT;
242 req->errors = 0;
243 if (!uptodate) {
244 printk(DEVICE_NAME " I/O error\n");
245 printk("dev %04lX, sector %lu\n",
246 (unsigned long)req->dev, req->sector);
247 req->nr_sectors--;
248 req->nr_sectors &= ~SECTOR_MASK;
249 req->sector += (BLOCK_SIZE / 512);
250 req->sector &= ~SECTOR_MASK;
251 }
252
253 if ((bh = req->bh) != NULL) {
254 req->bh = bh->b_reqnext;
255 bh->b_reqnext = NULL;
256 bh->b_uptodate = uptodate;
257 unlock_buffer(bh);
258 if ((bh = req->bh) != NULL) {
259 req->current_nr_sectors = bh->b_size >> 9;
260 if (req->nr_sectors < req->current_nr_sectors) {
261 req->nr_sectors = req->current_nr_sectors;
262 printk("end_request: buffer-list destroyed\n");
263 }
264 req->buffer = bh->b_data;
265 return;
266 }
267 }
268 DEVICE_OFF(req->dev);
269 CURRENT = req->next;
270 if ((p = req->waiting) != NULL) {
271 req->waiting = NULL;
272 p->state = TASK_RUNNING;
273 if (p->counter > current->counter)
274 need_resched = 1;
275 }
276 req->dev = -1;
277 wake_up(&wait_for_request);
278 }
279 #endif
280
281 #ifdef DEVICE_INTR
282 #define CLEAR_INTR SET_INTR(NULL)
283 #else
284 #define CLEAR_INTR
285 #endif
286
287 #define INIT_REQUEST \
288 if (!CURRENT) {\
289 CLEAR_INTR; \
290 return; \
291 } \
292 if (MAJOR(CURRENT->dev) != MAJOR_NR) \
293 panic(DEVICE_NAME ": request list destroyed"); \
294 if (CURRENT->bh) { \
295 if (!CURRENT->bh->b_lock) \
296 panic(DEVICE_NAME ": block not locked"); \
297 }
298
299 #endif
300
301 #endif
302 #endif