Annotation of Gnu-Mach/linux/src/drivers/block/ide.h, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.