Home | History | Annotate | Line # | Download | only in ata
wdvar.h revision 1.44
      1 /*	$NetBSD: wdvar.h,v 1.44 2017/10/07 16:05:32 jdolecek 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  *
     15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25  */
     26 
     27 #ifndef _DEV_ATA_WDVAR_H_
     28 #define	_DEV_ATA_WDVAR_H_
     29 
     30 #ifdef _KERNEL_OPT
     31 #include "opt_wd.h"
     32 #endif
     33 
     34 #include <sys/rndsource.h>
     35 #include <sys/sysctl.h>
     36 
     37 struct wd_softc {
     38 	/* General disk infos */
     39 	device_t sc_dev;
     40 	struct disk sc_dk;
     41 	struct bufq_state *sc_q;
     42 	kmutex_t sc_lock;
     43 	int sc_quirks;			/* any quirks drive might have */
     44 
     45 	/* IDE disk soft states */
     46 	struct ata_drive_datas *drvp; /* Our controller's infos */
     47 	const struct ata_bustype *atabus;
     48 	struct ataparams sc_params;/* drive characteristics found */
     49 	int sc_flags;
     50 #define	WDF_WLABEL	0x004 /* label is writable */
     51 #define	WDF_LABELLING	0x008 /* writing label */
     52 /*
     53  * XXX Nothing resets this yet, but disk change sensing will when ATA-4 is
     54  * more fully implemented.
     55  */
     56 #define WDF_LOADED	0x010 /* parameters loaded */
     57 #define WDF_WAIT	0x020 /* waiting for resources */
     58 #define WDF_LBA		0x040 /* using LBA mode */
     59 #define WDF_KLABEL	0x080 /* retain label after 'full' close */
     60 #define WDF_LBA48	0x100 /* using 48-bit LBA mode */
     61 #define WDF_FLUSH_PEND	0x200 /* cache flush waits for free xfer */
     62 	uint64_t sc_capacity; /* full capacity of the device */
     63 	uint64_t sc_capacity512; /* ... in DEV_BSIZE blocks */
     64 	uint32_t sc_capacity28; /* capacity accessible with LBA28 commands */
     65 	uint32_t sc_blksize; /* logical block size, in bytes */
     66 
     67 #ifdef WD_SOFTBADSECT
     68 	SLIST_HEAD(, disk_badsectors)	sc_bslist;
     69 	u_int sc_bscount;
     70 #endif
     71 	krndsource_t	rnd_source;
     72 
     73 	/* Sysctl nodes specific for the disk */
     74 	struct sysctllog *nodelog;
     75 	int drv_max_tags;
     76 #define WD_MAX_OPENINGS(wd)	\
     77 	(MAX(1, MIN((wd)->drvp->drv_openings, (wd)->drv_max_tags)))
     78 	bool drv_ncq;
     79 #define WD_USE_NCQ(wd)	\
     80 	((wd)->drv_ncq && ((wd)->drvp->drive_flags & ATA_DRIVE_NCQ))
     81 	bool drv_ncq_prio;
     82 #define WD_USE_NCQ_PRIO(wd) \
     83 	((wd)->drv_ncq_prio && ((wd)->drvp->drive_flags & ATA_DRIVE_NCQ_PRIO))
     84 #ifdef WD_CHAOS_MONKEY
     85 	int drv_chaos_freq;		/* frequency of simulated bio errors */
     86 	int drv_chaos_cnt;		/* count of processed bio read xfers */
     87 #endif
     88 };
     89 
     90 #endif /* _DEV_ATA_WDVAR_H_ */
     91