Home | History | Annotate | Line # | Download | only in ata
atareg.h revision 1.15
      1  1.15   thorpej /*	$NetBSD: atareg.h,v 1.15 2003/12/30 19:12:24 thorpej Exp $	*/
      2  1.15   thorpej 
      3  1.15   thorpej /*
      4  1.15   thorpej  * Copyright (c) 1998, 2001 Manuel Bouyer.
      5  1.15   thorpej  *
      6  1.15   thorpej  * Redistribution and use in source and binary forms, with or without
      7  1.15   thorpej  * modification, are permitted provided that the following conditions
      8  1.15   thorpej  * are met:
      9  1.15   thorpej  * 1. Redistributions of source code must retain the above copyright
     10  1.15   thorpej  *    notice, this list of conditions and the following disclaimer.
     11  1.15   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.15   thorpej  *    notice, this list of conditions and the following disclaimer in the
     13  1.15   thorpej  *    documentation and/or other materials provided with the distribution.
     14  1.15   thorpej  * 3. All advertising materials mentioning features or use of this software
     15  1.15   thorpej  *    must display the following acknowledgement:
     16  1.15   thorpej  *	This product includes software developed by Manuel Bouyer.
     17  1.15   thorpej  * 4. The name of the author may not be used to endorse or promote products
     18  1.15   thorpej  *    derived from this software without specific prior written permission.
     19  1.15   thorpej  *
     20  1.15   thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.15   thorpej  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.15   thorpej  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.15   thorpej  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.15   thorpej  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.15   thorpej  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.15   thorpej  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.15   thorpej  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.15   thorpej  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.15   thorpej  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  1.15   thorpej  */
     31  1.15   thorpej 
     32  1.15   thorpej #ifndef _DEV_ATA_ATAREG_H_
     33  1.15   thorpej #define	_DEV_ATA_ATAREG_H_
     34   1.2    bouyer 
     35   1.2    bouyer /*
     36   1.2    bouyer  * Drive parameter structure for ATA/ATAPI.
     37   1.2    bouyer  * Bit fields: WDC_* : common to ATA/ATAPI
     38   1.2    bouyer  *             ATA_* : ATA only
     39   1.2    bouyer  *             ATAPI_* : ATAPI only.
     40   1.2    bouyer  */
     41   1.2    bouyer struct ataparams {
     42   1.2    bouyer     /* drive info */
     43   1.2    bouyer     u_int16_t	atap_config;		/* 0: general configuration */
     44   1.2    bouyer #define WDC_CFG_ATAPI_MASK    	0xc000
     45   1.2    bouyer #define WDC_CFG_ATAPI    	0x8000
     46   1.2    bouyer #define	ATA_CFG_REMOVABLE	0x0080
     47   1.2    bouyer #define	ATA_CFG_FIXED		0x0040
     48   1.2    bouyer #define ATAPI_CFG_TYPE_MASK	0x1f00
     49   1.2    bouyer #define ATAPI_CFG_TYPE(x) (((x) & ATAPI_CFG_TYPE_MASK) >> 8)
     50   1.2    bouyer #define	ATAPI_CFG_REMOV		0x0080
     51   1.2    bouyer #define ATAPI_CFG_DRQ_MASK	0x0060
     52   1.2    bouyer #define ATAPI_CFG_STD_DRQ	0x0000
     53   1.2    bouyer #define ATAPI_CFG_IRQ_DRQ	0x0020
     54   1.2    bouyer #define ATAPI_CFG_ACCEL_DRQ	0x0040
     55   1.2    bouyer #define ATAPI_CFG_CMD_MASK	0x0003
     56   1.2    bouyer #define ATAPI_CFG_CMD_12	0x0000
     57   1.2    bouyer #define ATAPI_CFG_CMD_16	0x0001
     58   1.2    bouyer /* words 1-9 are ATA only */
     59   1.2    bouyer     u_int16_t	atap_cylinders;		/* 1: # of non-removable cylinders */
     60   1.2    bouyer     u_int16_t	__reserved1;
     61   1.2    bouyer     u_int16_t	atap_heads;		/* 3: # of heads */
     62   1.2    bouyer     u_int16_t	__retired1[2];		/* 4-5: # of unform. bytes/track */
     63   1.2    bouyer     u_int16_t	atap_sectors;		/* 6: # of sectors */
     64   1.2    bouyer     u_int16_t	__retired2[3];
     65   1.2    bouyer 
     66   1.2    bouyer     u_int8_t	atap_serial[20];	/* 10-19: serial number */
     67   1.2    bouyer     u_int16_t	__retired3[2];
     68   1.2    bouyer     u_int16_t	__obsolete1;
     69   1.2    bouyer     u_int8_t	atap_revision[8];	/* 23-26: firmware revision */
     70   1.2    bouyer     u_int8_t	atap_model[40];		/* 27-46: model number */
     71   1.2    bouyer     u_int16_t	atap_multi;		/* 47: maximum sectors per irq (ATA) */
     72   1.2    bouyer     u_int16_t	__reserved2;
     73   1.2    bouyer     u_int16_t	atap_capabilities1;	/* 49: capability flags */
     74   1.2    bouyer #define WDC_CAP_IORDY	0x0800
     75   1.2    bouyer #define WDC_CAP_IORDY_DSBL 0x0400
     76   1.2    bouyer #define	WDC_CAP_LBA	0x0200
     77   1.2    bouyer #define	WDC_CAP_DMA	0x0100
     78   1.2    bouyer #define ATA_CAP_STBY	0x2000
     79   1.2    bouyer #define ATAPI_CAP_INTERL_DMA	0x8000
     80   1.2    bouyer #define ATAPI_CAP_CMD_QUEUE	0x4000
     81   1.2    bouyer #define	ATAPI_CAP_OVERLP	0X2000
     82   1.2    bouyer #define ATAPI_CAP_ATA_RST	0x1000
     83   1.2    bouyer     u_int16_t	atap_capabilities2;	/* 50: capability flags (ATA) */
     84   1.4    tsubai #if BYTE_ORDER == LITTLE_ENDIAN
     85   1.2    bouyer     u_int8_t	__junk2;
     86   1.2    bouyer     u_int8_t	atap_oldpiotiming;	/* 51: old PIO timing mode */
     87   1.2    bouyer     u_int8_t	__junk3;
     88   1.2    bouyer     u_int8_t	atap_olddmatiming;	/* 52: old DMA timing mode (ATA) */
     89   1.4    tsubai #else
     90   1.4    tsubai     u_int8_t	atap_oldpiotiming;	/* 51: old PIO timing mode */
     91   1.4    tsubai     u_int8_t	__junk2;
     92   1.4    tsubai     u_int8_t	atap_olddmatiming;	/* 52: old DMA timing mode (ATA) */
     93   1.4    tsubai     u_int8_t	__junk3;
     94   1.4    tsubai #endif
     95   1.7    toshii     u_int16_t	atap_extensions;	/* 53: extensions supported */
     96   1.2    bouyer #define WDC_EXT_UDMA_MODES	0x0004
     97   1.2    bouyer #define WDC_EXT_MODES		0x0002
     98   1.2    bouyer #define WDC_EXT_GEOM		0x0001
     99   1.2    bouyer /* words 54-62 are ATA only */
    100  1.11       wiz     u_int16_t	atap_curcylinders;	/* 54: current logical cylinders */
    101   1.2    bouyer     u_int16_t	atap_curheads;		/* 55: current logical heads */
    102   1.2    bouyer     u_int16_t	atap_cursectors;	/* 56: current logical sectors/tracks */
    103   1.2    bouyer     u_int16_t	atap_curcapacity[2];	/* 57-58: current capacity */
    104   1.2    bouyer     u_int16_t	atap_curmulti;		/* 59: current multi-sector setting */
    105   1.2    bouyer #define WDC_MULTI_VALID 0x0100
    106   1.2    bouyer #define WDC_MULTI_MASK  0x00ff
    107   1.2    bouyer     u_int16_t	atap_capacity[2];  	/* 60-61: total capacity (LBA only) */
    108   1.2    bouyer     u_int16_t	__retired4;
    109   1.4    tsubai #if BYTE_ORDER == LITTLE_ENDIAN
    110   1.2    bouyer     u_int8_t	atap_dmamode_supp; 	/* 63: multiword DMA mode supported */
    111   1.2    bouyer     u_int8_t	atap_dmamode_act; 	/*     multiword DMA mode active */
    112   1.2    bouyer     u_int8_t	atap_piomode_supp;       /* 64: PIO mode supported */
    113   1.2    bouyer     u_int8_t	__junk4;
    114   1.4    tsubai #else
    115   1.4    tsubai     u_int8_t	atap_dmamode_act; 	/*     multiword DMA mode active */
    116   1.4    tsubai     u_int8_t	atap_dmamode_supp; 	/* 63: multiword DMA mode supported */
    117   1.4    tsubai     u_int8_t	__junk4;
    118   1.4    tsubai     u_int8_t	atap_piomode_supp;       /* 64: PIO mode supported */
    119   1.4    tsubai #endif
    120   1.2    bouyer     u_int16_t	atap_dmatiming_mimi;	/* 65: minimum DMA cycle time */
    121  1.11       wiz     u_int16_t	atap_dmatiming_recom;	/* 66: recommended DMA cycle time */
    122   1.2    bouyer     u_int16_t	atap_piotiming;    	/* 67: mini PIO cycle time without FC */
    123   1.2    bouyer     u_int16_t	atap_piotiming_iordy;	/* 68: mini PIO cycle time with IORDY FC */
    124   1.2    bouyer     u_int16_t	__reserved3[2];
    125   1.2    bouyer /* words 71-72 are ATAPI only */
    126   1.2    bouyer     u_int16_t	atap_pkt_br;		/* 71: time (ns) to bus release */
    127   1.2    bouyer     u_int16_t	atap_pkt_bsyclr;	/* 72: tme to clear BSY after service */
    128   1.2    bouyer     u_int16_t	__reserved4[2];
    129   1.2    bouyer     u_int16_t	atap_queuedepth;   	/* 75: */
    130   1.2    bouyer #define WDC_QUEUE_DEPTH_MASK 0x0F
    131  1.10       skd     u_int16_t   atap_sata_caps;/* 76: */
    132  1.10       skd #define SATA_SIGNAL_GEN1	0x02
    133  1.10       skd #define SATA_SIGNAL_GEN2	0x04
    134  1.10       skd #define SATA_NATIVE_CMDQ	0x0100
    135  1.10       skd #define SATA_HOST_PWR_MGMT	0x0200
    136  1.10       skd     u_int16_t   atap_sata_reserved;    /* 77: */
    137  1.10       skd     u_int16_t   atap_sata_features_supp;    /* 78: */
    138  1.10       skd #define SATA_NONZERO_OFFSETS	0x02
    139  1.10       skd #define SATA_DMA_SETUP_AUTO	0x04
    140  1.10       skd #define SATA_DRIVE_PWR_MGMT	0x08
    141  1.10       skd     u_int16_t   atap_sata_features_en;    /* 79: */
    142   1.2    bouyer     u_int16_t	atap_ata_major;  	/* 80: Major version number */
    143   1.2    bouyer #define	WDC_VER_ATA1	0x0002
    144   1.2    bouyer #define	WDC_VER_ATA2	0x0004
    145   1.2    bouyer #define	WDC_VER_ATA3	0x0008
    146   1.2    bouyer #define	WDC_VER_ATA4	0x0010
    147   1.5    bouyer #define	WDC_VER_ATA5	0x0020
    148  1.10       skd #define	WDC_VER_ATA6	0x0040
    149  1.14      yamt #define	WDC_VER_ATA7	0x0080
    150   1.2    bouyer     u_int16_t   atap_ata_minor;  	/* 81: Minor version number */
    151   1.6  augustss     u_int16_t	atap_cmd_set1;    	/* 82: command set supported */
    152  1.14      yamt #define	WDC_CMD1_NOP	0x4000		/*	NOP */
    153  1.14      yamt #define	WDC_CMD1_RB	0x2000		/*	READ BUFFER */
    154  1.14      yamt #define	WDC_CMD1_WB	0x1000		/*	WRITE BUFFER */
    155  1.14      yamt /*			0x0800			Obsolete */
    156  1.14      yamt #define	WDC_CMD1_HPA	0x0400		/*	Host Protected Area */
    157  1.14      yamt #define	WDC_CMD1_DVRST	0x0200		/*	DEVICE RESET */
    158  1.14      yamt #define	WDC_CMD1_SRV	0x0100		/*	SERVICE */
    159  1.14      yamt #define	WDC_CMD1_RLSE	0x0080		/*	release interrupt */
    160  1.14      yamt #define	WDC_CMD1_AHEAD	0x0040		/*	look-ahead */
    161  1.14      yamt #define	WDC_CMD1_CACHE	0x0020		/*	write cache */
    162  1.14      yamt #define	WDC_CMD1_PKT	0x0010		/*	PACKET */
    163  1.14      yamt #define	WDC_CMD1_PM	0x0008		/*	Power Management */
    164  1.14      yamt #define	WDC_CMD1_REMOV	0x0004		/*	Removable Media */
    165  1.14      yamt #define	WDC_CMD1_SEC	0x0002		/*	Security Mode */
    166  1.14      yamt #define	WDC_CMD1_SMART	0x0001		/*	SMART */
    167   1.6  augustss     u_int16_t	atap_cmd_set2;    	/* 83: command set supported */
    168  1.14      yamt #define	ATA_CMD2_FCE	0x2000		/*	FLUSH CACHE EXT */
    169  1.14      yamt #define	WDC_CMD2_FC	0x1000		/*	FLUSH CACHE */
    170  1.14      yamt #define	WDC_CMD2_DCO	0x0800		/*	Device Configuration Overlay */
    171  1.14      yamt #define	ATA_CMD2_LBA48	0x0400		/*	48-bit Address */
    172  1.14      yamt #define	WDC_CMD2_AAM	0x0200		/*	Automatic Acoustic Management */
    173  1.14      yamt #define	WDC_CMD2_SM	0x0100		/*	SET MAX security extention */
    174  1.14      yamt #define	WDC_CMD2_SFREQ	0x0040		/*	SET FEATURE is required
    175  1.14      yamt 						to spin-up after power-up */
    176  1.14      yamt #define	WDC_CMD2_PUIS	0x0020		/*	Power-Up In Standby */
    177  1.14      yamt #define	WDC_CMD2_RMSN	0x0010		/*	Removable Media Status Notify */
    178  1.14      yamt #define	ATA_CMD2_APM	0x0008		/*	Advanced Power Management */
    179  1.14      yamt #define	ATA_CMD2_CFA	0x0004		/*	CFA */
    180  1.14      yamt #define	ATA_CMD2_RWQ	0x0002		/*	READ/WRITE DMA QUEUED */
    181  1.14      yamt #define	WDC_CMD2_DM	0x0001		/*	DOWNLOAD MICROCODE */
    182   1.2    bouyer     u_int16_t	atap_cmd_ext;		/* 84: command/features supp. ext. */
    183  1.14      yamt #define	ATA_CMDE_TLCONT	0x1000		/*	Time-limited R/W Continuous */
    184  1.14      yamt #define	ATA_CMDE_TL	0x0800		/*	Time-limited R/W */
    185  1.14      yamt #define	ATA_CMDE_URGW	0x0400		/*	URG for WRITE STREAM DMA/PIO */
    186  1.14      yamt #define	ATA_CMDE_URGR	0x0200		/*	URG for READ STREAM DMA/PIO */
    187  1.14      yamt #define	ATA_CMDE_WWN	0x0100		/*	World Wide name */
    188  1.14      yamt #define	ATA_CMDE_WQFE	0x0080		/*	WRITE DMA QUEUED FUA EXT */
    189  1.14      yamt #define	ATA_CMDE_WFE	0x0040		/*	WRITE DMA/MULTIPLE FUA EXT */
    190  1.14      yamt #define	ATA_CMDE_GPL	0x0020		/*	General Purpose Logging */
    191  1.14      yamt #define	ATA_CMDE_STREAM	0x0010		/*	Streaming */
    192  1.14      yamt #define	ATA_CMDE_MCPTC	0x0008		/*	Media Card Pass Through Cmd */
    193  1.14      yamt #define	ATA_CMDE_MS	0x0004		/*	Media serial number */
    194  1.14      yamt #define	ATA_CMDE_SST	0x0002		/*	SMART self-test */
    195  1.14      yamt #define	ATA_CMDE_SEL	0x0001		/*	SMART error logging */
    196   1.2    bouyer     u_int16_t	atap_cmd1_en;		/* 85: cmd/features enabled */
    197   1.2    bouyer /* bits are the same as atap_cmd_set1 */
    198   1.2    bouyer     u_int16_t	atap_cmd2_en;		/* 86: cmd/features enabled */
    199   1.2    bouyer /* bits are the same as atap_cmd_set2 */
    200   1.2    bouyer     u_int16_t	atap_cmd_def;		/* 87: cmd/features default */
    201   1.4    tsubai #if BYTE_ORDER == LITTLE_ENDIAN
    202   1.2    bouyer     u_int8_t	atap_udmamode_supp; 	/* 88: Ultra-DMA mode supported */
    203   1.2    bouyer     u_int8_t	atap_udmamode_act; 	/*     Ultra-DMA mode active */
    204   1.4    tsubai #else
    205   1.4    tsubai     u_int8_t	atap_udmamode_act; 	/*     Ultra-DMA mode active */
    206   1.4    tsubai     u_int8_t	atap_udmamode_supp; 	/* 88: Ultra-DMA mode supported */
    207   1.4    tsubai #endif
    208   1.2    bouyer /* 89-92 are ATA-only */
    209   1.2    bouyer     u_int16_t	atap_seu_time;		/* 89: Sec. Erase Unit compl. time */
    210   1.2    bouyer     u_int16_t	atap_eseu_time;		/* 90: Enhanced SEU compl. time */
    211   1.2    bouyer     u_int16_t	atap_apm_val;		/* 91: current APM value */
    212   1.2    bouyer     u_int16_t	__reserved6[35];	/* 92-126: reserved */
    213   1.2    bouyer     u_int16_t	atap_rmsn_supp;		/* 127: remov. media status notif. */
    214   1.2    bouyer #define WDC_RMSN_SUPP_MASK 0x0003
    215   1.2    bouyer #define WDC_RMSN_SUPP 0x0001
    216   1.2    bouyer     u_int16_t	atap_sec_st;		/* 128: security status */
    217   1.2    bouyer #define WDC_SEC_LEV_MAX	0x0100
    218   1.2    bouyer #define WDC_SEC_ESE_SUPP 0x0020
    219   1.2    bouyer #define WDC_SEC_EXP	0x0010
    220   1.2    bouyer #define WDC_SEC_FROZEN	0x0008
    221   1.2    bouyer #define WDC_SEC_LOCKED	0x0004
    222   1.2    bouyer #define WDC_SEC_EN	0x0002
    223   1.2    bouyer #define WDC_SEC_SUPP	0x0001
    224   1.2    bouyer };
    225  1.15   thorpej 
    226  1.15   thorpej /*
    227  1.15   thorpej  * If WDSM_ATTR_ADVISORY, device exceeded intended design life period.
    228  1.15   thorpej  * If not WDSM_ATTR_ADVISORY, imminent data loss predicted.
    229  1.15   thorpej  */
    230  1.15   thorpej #define WDSM_ATTR_ADVISORY	1
    231  1.15   thorpej 
    232  1.15   thorpej /*
    233  1.15   thorpej  * If WDSM_ATTR_COLLECTIVE, attribute only updated in off-line testing.
    234  1.15   thorpej  * If not WDSM_ATTR_COLLECTIVE, attribute updated also in on-line testing.
    235  1.15   thorpej  */
    236  1.15   thorpej #define WDSM_ATTR_COLLECTIVE	2
    237  1.15   thorpej 
    238  1.15   thorpej struct ata_smart_attr {
    239  1.15   thorpej 	u_int8_t		id;		/* attribute id number */
    240  1.15   thorpej 	u_int16_t		flags;
    241  1.15   thorpej 	u_int8_t		value;		/* attribute value */
    242  1.15   thorpej 	u_int8_t		worst;
    243  1.15   thorpej 	u_int8_t		raw[6];
    244  1.15   thorpej 	u_int8_t		reserved;
    245  1.15   thorpej } __attribute__((packed));
    246  1.15   thorpej 
    247  1.15   thorpej struct ata_smart_attributes {
    248  1.15   thorpej 	u_int16_t		data_structure_revision;
    249  1.15   thorpej 	struct ata_smart_attr	attributes[30];
    250  1.15   thorpej 	u_int8_t		offline_data_collection_status;
    251  1.15   thorpej 	u_int8_t		self_test_exec_status;
    252  1.15   thorpej 	u_int16_t		total_time_to_complete_off_line;
    253  1.15   thorpej 	u_int8_t		vendor_specific_366;
    254  1.15   thorpej 	u_int8_t		offline_data_collection_capability;
    255  1.15   thorpej 	u_int16_t		smart_capability;
    256  1.15   thorpej 	u_int8_t		errorlog_capability;
    257  1.15   thorpej 	u_int8_t		vendor_specific_371;
    258  1.15   thorpej 	u_int8_t		short_test_completion_time;
    259  1.15   thorpej 	u_int8_t		extend_test_completion_time;
    260  1.15   thorpej 	u_int8_t		reserved_374_385[12];
    261  1.15   thorpej 	u_int8_t		vendor_specific_386_509[125];
    262  1.15   thorpej 	int8_t			checksum;
    263  1.15   thorpej } __attribute__((packed));
    264  1.15   thorpej 
    265  1.15   thorpej struct ata_smart_thresh {
    266  1.15   thorpej 	u_int8_t		id;
    267  1.15   thorpej 	u_int8_t		value;
    268  1.15   thorpej 	u_int8_t		reserved[10];
    269  1.15   thorpej } __attribute__((packed));
    270  1.15   thorpej 
    271  1.15   thorpej struct ata_smart_thresholds {
    272  1.15   thorpej 	u_int16_t		data_structure_revision;
    273  1.15   thorpej 	struct ata_smart_thresh	thresholds[30];
    274  1.15   thorpej 	u_int8_t		reserved[18];
    275  1.15   thorpej 	u_int8_t		vendor_specific[131];
    276  1.15   thorpej 	int8_t			checksum;
    277  1.15   thorpej } __attribute__((packed));
    278  1.15   thorpej 
    279  1.15   thorpej struct ata_smart_selftest {
    280  1.15   thorpej 	u_int8_t		number;
    281  1.15   thorpej 	u_int8_t		status;
    282  1.15   thorpej 	uint16_t		time_stamp;
    283  1.15   thorpej 	u_int8_t		failure_check_point;
    284  1.15   thorpej 	u_int32_t		lba_first_error;
    285  1.15   thorpej 	u_int8_t		vendor_specific[15];
    286  1.15   thorpej } __attribute__((packed));
    287  1.15   thorpej 
    288  1.15   thorpej struct ata_smart_selftestlog {
    289  1.15   thorpej 	u_int16_t		data_structure_revision;
    290  1.15   thorpej 	struct ata_smart_selftest log_entries[21];
    291  1.15   thorpej 	u_int8_t		vendorspecific[2];
    292  1.15   thorpej 	u_int8_t		mostrecenttest;
    293  1.15   thorpej 	u_int8_t		reserved[2];
    294  1.15   thorpej 	u_int8_t		checksum;
    295  1.15   thorpej } __attribute__((packed));
    296  1.15   thorpej 
    297  1.15   thorpej #endif /* _DEV_ATA_ATAREG_H_ */
    298