wdvar.h revision 1.8 1 /* $NetBSD: wdvar.h,v 1.8 2001/12/02 22:44:33 bouyer Exp $ */
2
3 /*
4 * Copyright (c) 1998 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 has to be done in single-sector 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 int multi; /* number of blocks to transfer in multi-mode */
46 struct disklabel *lp; /* pointer to drive's label info */
47 daddr_t blkno; /* block addr */
48 daddr_t blkdone; /* number of blks transferred */
49 daddr_t nblks; /* number of block currently transferring */
50 int nbytes; /* number of bytes currently transferring */
51 long bcount; /* total number of bytes */
52 char* databuf; /* data buffer adress */
53 volatile int error;
54 #define NOERROR 0 /* There was no error (r_error invalid) */
55 #define ERROR 1 /* check r_error */
56 #define ERR_DF 2 /* Drive fault */
57 #define ERR_DMA 3 /* DMA error */
58 #define TIMEOUT 4 /* device timed out */
59 #define ERR_NODEV 5 /* device has been gone */
60 u_int8_t r_error; /* copy of error register */
61 daddr_t badsect[127]; /* 126 plus trailing -1 marker */
62 };
63
64 /*
65 * ata_bustype. The first field has to be compatible with scsipi_bustype,
66 * as it's used for autoconfig by both ata and atapi drivers
67 */
68
69 struct ata_bustype {
70 int bustype_type; /* symbolic name of type */
71 };
72 /* bustype_type */
73 /* #define SCSIPI_BUSTYPE_SCSI 0 */
74 /* #define SCSIPI_BUSTYPE_ATAPI 1 */
75 #define SCSIPI_BUSTYPE_ATA 2
76
77 /*
78 * describe an ATA device. Has to be compatible with scsipi_channel, so start
79 * with a pointer to ata_bustype
80 */
81 struct ata_device {
82 const struct ata_bustype *adev_bustype;
83 int adev_channel;
84 int adev_openings;
85 struct ata_drive_datas *adev_drv_data;
86 };
87
88 int wdc_ata_bio __P((struct ata_drive_datas*, struct ata_bio*));
89
90 void wddone __P((void *));
91