1 /* 2 * linux/drivers/block/ide.h 3 * 4 * Copyright (C) 1994, 1995 Linus Torvalds & authors 5 */ 6 7 #include <linux/config.h> 8 9 /* 10 * This is the multiple IDE interface driver, as evolved from hd.c. 11 * It supports up to four IDE interfaces, on one or more IRQs (usually 14 & 15). 12 * There can be up to two drives per interface, as per the ATA-2 spec. 13 * 14 * Primary i/f: ide0: major=3; (hda) minor=0; (hdb) minor=64 15 * Secondary i/f: ide1: major=22; (hdc or hd1a) minor=0; (hdd or hd1b) minor=64 16 * Tertiary i/f: ide2: major=33; (hde) minor=0; (hdf) minor=64 17 * Quaternary i/f: ide3: major=34; (hdg) minor=0; (hdh) minor=64 18 */ 19 20 /****************************************************************************** 21 * IDE driver configuration options (play with these as desired): 22 * 23 * REALLY_SLOW_IO can be defined in ide.c and ide-cd.c, if necessary 24 */ 25 #undef REALLY_FAST_IO /* define if ide ports are perfect */ 26 #define INITIAL_MULT_COUNT 0 /* off=0; on=2,4,8,16,32, etc.. */ 27 28 #ifndef DISK_RECOVERY_TIME /* off=0; on=access_delay_time */ 29 #define DISK_RECOVERY_TIME 0 /* for hardware that needs it */ 30 #endif 31 #ifndef OK_TO_RESET_CONTROLLER /* 1 needed for good error recovery */ 32 #define OK_TO_RESET_CONTROLLER 1 /* 0 for use with AH2372A/B interface */ 33 #endif 34 #ifndef FAKE_FDISK_FOR_EZDRIVE /* 1 to help linux fdisk with EZDRIVE */ 35 #define FAKE_FDISK_FOR_EZDRIVE 1 /* 0 to reduce kernel size */ 36 #endif 37 #ifndef FANCY_STATUS_DUMPS /* 1 for human-readable drive errors */ 38 #define FANCY_STATUS_DUMPS 1 /* 0 to reduce kernel size */ 39 #endif 40 41 #if defined(CONFIG_BLK_DEV_IDECD) || defined(CONFIG_BLK_DEV_IDETAPE) 42 #define CONFIG_BLK_DEV_IDEATAPI 1 43 #endif 44 45 /* 46 * IDE_DRIVE_CMD is used to implement many features of the hdparm utility 47 */ 48 #define IDE_DRIVE_CMD 99 /* (magic) undef to reduce kernel size*/ 49 50 /* 51 * "No user-serviceable parts" beyond this point :) 52 *****************************************************************************/ 53 54 typedef unsigned char byte; /* used everywhere */ 55 56 /* 57 * Probably not wise to fiddle with these 58 */ 59 #define ERROR_MAX 8 /* Max read/write errors per sector */ 60 #define ERROR_RESET 3 /* Reset controller every 4th retry */ 61 #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ 62 63 /* 64 * Ensure that various configuration flags have compatible settings 65 */ 66 #ifdef REALLY_SLOW_IO 67 #undef REALLY_FAST_IO 68 #endif 69 70 /* 71 * Definitions for accessing IDE controller registers 72 */ 73 74 #define HWIF(drive) ((ide_hwif_t *)drive->hwif) 75 #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) 76 77 #define IDE_DATA_OFFSET (0) 78 #define IDE_ERROR_OFFSET (1) 79 #define IDE_NSECTOR_OFFSET (2) 80 #define IDE_SECTOR_OFFSET (3) 81 #define IDE_LCYL_OFFSET (4) 82 #define IDE_HCYL_OFFSET (5) 83 #define IDE_SELECT_OFFSET (6) 84 #define IDE_STATUS_OFFSET (7) 85 #define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET 86 #define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET 87 88 #define IDE_DATA_REG (HWIF(drive)->io_base+IDE_DATA_OFFSET) 89 #define IDE_ERROR_REG (HWIF(drive)->io_base+IDE_ERROR_OFFSET) 90 #define IDE_NSECTOR_REG (HWIF(drive)->io_base+IDE_NSECTOR_OFFSET) 91 #define IDE_SECTOR_REG (HWIF(drive)->io_base+IDE_SECTOR_OFFSET) 92 #define IDE_LCYL_REG (HWIF(drive)->io_base+IDE_LCYL_OFFSET) 93 #define IDE_HCYL_REG (HWIF(drive)->io_base+IDE_HCYL_OFFSET) 94 #define IDE_SELECT_REG (HWIF(drive)->io_base+IDE_SELECT_OFFSET) 95 #define IDE_STATUS_REG (HWIF(drive)->io_base+IDE_STATUS_OFFSET) 96 #define IDE_CONTROL_REG (HWIF(drive)->ctl_port) 97 #define IDE_FEATURE_REG IDE_ERROR_REG 98 #define IDE_COMMAND_REG IDE_STATUS_REG 99 #define IDE_ALTSTATUS_REG IDE_CONTROL_REG 100 101 #ifdef REALLY_FAST_IO 102 #define OUT_BYTE(b,p) outb((b),p) 103 #define IN_BYTE(p) (byte)inb(p) 104 #else 105 #define OUT_BYTE(b,p) outb_p((b),p) 106 #define IN_BYTE(p) (byte)inb_p(p) 107 #endif /* REALLY_FAST_IO */ 108 109 #define GET_ERR() IN_BYTE(IDE_ERROR_REG) 110 #define GET_STAT() IN_BYTE(IDE_STATUS_REG) 111 #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) 112 #define BAD_R_STAT (BUSY_STAT | ERR_STAT) 113 #define BAD_W_STAT (BAD_R_STAT | WRERR_STAT) 114 #define BAD_STAT (BAD_R_STAT | DRQ_STAT) 115 #define DRIVE_READY (READY_STAT | SEEK_STAT) 116 #define DATA_READY (DRIVE_READY | DRQ_STAT) 117 118 /* 119 * Some more useful definitions 120 */ 121 #define IDE_MAJOR_NAME "ide" /* the same for all i/f; see also genhd.c */ 122 #define MAJOR_NAME IDE_MAJOR_NAME 123 #define PARTN_BITS 6 /* number of minor dev bits for partitions */ 124 #define PARTN_MASK ((1<<PARTN_BITS)-1) /* a useful bit mask */ 125 #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ 126 #define MAX_HWIFS 4 /* an arbitrary, but realistic limit */ 127 #define SECTOR_WORDS (512 / 4) /* number of 32bit words per sector */ 128 129 /* 130 * Timeouts for various operations: 131 */ 132 #define WAIT_DRQ (5*HZ/100) /* 50msec - spec allows up to 20ms */ 133 #define WAIT_READY (3*HZ/100) /* 30msec - should be instantaneous */ 134 #define WAIT_PIDENTIFY (1*HZ) /* 1sec - should be less than 3ms (?) */ 135 #define WAIT_WORSTCASE (30*HZ) /* 30sec - worst case when spinning up */ 136 #define WAIT_CMD (10*HZ) /* 10sec - maximum wait for an IRQ to happen */ 137 138 #ifdef CONFIG_BLK_DEV_IDETAPE 139 #include "ide-tape.h" 140 #endif /* CONFIG_BLK_DEV_IDETAPE */ 141 142 #ifdef CONFIG_BLK_DEV_IDECD 143 144 struct atapi_request_sense { 145 unsigned char error_code : 7; 146 unsigned char valid : 1; 147 byte reserved1; 148 unsigned char sense_key : 4; 149 unsigned char reserved2 : 1; 150 unsigned char ili : 1; 151 unsigned char reserved3 : 2; 152 byte info[4]; 153 byte sense_len; 154 byte command_info[4]; 155 byte asc; 156 byte ascq; 157 byte fru; 158 byte sense_key_specific[3]; 159 }; 160 161 struct packet_command { 162 char *buffer; 163 int buflen; 164 int stat; 165 struct atapi_request_sense *sense_data; 166 unsigned char c[12]; 167 }; 168 169 /* Space to hold the disk TOC. */ 170 171 #define MAX_TRACKS 99 172 struct atapi_toc_header { 173 unsigned short toc_length; 174 byte first_track; 175 byte last_track; 176 }; 177 178 struct atapi_toc_entry { 179 byte reserved1; 180 unsigned control : 4; 181 unsigned adr : 4; 182 byte track; 183 byte reserved2; 184 union { 185 unsigned lba; 186 struct { 187 byte reserved3; 188 byte m; 189 byte s; 190 byte f; 191 } msf; 192 } addr; 193 }; 194 195 struct atapi_toc { 196 int last_session_lba; 197 int xa_flag; 198 unsigned capacity; 199 struct atapi_toc_header hdr; 200 struct atapi_toc_entry ent[MAX_TRACKS+1]; /* One extra for the leadout. */ 201 }; 202 203 204 /* This structure is annoyingly close to, but not identical with, 205 the cdrom_subchnl structure from cdrom.h. */ 206 struct atapi_cdrom_subchnl 207 { 208 u_char acdsc_reserved; 209 u_char acdsc_audiostatus; 210 u_short acdsc_length; 211 u_char acdsc_format; 212 213 u_char acdsc_adr: 4; 214 u_char acdsc_ctrl: 4; 215 u_char acdsc_trk; 216 u_char acdsc_ind; 217 union 218 { 219 struct 220 { 221 u_char minute; 222 u_char second; 223 u_char frame; 224 } msf; 225 int lba; 226 } acdsc_absaddr; 227 union 228 { 229 struct 230 { 231 u_char minute; 232 u_char second; 233 u_char frame; 234 } msf; 235 int lba; 236 } acdsc_reladdr; 237 }; 238 239 240 /* Extra per-device info for cdrom drives. */ 241 struct cdrom_info { 242 243 /* Buffer for table of contents. NULL if we haven't allocated 244 a TOC buffer for this device yet. */ 245 246 struct atapi_toc *toc; 247 248 /* Sector buffer. If a read request wants only the first part of a cdrom 249 block, we cache the rest of the block here, in the expectation that that 250 data is going to be wanted soon. SECTOR_BUFFERED is the number of the 251 first buffered sector, and NSECTORS_BUFFERED is the number of sectors 252 in the buffer. Before the buffer is allocated, we should have 253 SECTOR_BUFFER == NULL and NSECTORS_BUFFERED == 0. */ 254 255 unsigned long sector_buffered; 256 unsigned long nsectors_buffered; 257 char *sector_buffer; 258 259 /* The result of the last successful request sense command 260 on this device. */ 261 struct atapi_request_sense sense_data; 262 }; 263 264 #endif /* CONFIG_BLK_DEV_IDECD */ 265 266 /* 267 * Now for the data we need to maintain per-drive: ide_drive_t 268 */ 269 270 typedef enum {ide_disk, ide_cdrom, ide_tape} ide_media_t; 271 272 typedef union { 273 unsigned all : 8; /* all of the bits together */ 274 struct { 275 unsigned set_geometry : 1; /* respecify drive geometry */ 276 unsigned recalibrate : 1; /* seek to cyl 0 */ 277 unsigned set_multmode : 1; /* set multmode count */ 278 unsigned set_pio : 1; /* set pio mode */ 279 unsigned reserved : 4; /* unused */ 280 } b; 281 } special_t; 282 283 typedef union { 284 unsigned all : 8; /* all of the bits together */ 285 struct { 286 unsigned head : 4; /* always zeros here */ 287 unsigned unit : 1; /* drive select number, 0 or 1 */ 288 unsigned bit5 : 1; /* always 1 */ 289 unsigned lba : 1; /* using LBA instead of CHS */ 290 unsigned bit7 : 1; /* always 1 */ 291 } b; 292 } select_t; 293 294 typedef struct ide_drive_s { 295 special_t special; /* special action flags */ 296 unsigned present : 1; /* drive is physically present */ 297 unsigned noprobe : 1; /* from: hdx=noprobe */ 298 unsigned keep_settings : 1; /* restore settings after drive reset */ 299 unsigned busy : 1; /* currently doing revalidate_disk() */ 300 unsigned removeable : 1; /* 1 if need to do check_media_change */ 301 unsigned using_dma : 1; /* disk is using dma for read/write */ 302 unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ 303 unsigned unmask : 1; /* flag: okay to unmask other irqs */ 304 unsigned autotune : 2; /* 1=autotune, 2=noautotune, 0=default */ 305 #if FAKE_FDISK_FOR_EZDRIVE 306 unsigned remap_0_to_1 : 1; /* flag: partitioned with ezdrive */ 307 #endif /* FAKE_FDISK_FOR_EZDRIVE */ 308 ide_media_t media; /* disk, cdrom, tape */ 309 select_t select; /* basic drive/head select reg value */ 310 byte ctl; /* "normal" value for IDE_CONTROL_REG */ 311 byte ready_stat; /* min status value for drive ready */ 312 byte mult_count; /* current multiple sector setting */ 313 byte mult_req; /* requested multiple sector setting */ 314 byte pio_req; /* requested multiple sector setting */ 315 byte io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ 316 byte bad_wstat; /* used for ignoring WRERR_STAT */ 317 byte sect0; /* offset of first sector for DM6:DDO */ 318 byte usage; /* current "open()" count for drive */ 319 byte head; /* "real" number of heads */ 320 byte sect; /* "real" sectors per track */ 321 byte bios_head; /* BIOS/fdisk/LILO number of heads */ 322 byte bios_sect; /* BIOS/fdisk/LILO sectors per track */ 323 unsigned short bios_cyl; /* BIOS/fdisk/LILO number of cyls */ 324 unsigned short cyl; /* "real" number of cyls */ 325 void *hwif; /* actually (ide_hwif_t *) */ 326 struct wait_queue *wqueue; /* used to wait for drive in open() */ 327 struct hd_driveid *id; /* drive model identification info */ 328 struct hd_struct *part; /* drive partition table */ 329 char name[4]; /* drive name, such as "hda" */ 330 #ifdef CONFIG_BLK_DEV_IDECD 331 struct cdrom_info cdrom_info; /* for ide-cd.c */ 332 #endif /* CONFIG_BLK_DEV_IDECD */ 333 #ifdef CONFIG_BLK_DEV_IDETAPE 334 idetape_tape_t tape; /* for ide-tape.c */ 335 #endif /* CONFIG_BLK_DEV_IDETAPE */ 336 337 } ide_drive_t; 338 339 /* 340 * An ide_dmaproc_t() initiates/aborts DMA read/write operations on a drive. 341 * 342 * The caller is assumed to have selected the drive and programmed the drive's 343 * sector address using CHS or LBA. All that remains is to prepare for DMA 344 * and then issue the actual read/write DMA/PIO command to the drive. 345 * 346 * Returns 0 if all went well. 347 * Returns 1 if DMA read/write could not be started, in which case the caller 348 * should either try again later, or revert to PIO for the current request. 349 */ 350 typedef enum {ide_dma_read = 0, ide_dma_write = 1, ide_dma_abort = 2, ide_dma_check = 3} ide_dma_action_t; 351 typedef int (ide_dmaproc_t)(ide_dma_action_t, ide_drive_t *); 352 353 354 /* 355 * An ide_tuneproc_t() is used to set the speed of an IDE interface 356 * to a particular PIO mode. The "byte" parameter is used 357 * to select the PIO mode by number (0,1,2,3,4,5), and a value of 255 358 * indicates that the interface driver should "auto-tune" the PIO mode 359 * according to the drive capabilities in drive->id; 360 * 361 * Not all interface types support tuning, and not all of those 362 * support all possible PIO settings. They may silently ignore 363 * or round values as they see fit. 364 */ 365 typedef void (ide_tuneproc_t)(ide_drive_t *, byte); 366 367 /* 368 * This is used to provide HT6560B interface support. 369 * It will probably also be used by the DC4030VL driver. 370 */ 371 typedef void (ide_selectproc_t) (ide_drive_t *); 372 373 /* 374 * hwif_chipset_t is used to keep track of the specific hardware 375 * chipset used by each IDE interface, if known. 376 */ 377 typedef enum { ide_unknown, ide_generic, ide_triton, 378 ide_cmd640, ide_dtc2278, ide_ali14xx, 379 ide_qd6580, ide_umc8672, ide_ht6560b } 380 hwif_chipset_t; 381 382 typedef struct hwif_s { 383 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 384 void *hwgroup; /* actually (ide_hwgroup_t *) */ 385 unsigned short io_base; /* base io port addr */ 386 unsigned short ctl_port; /* usually io_base+0x206 */ 387 ide_drive_t drives[MAX_DRIVES]; /* drive info */ 388 struct gendisk *gd; /* gendisk structure */ 389 ide_tuneproc_t *tuneproc; /* routine to tune PIO mode for drives */ 390 #ifdef CONFIG_BLK_DEV_HT6560B 391 ide_selectproc_t *selectproc; /* tweaks hardware to select drive */ 392 #endif /* CONFIG_BLK_DEV_HT6560B */ 393 ide_dmaproc_t *dmaproc; /* dma read/write/abort routine */ 394 unsigned long *dmatable; /* dma physical region descriptor table */ 395 unsigned short dma_base; /* base addr for dma ports (triton) */ 396 byte irq; /* our irq number */ 397 byte major; /* our major number */ 398 char name[5]; /* name of interface, eg. "ide0" */ 399 byte index; /* 0 for ide0; 1 for ide1; ... */ 400 hwif_chipset_t chipset; /* sub-module for tuning.. */ 401 unsigned noprobe : 1; /* don't probe for this interface */ 402 unsigned present : 1; /* this interface exists */ 403 unsigned serialized : 1; /* valid only for ide_hwifs[0] */ 404 #if (DISK_RECOVERY_TIME > 0) 405 unsigned long last_time; /* time when previous rq was done */ 406 #endif 407 #ifdef CONFIG_BLK_DEV_IDECD 408 struct request request_sense_request; /* from ide-cd.c */ 409 struct packet_command request_sense_pc; /* from ide-cd.c */ 410 #endif /* CONFIG_BLK_DEV_IDECD */ 411 #ifdef CONFIG_BLK_DEV_IDETAPE 412 ide_drive_t *tape_drive; /* Pointer to the tape on this interface */ 413 #endif /* CONFIG_BLK_DEV_IDETAPE */ 414 } ide_hwif_t; 415 416 /* 417 * internal ide interrupt handler type 418 */ 419 typedef void (ide_handler_t)(ide_drive_t *); 420 421 typedef struct hwgroup_s { 422 ide_handler_t *handler;/* irq handler, if active */ 423 ide_drive_t *drive; /* current drive */ 424 ide_hwif_t *hwif; /* ptr to current hwif in linked-list */ 425 struct request *rq; /* current request */ 426 struct timer_list timer; /* failsafe timer */ 427 struct request wrq; /* local copy of current write rq */ 428 unsigned long poll_timeout; /* timeout value during long polls */ 429 } ide_hwgroup_t; 430 431 /* 432 * ide_hwifs[] is the master data structure used to keep track 433 * of just about everything in ide.c. Whenever possible, routines 434 * should be using pointers to a drive (ide_drive_t *) or 435 * pointers to a hwif (ide_hwif_t *), rather than indexing this 436 * structure directly (the allocation/layout may change!). 437 */ 438 #ifdef _IDE_C 439 ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ 440 #else 441 extern ide_hwif_t ide_hwifs[]; 442 #endif 443 444 /* 445 * One final include file, which references some of the data/defns from above 446 */ 447 #define IDE_DRIVER /* "parameter" for blk.h */ 448 #include <linux/blk.h> 449 450 #if (DISK_RECOVERY_TIME > 0) 451 void ide_set_recovery_timer (ide_hwif_t *); 452 #define SET_RECOVERY_TIMER(drive) ide_set_recovery_timer (drive) 453 #else 454 #define SET_RECOVERY_TIMER(drive) 455 #endif 456 457 /* 458 * This is used for (nearly) all data transfers from the IDE interface 459 */ 460 void ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount); 461 462 /* 463 * This is used for (nearly) all data transfers to the IDE interface 464 */ 465 void ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount); 466 467 /* 468 * This is used on exit from the driver, to designate the next irq handler 469 * and also to start the safety timer. 470 */ 471 void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout); 472 473 /* 474 * Error reporting, in human readable form (luxurious, but a memory hog). 475 */ 476 byte ide_dump_status (ide_drive_t *drive, const char *msg, byte stat); 477 478 /* 479 * ide_error() takes action based on the error returned by the controller. 480 * The calling function must return afterwards, to restart the request. 481 */ 482 void ide_error (ide_drive_t *drive, const char *msg, byte stat); 483 484 /* 485 * ide_fixstring() cleans up and (optionally) byte-swaps a text string, 486 * removing leading/trailing blanks and compressing internal blanks. 487 * It is primarily used to tidy up the model name/number fields as 488 * returned by the WIN_[P]IDENTIFY commands. 489 */ 490 void ide_fixstring (byte *s, const int bytecount, const int byteswap); 491 492 /* 493 * This routine busy-waits for the drive status to be not "busy". 494 * It then checks the status for all of the "good" bits and none 495 * of the "bad" bits, and if all is okay it returns 0. All other 496 * cases return 1 after invoking ide_error() -- caller should return. 497 * 498 */ 499 int ide_wait_stat (ide_drive_t *drive, byte good, byte bad, unsigned long timeout); 500 501 /* 502 * This routine is called from the partition-table code in genhd.c 503 * to "convert" a drive to a logical geometry with fewer than 1024 cyls. 504 * 505 * The second parameter, "xparm", determines exactly how the translation 506 * will be handled: 507 * 0 = convert to CHS with fewer than 1024 cyls 508 * using the same method as Ontrack DiskManager. 509 * 1 = same as "0", plus offset everything by 63 sectors. 510 * -1 = similar to "0", plus redirect sector 0 to sector 1. 511 * >1 = convert to a CHS geometry with "xparm" heads. 512 * 513 * Returns 0 if the translation was not possible, if the device was not 514 * an IDE disk drive, or if a geometry was "forced" on the commandline. 515 * Returns 1 if the geometry translation was successful. 516 */ 517 int ide_xlate_1024 (kdev_t, int, const char *); 518 519 /* 520 * Start a reset operation for an IDE interface. 521 * The caller should return immediately after invoking this. 522 */ 523 void ide_do_reset (ide_drive_t *); 524 525 /* 526 * This function is intended to be used prior to invoking ide_do_drive_cmd(). 527 */ 528 void ide_init_drive_cmd (struct request *rq); 529 530 /* 531 * "action" parameter type for ide_do_drive_cmd() below. 532 */ 533 typedef enum 534 {ide_wait, /* insert rq at end of list, and wait for it */ 535 ide_next, /* insert rq immediately after current request */ 536 ide_preempt, /* insert rq in front of current request */ 537 ide_end} /* insert rq at end of list, but don't wait for it */ 538 ide_action_t; 539 540 /* 541 * This function issues a special IDE device request 542 * onto the request queue. 543 * 544 * If action is ide_wait, then then rq is queued at the end of 545 * the request queue, and the function sleeps until it has been 546 * processed. This is for use when invoked from an ioctl handler. 547 * 548 * If action is ide_preempt, then the rq is queued at the head of 549 * the request queue, displacing the currently-being-processed 550 * request and this function returns immediately without waiting 551 * for the new rq to be completed. This is VERY DANGEROUS, and is 552 * intended for careful use by the ATAPI tape/cdrom driver code. 553 * 554 * If action is ide_next, then the rq is queued immediately after 555 * the currently-being-processed-request (if any), and the function 556 * returns without waiting for the new rq to be completed. As above, 557 * This is VERY DANGEROUS, and is intended for careful use by the 558 * ATAPI tape/cdrom driver code. 559 * 560 * If action is ide_end, then the rq is queued at the end of the 561 * request queue, and the function returns immediately without waiting 562 * for the new rq to be completed. This is again intended for careful 563 * use by the ATAPI tape/cdrom driver code. (Currently used by ide-tape.c, 564 * when operating in the pipelined operation mode). 565 */ 566 int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t action); 567 568 /* 569 * Clean up after success/failure of an explicit drive cmd. 570 * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_CMD). 571 */ 572 void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err); 573 574 #ifdef CONFIG_BLK_DEV_IDECD 575 /* 576 * These are routines in ide-cd.c invoked from ide.c 577 */ 578 void ide_do_rw_cdrom (ide_drive_t *, unsigned long); 579 int ide_cdrom_ioctl (ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long); 580 int ide_cdrom_check_media_change (ide_drive_t *); 581 int ide_cdrom_open (struct inode *, struct file *, ide_drive_t *); 582 void ide_cdrom_release (struct inode *, struct file *, ide_drive_t *); 583 void ide_cdrom_setup (ide_drive_t *); 584 #endif /* CONFIG_BLK_DEV_IDECD */ 585 586 #ifdef CONFIG_BLK_DEV_IDETAPE 587 588 /* 589 * Functions in ide-tape.c which are invoked from ide.c: 590 */ 591 592 /* 593 * idetape_identify_device is called during device probing stage to 594 * probe for an ide atapi tape drive and to initialize global variables 595 * in ide-tape.c which provide the link between the character device 596 * and the correspoding block device. 597 * 598 * Returns 1 if an ide tape was detected and is supported. 599 * Returns 0 otherwise. 600 */ 601 602 int idetape_identify_device (ide_drive_t *drive,struct hd_driveid *id); 603 604 /* 605 * idetape_setup is called a bit later than idetape_identify_device, 606 * during the search for disk partitions, to initialize various tape 607 * state variables in ide_drive_t *drive. 608 */ 609 610 void idetape_setup (ide_drive_t *drive); 611 612 /* 613 * idetape_do_request is our request function. It is called by ide.c 614 * to process a new request. 615 */ 616 617 void idetape_do_request (ide_drive_t *drive, struct request *rq, unsigned long block); 618 619 /* 620 * Block device interface functions. 621 */ 622 623 int idetape_blkdev_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, 624 unsigned int cmd, unsigned long arg); 625 int idetape_blkdev_open (struct inode *inode, struct file *filp, ide_drive_t *drive); 626 void idetape_blkdev_release (struct inode *inode, struct file *filp, ide_drive_t *drive); 627 628 /* 629 * idetape_register_chrdev initializes the character device interface to 630 * the ide tape drive. 631 */ 632 633 void idetape_register_chrdev (void); 634 635 #endif /* CONFIG_BLK_DEV_IDETAPE */ 636 637 #ifdef CONFIG_BLK_DEV_TRITON 638 void ide_init_triton (byte, byte); 639 #endif /* CONFIG_BLK_DEV_TRITON */