OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [include/] [linux/] [blk.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#ifndef _BLK_H
2
#define _BLK_H
3
 
4
#include <linux/blkdev.h>
5
#include <linux/locks.h>
6
#include <linux/random.h>
7
#include <linux/malloc.h>
8
#include <linux/config.h>
9
#include <linux/md.h>
10
 
11
/*
12
 * NR_REQUEST is the number of entries in the request-queue.
13
 * NOTE that writes may use only the low 2/3 of these: reads
14
 * take precedence.
15
 */
16
#define NR_REQUEST      64
17
 
18
/*
19
 * This is used in the elevator algorithm.  We don't prioritise reads
20
 * over writes any more --- although reads are more time-critical than
21
 * writes, by treating them equally we increase filesystem throughput.
22
 * This turns out to give better overall performance.  -- sct
23
 */
24
#define IN_ORDER(s1,s2) \
25
((s1)->rq_dev < (s2)->rq_dev || (((s1)->rq_dev == (s2)->rq_dev && \
26
(s1)->sector < (s2)->sector)))
27
 
28
/*
29
 * These will have to be changed to be aware of different buffer
30
 * sizes etc.. It actually needs a major cleanup.
31
 */
32
#if defined(IDE_DRIVER) || defined(MD_DRIVER)
33
#define SECTOR_MASK ((BLOCK_SIZE >> 9) - 1)
34
#else
35
#define SECTOR_MASK (blksize_size[MAJOR_NR] &&     \
36
        blksize_size[MAJOR_NR][MINOR(CURRENT->rq_dev)] ? \
37
        ((blksize_size[MAJOR_NR][MINOR(CURRENT->rq_dev)] >> 9) - 1) :  \
38
        ((BLOCK_SIZE >> 9)  -  1))
39
#endif /* IDE_DRIVER */
40
 
41
#define SUBSECTOR(block) (CURRENT->current_nr_sectors > 0)
42
 
43
#ifdef CONFIG_CDU31A
44
extern int cdu31a_init(void);
45
#endif CONFIG_CDU31A
46
#ifdef CONFIG_MCD
47
extern int mcd_init(void);
48
#endif CONFIG_MCD
49
#ifdef CONFIG_MCDX
50
extern int mcdx_init(void);
51
#endif CONFIG_MCDX
52
#ifdef CONFIG_SBPCD
53
extern int sbpcd_init(void);
54
#endif CONFIG_SBPCD
55
#ifdef CONFIG_AZTCD
56
extern int aztcd_init(void);
57
#endif CONFIG_AZTCD
58
#ifdef CONFIG_CDU535
59
extern int sony535_init(void);
60
#endif CONFIG_CDU535
61
#ifdef CONFIG_GSCD
62
extern int gscd_init(void);
63
#endif CONFIG_GSCD
64
#ifdef CONFIG_CM206
65
extern int cm206_init(void);
66
#endif CONFIG_CM206
67
#ifdef CONFIG_OPTCD
68
extern int optcd_init(void);
69
#endif CONFIG_OPTCD
70
#ifdef CONFIG_SJCD
71
extern int sjcd_init(void);
72
#endif CONFIG_SJCD
73
#ifdef CONFIG_CDI_INIT
74
extern int cdi_init(void);
75
#endif CONFIG_CDI_INIT
76
#ifdef CONFIG_BLK_DEV_HD
77
extern int hd_init(void);
78
#endif
79
#ifdef CONFIG_BLK_DEV_IDE
80
extern int ide_init(void);
81
#endif
82
#ifdef CONFIG_BLK_DEV_XD
83
extern int xd_init(void);
84
#endif
85
#ifdef CONFIG_BLK_DEV_LOOP
86
extern int loop_init(void);
87
#endif
88
#ifdef CONFIG_BLK_DEV_MD
89
extern int md_init(void);
90
#endif CONFIG_BLK_DEV_MD
91
#ifdef CONFIG_BLK_DEV_BLKMEM
92
extern int blkmem_init(void);
93
#endif CONFIG_BLK_DEV_BLKMEM
94
 
95
extern void set_device_ro(kdev_t dev,int flag);
96
void add_blkdev_randomness(int major);
97
 
98
extern int floppy_init(void);
99
extern void rd_load(void);
100
extern int rd_init(void);
101
extern int rd_doload;           /* 1 = load ramdisk, 0 = don't load */
102
extern int rd_prompt;           /* 1 = prompt for ramdisk, 0 = don't prompt */
103
extern int rd_image_start;      /* starting block # of image */
104
 
105
#ifdef CONFIG_BLK_DEV_INITRD
106
 
107
#define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
108
 
109
extern unsigned long initrd_start,initrd_end;
110
extern int mount_initrd; /* zero if initrd should not be mounted */
111
void initrd_init(void);
112
 
113
#endif
114
 
115
#define RO_IOCTLS(dev,where) \
116
  case BLKROSET: { int __err;  if (!suser()) return -EACCES; \
117
                   __err = verify_area(VERIFY_READ, (void *) (where), sizeof(long)); \
118
                   if (!__err) set_device_ro((dev),get_fs_long((long *) (where))); return __err; } \
119
  case BLKROGET: { int __err = verify_area(VERIFY_WRITE, (void *) (where), sizeof(long)); \
120
                   if (!__err) put_fs_long(0!=is_read_only(dev),(long *) (where)); return __err; }
121
 
122
#if defined(MAJOR_NR) || defined(IDE_DRIVER)
123
 
124
/*
125
 * Add entries as needed.
126
 */
127
 
128
#ifdef IDE_DRIVER
129
 
130
#define DEVICE_NR(device)       (MINOR(device) >> PARTN_BITS)
131
#define DEVICE_ON(device)       /* nothing */
132
#define DEVICE_OFF(device)      /* nothing */
133
 
134
#elif (MAJOR_NR == RAMDISK_MAJOR)
135
 
136
/* ram disk */
137
#define DEVICE_NAME "ramdisk"
138
#define DEVICE_REQUEST rd_request
139
#define DEVICE_NR(device) (MINOR(device))
140
#define DEVICE_ON(device) 
141
#define DEVICE_OFF(device)
142
#define DEVICE_NO_RANDOM
143
 
144
#elif (MAJOR_NR == FLOPPY_MAJOR)
145
 
146
static void floppy_off(unsigned int nr);
147
 
148
#define DEVICE_NAME "floppy"
149
#define DEVICE_INTR do_floppy
150
#define DEVICE_REQUEST do_fd_request
151
#define DEVICE_NR(device) ( (MINOR(device) & 3) | ((MINOR(device) & 0x80 ) >> 5 ))
152
#define DEVICE_ON(device)
153
#define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
154
 
155
#elif (MAJOR_NR == HD_MAJOR)
156
 
157
/* harddisk: timeout is 6 seconds.. */
158
#define DEVICE_NAME "harddisk"
159
#define DEVICE_INTR do_hd
160
#define DEVICE_TIMEOUT HD_TIMER
161
#define TIMEOUT_VALUE (6*HZ)
162
#define DEVICE_REQUEST do_hd_request
163
#define DEVICE_NR(device) (MINOR(device)>>6)
164
#define DEVICE_ON(device)
165
#define DEVICE_OFF(device)
166
 
167
#elif (MAJOR_NR == SCSI_DISK_MAJOR)
168
 
169
#define DEVICE_NAME "scsidisk"
170
#define DEVICE_INTR do_sd  
171
#define TIMEOUT_VALUE (2*HZ)
172
#define DEVICE_REQUEST do_sd_request
173
#define DEVICE_NR(device) (MINOR(device) >> 4)
174
#define DEVICE_ON(device)
175
#define DEVICE_OFF(device)
176
 
177
/* Kludge to use the same number for both char and block major numbers */
178
#elif  (MAJOR_NR == MD_MAJOR) && defined(MD_DRIVER)
179
 
180
#define DEVICE_NAME "Multiple devices driver"
181
#define DEVICE_REQUEST do_md_request
182
#define DEVICE_NR(device) (MINOR(device))
183
#define DEVICE_ON(device)
184
#define DEVICE_OFF(device)
185
 
186
#elif (MAJOR_NR == SCSI_TAPE_MAJOR)
187
 
188
#define DEVICE_NAME "scsitape"
189
#define DEVICE_INTR do_st  
190
#define DEVICE_NR(device) (MINOR(device) & 0x7f)
191
#define DEVICE_ON(device)
192
#define DEVICE_OFF(device)
193
 
194
#elif (MAJOR_NR == SCSI_CDROM_MAJOR)
195
 
196
#define DEVICE_NAME "CD-ROM"
197
#define DEVICE_INTR do_sr
198
#define DEVICE_REQUEST do_sr_request
199
#define DEVICE_NR(device) (MINOR(device))
200
#define DEVICE_ON(device)
201
#define DEVICE_OFF(device)
202
 
203
#elif (MAJOR_NR == XT_DISK_MAJOR)
204
 
205
#define DEVICE_NAME "xt disk"
206
#define DEVICE_REQUEST do_xd_request
207
#define DEVICE_NR(device) (MINOR(device) >> 6)
208
#define DEVICE_ON(device)
209
#define DEVICE_OFF(device)
210
 
211
#elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
212
 
213
#define DEVICE_NAME "CDU31A"
214
#define DEVICE_REQUEST do_cdu31a_request
215
#define DEVICE_NR(device) (MINOR(device))
216
#define DEVICE_ON(device)
217
#define DEVICE_OFF(device)
218
 
219
#elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
220
 
221
#define DEVICE_NAME "Mitsumi CD-ROM"
222
/* #define DEVICE_INTR do_mcd */
223
#define DEVICE_REQUEST do_mcd_request
224
#define DEVICE_NR(device) (MINOR(device))
225
#define DEVICE_ON(device)
226
#define DEVICE_OFF(device)
227
 
228
#elif (MAJOR_NR == MITSUMI_X_CDROM_MAJOR)
229
 
230
#define DEVICE_NAME "Mitsumi CD-ROM"
231
/* #define DEVICE_INTR do_mcdx */
232
#define DEVICE_REQUEST do_mcdx_request
233
#define DEVICE_NR(device) (MINOR(device))
234
#define DEVICE_ON(device)
235
#define DEVICE_OFF(device)
236
 
237
#elif (MAJOR_NR == MATSUSHITA_CDROM_MAJOR)
238
 
239
#define DEVICE_NAME "Matsushita CD-ROM controller #1"
240
#define DEVICE_REQUEST do_sbpcd_request
241
#define DEVICE_NR(device) (MINOR(device))
242
#define DEVICE_ON(device)
243
#define DEVICE_OFF(device)
244
 
245
#elif (MAJOR_NR == MATSUSHITA_CDROM2_MAJOR)
246
 
247
#define DEVICE_NAME "Matsushita CD-ROM controller #2"
248
#define DEVICE_REQUEST do_sbpcd2_request
249
#define DEVICE_NR(device) (MINOR(device))
250
#define DEVICE_ON(device)
251
#define DEVICE_OFF(device)
252
 
253
#elif (MAJOR_NR == MATSUSHITA_CDROM3_MAJOR)
254
 
255
#define DEVICE_NAME "Matsushita CD-ROM controller #3"
256
#define DEVICE_REQUEST do_sbpcd3_request
257
#define DEVICE_NR(device) (MINOR(device))
258
#define DEVICE_ON(device)
259
#define DEVICE_OFF(device)
260
 
261
#elif (MAJOR_NR == MATSUSHITA_CDROM4_MAJOR)
262
 
263
#define DEVICE_NAME "Matsushita CD-ROM controller #4"
264
#define DEVICE_REQUEST do_sbpcd4_request
265
#define DEVICE_NR(device) (MINOR(device))
266
#define DEVICE_ON(device)
267
#define DEVICE_OFF(device)
268
 
269
#elif (MAJOR_NR == AZTECH_CDROM_MAJOR)
270
 
271
#define DEVICE_NAME "Aztech CD-ROM"
272
#define DEVICE_REQUEST do_aztcd_request
273
#define DEVICE_NR(device) (MINOR(device))
274
#define DEVICE_ON(device)
275
#define DEVICE_OFF(device)
276
 
277
#elif (MAJOR_NR == CDU535_CDROM_MAJOR)
278
 
279
#define DEVICE_NAME "SONY-CDU535"
280
#define DEVICE_INTR do_cdu535
281
#define DEVICE_REQUEST do_cdu535_request
282
#define DEVICE_NR(device) (MINOR(device))
283
#define DEVICE_ON(device)
284
#define DEVICE_OFF(device)
285
 
286
#elif (MAJOR_NR == GOLDSTAR_CDROM_MAJOR)
287
 
288
#define DEVICE_NAME "Goldstar R420"
289
#define DEVICE_REQUEST do_gscd_request
290
#define DEVICE_NR(device) (MINOR(device))
291
#define DEVICE_ON(device)
292
#define DEVICE_OFF(device)
293
 
294
#elif (MAJOR_NR == CM206_CDROM_MAJOR)
295
#define DEVICE_NAME "Philips/LMS cd-rom cm206"
296
#define DEVICE_REQUEST do_cm206_request
297
#define DEVICE_NR(device) (MINOR(device))
298
#define DEVICE_ON(device)
299
#define DEVICE_OFF(device)
300
 
301
#elif (MAJOR_NR == OPTICS_CDROM_MAJOR)
302
 
303
#define DEVICE_NAME "DOLPHIN 8000AT CD-ROM"
304
#define DEVICE_REQUEST do_optcd_request
305
#define DEVICE_NR(device) (MINOR(device))
306
#define DEVICE_ON(device)
307
#define DEVICE_OFF(device)
308
 
309
#elif (MAJOR_NR == SANYO_CDROM_MAJOR)
310
 
311
#define DEVICE_NAME "Sanyo H94A CD-ROM"
312
#define DEVICE_REQUEST do_sjcd_request
313
#define DEVICE_NR(device) (MINOR(device))
314
#define DEVICE_ON(device)
315
#define DEVICE_OFF(device)
316
 
317
#elif (MAJOR_NR == BLKMEM_MAJOR)
318
 
319
#define DEVICE_NAME "Blkmem"
320
#define DEVICE_REQUEST do_blkmem_request
321
#define DEVICE_NR(device) (MINOR(device))
322
#define DEVICE_ON(device)
323
#define DEVICE_OFF(device)
324
 
325
#elif (MAJOR_NR == COMPAQ_SMART2_MAJOR)
326
 
327
#define DEVICE_NAME "ida"
328
#define DEVICE_INTR do_ida
329
#define TIMEOUT_VALUE (25*HZ)
330
#define DEVICE_REQUEST do_ida_request0
331
#define DEVICE_NR(device) (MINOR(device) >> 4)
332
#define DEVICE_ON(device)
333
#define DEVICE_OFF(device)
334
 
335
#endif /* MAJOR_NR == whatever */
336
 
337
#if (MAJOR_NR != SCSI_TAPE_MAJOR)
338
#if !defined(IDE_DRIVER)
339
 
340
#ifndef CURRENT
341
#define CURRENT (blk_dev[MAJOR_NR].current_request)
342
#endif
343
 
344
#define CURRENT_DEV DEVICE_NR(CURRENT->rq_dev)
345
 
346
#ifdef DEVICE_INTR
347
static void (*DEVICE_INTR)(void) = NULL;
348
#endif
349
#ifdef DEVICE_TIMEOUT
350
 
351
#define SET_TIMER \
352
((timer_table[DEVICE_TIMEOUT].expires = jiffies + TIMEOUT_VALUE), \
353
(timer_active |= 1<<DEVICE_TIMEOUT))
354
 
355
#define CLEAR_TIMER \
356
timer_active &= ~(1<<DEVICE_TIMEOUT)
357
 
358
#define SET_INTR(x) \
359
if ((DEVICE_INTR = (x)) != NULL) \
360
        SET_TIMER; \
361
else \
362
        CLEAR_TIMER;
363
 
364
#else
365
 
366
#define SET_INTR(x) (DEVICE_INTR = (x))
367
 
368
#endif /* DEVICE_TIMEOUT */
369
 
370
static void (DEVICE_REQUEST)(void);
371
 
372
#ifdef DEVICE_INTR
373
#define CLEAR_INTR SET_INTR(NULL)
374
#else
375
#define CLEAR_INTR
376
#endif
377
 
378
#define INIT_REQUEST \
379
        if (!CURRENT) {\
380
                CLEAR_INTR; \
381
                return; \
382
        } \
383
        if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) \
384
                panic(DEVICE_NAME ": request list destroyed"); \
385
        if (CURRENT->bh) { \
386
                if (!buffer_locked(CURRENT->bh)) \
387
                        panic(DEVICE_NAME ": block not locked"); \
388
        }
389
 
390
#endif /* !defined(IDE_DRIVER) */
391
 
392
/* end_request() - SCSI devices have their own version */
393
/*               - IDE drivers have their own copy too */
394
 
395
#if ! SCSI_BLK_MAJOR(MAJOR_NR) && (MAJOR_NR != COMPAQ_SMART2_MAJOR)
396
 
397
#if defined(IDE_DRIVER) && !defined(_IDE_C) /* shared copy for IDE modules */
398
void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup);
399
#else
400
 
401
#ifdef IDE_DRIVER
402
void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup) {
403
        struct request *req = hwgroup->rq;
404
#else
405
static void end_request(int uptodate) {
406
        struct request *req = CURRENT;
407
#endif /* IDE_DRIVER */
408
        struct buffer_head * bh;
409
        int nsect;
410
 
411
        req->errors = 0;
412
        if (!uptodate) {
413
                printk("end_request: I/O error, dev %s, sector %lu\n",
414
                        kdevname(req->rq_dev), req->sector);
415
                if ((bh = req->bh) != NULL) {
416
                        nsect = bh->b_size >> 9;
417
                        req->nr_sectors--;
418
                        req->nr_sectors &= ~(nsect - 1);
419
                        req->sector += nsect;
420
                        req->sector &= ~(nsect - 1);
421
                }
422
        }
423
 
424
        if ((bh = req->bh) != NULL) {
425
                req->bh = bh->b_reqnext;
426
                bh->b_reqnext = NULL;
427
 
428
                /*
429
                 * This is our 'MD IO has finished' event handler.
430
                 * note that b_state should be cached in a register
431
                 * anyways, so the overhead if this checking is almost
432
                 * zero. But anyways .. we never get OO for free :)
433
                 */
434
                if (test_bit(BH_MD, &bh->b_state)) {
435
                        struct md_personality * pers=(struct md_personality *)bh->personality;
436
                        pers->end_request(bh,uptodate);
437
                }
438
                /*
439
                 * the normal (nonmirrored and no RAID5) case:
440
                 */
441
                else {
442
                        mark_buffer_uptodate(bh, uptodate);
443
                        unlock_buffer(bh);
444
                }
445
                if ((bh = req->bh) != NULL) {
446
                        req->current_nr_sectors = bh->b_size >> 9;
447
                        if (req->nr_sectors < req->current_nr_sectors) {
448
                                req->nr_sectors = req->current_nr_sectors;
449
                                printk("end_request: buffer-list destroyed\n");
450
                        }
451
                        req->buffer = bh->b_data;
452
                        return;
453
                }
454
        }
455
#ifndef DEVICE_NO_RANDOM
456
        add_blkdev_randomness(MAJOR(req->rq_dev));
457
#endif
458
#ifdef IDE_DRIVER
459
        blk_dev[MAJOR(req->rq_dev)].current_request = req->next;
460
        hwgroup->rq = NULL;
461
#else
462
        DEVICE_OFF(req->rq_dev);
463
        CURRENT = req->next;
464
#endif /* IDE_DRIVER */
465
        if (req->sem != NULL)
466
                up(req->sem);
467
        req->rq_status = RQ_INACTIVE;
468
        wake_up(&wait_for_request);
469
}
470
#endif /* defined(IDE_DRIVER) && !defined(_IDE_C) */
471
#endif /* ! SCSI_BLK_MAJOR(MAJOR_NR) */
472
#endif /* (MAJOR_NR != SCSI_TAPE_MAJOR) */
473
 
474
#endif /* defined(MAJOR_NR) || defined(IDE_DRIVER) */
475
 
476
#endif /* _BLK_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.