wdcreg.h revision 1.28 1 /* $NetBSD: wdcreg.h,v 1.28 2003/08/07 16:31:03 agc Exp $ */
2
3 /*-
4 * Copyright (c) 1991 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * William Jolitz.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)wdreg.h 7.1 (Berkeley) 5/9/91
35 */
36
37 /*
38 * Disk Controller register definitions.
39 */
40
41 /* offsets of registers in the 'regular' register region */
42 #define wd_data 0 /* data register (R/W - 16 bits) */
43 #define wd_error 1 /* error register (R) */
44 #define wd_precomp 1 /* write precompensation (W) */
45 #define wd_features 1 /* features (W), same as wd_precomp */
46 #define wd_seccnt 2 /* sector count (R/W) */
47 #define wd_ireason 2 /* interrupt reason (R/W) (for atapi) */
48 #define wd_sector 3 /* first sector number (R/W) */
49 #define wd_cyl_lo 4 /* cylinder address, low byte (R/W) */
50 #define wd_cyl_hi 5 /* cylinder address, high byte (R/W) */
51 #define wd_sdh 6 /* sector size/drive/head (R/W) */
52 #define wd_command 7 /* command register (W) */
53 #define wd_status 7 /* immediate status (R) */
54 #define wd_lba_lo 3 /* lba address, low byte (RW) */
55 #define wd_lba_mi 4 /* lba address, middle byte (RW) */
56 #define wd_lba_hi 5 /* lba address, high byte (RW) */
57
58 /* offsets of registers in the auxiliary register region */
59 #define wd_aux_altsts 0 /* alternate fixed disk status (R) */
60 #define wd_aux_ctlr 0 /* fixed disk controller control (W) */
61 #define WDCTL_4BIT 0x08 /* use four head bits (wd1003) */
62 #define WDCTL_RST 0x04 /* reset the controller */
63 #define WDCTL_IDS 0x02 /* disable controller interrupts */
64 #if 0 /* NOT MAPPED; fd uses this register on PCs */
65 #define wd_digin 1 /* disk controller input (R) */
66 #endif
67
68 /*
69 * Status bits.
70 */
71 #define WDCS_BSY 0x80 /* busy */
72 #define WDCS_DRDY 0x40 /* drive ready */
73 #define WDCS_DWF 0x20 /* drive write fault */
74 #define WDCS_DSC 0x10 /* drive seek complete */
75 #define WDCS_DRQ 0x08 /* data request */
76 #define WDCS_CORR 0x04 /* corrected data */
77 #define WDCS_IDX 0x02 /* index */
78 #define WDCS_ERR 0x01 /* error */
79 #define WDCS_BITS \
80 "\020\010bsy\007drdy\006dwf\005dsc\004drq\003corr\002idx\001err"
81
82 /*
83 * Error bits.
84 */
85 #define WDCE_BBK 0x80 /* bad block detected */
86 #define WDCE_CRC 0x80 /* CRC error (Ultra-DMA only) */
87 #define WDCE_UNC 0x40 /* uncorrectable data error */
88 #define WDCE_MC 0x20 /* media changed */
89 #define WDCE_IDNF 0x10 /* id not found */
90 #define WDCE_MCR 0x08 /* media change requested */
91 #define WDCE_ABRT 0x04 /* aborted command */
92 #define WDCE_TK0NF 0x02 /* track 0 not found */
93 #define WDCE_AMNF 0x01 /* address mark not found */
94
95 /*
96 * Commands for Disk Controller.
97 */
98 #define WDCC_NOP 0x00 /* Always fail with "aborted command" */
99 #define WDCC_RECAL 0x10 /* disk restore code -- resets cntlr */
100
101 #define WDCC_READ 0x20 /* disk read code */
102 #define WDCC_WRITE 0x30 /* disk write code */
103 #define WDCC__LONG 0x02 /* modifier -- access ecc bytes */
104 #define WDCC__NORETRY 0x01 /* modifier -- no retrys */
105
106 #define WDCC_FORMAT 0x50 /* disk format code */
107 #define WDCC_DIAGNOSE 0x90 /* controller diagnostic */
108 #define WDCC_IDP 0x91 /* initialize drive parameters */
109
110 #define WDCC_SMART 0xb0 /* Self Mon, Analysis, Reporting Tech */
111
112 #define WDCC_READMULTI 0xc4 /* read multiple */
113 #define WDCC_WRITEMULTI 0xc5 /* write multiple */
114 #define WDCC_SETMULTI 0xc6 /* set multiple mode */
115
116 #define WDCC_READDMA 0xc8 /* read with DMA */
117 #define WDCC_WRITEDMA 0xca /* write with DMA */
118
119 #define WDCC_ACKMC 0xdb /* acknowledge media change */
120 #define WDCC_LOCK 0xde /* lock drawer */
121 #define WDCC_UNLOCK 0xdf /* unlock drawer */
122
123 #define WDCC_FLUSHCACHE 0xe7 /* Flush cache */
124 #define WDCC_IDENTIFY 0xec /* read parameters from controller */
125 #define SET_FEATURES 0xef /* set features */
126
127 #define WDCC_IDLE 0xe3 /* set idle timer & enter idle mode */
128 #define WDCC_IDLE_IMMED 0xe1 /* enter idle mode */
129 #define WDCC_SLEEP 0xe6 /* enter sleep mode */
130 #define WDCC_STANDBY 0xe2 /* set standby timer & enter standby */
131 #define WDCC_STANDBY_IMMED 0xe0 /* enter standby mode */
132 #define WDCC_CHECK_PWR 0xe5 /* check power mode */
133
134 /*
135 * Big Drive support
136 */
137 #define WDCC_READ_EXT 0x24 /* read 48-bit addressing */
138 #define WDCC_WRITE_EXT 0x34 /* write 48-bit addressing */
139
140 #define WDCC_READMULTI_EXT 0x29 /* read multiple 48-bit addressing */
141 #define WDCC_WRITEMULTI_EXT 0x39 /* write multiple 48-bit addressing */
142
143 #define WDCC_READDMA_EXT 0x25 /* read 48-bit addressing with DMA */
144 #define WDCC_WRITEDMA_EXT 0x35 /* write 48-bit addressing with DMA */
145
146 /* Subcommands for SET_FEATURES (features register) */
147 #define WDSF_WRITE_CACHE_EN 0x02
148 #define WDSF_SET_MODE 0x03
149 #define WDSF_REASSIGN_EN 0x04
150 #define WDSF_RETRY_DS 0x33
151 #define WDSF_SET_CACHE_SGMT 0x54
152 #define WDSF_READAHEAD_DS 0x55
153 #define WDSF_POD_DS 0x66
154 #define WDSF_ECC_DS 0x77
155 #define WDSF_WRITE_CACHE_DS 0x82
156 #define WDSF_REASSIGN_DS 0x84
157 #define WDSF_ECC_EN 0x88
158 #define WDSF_RETRY_EN 0x99
159 #define WDSF_SET_CURRENT 0x9a
160 #define WDSF_READAHEAD_EN 0xaa
161 #define WDSF_PREFETCH_SET 0xab
162 #define WDSF_POD_EN 0xcc
163
164 /* Subcommands for SMART (features register) */
165 #define WDSM_RD_DATA 0xd0
166 #define WDSM_RD_THRESHOLDS 0xd1
167 #define WDSM_ATTR_AUTOSAVE_EN 0xd2
168 #define WDSM_SAVE_ATTR 0xd3
169 #define WDSM_EXEC_OFFL_IMM 0xd4
170 #define WDSM_ENABLE_OPS 0xd8
171 #define WDSM_DISABLE_OPS 0xd9
172 #define WDSM_STATUS 0xda
173
174 #define WDSMART_CYL 0xc24f
175
176 /* parameters uploaded to device/heads register */
177 #define WDSD_IBM 0xa0 /* forced to 512 byte sector, ecc */
178 #define WDSD_CHS 0x00 /* cylinder/head/sector addressing */
179 #define WDSD_LBA 0x40 /* logical block addressing */
180
181 /* Commands for ATAPI devices */
182 #define ATAPI_CHECK_POWER_MODE 0xe5
183 #define ATAPI_EXEC_DRIVE_DIAGS 0x90
184 #define ATAPI_IDLE_IMMEDIATE 0xe1
185 #define ATAPI_NOP 0x00
186 #define ATAPI_PKT_CMD 0xa0
187 #define ATAPI_IDENTIFY_DEVICE 0xa1
188 #define ATAPI_SOFT_RESET 0x08
189 #define ATAPI_SLEEP 0xe6
190 #define ATAPI_STANDBY_IMMEDIATE 0xe0
191
192 /* Bytes used by ATAPI_PACKET_COMMAND ( feature register) */
193 #define ATAPI_PKT_CMD_FTRE_DMA 0x01
194 #define ATAPI_PKT_CMD_FTRE_OVL 0x02
195
196 /* ireason */
197 #define WDCI_CMD 0x01 /* command(1) or data(0) */
198 #define WDCI_IN 0x02 /* transfer to(1) or from(0) the host */
199 #define WDCI_RELEASE 0x04 /* bus released until completion */
200
201 #define PHASE_CMDOUT (WDCS_DRQ | WDCI_CMD)
202 #define PHASE_DATAIN (WDCS_DRQ | WDCI_IN)
203 #define PHASE_DATAOUT (WDCS_DRQ)
204 #define PHASE_COMPLETED (WDCI_IN | WDCI_CMD)
205 #define PHASE_ABORTED (0)
206