Home | History | Annotate | Line # | Download | only in ata
wdvar.h revision 1.14
      1  1.14   thorpej /*	$NetBSD: wdvar.h,v 1.14 2003/03/21 22:40:57 thorpej Exp $	*/
      2   1.2    bouyer 
      3   1.2    bouyer /*
      4  1.10    bouyer  * Copyright (c) 1998, 2001 Manuel Bouyer.
      5   1.2    bouyer  *
      6   1.2    bouyer  * Redistribution and use in source and binary forms, with or without
      7   1.2    bouyer  * modification, are permitted provided that the following conditions
      8   1.2    bouyer  * are met:
      9   1.2    bouyer  * 1. Redistributions of source code must retain the above copyright
     10   1.2    bouyer  *    notice, this list of conditions and the following disclaimer.
     11   1.2    bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.2    bouyer  *    notice, this list of conditions and the following disclaimer in the
     13   1.2    bouyer  *    documentation and/or other materials provided with the distribution.
     14   1.2    bouyer  * 3. All advertising materials mentioning features or use of this software
     15   1.2    bouyer  *    must display the following acknowledgement:
     16  1.12    bouyer  *	This product includes software developed by Manuel Bouyer.
     17   1.2    bouyer  * 4. Neither the name of the University nor the names of its contributors
     18   1.2    bouyer  *    may be used to endorse or promote products derived from this software
     19   1.2    bouyer  *    without specific prior written permission.
     20   1.2    bouyer  *
     21   1.6    bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.6    bouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.6    bouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24   1.6    bouyer  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.6    bouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.6    bouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.6    bouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.6    bouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.6    bouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.6    bouyer  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.2    bouyer  *
     32   1.2    bouyer  */
     33   1.2    bouyer 
     34   1.2    bouyer /* Params needed by the controller to perform an ATA bio */
     35   1.2    bouyer struct ata_bio {
     36  1.11  christos 	volatile u_int16_t flags;/* cmd flags */
     37  1.11  christos #define	ATA_NOSLEEP	0x0001	/* Can't sleep */
     38  1.11  christos #define	ATA_POLL	0x0002	/* poll for completion */
     39  1.11  christos #define	ATA_ITSDONE	0x0004	/* the transfer is as done as it gets */
     40  1.11  christos #define	ATA_SINGLE	0x0008	/* transfer must be done in singlesector mode */
     41  1.11  christos #define	ATA_LBA		0x0010	/* transfer uses LBA adressing */
     42  1.11  christos #define	ATA_READ	0x0020	/* transfer is a read (otherwise a write) */
     43  1.11  christos #define	ATA_CORR	0x0040	/* transfer had a corrected error */
     44  1.11  christos #define	ATA_LBA48	0x0080	/* transfer uses 48-bit LBA adressing */
     45  1.11  christos 	int		multi;	/* # of blocks to transfer in multi-mode */
     46  1.11  christos 	struct disklabel *lp;	/* pointer to drive's label info */
     47  1.11  christos 	daddr_t		blkno;	/* block addr */
     48  1.11  christos 	daddr_t		blkdone;/* number of blks transferred */
     49  1.11  christos 	daddr_t		nblks;	/* number of block currently transferring */
     50  1.11  christos 	int		nbytes;	/* number of bytes currently transferring */
     51  1.11  christos 	long		bcount;	/* total number of bytes */
     52  1.11  christos 	char		*databuf;/* data buffer adress */
     53  1.11  christos 	volatile int	error;
     54  1.11  christos #define	NOERROR 	0	/* There was no error (r_error invalid) */
     55  1.11  christos #define	ERROR		1	/* check r_error */
     56  1.11  christos #define	ERR_DF		2	/* Drive fault */
     57  1.11  christos #define	ERR_DMA		3	/* DMA error */
     58  1.11  christos #define	TIMEOUT		4	/* device timed out */
     59  1.11  christos #define	ERR_NODEV	5	/* device has been gone */
     60  1.11  christos 	u_int8_t	r_error;/* copy of error register */
     61  1.11  christos 	daddr_t		badsect[127];/* 126 plus trailing -1 marker */
     62   1.8    bouyer };
     63   1.8    bouyer 
     64   1.8    bouyer /*
     65   1.8    bouyer  * ata_bustype. The first field has to be compatible with scsipi_bustype,
     66   1.8    bouyer  * as it's used for autoconfig by both ata and atapi drivers
     67   1.8    bouyer  */
     68   1.8    bouyer 
     69   1.8    bouyer struct ata_bustype {
     70   1.8    bouyer 	int bustype_type;	/* symbolic name of type */
     71   1.9    bouyer 	int (*ata_bio) __P((struct ata_drive_datas*, struct ata_bio *));
     72   1.9    bouyer 	void (*ata_reset_channel) __P((struct ata_drive_datas *));
     73   1.9    bouyer 	int (*ata_exec_command) __P((struct ata_drive_datas *,
     74   1.9    bouyer 					struct wdc_command *));
     75   1.9    bouyer #define WDC_COMPLETE 0x01
     76   1.9    bouyer #define WDC_QUEUED   0x02
     77   1.9    bouyer #define WDC_TRY_AGAIN 0x03
     78   1.9    bouyer 	int (*ata_get_params) __P((struct ata_drive_datas*, u_int8_t,
     79   1.9    bouyer 					struct ataparams *));
     80   1.9    bouyer 	int (*ata_addref) __P((struct ata_drive_datas *));
     81   1.9    bouyer 	void (*ata_delref) __P((struct ata_drive_datas *));
     82   1.9    bouyer 	void (*ata_killpending) __P((struct ata_drive_datas *));
     83   1.8    bouyer };
     84   1.8    bouyer /* bustype_type */
     85   1.8    bouyer /* #define SCSIPI_BUSTYPE_SCSI	0 */
     86   1.8    bouyer /* #define SCSIPI_BUSTYPE_ATAPI	1 */
     87   1.8    bouyer #define SCSIPI_BUSTYPE_ATA	2
     88   1.8    bouyer 
     89   1.8    bouyer /*
     90   1.8    bouyer  * describe an ATA device. Has to be compatible with scsipi_channel, so start
     91   1.8    bouyer  * with a pointer to ata_bustype
     92   1.8    bouyer  */
     93   1.8    bouyer struct ata_device {
     94   1.8    bouyer 	const struct ata_bustype *adev_bustype;
     95   1.8    bouyer 	int adev_channel;
     96   1.8    bouyer 	int adev_openings;
     97   1.8    bouyer 	struct ata_drive_datas *adev_drv_data;
     98   1.2    bouyer };
     99  1.13   thorpej 
    100  1.13   thorpej #ifdef __ATA_DISK_PRIVATE
    101  1.13   thorpej 
    102  1.13   thorpej struct wd_softc {
    103  1.13   thorpej 	/* General disk infos */
    104  1.13   thorpej 	struct device sc_dev;
    105  1.13   thorpej 	struct disk sc_dk;
    106  1.13   thorpej 	struct bufq_state sc_q;
    107  1.13   thorpej 	struct callout sc_restart_ch;
    108  1.14   thorpej 	int sc_quirks;			/* any quirks drive might have */
    109  1.13   thorpej 	/* IDE disk soft states */
    110  1.13   thorpej 	struct ata_bio sc_wdc_bio; /* current transfer */
    111  1.13   thorpej 	struct buf *sc_bp; /* buf being transfered */
    112  1.13   thorpej 	void *wdc_softc;   /* pointer to our parent */
    113  1.13   thorpej 	struct ata_drive_datas *drvp; /* Our controller's infos */
    114  1.13   thorpej 	const struct ata_bustype *atabus;
    115  1.13   thorpej 	int openings;
    116  1.13   thorpej 	struct ataparams sc_params;/* drive characteistics found */
    117  1.13   thorpej 	int sc_flags;
    118  1.13   thorpej #define	WDF_LOCKED	0x001
    119  1.13   thorpej #define	WDF_WANTED	0x002
    120  1.13   thorpej #define	WDF_WLABEL	0x004 /* label is writable */
    121  1.13   thorpej #define	WDF_LABELLING	0x008 /* writing label */
    122  1.13   thorpej /*
    123  1.13   thorpej  * XXX Nothing resets this yet, but disk change sensing will when ATA-4 is
    124  1.13   thorpej  * more fully implemented.
    125  1.13   thorpej  */
    126  1.13   thorpej #define WDF_LOADED	0x010 /* parameters loaded */
    127  1.13   thorpej #define WDF_WAIT	0x020 /* waiting for resources */
    128  1.13   thorpej #define WDF_LBA		0x040 /* using LBA mode */
    129  1.13   thorpej #define WDF_KLABEL	0x080 /* retain label after 'full' close */
    130  1.13   thorpej #define WDF_LBA48	0x100 /* using 48-bit LBA mode */
    131  1.13   thorpej 	int sc_capacity;
    132  1.13   thorpej 	int cyl; /* actual drive parameters */
    133  1.13   thorpej 	int heads;
    134  1.13   thorpej 	int sectors;
    135  1.13   thorpej 	int retries; /* number of xfer retry */
    136  1.13   thorpej 
    137  1.13   thorpej 	void *sc_sdhook;		/* our shutdown hook */
    138  1.13   thorpej 
    139  1.13   thorpej #if NRND > 0
    140  1.13   thorpej 	rndsource_element_t	rnd_source;
    141  1.13   thorpej #endif
    142  1.13   thorpej };
    143  1.13   thorpej 
    144  1.13   thorpej #define sc_drive sc_wdc_bio.drive
    145  1.13   thorpej #define sc_mode sc_wdc_bio.mode
    146  1.13   thorpej #define sc_multi sc_wdc_bio.multi
    147  1.13   thorpej #define sc_badsect sc_wdc_bio.badsect
    148  1.13   thorpej 
    149  1.13   thorpej #endif /* __ATA_DISK_PRIVATE */
    150   1.2    bouyer 
    151   1.2    bouyer void wddone __P((void *));
    152