FreeBSD/Linux Kernel Cross Reference
sys/i386/isa/wdreg.h
1 /*-
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)wdreg.h 7.1 (Berkeley) 5/9/91
37 * $FreeBSD: src/sys/i386/isa/wdreg.h,v 1.12.2.6 1999/09/05 08:13:44 peter Exp $
38 */
39
40 /*
41 * modified for PC9801 by F.Ukai
42 * Kyoto University Microcomputer Club (KMC)
43 */
44
45 /*
46 * Disk Controller register definitions.
47 */
48 #ifdef PC98
49 #define wd_data 0x0 /* data register (R/W - 16 bits) */
50 #define wd_error 0x2 /* error register (R) */
51 #define wd_precomp wd_error /* write precompensation (W) */
52 #define wd_features wd_error /* features register (W) */
53 #define wd_seccnt 0x4 /* sector count (R/W) */
54 #define wd_sector 0x6 /* first sector number (R/W) */
55 #define wd_cyl_lo 0x8 /* cylinder address, low byte (R/W) */
56 #define wd_cyl_hi 0xa /* cylinder address, high byte (R/W)*/
57 #define wd_sdh 0xc /* sector size/drive/head (R/W)*/
58 #define wd_command 0xe /* command register (W) */
59 #define wd_status wd_command /* immediate status (R) */
60
61 #define wd_altsts_nec 0x10c /*alternate fixed disk status(via 1015) (R)*/
62 #define wd_ctlr_nec 0x10c /*fixed disk controller control(via 1015) (W)*/
63 #define wd_altsts_epson 0x3 /*alternate fixed disk status(via 1015) (R)*/
64 #define wd_ctlr_epson 0x3 /*fixed disk controller control(via 1015) (W)*/
65 #define wd_altsts wd_altsts_nec
66
67 #define WDCTL_4BIT 0x8 /* use four head bits (wd1003) */
68 #define WDCTL_RST 0x4 /* reset the controller */
69 #define WDCTL_IDS 0x2 /* disable controller interrupts */
70 #define wd_digin 0x10e /* disk controller input(via 1015) (R)*/
71 #else /* IBM-PC */
72 #define wd_data 0x0 /* data register (R/W - 16 bits) */
73 #define wd_error 0x1 /* error register (R) */
74 #define wd_precomp wd_error /* write precompensation (W) */
75 #define wd_features wd_error /* features register (W) */
76 #define wd_seccnt 0x2 /* sector count (R/W) */
77 #define wd_sector 0x3 /* first sector number (R/W) */
78 #define wd_cyl_lo 0x4 /* cylinder address, low byte (R/W) */
79 #define wd_cyl_hi 0x5 /* cylinder address, high byte (R/W)*/
80 #define wd_sdh 0x6 /* sector size/drive/head (R/W)*/
81 #define wd_command 0x7 /* command register (W) */
82 #define wd_status wd_command /* immediate status (R) */
83
84 #define wd_altsts 0x206 /*alternate fixed disk status(via 1015) (R)*/
85 #define wd_ctlr 0x206 /*fixed disk controller control(via 1015) (W)*/
86 #define WDCTL_4BIT 0x8 /* use four head bits (wd1003) */
87 #define WDCTL_RST 0x4 /* reset the controller */
88 #define WDCTL_IDS 0x2 /* disable controller interrupts */
89 #define wd_digin 0x207 /* disk controller input(via 1015) (R)*/
90 #endif /* PC98 */
91
92 /*
93 * Status Bits.
94 */
95 #define WDCS_BUSY 0x80 /* Controller busy bit. */
96 #define WDCS_READY 0x40 /* Selected drive is ready */
97 #define WDCS_WRTFLT 0x20 /* Write fault */
98 #define WDCS_SEEKCMPLT 0x10 /* Seek complete */
99 #define WDCS_DRQ 0x08 /* Data request bit. */
100 #define WDCS_ECCCOR 0x04 /* ECC correction made in data */
101 #define WDCS_INDEX 0x02 /* Index pulse from selected drive */
102 #define WDCS_ERR 0x01 /* Error detect bit. */
103
104 #define WDCS_BITS "\020\010busy\007rdy\006wrtflt\005seekdone\004drq\003ecc_cor\002index\001err"
105 #define WDERR_ABORT 0x04
106
107 #define WDERR_BITS "\020\010badblk\007uncorr\006id_crc\005no_id\003abort\002tr000\001no_dam"
108
109 /*
110 * Commands for Disk Controller.
111 */
112 #define WDCC_RESTORE 0x10 /* disk restore code -- resets cntlr */
113
114 #define WDCC_READ 0x20 /* disk read code */
115 #define WDCC_WRITE 0x30 /* disk write code */
116 #define WDCC__LONG 0x02 /* modifier -- access ecc bytes */
117 #define WDCC__NORETRY 0x01 /* modifier -- no retrys */
118
119 #define WDCC_FORMAT 0x50 /* disk format code */
120 #define WDCC_DIAGNOSE 0x90 /* controller diagnostic */
121 #define WDCC_IDC 0x91 /* initialize drive command */
122 #define WDCC_READ_MULTI 0xC4 /* read multiple */
123 #define WDCC_WRITE_MULTI 0xC5 /* write multiple */
124 #define WDCC_SET_MULTI 0xC6 /* set multiple count */
125
126 #define WDCC_EXTDCMD 0xE0 /* send extended command */
127 #define WDCC_READP 0xEC /* read parameters from controller */
128 #define WDCC_FEATURES 0xEF /* features control */
129
130 #define WDFEA_RCACHE 0xAA /* read cache enable */
131 #define WDFEA_WCACHE 0x02 /* write cache enable */
132
133 #define WD_STEP 0 /* winchester- default 35us step */
134
135 #define WDSD_IBM 0xa0 /* forced to 512 byte sector, ecc */
136
137 #ifdef KERNEL
138 /*
139 * read parameters command returns this:
140 */
141 struct wdparams {
142 /*
143 * XXX partly based on DRAFT X3T13/1153D rev 14.
144 * by the time you read this it will have changed.
145 */
146 /* drive info */
147 short wdp_config; /* general configuration bits */
148 u_short wdp_cylinders; /* number of cylinders */
149 short wdp_reserved2;
150 u_short wdp_heads; /* number of heads */
151 short wdp_unfbytespertrk; /* number of unformatted bytes/track */
152 short wdp_unfbytes; /* number of unformatted bytes/sector */
153 u_short wdp_sectors; /* number of sectors per track */
154 short wdp_vendorunique[3];
155 /* controller info */
156 char wdp_serial[20]; /* serial number */
157 short wdp_buffertype; /* buffer type */
158 #define WDTYPE_SINGLEPORTSECTOR 1 /* single port, single sector buffer */
159 #define WDTYPE_DUALPORTMULTI 2 /* dual port, multiple sector buffer */
160 #define WDTYPE_DUALPORTMULTICACHE 3 /* above plus track cache */
161 short wdp_buffersize; /* buffer size, in 512-byte units */
162 short wdp_necc; /* ecc bytes appended */
163 char wdp_rev[8]; /* firmware revision */
164 char wdp_model[40]; /* model name */
165 char wdp_nsecperint; /* sectors per interrupt */
166 char wdp_vendorunique1;
167 short wdp_usedmovsd; /* can use double word read/write? */
168 char wdp_vendorunique2;
169 char wdp_capability; /* various capability bits */
170 short wdp_cap_validate; /* validation for above */
171 char wdp_vendorunique3;
172 char wdp_opiomode; /* PIO modes 0-2 */
173 char wdp_vendorunique4;
174 char wdp_odmamode; /* old DMA modes, not in ATA-3 */
175 short wdp_atavalid; /* validation for newer fields */
176 short wdp_currcyls;
177 short wdp_currheads;
178 short wdp_currsectors;
179 short wdp_currsize0;
180 short wdp_currsize1;
181 char wdp_currmultsect;
182 char wdp_multsectvalid;
183 int wdp_lbasize;
184 short wdp_dmasword; /* obsolete in ATA-3 */
185 short wdp_dmamword; /* multiword DMA modes */
186 short wdp_eidepiomodes; /* advanced PIO modes */
187 short wdp_eidedmamin; /* fastest possible DMA timing */
188 short wdp_eidedmanorm; /* recommended DMA timing */
189 short wdp_eidepioblind; /* fastest possible blind PIO */
190 short wdp_eidepioacked; /* fastest possible IORDY PIO */
191 short wdp_reserved69;
192 short wdp_reserved70;
193 short wdp_reserved71;
194 short wdp_reserved72;
195 short wdp_reserved73;
196 short wdp_reserved74;
197 short wdp_queuelen;
198 short wdp_reserved76;
199 short wdp_reserved77;
200 short wdp_reserved78;
201 short wdp_reserved79;
202 short wdp_versmaj;
203 short wdp_versmin;
204 short wdp_featsupp1;
205 short wdp_featsupp2;
206 short wdp_featsupp3;
207 short wdp_featenab1;
208 short wdp_featenab2;
209 short wdp_featenab3;
210 short wdp_udmamode; /* UltraDMA modes */
211 short wdp_erasetime;
212 short wdp_enherasetime;
213 short wdp_apmlevel;
214 short wdp_reserved92[34];
215 short wdp_rmvcap;
216 short wdp_securelevel;
217 };
218
219 /*
220 * wd driver entry points
221 */
222 #ifdef B_FORMAT
223 int wdformat(struct buf *bp);
224 #endif
225
226 /*
227 * IDE DMA support.
228 * This is based on what is needed for the IDE DMA function of the Intel
229 * Triton chipset; hopefully it's general enough to be used for other
230 * chipsets as well.
231 *
232 * To use this:
233 * For each drive which you might want to do DMA on, call wdd_candma()
234 * to get a cookie. If it returns a null pointer, then the drive
235 * can't do DMA.
236 *
237 * Set up the transfer be calling wdd_dmaprep(). The cookie is what
238 * you got before; vaddr is the virtual address of the buffer to be
239 * written; len is the length of the buffer; and direction is either
240 * B_READ or B_WRITE.
241 *
242 * Send a read/write DMA command to the drive.
243 *
244 * Call wdd_dmastart().
245 *
246 * Wait for an interrupt. Multi-sector transfers will only interrupt
247 * at the end of the transfer.
248 *
249 * Call wdd_dmadone(). It will return the status as defined by the
250 * WDDS_* constants below.
251 */
252 struct wddma {
253 void *(*wdd_candma) /* returns a cookie if can do DMA */
254 __P((int ctlr, int drive));
255 int (*wdd_dmaprep) /* prepare DMA hardware */
256 __P((void *cookie, char *vaddr, u_long len, int direction));
257 void (*wdd_dmastart) /* begin DMA transfer */
258 __P((void *cookie));
259 int (*wdd_dmadone) /* DMA transfer completed */
260 __P((void *cookie));
261 int (*wdd_dmastatus) /* return status of DMA */
262 __P((void *cookie));
263 };
264
265 #define WDDS_ACTIVE 0x0001
266 #define WDDS_ERROR 0x0002
267 #define WDDS_INTERRUPT 0x0004
268
269 extern struct wddma wddma;
270
271 #endif /* KERNEL */
Cache object: 3cbf956f5f78f7a146c9b8479e7c7c2d
|