root/drivers/block/blk.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ide_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 #ifdef CONFIG_CDU31A
  41 extern unsigned long cdu31a_init(unsigned long, unsigned long);
  42 #endif CONFIG_CDU31A
  43 #ifdef CONFIG_MCD
  44 extern unsigned long mcd_init(unsigned long, unsigned long);
  45 #endif CONFIG_MCD
  46 #ifdef CONFIG_MCDX
  47 extern unsigned long mcdx_init(unsigned long, unsigned long);
  48 #endif CONFIG_MCDX
  49 #ifdef CONFIG_SBPCD
  50 extern unsigned long sbpcd_init(unsigned long, unsigned long);
  51 #endif CONFIG_SBPCD
  52 #ifdef CONFIG_AZTCD
  53 extern unsigned long aztcd_init(unsigned long, unsigned long);
  54 #endif CONFIG_AZTCD
  55 #ifdef CONFIG_CDU535
  56 extern unsigned long sony535_init(unsigned long, unsigned long);
  57 #endif CONFIG_CDU535
  58 #ifdef CONFIG_GSCD
  59 extern unsigned long gscd_init(unsigned long, unsigned long);
  60 #endif CONFIG_GSCD
  61 #ifdef CONFIG_CM206
  62 extern unsigned long cm206_init(unsigned long, unsigned long);
  63 #endif CONFIG_CM206
  64 #ifdef CONFIG_OPTCD
  65 extern unsigned long optcd_init(unsigned long, unsigned long);
  66 #endif CONFIG_OPTCD
  67 #ifdef CONFIG_SJCD
  68 extern unsigned long sjcd_init(unsigned long, unsigned long);
  69 #endif CONFIG_SJCD
  70 #ifdef CONFIG_BLK_DEV_HD
  71 extern unsigned long hd_init(unsigned long mem_start, unsigned long mem_end);
  72 #endif
  73 #ifdef CONFIG_BLK_DEV_IDE
  74 extern unsigned long ide_init(unsigned long mem_start, unsigned long mem_end);
  75 #endif
  76 extern void set_device_ro(int dev,int flag);
  77 
  78 extern int floppy_init(void);
  79 extern void rd_load(void);
  80 extern long rd_init(long mem_start, int length);
  81 extern int ramdisk_size;
  82 
  83 #ifdef CONFIG_BLK_DEV_XD
  84 extern unsigned long xd_init(unsigned long mem_start, unsigned long mem_end);
  85 #endif
  86 
  87 #define RO_IOCTLS(dev,where) \
  88   case BLKROSET: if (!suser()) return -EACCES; \
  89                  set_device_ro((dev),get_fs_long((long *) (where))); return 0; \
  90   case BLKROGET: { int __err = verify_area(VERIFY_WRITE, (void *) (where), sizeof(long)); \
  91                    if (!__err) put_fs_long(0!=is_read_only(dev),(long *) (where)); return __err; }
  92                  
  93 #if defined(MAJOR_NR) || defined(IDE_DRIVER)
  94 
  95 /*
  96  * Add entries as needed.
  97  */
  98 
  99 #ifdef IDE_DRIVER
 100 
 101 #define DEVICE_NR(device)       (MINOR(device) >> PARTN_BITS)
 102 #define DEVICE_ON(device)       /* nothing */
 103 #define DEVICE_OFF(device)      /* nothing */
 104 
 105 #elif (MAJOR_NR == MEM_MAJOR)
 106 
 107 /* ram disk */
 108 #define DEVICE_NAME "ramdisk"
 109 #define DEVICE_REQUEST do_rd_request
 110 #define DEVICE_NR(device) ((device) & 7)
 111 #define DEVICE_ON(device) 
 112 #define DEVICE_OFF(device)
 113 
 114 #elif (MAJOR_NR == FLOPPY_MAJOR)
 115 
 116 static void floppy_off(unsigned int nr);
 117 
 118 #define DEVICE_NAME "floppy"
 119 #define DEVICE_INTR do_floppy
 120 #define DEVICE_REQUEST do_fd_request
 121 #define DEVICE_NR(device) ( ((device) & 3) | (((device) & 0x80 ) >> 5 ))
 122 #define DEVICE_ON(device)
 123 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
 124 
 125 #elif (MAJOR_NR == HD_MAJOR)
 126 
 127 /* harddisk: timeout is 6 seconds.. */
 128 #define DEVICE_NAME "harddisk"
 129 #define DEVICE_INTR do_hd
 130 #define DEVICE_TIMEOUT HD_TIMER
 131 #define TIMEOUT_VALUE (6*HZ)
 132 #define DEVICE_REQUEST do_hd_request
 133 #define DEVICE_NR(device) (MINOR(device)>>6)
 134 #define DEVICE_ON(device)
 135 #define DEVICE_OFF(device)
 136 
 137 #elif (MAJOR_NR == SCSI_DISK_MAJOR)
 138 
 139 #define DEVICE_NAME "scsidisk"
 140 #define DEVICE_INTR do_sd  
 141 #define TIMEOUT_VALUE (2*HZ)
 142 #define DEVICE_REQUEST do_sd_request
 143 #define DEVICE_NR(device) (MINOR(device) >> 4)
 144 #define DEVICE_ON(device)
 145 #define DEVICE_OFF(device)
 146 
 147 #elif (MAJOR_NR == SCSI_TAPE_MAJOR)
 148 
 149 #define DEVICE_NAME "scsitape"
 150 #define DEVICE_INTR do_st  
 151 #define DEVICE_NR(device) (MINOR(device) & 0x7f)
 152 #define DEVICE_ON(device)
 153 #define DEVICE_OFF(device)
 154 
 155 #elif (MAJOR_NR == SCSI_CDROM_MAJOR)
 156 
 157 #define DEVICE_NAME "CD-ROM"
 158 #define DEVICE_INTR do_sr
 159 #define DEVICE_REQUEST do_sr_request
 160 #define DEVICE_NR(device) (MINOR(device))
 161 #define DEVICE_ON(device)
 162 #define DEVICE_OFF(device)
 163 
 164 #elif (MAJOR_NR == XT_DISK_MAJOR)
 165 
 166 #define DEVICE_NAME "xt disk"
 167 #define DEVICE_REQUEST do_xd_request
 168 #define DEVICE_NR(device) (MINOR(device) >> 6)
 169 #define DEVICE_ON(device)
 170 #define DEVICE_OFF(device)
 171 
 172 #elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
 173 
 174 #define DEVICE_NAME "CDU31A"
 175 #define DEVICE_REQUEST do_cdu31a_request
 176 #define DEVICE_NR(device) (MINOR(device))
 177 #define DEVICE_ON(device)
 178 #define DEVICE_OFF(device)
 179 
 180 #elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
 181 
 182 #define DEVICE_NAME "Mitsumi CD-ROM"
 183 /* #define DEVICE_INTR do_mcd */
 184 #define DEVICE_REQUEST do_mcd_request
 185 #define DEVICE_NR(device) (MINOR(device))
 186 #define DEVICE_ON(device)
 187 #define DEVICE_OFF(device)
 188 
 189 #elif (MAJOR_NR == MITSUMI_X_CDROM_MAJOR)
 190 
 191 #define DEVICE_NAME "Mitsumi CD-ROM"
 192 /* #define DEVICE_INTR do_mcdx */
 193 #define DEVICE_REQUEST do_mcdx_request
 194 #define DEVICE_NR(device) (MINOR(device))
 195 #define DEVICE_ON(device)
 196 #define DEVICE_OFF(device)
 197 
 198 #elif (MAJOR_NR == MATSUSHITA_CDROM_MAJOR)
 199 
 200 #define DEVICE_NAME "Matsushita CD-ROM controller #1"
 201 #define DEVICE_REQUEST do_sbpcd_request
 202 #define DEVICE_NR(device) (MINOR(device))
 203 #define DEVICE_ON(device)
 204 #define DEVICE_OFF(device)
 205 
 206 #elif (MAJOR_NR == MATSUSHITA_CDROM2_MAJOR)
 207 
 208 #define DEVICE_NAME "Matsushita CD-ROM controller #2"
 209 #define DEVICE_REQUEST do_sbpcd2_request
 210 #define DEVICE_NR(device) (MINOR(device))
 211 #define DEVICE_ON(device)
 212 #define DEVICE_OFF(device)
 213 
 214 #elif (MAJOR_NR == MATSUSHITA_CDROM3_MAJOR)
 215 
 216 #define DEVICE_NAME "Matsushita CD-ROM controller #3"
 217 #define DEVICE_REQUEST do_sbpcd3_request
 218 #define DEVICE_NR(device) (MINOR(device))
 219 #define DEVICE_ON(device)
 220 #define DEVICE_OFF(device)
 221 
 222 #elif (MAJOR_NR == MATSUSHITA_CDROM4_MAJOR)
 223 
 224 #define DEVICE_NAME "Matsushita CD-ROM controller #4"
 225 #define DEVICE_REQUEST do_sbpcd4_request
 226 #define DEVICE_NR(device) (MINOR(device))
 227 #define DEVICE_ON(device)
 228 #define DEVICE_OFF(device)
 229 
 230 #elif (MAJOR_NR == AZTECH_CDROM_MAJOR)
 231 
 232 #define DEVICE_NAME "Aztech CD-ROM"
 233 #define DEVICE_REQUEST do_aztcd_request
 234 #define DEVICE_NR(device) (MINOR(device))
 235 #define DEVICE_ON(device)
 236 #define DEVICE_OFF(device)
 237 
 238 #elif (MAJOR_NR == CDU535_CDROM_MAJOR)
 239 
 240 #define DEVICE_NAME "SONY-CDU535"
 241 #define DEVICE_INTR do_cdu535
 242 #define DEVICE_REQUEST do_cdu535_request
 243 #define DEVICE_NR(device) (MINOR(device))
 244 #define DEVICE_ON(device)
 245 #define DEVICE_OFF(device)
 246 
 247 #elif (MAJOR_NR == GOLDSTAR_CDROM_MAJOR)
 248 
 249 #define DEVICE_NAME "Goldstar R420"
 250 #define DEVICE_REQUEST do_gscd_request
 251 #define DEVICE_NR(device) (MINOR(device))
 252 #define DEVICE_ON(device)
 253 #define DEVICE_OFF(device)
 254 
 255 #elif (MAJOR_NR == CM206_CDROM_MAJOR)
 256 #define DEVICE_NAME "Philips/LMS cd-rom cm206"
 257 #define DEVICE_REQUEST do_cm206_request
 258 #define DEVICE_NR(device) (MINOR(device))
 259 #define DEVICE_ON(device)
 260 #define DEVICE_OFF(device)
 261 
 262 #elif (MAJOR_NR == OPTICS_CDROM_MAJOR)
 263 
 264 #define DEVICE_NAME "DOLPHIN 8000AT CD-ROM"
 265 #define DEVICE_REQUEST do_optcd_request
 266 #define DEVICE_NR(device) (MINOR(device))
 267 #define DEVICE_ON(device)
 268 #define DEVICE_OFF(device)
 269 
 270 #elif (MAJOR_NR == SANYO_CDROM_MAJOR)
 271 
 272 #define DEVICE_NAME "Sanyo H94A CD-ROM"
 273 #define DEVICE_REQUEST do_sjcd_request
 274 #define DEVICE_NR(device) (MINOR(device))
 275 #define DEVICE_ON(device)
 276 #define DEVICE_OFF(device)
 277 
 278 #endif /* MAJOR_NR == whatever */
 279 
 280 #if (MAJOR_NR != SCSI_TAPE_MAJOR) && !defined(IDE_DRIVER)
 281 
 282 #ifndef CURRENT
 283 #define CURRENT (blk_dev[MAJOR_NR].current_request)
 284 #endif
 285 
 286 #define CURRENT_DEV DEVICE_NR(CURRENT->dev)
 287 
 288 #ifdef DEVICE_INTR
 289 void (*DEVICE_INTR)(void) = NULL;
 290 #endif
 291 #ifdef DEVICE_TIMEOUT
 292 
 293 #define SET_TIMER \
 294 ((timer_table[DEVICE_TIMEOUT].expires = jiffies + TIMEOUT_VALUE), \
 295 (timer_active |= 1<<DEVICE_TIMEOUT))
 296 
 297 #define CLEAR_TIMER \
 298 timer_active &= ~(1<<DEVICE_TIMEOUT)
 299 
 300 #define SET_INTR(x) \
 301 if ((DEVICE_INTR = (x)) != NULL) \
 302         SET_TIMER; \
 303 else \
 304         CLEAR_TIMER;
 305 
 306 #else
 307 
 308 #define SET_INTR(x) (DEVICE_INTR = (x))
 309 
 310 #endif /* DEVICE_TIMEOUT */
 311 
 312 static void (DEVICE_REQUEST)(void);
 313 
 314 #ifdef DEVICE_INTR
 315 #define CLEAR_INTR SET_INTR(NULL)
 316 #else
 317 #define CLEAR_INTR
 318 #endif
 319 
 320 #define INIT_REQUEST \
 321         if (!CURRENT) {\
 322                 CLEAR_INTR; \
 323                 return; \
 324         } \
 325         if (MAJOR(CURRENT->dev) != MAJOR_NR) \
 326                 panic(DEVICE_NAME ": request list destroyed"); \
 327         if (CURRENT->bh) { \
 328                 if (!CURRENT->bh->b_lock) \
 329                         panic(DEVICE_NAME ": block not locked"); \
 330         }
 331 
 332 #endif /* (MAJOR_NR != SCSI_TAPE_MAJOR) && !defined(IDE_DRIVER) */
 333 
 334 /* end_request() - SCSI devices have their own version */
 335 /*               - IDE drivers have their own copy too */
 336 
 337 #if ! SCSI_MAJOR(MAJOR_NR)
 338 
 339 #if defined(_IDE_CD_C) || defined(_TRITON_C) /* shares copy with ide.c */
 340 void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup);
 341 #else
 342 
 343 #ifdef IDE_DRIVER
 344 void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup) {
     /* [previous][next][first][last][top][bottom][index][help] */
 345         struct request *req = hwgroup->rq;
 346 #else
 347 static void end_request(int uptodate) {
     /* [previous][next][first][last][top][bottom][index][help] */
 348         struct request *req = CURRENT;
 349 #endif /* IDE_DRIVER */
 350         struct buffer_head * bh;
 351 
 352         req->errors = 0;
 353         if (!uptodate) {
 354                 printk("end_request: I/O error, dev %04lX, sector %lu\n",
 355                        (unsigned long)req->dev, req->sector);
 356                 req->nr_sectors--;
 357                 req->nr_sectors &= ~SECTOR_MASK;
 358                 req->sector += (BLOCK_SIZE / 512);
 359                 req->sector &= ~SECTOR_MASK;            
 360         }
 361 
 362         if ((bh = req->bh) != NULL) {
 363                 req->bh = bh->b_reqnext;
 364                 bh->b_reqnext = NULL;
 365                 bh->b_uptodate = uptodate;              
 366                 if (!uptodate) bh->b_req = 0; /* So no "Weird" errors */
 367                 unlock_buffer(bh);
 368                 if ((bh = req->bh) != NULL) {
 369                         req->current_nr_sectors = bh->b_size >> 9;
 370                         if (req->nr_sectors < req->current_nr_sectors) {
 371                                 req->nr_sectors = req->current_nr_sectors;
 372                                 printk("end_request: buffer-list destroyed\n");
 373                         }
 374                         req->buffer = bh->b_data;
 375                         return;
 376                 }
 377         }
 378 #ifdef IDE_DRIVER
 379         hwgroup->rq = NULL;
 380 #else
 381         DEVICE_OFF(req->dev);
 382         CURRENT = req->next;
 383 #endif /* IDE_DRIVER */
 384         if (req->sem != NULL)
 385                 up(req->sem);
 386         req->dev = -1;
 387         wake_up(&wait_for_request);
 388 }
 389 #endif /* ndef _IDE_CD_C */
 390 #endif /* ! SCSI_MAJOR(MAJOR_NR) */
 391 
 392 #endif /* defined(MAJOR_NR) || defined(IDE_DRIVER) */
 393 
 394 #endif /* _BLK_H */

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