root/drivers/block/blk.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. end_request
  2. end_request

   1 #ifndef _BLK_H
   2 #define _BLK_H
   3 
   4 #include <linux/blkdev.h>
   5 #include <linux/locks.h>
   6 #include <linux/config.h>
   7 
   8 /*
   9  * NR_REQUEST is the number of entries in the request-queue.
  10  * NOTE that writes may use only the low 2/3 of these: reads
  11  * take precedence.
  12  */
  13 #define NR_REQUEST      64
  14 
  15 /*
  16  * This is used in the elevator algorithm: Note that
  17  * reads always go before writes. This is natural: reads
  18  * are much more time-critical than writes.
  19  */
  20 #define IN_ORDER(s1,s2) \
  21 ((s1)->cmd < (s2)->cmd || ((s1)->cmd == (s2)->cmd && \
  22 ((s1)->dev < (s2)->dev || (((s1)->dev == (s2)->dev && \
  23 (s1)->sector < (s2)->sector)))))
  24 
  25 /*
  26  * These will have to be changed to be aware of different buffer
  27  * sizes etc.. It actually needs a major cleanup.
  28  */
  29 #ifdef IDE_DRIVER
  30 #define SECTOR_MASK ((BLOCK_SIZE >> 9) - 1)
  31 #else
  32 #define SECTOR_MASK (blksize_size[MAJOR_NR] &&     \
  33         blksize_size[MAJOR_NR][MINOR(CURRENT->dev)] ? \
  34         ((blksize_size[MAJOR_NR][MINOR(CURRENT->dev)] >> 9) - 1) :  \
  35         ((BLOCK_SIZE >> 9)  -  1))
  36 #endif /* IDE_DRIVER */
  37 
  38 #define SUBSECTOR(block) (CURRENT->current_nr_sectors > 0)
  39 
  40 extern unsigned long cdu31a_init(unsigned long mem_start, unsigned long mem_end);
  41 extern unsigned long mcd_init(unsigned long mem_start, unsigned long mem_end);
  42 #ifdef CONFIG_AZTCD
  43 extern unsigned long aztcd_init(unsigned long mem_start, unsigned long mem_end);
  44 #endif
  45 #ifdef CONFIG_CDU535
  46 extern unsigned long sony535_init(unsigned long mem_start, unsigned long mem_end);
  47 #endif
  48 #ifdef CONFIG_BLK_DEV_HD
  49 extern unsigned long hd_init(unsigned long mem_start, unsigned long mem_end);
  50 #endif
  51 #ifdef CONFIG_BLK_DEV_IDE
  52 extern unsigned long ide_init(unsigned long mem_start, unsigned long mem_end);
  53 #endif
  54 #ifdef CONFIG_SBPCD
  55 extern unsigned long sbpcd_init(unsigned long, unsigned long);
  56 #endif CONFIG_SBPCD
  57 extern void set_device_ro(int dev,int flag);
  58 
  59 extern void floppy_init(void);
  60 #ifdef FD_MODULE
  61 static
  62 #else
  63 extern
  64 #endif
  65 int new_floppy_init(void);
  66 extern void rd_load(void);
  67 extern long rd_init(long mem_start, int length);
  68 extern int ramdisk_size;
  69 
  70 extern unsigned long xd_init(unsigned long mem_start, unsigned long mem_end);
  71 
  72 #define RO_IOCTLS(dev,where) \
  73   case BLKROSET: if (!suser()) return -EACCES; \
  74                  set_device_ro((dev),get_fs_long((long *) (where))); return 0; \
  75   case BLKROGET: { int __err = verify_area(VERIFY_WRITE, (void *) (where), sizeof(long)); \
  76                    if (!__err) put_fs_long(0!=is_read_only(dev),(long *) (where)); return __err; }
  77                  
  78 #if defined(MAJOR_NR) || defined(IDE_DRIVER)
  79 
  80 /*
  81  * Add entries as needed.
  82  */
  83 
  84 #ifdef IDE_DRIVER
  85 
  86 #define DEVICE_NR(device)       (MINOR(device) >> PARTN_BITS)
  87 #define DEVICE_ON(device)       /* nothing */
  88 #define DEVICE_OFF(device)      /* nothing */
  89 
  90 #elif (MAJOR_NR == MEM_MAJOR)
  91 
  92 /* ram disk */
  93 #define DEVICE_NAME "ramdisk"
  94 #define DEVICE_REQUEST do_rd_request
  95 #define DEVICE_NR(device) ((device) & 7)
  96 #define DEVICE_ON(device) 
  97 #define DEVICE_OFF(device)
  98 
  99 #elif (MAJOR_NR == FLOPPY_MAJOR)
 100 
 101 static void floppy_off(unsigned int nr);
 102 
 103 #define DEVICE_NAME "floppy"
 104 #define DEVICE_INTR do_floppy
 105 #define DEVICE_REQUEST do_fd_request
 106 #define DEVICE_NR(device) ( ((device) & 3) | (((device) & 0x80 ) >> 5 ))
 107 #define DEVICE_ON(device)
 108 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
 109 
 110 #elif (MAJOR_NR == HD_MAJOR)
 111 
 112 /* harddisk: timeout is 6 seconds.. */
 113 #define DEVICE_NAME "harddisk"
 114 #define DEVICE_INTR do_hd
 115 #define DEVICE_TIMEOUT HD_TIMER
 116 #define TIMEOUT_VALUE 600
 117 #define DEVICE_REQUEST do_hd_request
 118 #define DEVICE_NR(device) (MINOR(device)>>6)
 119 #define DEVICE_ON(device)
 120 #define DEVICE_OFF(device)
 121 
 122 #elif (MAJOR_NR == SCSI_DISK_MAJOR)
 123 
 124 #define DEVICE_NAME "scsidisk"
 125 #define DEVICE_INTR do_sd  
 126 #define TIMEOUT_VALUE 200
 127 #define DEVICE_REQUEST do_sd_request
 128 #define DEVICE_NR(device) (MINOR(device) >> 4)
 129 #define DEVICE_ON(device)
 130 #define DEVICE_OFF(device)
 131 
 132 #elif (MAJOR_NR == SCSI_TAPE_MAJOR)
 133 
 134 #define DEVICE_NAME "scsitape"
 135 #define DEVICE_INTR do_st  
 136 #define DEVICE_NR(device) (MINOR(device) & 0x7f)
 137 #define DEVICE_ON(device)
 138 #define DEVICE_OFF(device)
 139 
 140 #elif (MAJOR_NR == SCSI_CDROM_MAJOR)
 141 
 142 #define DEVICE_NAME "CD-ROM"
 143 #define DEVICE_INTR do_sr
 144 #define DEVICE_REQUEST do_sr_request
 145 #define DEVICE_NR(device) (MINOR(device))
 146 #define DEVICE_ON(device)
 147 #define DEVICE_OFF(device)
 148 
 149 #elif (MAJOR_NR == XT_DISK_MAJOR)
 150 
 151 #define DEVICE_NAME "xt disk"
 152 #define DEVICE_REQUEST do_xd_request
 153 #define DEVICE_NR(device) (MINOR(device) >> 6)
 154 #define DEVICE_ON(device)
 155 #define DEVICE_OFF(device)
 156 
 157 #elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
 158 
 159 #define DEVICE_NAME "CDU31A"
 160 #define DEVICE_REQUEST do_cdu31a_request
 161 #define DEVICE_NR(device) (MINOR(device))
 162 #define DEVICE_ON(device)
 163 #define DEVICE_OFF(device)
 164 
 165 #elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
 166 
 167 #define DEVICE_NAME "Mitsumi CD-ROM"
 168 /* #define DEVICE_INTR do_mcd */
 169 #define DEVICE_REQUEST do_mcd_request
 170 #define DEVICE_NR(device) (MINOR(device))
 171 #define DEVICE_ON(device)
 172 #define DEVICE_OFF(device)
 173 
 174 #elif (MAJOR_NR == AZTECH_CDROM_MAJOR)
 175 
 176 #define DEVICE_NAME "Aztech CD-ROM"
 177 #define DEVICE_REQUEST do_aztcd_request
 178 #define DEVICE_NR(device) (MINOR(device))
 179 #define DEVICE_ON(device)
 180 #define DEVICE_OFF(device)
 181 
 182 #elif (MAJOR_NR == CDU535_CDROM_MAJOR)
 183 
 184 #define DEVICE_NAME "SONY-CDU535"
 185 #define DEVICE_INTR do_cdu535
 186 #define DEVICE_REQUEST do_cdu535_request
 187 #define DEVICE_NR(device) (MINOR(device))
 188 #define DEVICE_ON(device)
 189 #define DEVICE_OFF(device)
 190 
 191 #elif (MAJOR_NR == MATSUSHITA_CDROM_MAJOR)
 192 
 193 #define DEVICE_NAME "Matsushita CD-ROM controller #1"
 194 #define DEVICE_REQUEST do_sbpcd_request
 195 #define DEVICE_NR(device) (MINOR(device))
 196 #define DEVICE_ON(device)
 197 #define DEVICE_OFF(device)
 198 
 199 #elif (MAJOR_NR == MATSUSHITA_CDROM2_MAJOR)
 200 
 201 #define DEVICE_NAME "Matsushita CD-ROM controller #2"
 202 #define DEVICE_REQUEST do_sbpcd2_request
 203 #define DEVICE_NR(device) (MINOR(device))
 204 #define DEVICE_ON(device)
 205 #define DEVICE_OFF(device)
 206 
 207 #elif (MAJOR_NR == MATSUSHITA_CDROM3_MAJOR)
 208 
 209 #define DEVICE_NAME "Matsushita CD-ROM controller #3"
 210 #define DEVICE_REQUEST do_sbpcd3_request
 211 #define DEVICE_NR(device) (MINOR(device))
 212 #define DEVICE_ON(device)
 213 #define DEVICE_OFF(device)
 214 
 215 #elif (MAJOR_NR == MATSUSHITA_CDROM4_MAJOR)
 216 
 217 #define DEVICE_NAME "Matsushita CD-ROM controller #4"
 218 #define DEVICE_REQUEST do_sbpcd4_request
 219 #define DEVICE_NR(device) (MINOR(device))
 220 #define DEVICE_ON(device)
 221 #define DEVICE_OFF(device)
 222 
 223 #endif /* MAJOR_NR == whatever */
 224 
 225 #if (MAJOR_NR != SCSI_TAPE_MAJOR) && !defined(IDE_DRIVER)
 226 
 227 #ifndef CURRENT
 228 #define CURRENT (blk_dev[MAJOR_NR].current_request)
 229 #endif
 230 
 231 #define CURRENT_DEV DEVICE_NR(CURRENT->dev)
 232 
 233 #ifdef DEVICE_INTR
 234 void (*DEVICE_INTR)(void) = NULL;
 235 #endif
 236 #ifdef DEVICE_TIMEOUT
 237 
 238 #define SET_TIMER \
 239 ((timer_table[DEVICE_TIMEOUT].expires = jiffies + TIMEOUT_VALUE), \
 240 (timer_active |= 1<<DEVICE_TIMEOUT))
 241 
 242 #define CLEAR_TIMER \
 243 timer_active &= ~(1<<DEVICE_TIMEOUT)
 244 
 245 #define SET_INTR(x) \
 246 if ((DEVICE_INTR = (x)) != NULL) \
 247         SET_TIMER; \
 248 else \
 249         CLEAR_TIMER;
 250 
 251 #else
 252 
 253 #define SET_INTR(x) (DEVICE_INTR = (x))
 254 
 255 #endif /* DEVICE_TIMEOUT */
 256 
 257 static void (DEVICE_REQUEST)(void);
 258 
 259 #ifdef DEVICE_INTR
 260 #define CLEAR_INTR SET_INTR(NULL)
 261 #else
 262 #define CLEAR_INTR
 263 #endif
 264 
 265 #define INIT_REQUEST \
 266         if (!CURRENT) {\
 267                 CLEAR_INTR; \
 268                 return; \
 269         } \
 270         if (MAJOR(CURRENT->dev) != MAJOR_NR) \
 271                 panic(DEVICE_NAME ": request list destroyed"); \
 272         if (CURRENT->bh) { \
 273                 if (!CURRENT->bh->b_lock) \
 274                         panic(DEVICE_NAME ": block not locked"); \
 275         }
 276 
 277 #endif /* (MAJOR_NR != SCSI_TAPE_MAJOR) && !defined(IDE_DRIVER) */
 278 
 279 /* end_request() - SCSI devices have their own version */
 280 
 281 #if ! SCSI_MAJOR(MAJOR_NR)
 282 
 283 #ifdef IDE_DRIVER
 284 static void end_request(byte uptodate, byte hwif) {
     /* [previous][next][first][last][top][bottom][index][help] */
 285         struct request *req = ide_cur_rq[HWIF];
 286 #else
 287 static void end_request(int uptodate) {
     /* [previous][next][first][last][top][bottom][index][help] */
 288         struct request *req = CURRENT;
 289 #endif /* IDE_DRIVER */
 290         struct buffer_head * bh;
 291 
 292         req->errors = 0;
 293         if (!uptodate) {
 294                 printk("end_request: I/O error, dev %04lX, sector %lu\n",
 295                        (unsigned long)req->dev, req->sector);
 296                 req->nr_sectors--;
 297                 req->nr_sectors &= ~SECTOR_MASK;
 298                 req->sector += (BLOCK_SIZE / 512);
 299                 req->sector &= ~SECTOR_MASK;            
 300         }
 301 
 302         if ((bh = req->bh) != NULL) {
 303                 req->bh = bh->b_reqnext;
 304                 bh->b_reqnext = NULL;
 305                 bh->b_uptodate = uptodate;              
 306                 if (!uptodate) bh->b_req = 0; /* So no "Weird" errors */
 307                 unlock_buffer(bh);
 308                 if ((bh = req->bh) != NULL) {
 309                         req->current_nr_sectors = bh->b_size >> 9;
 310                         if (req->nr_sectors < req->current_nr_sectors) {
 311                                 req->nr_sectors = req->current_nr_sectors;
 312                                 printk("end_request: buffer-list destroyed\n");
 313                         }
 314                         req->buffer = bh->b_data;
 315                         return;
 316                 }
 317         }
 318 #ifdef IDE_DRIVER
 319         ide_cur_rq[HWIF] = NULL;
 320 #else
 321         DEVICE_OFF(req->dev);
 322         CURRENT = req->next;
 323 #endif /* IDE_DRIVER */
 324         if (req->sem != NULL)
 325                 up(req->sem);
 326         req->dev = -1;
 327         wake_up(&wait_for_request);
 328 }
 329 #endif /* ! SCSI_MAJOR(MAJOR_NR) */
 330 
 331 #endif /* defined(MAJOR_NR) || defined(IDE_DRIVER) */
 332 
 333 #endif /* _BLK_H */

/* [previous][next][first][last][top][bottom][index][help] */