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

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