wdvar.h revision 1.11 1 1.11 christos /* $NetBSD: wdvar.h,v 1.11 2002/01/13 17:24:30 christos 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.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.11 christos volatile u_int16_t flags;/* cmd flags */
38 1.11 christos #define ATA_NOSLEEP 0x0001 /* Can't sleep */
39 1.11 christos #define ATA_POLL 0x0002 /* poll for completion */
40 1.11 christos #define ATA_ITSDONE 0x0004 /* the transfer is as done as it gets */
41 1.11 christos #define ATA_SINGLE 0x0008 /* transfer must be done in singlesector mode */
42 1.11 christos #define ATA_LBA 0x0010 /* transfer uses LBA adressing */
43 1.11 christos #define ATA_READ 0x0020 /* transfer is a read (otherwise a write) */
44 1.11 christos #define ATA_CORR 0x0040 /* transfer had a corrected error */
45 1.11 christos #define ATA_LBA48 0x0080 /* transfer uses 48-bit LBA adressing */
46 1.11 christos int multi; /* # of blocks to transfer in multi-mode */
47 1.11 christos struct disklabel *lp; /* pointer to drive's label info */
48 1.11 christos daddr_t blkno; /* block addr */
49 1.11 christos daddr_t blkdone;/* number of blks transferred */
50 1.11 christos daddr_t nblks; /* number of block currently transferring */
51 1.11 christos int nbytes; /* number of bytes currently transferring */
52 1.11 christos long bcount; /* total number of bytes */
53 1.11 christos char *databuf;/* data buffer adress */
54 1.11 christos volatile int error;
55 1.11 christos #define NOERROR 0 /* There was no error (r_error invalid) */
56 1.11 christos #define ERROR 1 /* check r_error */
57 1.11 christos #define ERR_DF 2 /* Drive fault */
58 1.11 christos #define ERR_DMA 3 /* DMA error */
59 1.11 christos #define TIMEOUT 4 /* device timed out */
60 1.11 christos #define ERR_NODEV 5 /* device has been gone */
61 1.11 christos u_int8_t r_error;/* copy of error register */
62 1.11 christos daddr_t badsect[127];/* 126 plus trailing -1 marker */
63 1.8 bouyer };
64 1.8 bouyer
65 1.8 bouyer /*
66 1.8 bouyer * ata_bustype. The first field has to be compatible with scsipi_bustype,
67 1.8 bouyer * as it's used for autoconfig by both ata and atapi drivers
68 1.8 bouyer */
69 1.8 bouyer
70 1.8 bouyer struct ata_bustype {
71 1.8 bouyer int bustype_type; /* symbolic name of type */
72 1.9 bouyer int (*ata_bio) __P((struct ata_drive_datas*, struct ata_bio *));
73 1.9 bouyer void (*ata_reset_channel) __P((struct ata_drive_datas *));
74 1.9 bouyer int (*ata_exec_command) __P((struct ata_drive_datas *,
75 1.9 bouyer struct wdc_command *));
76 1.9 bouyer #define WDC_COMPLETE 0x01
77 1.9 bouyer #define WDC_QUEUED 0x02
78 1.9 bouyer #define WDC_TRY_AGAIN 0x03
79 1.9 bouyer int (*ata_get_params) __P((struct ata_drive_datas*, u_int8_t,
80 1.9 bouyer struct ataparams *));
81 1.9 bouyer int (*ata_addref) __P((struct ata_drive_datas *));
82 1.9 bouyer void (*ata_delref) __P((struct ata_drive_datas *));
83 1.9 bouyer void (*ata_killpending) __P((struct ata_drive_datas *));
84 1.8 bouyer };
85 1.8 bouyer /* bustype_type */
86 1.8 bouyer /* #define SCSIPI_BUSTYPE_SCSI 0 */
87 1.8 bouyer /* #define SCSIPI_BUSTYPE_ATAPI 1 */
88 1.8 bouyer #define SCSIPI_BUSTYPE_ATA 2
89 1.8 bouyer
90 1.8 bouyer /*
91 1.8 bouyer * describe an ATA device. Has to be compatible with scsipi_channel, so start
92 1.8 bouyer * with a pointer to ata_bustype
93 1.8 bouyer */
94 1.8 bouyer struct ata_device {
95 1.8 bouyer const struct ata_bustype *adev_bustype;
96 1.8 bouyer int adev_channel;
97 1.8 bouyer int adev_openings;
98 1.8 bouyer struct ata_drive_datas *adev_drv_data;
99 1.2 bouyer };
100 1.2 bouyer
101 1.2 bouyer void wddone __P((void *));
102