wdcreg.h revision 1.2 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 * $Id: wdcreg.h,v 1.2 1993/05/22 08:01:47 cgd Exp $
38 */
39
40 /*
41 * Disk Controller register definitions.
42 */
43 #define wd_data 0x0 /* data register (R/W - 16 bits) */
44 #define wd_error 0x1 /* error register (R) */
45 #define wd_precomp wd_error /* write precompensation (W) */
46 #define wd_seccnt 0x2 /* sector count (R/W) */
47 #define wd_sector 0x3 /* first sector number (R/W) */
48 #define wd_cyl_lo 0x4 /* cylinder address, low byte (R/W) */
49 #define wd_cyl_hi 0x5 /* cylinder address, high byte (R/W)*/
50 #define wd_sdh 0x6 /* sector size/drive/head (R/W)*/
51 #define wd_command 0x7 /* command register (W) */
52 #define wd_status wd_command /* immediate status (R) */
53
54 #define wd_altsts 0x206 /*alternate fixed disk status(via 1015) (R)*/
55 #define wd_ctlr 0x206 /*fixed disk controller control(via 1015) (W)*/
56 #define WDCTL_4BIT 0x8 /* use four head bits (wd1003) */
57 #define WDCTL_RST 0x4 /* reset the controller */
58 #define WDCTL_IDS 0x2 /* disable controller interrupts */
59 #define wd_digin 0x207 /* disk controller input(via 1015) (R)*/
60
61 /*
62 * Status Bits.
63 */
64 #define WDCS_BUSY 0x80 /* Controller busy bit. */
65 #define WDCS_READY 0x40 /* Selected drive is ready */
66 #define WDCS_WRTFLT 0x20 /* Write fault */
67 #define WDCS_SEEKCMPLT 0x10 /* Seek complete */
68 #define WDCS_DRQ 0x08 /* Data request bit. */
69 #define WDCS_ECCCOR 0x04 /* ECC correction made in data */
70 #define WDCS_INDEX 0x02 /* Index pulse from selected drive */
71 #define WDCS_ERR 0x01 /* Error detect bit. */
72
73 #define WDCS_BITS "\020\010busy\006rdy\006wrtflt\005seekdone\004drq\003ecc_cor\002index\001err"
74
75 #define WDERR_BITS "\020\010badblk\007uncorr\006id_crc\005no_id\003abort\002tr000\001no_dam"
76
77 /*
78 * Commands for Disk Controller.
79 */
80 #define WDCC_RESTORE 0x10 /* disk restore code -- resets cntlr */
81
82 #define WDCC_READ 0x20 /* disk read code */
83 #define WDCC_WRITE 0x30 /* disk write code */
84 #define WDCC__LONG 0x02 /* modifier -- access ecc bytes */
85 #define WDCC__NORETRY 0x01 /* modifier -- no retrys */
86
87 #define WDCC_FORMAT 0x50 /* disk format code */
88 #define WDCC_DIAGNOSE 0x90 /* controller diagnostic */
89 #define WDCC_IDC 0x91 /* initialize drive command */
90
91 #define WDCC_EXTDCMD 0xE0 /* send extended command */
92 #define WDCC_READP 0xEC /* read parameters from controller */
93 #define WDCC_CACHEC 0xEF /* cache control */
94
95 #define WD_STEP 0 /* winchester- default 35us step */
96
97 #define WDSD_IBM 0xa0 /* forced to 512 byte sector, ecc */
98
99
100 #ifdef KERNEL
101 /*
102 * read parameters command returns this:
103 */
104 struct wdparams {
105 /* drive info */
106 short wdp_config; /* general configuration */
107 short wdp_fixedcyl; /* number of non-removable cylinders */
108 short wdp_removcyl; /* number of removable cylinders */
109 short wdp_heads; /* number of heads */
110 short wdp_unfbytespertrk; /* number of unformatted bytes/track */
111 short wdp_unfbytes; /* number of unformatted bytes/sector */
112 short wdp_sectors; /* number of sectors */
113 short wdp_minisg; /* minimum bytes in inter-sector gap*/
114 short wdp_minplo; /* minimum bytes in postamble */
115 short wdp_vendstat; /* number of words of vendor status */
116 /* controller info */
117 char wdp_cnsn[20]; /* controller serial number */
118 short wdp_cntype; /* controller type */
119 #define WDTYPE_SINGLEPORTSECTOR 1 /* single port, single sector buffer */
120 #define WDTYPE_DUALPORTMULTI 2 /* dual port, multiple sector buffer */
121 #define WDTYPE_DUALPORTMULTICACHE 3 /* above plus track cache */
122 short wdp_cnsbsz; /* sector buffer size, in sectors */
123 short wdp_necc; /* ecc bytes appended */
124 char wdp_rev[8]; /* firmware revision */
125 char wdp_model[40]; /* model name */
126 short wdp_nsecperint; /* sectors per interrupt */
127 short wdp_usedmovsd; /* can use double word read/write? */
128 };
129
130 /*
131 * wd driver entry points
132 */
133 int wdprobe(struct isa_device *);
134 int wdattach(struct isa_device *);
135 int wdstrategy(struct buf *);
136 void wdintr(struct intrframe);
137 int wdopen(dev_t, int, int, struct proc *);
138 int wdclose(dev_t dev, int flags, int fmt);
139 int wdioctl(dev_t, int, caddr_t, int);
140 /* int wdformat(struct buf *bp); */
141 int wdsize(dev_t);
142 int wddump(dev_t);
143
144 #endif KERNEL
145