ia64/xen-unstable

view xenolinux-2.4.21-pre4-sparse/include/linux/blk.h @ 235:d7d0a23b2e07

bitkeeper revision 1.93 (3e5a4e6bkPheUp3x1uufN2MS3LAB7A)

Latest and Greatest version of XenoLinux based on the Linux-2.4.21-pre4
kernel.
author iap10@labyrinth.cl.cam.ac.uk
date Mon Feb 24 16:55:07 2003 +0000 (2003-02-24)
parents
children 8d7cbb78020d
line source
1 #ifndef _BLK_H
2 #define _BLK_H
4 #include <linux/blkdev.h>
5 #include <linux/locks.h>
6 #include <linux/config.h>
7 #include <linux/spinlock.h>
9 /*
10 * Spinlock for protecting the request queue which
11 * is mucked around with in interrupts on potentially
12 * multiple CPU's..
13 */
14 extern spinlock_t io_request_lock;
16 /*
17 * Initialization functions.
18 */
19 extern int isp16_init(void);
20 extern int cdu31a_init(void);
21 extern int acsi_init(void);
22 extern int mcd_init(void);
23 extern int mcdx_init(void);
24 extern int sbpcd_init(void);
25 extern int aztcd_init(void);
26 extern int sony535_init(void);
27 extern int gscd_init(void);
28 extern int cm206_init(void);
29 extern int optcd_init(void);
30 extern int sjcd_init(void);
31 extern int cdi_init(void);
32 extern int hd_init(void);
33 extern int ide_init(void);
34 extern int xd_init(void);
35 extern int mfm_init(void);
36 extern int loop_init(void);
37 extern int md_init(void);
38 extern int ap_init(void);
39 extern int ddv_init(void);
40 extern int z2_init(void);
41 extern int swim3_init(void);
42 extern int swimiop_init(void);
43 extern int amiga_floppy_init(void);
44 extern int atari_floppy_init(void);
45 extern int ez_init(void);
46 extern int bpcd_init(void);
47 extern int ps2esdi_init(void);
48 extern int jsfd_init(void);
49 extern int viodasd_init(void);
50 extern int viocd_init(void);
51 extern int xlblk_init(void);
53 #if defined(CONFIG_ARCH_S390)
54 extern int dasd_init(void);
55 extern int xpram_init(void);
56 extern int tapeblock_init(void);
57 #endif /* CONFIG_ARCH_S390 */
59 extern void set_device_ro(kdev_t dev,int flag);
60 void add_blkdev_randomness(int major);
62 extern int floppy_init(void);
63 extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */
64 extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */
65 extern int rd_image_start; /* starting block # of image */
67 #ifdef CONFIG_BLK_DEV_INITRD
69 #define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
71 extern unsigned long initrd_start,initrd_end;
72 extern int initrd_below_start_ok; /* 1 if it is not an error if initrd_start < memory_start */
73 void initrd_init(void);
75 #endif
78 /*
79 * end_request() and friends. Must be called with the request queue spinlock
80 * acquired. All functions called within end_request() _must_be_ atomic.
81 *
82 * Several drivers define their own end_request and call
83 * end_that_request_first() and end_that_request_last()
84 * for parts of the original function. This prevents
85 * code duplication in drivers.
86 */
88 static inline void blkdev_dequeue_request(struct request * req)
89 {
90 list_del(&req->queue);
91 }
93 int end_that_request_first(struct request *req, int uptodate, char *name);
94 void end_that_request_last(struct request *req);
96 #if defined(MAJOR_NR) || defined(IDE_DRIVER)
98 #undef DEVICE_ON
99 #undef DEVICE_OFF
101 /*
102 * Add entries as needed.
103 */
105 #ifdef IDE_DRIVER
107 #define DEVICE_NR(device) (MINOR(device) >> PARTN_BITS)
108 #define DEVICE_NAME "ide"
110 #elif (MAJOR_NR == RAMDISK_MAJOR)
112 /* ram disk */
113 #define DEVICE_NAME "ramdisk"
114 #define DEVICE_NR(device) (MINOR(device))
115 #define DEVICE_NO_RANDOM
117 #elif (MAJOR_NR == Z2RAM_MAJOR)
119 /* Zorro II Ram */
120 #define DEVICE_NAME "Z2RAM"
121 #define DEVICE_REQUEST do_z2_request
122 #define DEVICE_NR(device) (MINOR(device))
124 #elif (MAJOR_NR == FLOPPY_MAJOR)
126 static void floppy_off(unsigned int nr);
128 #define DEVICE_NAME "floppy"
129 #define DEVICE_INTR do_floppy
130 #define DEVICE_REQUEST do_fd_request
131 #define DEVICE_NR(device) ( (MINOR(device) & 3) | ((MINOR(device) & 0x80 ) >> 5 ))
132 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
134 #elif (MAJOR_NR == HD_MAJOR)
136 /* Hard disk: timeout is 6 seconds. */
137 #define DEVICE_NAME "hard disk"
138 #define DEVICE_INTR do_hd
139 #define TIMEOUT_VALUE (6*HZ)
140 #define DEVICE_REQUEST do_hd_request
141 #define DEVICE_NR(device) (MINOR(device)>>6)
143 #elif (SCSI_DISK_MAJOR(MAJOR_NR))
145 #define DEVICE_NAME "scsidisk"
146 #define TIMEOUT_VALUE (2*HZ)
147 #define DEVICE_NR(device) (((MAJOR(device) & SD_MAJOR_MASK) << (8 - 4)) + (MINOR(device) >> 4))
149 /* Kludge to use the same number for both char and block major numbers */
150 #elif (MAJOR_NR == MD_MAJOR) && defined(MD_DRIVER)
152 #define DEVICE_NAME "Multiple devices driver"
153 #define DEVICE_REQUEST do_md_request
154 #define DEVICE_NR(device) (MINOR(device))
156 #elif (MAJOR_NR == SCSI_TAPE_MAJOR)
158 #define DEVICE_NAME "scsitape"
159 #define DEVICE_INTR do_st
160 #define DEVICE_NR(device) (MINOR(device) & 0x7f)
162 #elif (MAJOR_NR == OSST_MAJOR)
164 #define DEVICE_NAME "onstream"
165 #define DEVICE_INTR do_osst
166 #define DEVICE_NR(device) (MINOR(device) & 0x7f)
167 #define DEVICE_ON(device)
168 #define DEVICE_OFF(device)
170 #elif (MAJOR_NR == SCSI_CDROM_MAJOR)
172 #define DEVICE_NAME "CD-ROM"
173 #define DEVICE_NR(device) (MINOR(device))
175 #elif (MAJOR_NR == XT_DISK_MAJOR)
177 #define DEVICE_NAME "xt disk"
178 #define DEVICE_REQUEST do_xd_request
179 #define DEVICE_NR(device) (MINOR(device) >> 6)
181 #elif (MAJOR_NR == PS2ESDI_MAJOR)
183 #define DEVICE_NAME "PS/2 ESDI"
184 #define DEVICE_REQUEST do_ps2esdi_request
185 #define DEVICE_NR(device) (MINOR(device) >> 6)
187 #elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
189 #define DEVICE_NAME "CDU31A"
190 #define DEVICE_REQUEST do_cdu31a_request
191 #define DEVICE_NR(device) (MINOR(device))
193 #elif (MAJOR_NR == ACSI_MAJOR) && (defined(CONFIG_ATARI_ACSI) || defined(CONFIG_ATARI_ACSI_MODULE))
195 #define DEVICE_NAME "ACSI"
196 #define DEVICE_INTR do_acsi
197 #define DEVICE_REQUEST do_acsi_request
198 #define DEVICE_NR(device) (MINOR(device) >> 4)
200 #elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
202 #define DEVICE_NAME "Mitsumi CD-ROM"
203 /* #define DEVICE_INTR do_mcd */
204 #define DEVICE_REQUEST do_mcd_request
205 #define DEVICE_NR(device) (MINOR(device))
207 #elif (MAJOR_NR == MITSUMI_X_CDROM_MAJOR)
209 #define DEVICE_NAME "Mitsumi CD-ROM"
210 /* #define DEVICE_INTR do_mcdx */
211 #define DEVICE_REQUEST do_mcdx_request
212 #define DEVICE_NR(device) (MINOR(device))
214 #elif (MAJOR_NR == MATSUSHITA_CDROM_MAJOR)
216 #define DEVICE_NAME "Matsushita CD-ROM controller #1"
217 #define DEVICE_REQUEST do_sbpcd_request
218 #define DEVICE_NR(device) (MINOR(device))
220 #elif (MAJOR_NR == MATSUSHITA_CDROM2_MAJOR)
222 #define DEVICE_NAME "Matsushita CD-ROM controller #2"
223 #define DEVICE_REQUEST do_sbpcd2_request
224 #define DEVICE_NR(device) (MINOR(device))
226 #elif (MAJOR_NR == MATSUSHITA_CDROM3_MAJOR)
228 #define DEVICE_NAME "Matsushita CD-ROM controller #3"
229 #define DEVICE_REQUEST do_sbpcd3_request
230 #define DEVICE_NR(device) (MINOR(device))
232 #elif (MAJOR_NR == MATSUSHITA_CDROM4_MAJOR)
234 #define DEVICE_NAME "Matsushita CD-ROM controller #4"
235 #define DEVICE_REQUEST do_sbpcd4_request
236 #define DEVICE_NR(device) (MINOR(device))
238 #elif (MAJOR_NR == AZTECH_CDROM_MAJOR)
240 #define DEVICE_NAME "Aztech CD-ROM"
241 #define DEVICE_REQUEST do_aztcd_request
242 #define DEVICE_NR(device) (MINOR(device))
244 #elif (MAJOR_NR == CDU535_CDROM_MAJOR)
246 #define DEVICE_NAME "SONY-CDU535"
247 #define DEVICE_INTR do_cdu535
248 #define DEVICE_REQUEST do_cdu535_request
249 #define DEVICE_NR(device) (MINOR(device))
251 #elif (MAJOR_NR == GOLDSTAR_CDROM_MAJOR)
253 #define DEVICE_NAME "Goldstar R420"
254 #define DEVICE_REQUEST do_gscd_request
255 #define DEVICE_NR(device) (MINOR(device))
257 #elif (MAJOR_NR == CM206_CDROM_MAJOR)
258 #define DEVICE_NAME "Philips/LMS CD-ROM cm206"
259 #define DEVICE_REQUEST do_cm206_request
260 #define DEVICE_NR(device) (MINOR(device))
262 #elif (MAJOR_NR == OPTICS_CDROM_MAJOR)
264 #define DEVICE_NAME "DOLPHIN 8000AT CD-ROM"
265 #define DEVICE_REQUEST do_optcd_request
266 #define DEVICE_NR(device) (MINOR(device))
268 #elif (MAJOR_NR == SANYO_CDROM_MAJOR)
270 #define DEVICE_NAME "Sanyo H94A CD-ROM"
271 #define DEVICE_REQUEST do_sjcd_request
272 #define DEVICE_NR(device) (MINOR(device))
274 #elif (MAJOR_NR == APBLOCK_MAJOR)
276 #define DEVICE_NAME "apblock"
277 #define DEVICE_REQUEST ap_request
278 #define DEVICE_NR(device) (MINOR(device))
280 #elif (MAJOR_NR == DDV_MAJOR)
282 #define DEVICE_NAME "ddv"
283 #define DEVICE_REQUEST ddv_request
284 #define DEVICE_NR(device) (MINOR(device)>>PARTN_BITS)
286 #elif (MAJOR_NR == MFM_ACORN_MAJOR)
288 #define DEVICE_NAME "mfm disk"
289 #define DEVICE_INTR do_mfm
290 #define DEVICE_REQUEST do_mfm_request
291 #define DEVICE_NR(device) (MINOR(device) >> 6)
293 #elif (MAJOR_NR == NBD_MAJOR)
295 #define DEVICE_NAME "nbd"
296 #define DEVICE_REQUEST do_nbd_request
297 #define DEVICE_NR(device) (MINOR(device))
299 #elif (MAJOR_NR == MDISK_MAJOR)
301 #define DEVICE_NAME "mdisk"
302 #define DEVICE_REQUEST mdisk_request
303 #define DEVICE_NR(device) (MINOR(device))
305 #elif (MAJOR_NR == DASD_MAJOR)
307 #define DEVICE_NAME "dasd"
308 #define DEVICE_REQUEST do_dasd_request
309 #define DEVICE_NR(device) (MINOR(device) >> PARTN_BITS)
311 #elif (MAJOR_NR == I2O_MAJOR)
313 #define DEVICE_NAME "I2O block"
314 #define DEVICE_REQUEST i2ob_request
315 #define DEVICE_NR(device) (MINOR(device)>>4)
317 #elif (MAJOR_NR == COMPAQ_SMART2_MAJOR)
319 #define DEVICE_NAME "ida"
320 #define TIMEOUT_VALUE (25*HZ)
321 #define DEVICE_REQUEST do_ida_request
322 #define DEVICE_NR(device) (MINOR(device) >> 4)
324 #elif (MAJOR_NR == XLBLK_MAJOR)
326 #define DEVICE_NAME "xeno disk"
327 #define DEVICE_REQUEST do_xlblk_request
328 /* #define DEVICE_INTR */
329 #define DEVICE_NR(device) (MINOR(device))
331 #endif /* MAJOR_NR == whatever */
333 /* provide DEVICE_xxx defaults, if not explicitly defined
334 * above in the MAJOR_NR==xxx if-elif tree */
335 #ifndef DEVICE_ON
336 #define DEVICE_ON(device) do {} while (0)
337 #endif
338 #ifndef DEVICE_OFF
339 #define DEVICE_OFF(device) do {} while (0)
340 #endif
342 #if (MAJOR_NR != SCSI_TAPE_MAJOR) && (MAJOR_NR != OSST_MAJOR)
343 #if !defined(IDE_DRIVER)
345 #ifndef CURRENT
346 #define CURRENT blkdev_entry_next_request(&blk_dev[MAJOR_NR].request_queue.queue_head)
347 #endif
348 #ifndef QUEUE_EMPTY
349 #define QUEUE_EMPTY list_empty(&blk_dev[MAJOR_NR].request_queue.queue_head)
350 #endif
352 #ifndef DEVICE_NAME
353 #define DEVICE_NAME "unknown"
354 #endif
356 #define CURRENT_DEV DEVICE_NR(CURRENT->rq_dev)
358 #ifdef DEVICE_INTR
359 static void (*DEVICE_INTR)(void) = NULL;
360 #endif
362 #define SET_INTR(x) (DEVICE_INTR = (x))
364 #ifdef DEVICE_REQUEST
365 static void (DEVICE_REQUEST)(request_queue_t *);
366 #endif
368 #ifdef DEVICE_INTR
369 #define CLEAR_INTR SET_INTR(NULL)
370 #else
371 #define CLEAR_INTR
372 #endif
374 #define INIT_REQUEST \
375 if (QUEUE_EMPTY) {\
376 CLEAR_INTR; \
377 return; \
378 } \
379 if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) \
380 panic(DEVICE_NAME ": request list destroyed"); \
381 if (CURRENT->bh) { \
382 if (!buffer_locked(CURRENT->bh)) \
383 panic(DEVICE_NAME ": block not locked"); \
384 }
386 #endif /* !defined(IDE_DRIVER) */
389 #ifndef LOCAL_END_REQUEST /* If we have our own end_request, we do not want to include this mess */
391 #if ! SCSI_BLK_MAJOR(MAJOR_NR) && (MAJOR_NR != COMPAQ_SMART2_MAJOR)
393 static inline void end_request(int uptodate) {
394 struct request *req = CURRENT;
396 if (end_that_request_first(req, uptodate, DEVICE_NAME))
397 return;
399 #ifndef DEVICE_NO_RANDOM
400 add_blkdev_randomness(MAJOR(req->rq_dev));
401 #endif
402 DEVICE_OFF(req->rq_dev);
403 blkdev_dequeue_request(req);
404 end_that_request_last(req);
405 }
407 #endif /* ! SCSI_BLK_MAJOR(MAJOR_NR) */
408 #endif /* LOCAL_END_REQUEST */
410 #endif /* (MAJOR_NR != SCSI_TAPE_MAJOR) */
411 #endif /* defined(MAJOR_NR) || defined(IDE_DRIVER) */
413 #endif /* _BLK_H */