Home | History | Annotate | Line # | Download | only in ata
wdvar.h revision 1.22
      1 /*	$NetBSD: wdvar.h,v 1.22 2003/12/14 05:03:28 thorpej 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 Manuel Bouyer.
     17  * 4. The name of the author may not be used to endorse or promote products
     18  *    derived from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  *
     31  */
     32 
     33 /*
     34  * ata_bustype. The first field has to be compatible with scsipi_bustype,
     35  * as it's used for autoconfig by both ata and atapi drivers
     36  */
     37 
     38 struct ata_bustype {
     39 	int bustype_type;	/* symbolic name of type */
     40 	int (*ata_bio) __P((struct ata_drive_datas*, struct ata_bio *));
     41 	void (*ata_reset_channel) __P((struct ata_drive_datas *, int));
     42 	int (*ata_exec_command) __P((struct ata_drive_datas *,
     43 					struct wdc_command *));
     44 #define WDC_COMPLETE 0x01
     45 #define WDC_QUEUED   0x02
     46 #define WDC_TRY_AGAIN 0x03
     47 	int (*ata_get_params) __P((struct ata_drive_datas*, u_int8_t,
     48 					struct ataparams *));
     49 	int (*ata_addref) __P((struct ata_drive_datas *));
     50 	void (*ata_delref) __P((struct ata_drive_datas *));
     51 	void (*ata_killpending) __P((struct ata_drive_datas *));
     52 };
     53 /* bustype_type */
     54 /* #define SCSIPI_BUSTYPE_SCSI	0 */
     55 /* #define SCSIPI_BUSTYPE_ATAPI	1 */
     56 #define SCSIPI_BUSTYPE_ATA	2
     57 
     58 /*
     59  * describe an ATA device. Has to be compatible with scsipi_channel, so start
     60  * with a pointer to ata_bustype
     61  */
     62 struct ata_device {
     63 	const struct ata_bustype *adev_bustype;
     64 	int adev_channel;
     65 	int adev_openings;
     66 	struct ata_drive_datas *adev_drv_data;
     67 };
     68 
     69 #ifdef __ATA_DISK_PRIVATE
     70 
     71 struct wd_softc {
     72 	/* General disk infos */
     73 	struct device sc_dev;
     74 	struct disk sc_dk;
     75 	struct lock sc_lock;
     76 	struct bufq_state sc_q;
     77 	struct callout sc_restart_ch;
     78 	int sc_quirks;			/* any quirks drive might have */
     79 	/* IDE disk soft states */
     80 	struct ata_bio sc_wdc_bio; /* current transfer */
     81 	struct buf *sc_bp; /* buf being transfered */
     82 	struct ata_drive_datas *drvp; /* Our controller's infos */
     83 	const struct ata_bustype *atabus;
     84 	int openings;
     85 	struct ataparams sc_params;/* drive characteristics found */
     86 	int sc_flags;
     87 #define	WDF_WLABEL	0x004 /* label is writable */
     88 #define	WDF_LABELLING	0x008 /* writing label */
     89 /*
     90  * XXX Nothing resets this yet, but disk change sensing will when ATA-4 is
     91  * more fully implemented.
     92  */
     93 #define WDF_LOADED	0x010 /* parameters loaded */
     94 #define WDF_WAIT	0x020 /* waiting for resources */
     95 #define WDF_LBA		0x040 /* using LBA mode */
     96 #define WDF_KLABEL	0x080 /* retain label after 'full' close */
     97 #define WDF_LBA48	0x100 /* using 48-bit LBA mode */
     98 	u_int64_t sc_capacity;
     99 	int cyl; /* actual drive parameters */
    100 	int heads;
    101 	int sectors;
    102 	int retries; /* number of xfer retry */
    103 
    104 	void *sc_sdhook;		/* our shutdown hook */
    105 
    106 	SLIST_HEAD(, disk_badsectors)	sc_bslist;
    107 	u_int sc_bscount;
    108 
    109 #if NRND > 0
    110 	rndsource_element_t	rnd_source;
    111 #endif
    112 };
    113 
    114 #define sc_drive sc_wdc_bio.drive
    115 #define sc_mode sc_wdc_bio.mode
    116 #define sc_multi sc_wdc_bio.multi
    117 #define sc_badsect sc_wdc_bio.badsect
    118 
    119 #endif /* __ATA_DISK_PRIVATE */
    120 
    121 void wddone __P((void *));
    122