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