root/drivers/block/ide.h

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

INCLUDED FROM


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

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