hdc9224.h revision 1.4.6.2 1 1.4.6.2 wiz /* $NetBSD: hdc9224.h,v 1.4.6.2 2001/07/26 15:05:11 wiz Exp $ */
2 1.4.6.2 wiz /*
3 1.4.6.2 wiz * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
4 1.4.6.2 wiz * All rights reserved.
5 1.4.6.2 wiz *
6 1.4.6.2 wiz * This code is derived from software contributed to Ludd by Bertram Barth.
7 1.4.6.2 wiz *
8 1.4.6.2 wiz * Redistribution and use in source and binary forms, with or without
9 1.4.6.2 wiz * modification, are permitted provided that the following conditions
10 1.4.6.2 wiz * are met:
11 1.4.6.2 wiz * 1. Redistributions of source code must retain the above copyright
12 1.4.6.2 wiz * notice, this list of conditions and the following disclaimer.
13 1.4.6.2 wiz * 2. Redistributions in binary form must reproduce the above copyright
14 1.4.6.2 wiz * notice, this list of conditions and the following disclaimer in the
15 1.4.6.2 wiz * documentation and/or other materials provided with the distribution.
16 1.4.6.2 wiz * 3. All advertising materials mentioning features or use of this software
17 1.4.6.2 wiz * must display the following acknowledgement:
18 1.4.6.2 wiz * This product includes software developed at Ludd, University of
19 1.4.6.2 wiz * Lule}, Sweden and its contributors.
20 1.4.6.2 wiz * 4. The name of the author may not be used to endorse or promote products
21 1.4.6.2 wiz * derived from this software without specific prior written permission
22 1.4.6.2 wiz *
23 1.4.6.2 wiz * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 1.4.6.2 wiz * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.4.6.2 wiz * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.4.6.2 wiz * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.4.6.2 wiz * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.4.6.2 wiz * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.4.6.2 wiz * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.4.6.2 wiz * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.4.6.2 wiz * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.4.6.2 wiz * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.4.6.2 wiz */
34 1.4.6.2 wiz
35 1.4.6.2 wiz
36 1.4.6.2 wiz struct hdc9224_DKCreg {
37 1.4.6.2 wiz unsigned char dkc_reg; /* Disk Register Data Access Port (rw)*/
38 1.4.6.2 wiz unsigned char fill[3]; /* bytes are longword aligned */
39 1.4.6.2 wiz unsigned char dkc_cmd; /* Disk Controller Command Port (wo) */
40 1.4.6.2 wiz #define dkc_stat dkc_cmd /* Interrupt Status Port (ro) */
41 1.4.6.2 wiz };
42 1.4.6.2 wiz
43 1.4.6.2 wiz /*
44 1.4.6.2 wiz * definition of some commands (constant bits only, incomplete!)
45 1.4.6.2 wiz */
46 1.4.6.2 wiz #define DKC_CMD_RESET 0x00 /* terminate non-data-transfer cmds */
47 1.4.6.2 wiz #define DKC_CMD_DRDESELECT 0x01 /* done when no drive is in use */
48 1.4.6.2 wiz #define DKC_CMD_SETREGPTR 0x40 /* logically or-ed with reg-number */
49 1.4.6.2 wiz #define DKC_CMD_DRSELECT 0x20
50 1.4.6.2 wiz #define DKC_CMD_DRSEL_HDD 0x24 /* select HDD, or-ed with unit-numb. */
51 1.4.6.2 wiz #define DKC_CMD_DRSEL_RX33 0x28 /* or-ed with unit-number of RX33 */
52 1.4.6.2 wiz #define DKC_CMD_DRSEL_RX50 0x2C /* or-ed with unit-number of RX50 */
53 1.4.6.2 wiz #define DKC_CMD_RESTORE 0x02
54 1.4.6.2 wiz #define DKC_CMD_STEP 0x04
55 1.4.6.2 wiz #define DKC_CMD_STEPIN_FDD 0x04 /* one step inward for floppy */
56 1.4.6.2 wiz #define DKC_CMD_STEPOUT_FDD 0x06 /* one step outward (toward cyl #0) */
57 1.4.6.2 wiz #define DKC_CMD_POLLDRIVE 0x10
58 1.4.6.2 wiz #define DKC_CMD_SEEKREADID 0x50
59 1.4.6.2 wiz #define DKC_CMD_FORMATTRACK 0x60
60 1.4.6.2 wiz #define DKC_CMD_READTRACK 0x5A
61 1.4.6.2 wiz #define DKC_CMD_READPHYSICAL 0x58
62 1.4.6.2 wiz #define DKC_CMD_READLOGICAL 0x5C
63 1.4.6.2 wiz #define DKC_CMD_READ_HDD 0x5D /* read-logical, bypass=0, xfer=1 */
64 1.4.6.2 wiz #define DKC_CMD_READ_RX33 0x5D /* ??? */
65 1.4.6.2 wiz #define DKC_CMD_WRITEPHYSICAL 0x80
66 1.4.6.2 wiz #define DKC_CMD_WRITELOGICAL 0xC0
67 1.4.6.2 wiz #define DKC_CMD_WRITE_HDD 0xA0 /* bypass=0, ddmark=0 */
68 1.4.6.2 wiz #define DKC_CMD_WRITE_RX33 0xA1 /* precompensation differs... */
69 1.4.6.2 wiz #define DKC_CMD_WRITE_RX50 0xA4
70 1.4.6.2 wiz
71 1.4.6.2 wiz /*
72 1.4.6.2 wiz * Definition of bits in the DKC_STAT register
73 1.4.6.2 wiz */
74 1.4.6.2 wiz #define DKC_ST_INTPEND (1<<7) /* interrupt pending */
75 1.4.6.2 wiz #define DKC_ST_DMAREQ (1<<6) /* DMA request */
76 1.4.6.2 wiz #define DKC_ST_DONE (1<<5) /* command done */
77 1.4.6.2 wiz #define DKC_ST_TERMCOD (3<<3) /* termination code (see below) */
78 1.4.6.2 wiz #define DKC_ST_RDYCHNG (1<<2) /* ready change */
79 1.4.6.2 wiz #define DKC_ST_OVRUN (1<<1) /* overrun/underrun */
80 1.4.6.2 wiz #define DKC_ST_BADSECT (1<<0) /* bad sector */
81 1.4.6.2 wiz
82 1.4.6.2 wiz /*
83 1.4.6.2 wiz * Definition of the termination codes
84 1.4.6.2 wiz */
85 1.4.6.2 wiz #define DKC_TC_SUCCESS (0<<3) /* Successful completion */
86 1.4.6.2 wiz #define DKC_TC_RDIDERR (1<<3) /* Error in READ-ID sequence */
87 1.4.6.2 wiz #define DKC_TC_VRFYERR (2<<3) /* Error in VERIFY sequence */
88 1.4.6.2 wiz #define DKC_TC_DATAERR (3<<3) /* Error in DATA-TRANSFER seq. */
89 1.4.6.2 wiz
90 1.4.6.2 wiz /*
91 1.4.6.2 wiz * Definitions of delays necessary for floppy-operation
92 1.4.6.2 wiz */
93 1.4.6.2 wiz #define DKC_DELAY_MOTOR 500 /* allow 500 ms to reach speed */
94 1.4.6.2 wiz #define DKC_DELAY_SELECT 70 /* 70 ms for data-recovery-circuit */
95 1.4.6.2 wiz #define DKC_DELAY_POSITION 59 /* 59 ms for RX33, 100 ms for RX50 */
96 1.4.6.2 wiz #define DKC_DELAY_HEADSET 18 /* 18 ms when changing head-number */
97 1.4.6.2 wiz
98 1.4.6.2 wiz /*
99 1.4.6.2 wiz * The HDC9224 has 11/15(?) internal registers which are accessible via
100 1.4.6.2 wiz * the Disk-Register-Data-Access-Port DKC_REG
101 1.4.6.2 wiz */
102 1.4.6.2 wiz struct hdc9224_UDCreg { /* internal disk controller registers */
103 1.4.6.2 wiz u_char udc_dma7; /* 0: DMA adress bits 0 - 7 */
104 1.4.6.2 wiz u_char udc_dma15; /* 1: DMA adress bits 8 - 15 */
105 1.4.6.2 wiz u_char udc_dma23; /* 2: DMA adress bits 16 - 23 */
106 1.4.6.2 wiz u_char udc_dsect; /* 3: desired/starting sector number */
107 1.4.6.2 wiz #define udc_csect udc_dsect /* current sector number */
108 1.4.6.2 wiz u_char udc_dhead; /* 4: cyl-bits 8-10, desired head number */
109 1.4.6.2 wiz #define udc_chead udc_dhead /* current head number */
110 1.4.6.2 wiz u_char udc_dcyl; /* 5: desired cylinder number */
111 1.4.6.2 wiz #define udc_ccyl udc_dcyl /* current cylinder number */
112 1.4.6.2 wiz u_char udc_scnt; /* 6: sector count register */
113 1.4.6.2 wiz u_char udc_rtcnt; /* 7: retry count register */
114 1.4.6.2 wiz u_char udc_mode; /* 8: operation mode/chip status */
115 1.4.6.2 wiz #define udc_cstat udc_mode /* chip status register */
116 1.4.6.2 wiz u_char udc_term; /* 9: termination conditions/drive status */
117 1.4.6.2 wiz #define udc_dstat udc_term /* drive status register */
118 1.4.6.2 wiz u_char udc_data; /* 10: data */
119 1.4.6.2 wiz };
120 1.4.6.2 wiz
121 1.4.6.2 wiz /* UDC regs */
122 1.4.6.2 wiz #define UDC_TERM 9
123 1.4.6.2 wiz
124 1.4.6.2 wiz /*
125 1.4.6.2 wiz * Definition of bits in the Current-Head register
126 1.4.6.2 wiz */
127 1.4.6.2 wiz #define UDC_CH_BADSECT (1<<7) /* indicates a bad sector (if bypass=0) */
128 1.4.6.2 wiz #define UDC_CH_CYLBITS (0x70) /* bits 10-8 of current cylinder number */
129 1.4.6.2 wiz #define UDC_CH_HEADNO (0x0F) /* current head number */
130 1.4.6.2 wiz
131 1.4.6.2 wiz /*
132 1.4.6.2 wiz * Definition of bits in the Retry-Count register
133 1.4.6.2 wiz */
134 1.4.6.2 wiz #define UDC_RC_RTRYCNT (0xF0) /* 1's compl. in read-log, 0 all others */
135 1.4.6.2 wiz #define UDC_RC_RXDISAB (1<<3) /* must/should be 0 for normal operation */
136 1.4.6.2 wiz #define UDC_RC_INVRDY (1<<2) /* polarity of floppy-status, important! */
137 1.4.6.2 wiz #define UDC_RC_MOTOR (1<<1) /* turn on floppy-motor, no effect on HDD */
138 1.4.6.2 wiz #define UDC_RC_LOSPEED (1<<0) /* floppy-speed select, RX33: 0, RX50: 1 */
139 1.4.6.2 wiz
140 1.4.6.2 wiz #define UDC_RC_HDD_READ 0xF2 /* 0x72 ??? */
141 1.4.6.2 wiz #define UDC_RC_HDD_WRT 0xF2 /* 0xF0 ??? */
142 1.4.6.2 wiz #define UDC_RC_RX33READ 0x76 /* enable retries when reading floppies */
143 1.4.6.2 wiz #define UDC_RC_RX33WRT 0xF6
144 1.4.6.2 wiz #define UDC_RC_RX50READ 0x77 /* enable retries when reading floppies */
145 1.4.6.2 wiz #define UDC_RC_RX50WRT 0xF7
146 1.4.6.2 wiz
147 1.4.6.2 wiz /*
148 1.4.6.2 wiz * Definition of bits in the Operating-Mode register
149 1.4.6.2 wiz */
150 1.4.6.2 wiz #define UDC_MD_HDMODE (1<<7) /* must be 1 for all FDD and HDD */
151 1.4.6.2 wiz #define UDC_MD_CHKCOD (3<<5) /* error-check: FDD/CRC: 0, HDD/ECC: 1 */
152 1.4.6.2 wiz #define UDC_MD_DENS (1<<4) /* density select, must be 0 */
153 1.4.6.2 wiz #define UDC_MD_UNUSED (1<<3) /* bit 3 is not used and must be 0 */
154 1.4.6.2 wiz #define UDC_MD_SRATE (7<<0) /* seek step rate */
155 1.4.6.2 wiz
156 1.4.6.2 wiz #define UDC_MD_HDD 0xC0
157 1.4.6.2 wiz #define UDC_MD_RX33 0x82
158 1.4.6.2 wiz #define UDC_MD_RX50 0x81
159 1.4.6.2 wiz
160 1.4.6.2 wiz /*
161 1.4.6.2 wiz * Definition of bits in the Chip-Status register
162 1.4.6.2 wiz */
163 1.4.6.2 wiz #define UDC_CS_RETREQ (1<<7) /* retry required */
164 1.4.6.2 wiz #define UDC_CS_ECCATT (1<<6) /* error correction attempted */
165 1.4.6.2 wiz #define UDC_CS_ECCERR (1<<5) /* ECC/CRC error */
166 1.4.6.2 wiz #define UDC_CS_DELDATA (1<<4) /* deleted data mark */
167 1.4.6.2 wiz #define UDC_CS_SYNCERR (1<<3) /* synchronization error */
168 1.4.6.2 wiz #define UDC_CS_COMPERR (1<<2) /* compare error */
169 1.4.6.2 wiz #define UDC_CS_PRESDRV (0x3) /* present drive selected */
170 1.4.6.2 wiz
171 1.4.6.2 wiz /*
172 1.4.6.2 wiz * Definition of bits in the Termination-Conditions register
173 1.4.6.2 wiz */
174 1.4.6.2 wiz #define UDC_TC_CRCPRE (1<<7) /* CRC register preset, must be 1 */
175 1.4.6.2 wiz #define UDC_TC_UNUSED (1<<6) /* bit 6 is not used and must be 0 */
176 1.4.6.2 wiz #define UDC_TC_INTDONE (1<<5) /* interrupt on done */
177 1.4.6.2 wiz #define UDC_TC_TDELDAT (1<<4) /* terminate on deleted data */
178 1.4.6.2 wiz #define UDC_TC_TDSTAT3 (1<<3) /* terminate on drive status 3 change */
179 1.4.6.2 wiz #define UDC_TC_TWPROT (1<<2) /* terminate on write-protect (FDD only) */
180 1.4.6.2 wiz #define UDC_TC_INTRDCH (1<<1) /* interrupt on ready change (FDD only) */
181 1.4.6.2 wiz #define UDC_TC_TWRFLT (1<<0) /* interrupt on write-fault (HDD only) */
182 1.4.6.2 wiz
183 1.4.6.2 wiz #define UDC_TC_HDD 0xA5 /* 0xB5 ??? */
184 1.4.6.2 wiz #define UDC_TC_FDD 0xA0 /* 0xAA ??? 0xB4 ??? */
185 1.4.6.2 wiz
186 1.4.6.2 wiz /*
187 1.4.6.2 wiz * Definition of bits in the Disk-Status register
188 1.4.6.2 wiz */
189 1.4.6.2 wiz #define UDC_DS_SELACK (1<<7) /* select acknowledge (harddisk only!) */
190 1.4.6.2 wiz #define UDC_DS_INDEX (1<<6) /* index point */
191 1.4.6.2 wiz #define UDC_DS_SKCOM (1<<5) /* seek complete */
192 1.4.6.2 wiz #define UDC_DS_TRK00 (1<<4) /* track 0 */
193 1.4.6.2 wiz #define UDC_DS_DSTAT3 (1<<3) /* drive status 3 (MBZ) */
194 1.4.6.2 wiz #define UDC_DS_WRPROT (1<<2) /* write protect (floppy only!) */
195 1.4.6.2 wiz #define UDC_DS_READY (1<<1) /* drive ready bit */
196 1.4.6.2 wiz #define UDC_DS_WRFAULT (1<<0) /* write fault */
197 1.4.6.2 wiz
198 1.4.6.2 wiz
199