OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [armnommu/] [drivers/] [block/] [ide.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1622 jcastillo
/*
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 0        /* 0 to reduce kernel size */
30
#endif
31
#ifndef SUPPORT_VLB_SYNC                /* 1 to support weird 32-bit chips */
32
#define SUPPORT_VLB_SYNC        0        /* 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.io_base+(IDE_DATA_OFFSET<<HWIF(drive)->io.io_shift))
107
#define IDE_ERROR_REG           (HWIF(drive)->io.io_base+(IDE_ERROR_OFFSET<<HWIF(drive)->io.io_shift))
108
#define IDE_NSECTOR_REG         (HWIF(drive)->io.io_base+(IDE_NSECTOR_OFFSET<<HWIF(drive)->io.io_shift))
109
#define IDE_SECTOR_REG          (HWIF(drive)->io.io_base+(IDE_SECTOR_OFFSET<<HWIF(drive)->io.io_shift))
110
#define IDE_LCYL_REG            (HWIF(drive)->io.io_base+(IDE_LCYL_OFFSET<<HWIF(drive)->io.io_shift))
111
#define IDE_HCYL_REG            (HWIF(drive)->io.io_base+(IDE_HCYL_OFFSET<<HWIF(drive)->io.io_shift))
112
#define IDE_SELECT_REG          (HWIF(drive)->io.io_base+(IDE_SELECT_OFFSET<<HWIF(drive)->io.io_shift))
113
#define IDE_STATUS_REG          (HWIF(drive)->io.io_base+(IDE_STATUS_OFFSET<<HWIF(drive)->io.io_shift))
114
#define IDE_CONTROL_REG         (HWIF(drive)->io.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 << hwif->io.io_shift)); \
172
}
173
#else
174
#define SELECT_DRIVE(hwif,drive)  OUT_BYTE((drive)->select.all, hwif->io.io_base + (IDE_SELECT_OFFSET << hwif->io.io_shift));
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
typedef struct hwreg_s {
388
        unsigned long   io_base;
389
        unsigned long   io_shift;       /* 0 = normal, 4 = ICS ide */
390
        unsigned long   ctl_port;
391
        } hwreg_t;
392
/*
393
 * An ide_dmaproc_t() initiates/aborts DMA read/write operations on a drive.
394
 *
395
 * The caller is assumed to have selected the drive and programmed the drive's
396
 * sector address using CHS or LBA.  All that remains is to prepare for DMA
397
 * and then issue the actual read/write DMA/PIO command to the drive.
398
 *
399
 * Returns 0 if all went well.
400
 * Returns 1 if DMA read/write could not be started, in which case the caller
401
 * should either try again later, or revert to PIO for the current request.
402
 */
403
typedef enum {  ide_dma_read = 0,        ide_dma_write = 1,
404
                ide_dma_abort = 2,      ide_dma_check = 3,
405
                ide_dma_status_bad = 4, ide_dma_transferred = 5,
406
                ide_dma_begin = 6 }
407
        ide_dma_action_t;
408
 
409
typedef int (ide_dmaproc_t)(ide_dma_action_t, ide_drive_t *);
410
 
411
 
412
/*
413
 * An ide_tuneproc_t() is used to set the speed of an IDE interface
414
 * to a particular PIO mode.  The "byte" parameter is used
415
 * to select the PIO mode by number (0,1,2,3,4,5), and a value of 255
416
 * indicates that the interface driver should "auto-tune" the PIO mode
417
 * according to the drive capabilities in drive->id;
418
 *
419
 * Not all interface types support tuning, and not all of those
420
 * support all possible PIO settings.  They may silently ignore
421
 * or round values as they see fit.
422
 */
423
typedef void (ide_tuneproc_t)(ide_drive_t *, byte);
424
 
425
/*
426
 * This is used to provide HT6560B & PROMISE interface support.
427
 */
428
typedef void (ide_selectproc_t) (ide_drive_t *);
429
 
430
/*
431
 * hwif_chipset_t is used to keep track of the specific hardware
432
 * chipset used by each IDE interface, if known.
433
 */
434
typedef enum {  ide_unknown,    ide_generic,    ide_triton,
435
                ide_cmd640,     ide_dtc2278,    ide_ali14xx,
436
                ide_qd6580,     ide_umc8672,    ide_ht6560b,
437
                ide_promise,    ide_promise_udma, ide_dmaics }
438
        hwif_chipset_t;
439
 
440
typedef struct hwif_s {
441
        struct hwif_s   *next;          /* for linked-list in ide_hwgroup_t */
442
        void            *hwgroup;       /* actually (ide_hwgroup_t *) */
443
        hwreg_t         io;
444
        ide_drive_t     drives[MAX_DRIVES];     /* drive info */
445
        struct gendisk  *gd;            /* gendisk structure */
446
        ide_tuneproc_t  *tuneproc;      /* routine to tune PIO mode for drives */
447
#if defined(CONFIG_BLK_DEV_HT6560B) || defined(CONFIG_BLK_DEV_PROMISE)
448
        ide_selectproc_t *selectproc;   /* tweaks hardware to select drive */
449
#endif
450
        ide_dmaproc_t   *dmaproc;       /* dma read/write/abort routine */
451
        unsigned long   *dmatable;      /* dma physical region descriptor table */
452
        unsigned short  dma_base;       /* base addr for dma ports (triton) */
453
        byte            irq;            /* our irq number */
454
        byte            major;          /* our major number */
455
        char            name[5];        /* name of interface, eg. "ide0" */
456
        byte            index;          /* 0 for ide0; 1 for ide1; ... */
457
        hwif_chipset_t  chipset;        /* sub-module for tuning.. */
458
        unsigned        noprobe    : 1; /* don't probe for this interface */
459
        unsigned        present    : 1; /* this interface exists */
460
        unsigned        serialized : 1; /* serialized operation with mate hwif */
461
        unsigned        sharing_irq: 1; /* 1 = sharing irq with another hwif */
462
#ifdef CONFIG_BLK_DEV_PROMISE
463
        unsigned        is_promise2: 1; /* 2nd i/f on promise DC4030 */
464
#endif /* CONFIG_BLK_DEV_PROMISE */
465
#if (DISK_RECOVERY_TIME > 0)
466
        unsigned long   last_time;      /* time when previous rq was done */
467
#endif
468
#ifdef CONFIG_BLK_DEV_IDECD
469
        struct request request_sense_request;   /* from ide-cd.c */
470
        struct packet_command request_sense_pc; /* from ide-cd.c */
471
#endif /* CONFIG_BLK_DEV_IDECD */
472
#ifdef CONFIG_BLK_DEV_IDETAPE
473
        ide_drive_t     *tape_drive;    /* Pointer to the tape on this interface */
474
#endif /* CONFIG_BLK_DEV_IDETAPE */
475
        } ide_hwif_t;
476
 
477
/*
478
 *  internal ide interrupt handler type
479
 */
480
typedef void (ide_handler_t)(ide_drive_t *);
481
 
482
typedef struct hwgroup_s {
483
        ide_handler_t           *handler;/* irq handler, if active */
484
        ide_drive_t             *drive; /* current drive */
485
        ide_hwif_t              *hwif;  /* ptr to current hwif in linked-list */
486
        ide_hwif_t              *next_hwif; /* next selected hwif (for tape) */
487
        struct request          *rq;    /* current request */
488
        struct timer_list       timer;  /* failsafe timer */
489
        struct request          wrq;    /* local copy of current write rq */
490
        unsigned long           poll_timeout;   /* timeout value during long polls */
491
        int                     active; /* set when servicing requests */
492
        } ide_hwgroup_t;
493
 
494
/*
495
 * ide_hwifs[] is the master data structure used to keep track
496
 * of just about everything in ide.c.  Whenever possible, routines
497
 * should be using pointers to a drive (ide_drive_t *) or
498
 * pointers to a hwif (ide_hwif_t *), rather than indexing this
499
 * structure directly (the allocation/layout may change!).
500
 *
501
 */
502
#ifndef _IDE_C
503
extern  ide_hwif_t      ide_hwifs[];            /* master data repository */
504
#endif
505
 
506
/*
507
 * One final include file, which references some of the data/defns from above
508
 */
509
#define IDE_DRIVER      /* "parameter" for blk.h */
510
#include <linux/blk.h>
511
 
512
#if (DISK_RECOVERY_TIME > 0)
513
void ide_set_recovery_timer (ide_hwif_t *);
514
#define SET_RECOVERY_TIMER(drive) ide_set_recovery_timer (drive)
515
#else
516
#define SET_RECOVERY_TIMER(drive)
517
#endif
518
 
519
/*
520
 * This is used for (nearly) all data transfers from the IDE interface
521
 */
522
void ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
523
 
524
/*
525
 * This is used for (nearly) all data transfers to the IDE interface
526
 */
527
void ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
528
 
529
/*
530
 * This is used for (nearly) all ATAPI data transfers from/to the IDE interface
531
 */
532
void atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);
533
void atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);
534
 
535
/*
536
 * This is used on exit from the driver, to designate the next irq handler
537
 * and also to start the safety timer.
538
 */
539
void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout);
540
 
541
/*
542
 * Error reporting, in human readable form (luxurious, but a memory hog).
543
 */
544
byte ide_dump_status (ide_drive_t *drive, const char *msg, byte stat);
545
 
546
/*
547
 * ide_error() takes action based on the error returned by the controller.
548
 * The calling function must return afterwards, to restart the request.
549
 */
550
void ide_error (ide_drive_t *drive, const char *msg, byte stat);
551
 
552
/*
553
 * ide_fixstring() cleans up and (optionally) byte-swaps a text string,
554
 * removing leading/trailing blanks and compressing internal blanks.
555
 * It is primarily used to tidy up the model name/number fields as
556
 * returned by the WIN_[P]IDENTIFY commands.
557
 */
558
void ide_fixstring (byte *s, const int bytecount, const int byteswap);
559
 
560
/*
561
 * This routine busy-waits for the drive status to be not "busy".
562
 * It then checks the status for all of the "good" bits and none
563
 * of the "bad" bits, and if all is okay it returns 0.  All other
564
 * cases return 1 after invoking ide_error() -- caller should return.
565
 *
566
 */
567
int ide_wait_stat (ide_drive_t *drive, byte good, byte bad, unsigned long timeout);
568
 
569
/*
570
 * This routine is called from the partition-table code in genhd.c
571
 * to "convert" a drive to a logical geometry with fewer than 1024 cyls.
572
 *
573
 * The second parameter, "xparm", determines exactly how the translation
574
 * will be handled:
575
 *               0 = convert to CHS with fewer than 1024 cyls
576
 *                      using the same method as Ontrack DiskManager.
577
 *               1 = same as "0", plus offset everything by 63 sectors.
578
 *              -1 = similar to "0", plus redirect sector 0 to sector 1.
579
 *              >1 = convert to a CHS geometry with "xparm" heads.
580
 *
581
 * Returns 0 if the translation was not possible, if the device was not
582
 * an IDE disk drive, or if a geometry was "forced" on the commandline.
583
 * Returns 1 if the geometry translation was successful.
584
 */
585
int ide_xlate_1024 (kdev_t, int, const char *);
586
 
587
/*
588
 * Start a reset operation for an IDE interface.
589
 * The caller should return immediately after invoking this.
590
 */
591
void ide_do_reset (ide_drive_t *);
592
 
593
/*
594
 * This function is intended to be used prior to invoking ide_do_drive_cmd().
595
 */
596
void ide_init_drive_cmd (struct request *rq);
597
 
598
/*
599
 * "action" parameter type for ide_do_drive_cmd() below.
600
 */
601
typedef enum
602
        {ide_wait,      /* insert rq at end of list, and wait for it */
603
         ide_next,      /* insert rq immediately after current request */
604
         ide_preempt,   /* insert rq in front of current request */
605
         ide_end}       /* insert rq at end of list, but don't wait for it */
606
 ide_action_t;
607
 
608
/*
609
 * This function issues a special IDE device request
610
 * onto the request queue.
611
 *
612
 * If action is ide_wait, then then rq is queued at the end of
613
 * the request queue, and the function sleeps until it has been
614
 * processed.  This is for use when invoked from an ioctl handler.
615
 *
616
 * If action is ide_preempt, then the rq is queued at the head of
617
 * the request queue, displacing the currently-being-processed
618
 * request and this function returns immediately without waiting
619
 * for the new rq to be completed.  This is VERY DANGEROUS, and is
620
 * intended for careful use by the ATAPI tape/cdrom driver code.
621
 *
622
 * If action is ide_next, then the rq is queued immediately after
623
 * the currently-being-processed-request (if any), and the function
624
 * returns without waiting for the new rq to be completed.  As above,
625
 * This is VERY DANGEROUS, and is intended for careful use by the
626
 * ATAPI tape/cdrom driver code.
627
 *
628
 * If action is ide_end, then the rq is queued at the end of the
629
 * request queue, and the function returns immediately without waiting
630
 * for the new rq to be completed. This is again intended for careful
631
 * use by the ATAPI tape/cdrom driver code. (Currently used by ide-tape.c,
632
 * when operating in the pipelined operation mode).
633
 */
634
int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t action);
635
 
636
/*
637
 * Clean up after success/failure of an explicit drive cmd.
638
 * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_CMD).
639
 */
640
void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err);
641
 
642
/*
643
 * ide_system_bus_speed() returns what we think is the system VESA/PCI
644
 * bus speed (in Mhz).  This is used for calculating interface PIO timings.
645
 * The default is 40 for known PCI systems, 50 otherwise.
646
 * The "idebus=xx" parameter can be used to override this value.
647
 */
648
int ide_system_bus_speed (void);
649
 
650
/*
651
 * ide_multwrite() transfers a block of up to mcount sectors of data
652
 * to a drive as part of a disk multwrite operation.
653
 */
654
void ide_multwrite (ide_drive_t *drive, unsigned int mcount);
655
 
656
#ifdef CONFIG_BLK_DEV_IDECD
657
/*
658
 * These are routines in ide-cd.c invoked from ide.c
659
 */
660
void ide_do_rw_cdrom (ide_drive_t *, unsigned long);
661
int ide_cdrom_ioctl (ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
662
int ide_cdrom_check_media_change (ide_drive_t *);
663
int ide_cdrom_open (struct inode *, struct file *, ide_drive_t *);
664
void ide_cdrom_release (struct inode *, struct file *, ide_drive_t *);
665
void ide_cdrom_setup (ide_drive_t *);
666
#endif /* CONFIG_BLK_DEV_IDECD */
667
 
668
#ifdef CONFIG_BLK_DEV_IDETAPE
669
 
670
/*
671
 *      Functions in ide-tape.c which are invoked from ide.c:
672
 */
673
 
674
/*
675
 *      idetape_identify_device is called during device probing stage to
676
 *      probe for an ide atapi tape drive and to initialize global variables
677
 *      in ide-tape.c which provide the link between the character device
678
 *      and the corresponding block device.
679
 *
680
 *      Returns 1 if an ide tape was detected and is supported.
681
 *      Returns 0 otherwise.
682
 */
683
 
684
int idetape_identify_device (ide_drive_t *drive,struct hd_driveid *id);
685
 
686
/*
687
 *      idetape_setup is called a bit later than idetape_identify_device,
688
 *      during the search for disk partitions, to initialize various tape
689
 *      state variables in ide_drive_t *drive.
690
 */
691
 
692
void idetape_setup (ide_drive_t *drive);
693
 
694
/*
695
 *      idetape_do_request is our request function. It is called by ide.c
696
 *      to process a new request.
697
 */
698
 
699
void idetape_do_request (ide_drive_t *drive, struct request *rq, unsigned long block);
700
 
701
/*
702
 *      idetape_end_request is used to finish servicing a request, and to
703
 *      insert a pending pipeline request into the main device queue.
704
 */
705
 
706
void idetape_end_request (byte uptodate, ide_hwgroup_t *hwgroup);
707
 
708
/*
709
 *      Block device interface functions.
710
 */
711
 
712
int idetape_blkdev_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file,
713
                        unsigned int cmd, unsigned long arg);
714
int idetape_blkdev_open (struct inode *inode, struct file *filp, ide_drive_t *drive);
715
void idetape_blkdev_release (struct inode *inode, struct file *filp, ide_drive_t *drive);
716
 
717
/*
718
 *      idetape_register_chrdev initializes the character device interface to
719
 *      the ide tape drive.
720
 */
721
 
722
void idetape_register_chrdev (void);
723
 
724
#endif /* CONFIG_BLK_DEV_IDETAPE */
725
 
726
#ifdef CONFIG_BLK_DEV_IDEFLOPPY
727
int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id);
728
void idefloppy_setup (ide_drive_t *drive);
729
void idefloppy_do_request (ide_drive_t *drive, struct request *rq, unsigned long block);
730
void idefloppy_end_request (byte uptodate, ide_hwgroup_t *hwgroup);
731
int idefloppy_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file,
732
                        unsigned int cmd, unsigned long arg);
733
int idefloppy_open (struct inode *inode, struct file *filp, ide_drive_t *drive);
734
void idefloppy_release (struct inode *inode, struct file *filp, ide_drive_t *drive);
735
int idefloppy_media_change (ide_drive_t *drive);
736
unsigned long idefloppy_capacity (ide_drive_t *drive);
737
#endif /* CONFIG_BLK_DEV_IDEFLOPPY */
738
 
739
#ifdef CONFIG_BLK_DEV_IDESCSI
740
void idescsi_setup (ide_drive_t *drive);
741
void idescsi_do_request (ide_drive_t *drive, struct request *rq, unsigned long block);
742
void idescsi_end_request (byte uptodate, ide_hwgroup_t *hwgroup);
743
int idescsi_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
744
int idescsi_open (struct inode *inode, struct file *filp, ide_drive_t *drive);
745
void idescsi_ide_release (struct inode *inode, struct file *filp, ide_drive_t *drive);
746
#endif /* CONFIG_BLK_DEV_IDESCSI */
747
 
748
#ifdef CONFIG_BLK_DEV_TRITON
749
void ide_init_triton (byte, byte);
750
void ide_init_promise (byte bus, byte fn, ide_hwif_t *hwif0, ide_hwif_t *hwif1, unsigned short dma);
751
#endif /* CONFIG_BLK_DEV_TRITON */
752
 
753
#ifdef CONFIG_BLK_DEV_IDE_CARDS
754
extern int ide_register_port (int io_base, int ctrl_base, int stepping, int irq);
755
#ifdef CONFIG_BLK_DEV_IDE_ICSIDE
756
extern int icside_init (void);
757
#endif
758
#ifdef CONFIG_BLK_DEV_IDE_RAPIDE
759
extern int rapide_init (void);
760
#endif
761
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.