Home | History | Annotate | Line # | Download | only in ata
wdvar.h revision 1.11
      1 /*	$NetBSD: wdvar.h,v 1.11 2002/01/13 17:24:30 christos Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1998, 2001 Manuel Bouyer.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *	This product includes software developed by the University of
     17  *	California, Berkeley and its contributors.
     18  * 4. Neither the name of the University nor the names of its contributors
     19  *    may be used to endorse or promote products derived from this software
     20  *    without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  *
     33  */
     34 
     35 /* Params needed by the controller to perform an ATA bio */
     36 struct ata_bio {
     37 	volatile u_int16_t flags;/* cmd flags */
     38 #define	ATA_NOSLEEP	0x0001	/* Can't sleep */
     39 #define	ATA_POLL	0x0002	/* poll for completion */
     40 #define	ATA_ITSDONE	0x0004	/* the transfer is as done as it gets */
     41 #define	ATA_SINGLE	0x0008	/* transfer must be done in singlesector mode */
     42 #define	ATA_LBA		0x0010	/* transfer uses LBA adressing */
     43 #define	ATA_READ	0x0020	/* transfer is a read (otherwise a write) */
     44 #define	ATA_CORR	0x0040	/* transfer had a corrected error */
     45 #define	ATA_LBA48	0x0080	/* transfer uses 48-bit LBA adressing */
     46 	int		multi;	/* # of blocks to transfer in multi-mode */
     47 	struct disklabel *lp;	/* pointer to drive's label info */
     48 	daddr_t		blkno;	/* block addr */
     49 	daddr_t		blkdone;/* number of blks transferred */
     50 	daddr_t		nblks;	/* number of block currently transferring */
     51 	int		nbytes;	/* number of bytes currently transferring */
     52 	long		bcount;	/* total number of bytes */
     53 	char		*databuf;/* data buffer adress */
     54 	volatile int	error;
     55 #define	NOERROR 	0	/* There was no error (r_error invalid) */
     56 #define	ERROR		1	/* check r_error */
     57 #define	ERR_DF		2	/* Drive fault */
     58 #define	ERR_DMA		3	/* DMA error */
     59 #define	TIMEOUT		4	/* device timed out */
     60 #define	ERR_NODEV	5	/* device has been gone */
     61 	u_int8_t	r_error;/* copy of error register */
     62 	daddr_t		badsect[127];/* 126 plus trailing -1 marker */
     63 };
     64 
     65 /*
     66  * ata_bustype. The first field has to be compatible with scsipi_bustype,
     67  * as it's used for autoconfig by both ata and atapi drivers
     68  */
     69 
     70 struct ata_bustype {
     71 	int bustype_type;	/* symbolic name of type */
     72 	int (*ata_bio) __P((struct ata_drive_datas*, struct ata_bio *));
     73 	void (*ata_reset_channel) __P((struct ata_drive_datas *));
     74 	int (*ata_exec_command) __P((struct ata_drive_datas *,
     75 					struct wdc_command *));
     76 #define WDC_COMPLETE 0x01
     77 #define WDC_QUEUED   0x02
     78 #define WDC_TRY_AGAIN 0x03
     79 	int (*ata_get_params) __P((struct ata_drive_datas*, u_int8_t,
     80 					struct ataparams *));
     81 	int (*ata_addref) __P((struct ata_drive_datas *));
     82 	void (*ata_delref) __P((struct ata_drive_datas *));
     83 	void (*ata_killpending) __P((struct ata_drive_datas *));
     84 };
     85 /* bustype_type */
     86 /* #define SCSIPI_BUSTYPE_SCSI	0 */
     87 /* #define SCSIPI_BUSTYPE_ATAPI	1 */
     88 #define SCSIPI_BUSTYPE_ATA	2
     89 
     90 /*
     91  * describe an ATA device. Has to be compatible with scsipi_channel, so start
     92  * with a pointer to ata_bustype
     93  */
     94 struct ata_device {
     95 	const struct ata_bustype *adev_bustype;
     96 	int adev_channel;
     97 	int adev_openings;
     98 	struct ata_drive_datas *adev_drv_data;
     99 };
    100 
    101 void wddone __P((void *));
    102