xref: /netbsd-src/sys/arch/hp300/dev/rdreg.h (revision 734527fb7d4ba6a89f7fe2798936ed9501e6e255)
1 /*	$NetBSD: rdreg.h,v 1.21 2024/02/10 08:24:50 andvar Exp $	*/
2 
3 /*
4  * Copyright (c) 1988 University of Utah.
5  * Copyright (c) 1982, 1990, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * the Systems Programming Group of the University of Utah Computer
10  * Science Department.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. 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: Utah $Hdr: rdreg.h 1.2 90/10/12$
37  *
38  *	@(#)rdreg.h	8.1 (Berkeley) 6/10/93
39  */
40 
41 struct	rd_iocmd {
42 	uint8_t 	c_pad;
43 	uint8_t 	c_unit;
44 	uint8_t 	c_volume;
45 	uint8_t 	c_saddr;
46 	uint16_t	c_hiaddr;
47 	uint32_t	c_addr;
48 	uint8_t 	c_nop2;
49 	uint8_t 	c_slen;
50 	uint32_t	c_len;
51 	uint8_t 	c_cmd;
52 	uint8_t 	c_pad2;
53 } __attribute__((__packed__));
54 
55 struct	rd_rscmd {
56 	uint8_t 	c_unit;
57 	uint8_t 	c_sram;
58 	uint8_t 	c_ram;
59 	uint8_t 	c_cmd;
60 } __attribute__((__packed__));
61 
62 struct	rd_stat {
63 	uint8_t 	c_vu;
64 	uint8_t 	c_pend;
65 	uint16_t	c_ref;
66 	uint16_t	c_fef;
67 	uint16_t	c_aef;
68 	uint16_t	c_ief;
69 	union {
70 		uint8_t cu_raw[10];
71 		struct {
72 			uint16_t	cu_msw;
73 			uint32_t	cu_lsl;
74 		} cu_sva;
75 		struct {
76 			uint32_t	cu_cyhd;
77 			uint16_t	cu_sect;
78 		} cu_tva;
79 	} c_pf;
80 } __attribute__((__packed__));
81 #define	c_raw	c_pf.cu_raw
82 #define	c_blk	c_pf.cu_sva.cu_lsl	/* for now */
83 #define	c_tva	c_pf.cu_tva
84 
85 struct	rd_ssmcmd {
86 	uint8_t 	c_unit;
87 	uint8_t 	c_cmd;
88 	uint16_t	c_refm;
89 	uint16_t	c_fefm;
90 	uint16_t	c_aefm;
91 	uint16_t	c_iefm;
92 } __attribute__((__packed__));
93 
94 struct	rd_srcmd {
95 	uint8_t 	c_unit;
96 	uint8_t 	c_nop;
97 	uint8_t 	c_cmd;
98 	uint8_t 	c_param;
99 } __attribute__((__packed__));
100 
101 struct	rd_clearcmd {
102 	uint8_t 	c_unit;
103 	uint8_t 	c_cmd;
104 } __attribute__((__packed__));
105 
106 /* HW ids */
107 #define	RD7946AID	0x220	/* also 7945A and 7941A */
108 #define	RD9134DID	0x221	/* also 9122S */
109 #define	RD9134LID	0x222	/* also 9122D */
110 #define	RD7912PID	0x209
111 #define	RD7914CTID	0x20A
112 #define	RD7914PID	0x20B
113 #define	RD7958AID	0x22B
114 #define	RD7957AID	0x22A
115 #define	RD7933HID	0x212
116 #define	RD7936HID	0x213	/* just guessing -- as of yet unknown */
117 #define	RD7937HID	0x214
118 #define	RD7957BID	0x22C	/* another guess based on 7958B */
119 #define	RD7958BID	0x22D
120 #define	RD7959BID	0x22E	/* another guess based on 7958B */
121 #define	RD2200AID	0x22F
122 #define	RD2203AID	0x230	/* yet another guess */
123 #define	RD2202AID	0x231	/* from hpdrive.ini.sample */
124 #define	RD7908AID	0x200	/* from hpdrive.ini.sample */
125 #define	RD7911AID	0x204	/* from hpdrive.ini.sample */
126 
127 /* Drive names -- per identify description structure */
128 #define	RD7945ANAME	"079450"
129 #define	RD9134DNAME	"091340"
130 #define	RD9122SNAME	"091220"
131 #define	RD7912PNAME	"079120"
132 #define	RD7914PNAME	"079140"
133 #define	RD7958ANAME	"079580"
134 #define	RD7957ANAME	"079570"
135 #define	RD7933HNAME	"079330"
136 #define	RD9134LNAME	"091340"
137 #define	RD7936HNAME	"079360"
138 #define	RD7937HNAME	"079370"
139 #define	RD7914CTNAME	"079140"
140 #define	RD9122DNAME	RD9122SNAME
141 #define	RD7957BNAME	"079571"
142 #define	RD7958BNAME	"079581"
143 #define	RD7959BNAME	"079591"
144 #define	RD2200ANAME	"022000"
145 #define	RD2203ANAME	"022030"
146 #define	RD2202ANAME	"022020"
147 #define	RD7908ANAME	"079080"
148 #define	RD7911ANAME	"079110"
149 #define	RD7941ANAME	"079410"
150 
151 #define	RDNAMELEN	6
152 
153 /* SW ids -- indices into rdidentinfo, order is arbitrary */
154 #define	RD7945A		0
155 #define	RD9134D		1
156 #define	RD9122S		2
157 #define	RD7912P		3
158 #define	RD7914P		4
159 #define	RD7958A		5
160 #define	RD7957A		6
161 #define	RD7933H		7
162 #define	RD9134L		8
163 #define	RD7936H		9
164 #define	RD7937H		10
165 #define	RD7914CT	11
166 #define	RD7946A		12
167 #define	RD9122D		13
168 #define	RD7957B		14
169 #define	RD7958B		15
170 #define	RD7959B		16
171 #define	RD2200A		17
172 #define	RD2203A		18
173 #define	RD2202A		19
174 #define	RD7908A		20
175 #define	RD7911A		21
176 #define	RD7941A		22
177 
178 #define	NRD7945ABPT	16
179 #define	NRD7945ATRK	7
180 #define	NRD7945ACYL	968
181 #define	NRD7945ABLK	108416
182 
183 #define	NRD9134DBPT	16
184 #define	NRD9134DTRK	6
185 #define	NRD9134DCYL	303
186 #define	NRD9134DBLK	29088
187 
188 #define	NRD9122SBPT	8
189 #define	NRD9122STRK	2
190 #define	NRD9122SCYL	77
191 #define	NRD9122SBLK	1232
192 
193 #define	NRD7912PBPT	32
194 #define	NRD7912PTRK	7
195 #define	NRD7912PCYL	572
196 #define	NRD7912PBLK	128128
197 
198 #define	NRD7914PBPT	32
199 #define	NRD7914PTRK	7
200 #define	NRD7914PCYL	1152
201 #define	NRD7914PBLK	258048
202 
203 #define	NRD7933HBPT	46
204 #define	NRD7933HTRK	13
205 #define	NRD7933HCYL	1321
206 #define	NRD7933HBLK	789958
207 
208 #define	NRD9134LBPT	16
209 #define	NRD9134LTRK	5
210 #define	NRD9134LCYL	973
211 #define	NRD9134LBLK	77840
212 
213 #define	NRD7911ABPT	32
214 #define	NRD7911ATRK	3
215 #define	NRD7911ACYL	572
216 #define	NRD7911ABLK	54912
217 
218 #define	NRD7941ABPT	16
219 #define	NRD7941ATRK	3
220 #define	NRD7941ACYL	968
221 #define	NRD7941ABLK	46464
222 
223 /*
224  * Several HP drives have an odd number of 256 byte sectors per track.
225  * This makes it rather difficult to break them into 512 and 1024 byte blocks.
226  * So...we just do like HPUX and don't bother to respect hardware track/head
227  * boundaries -- we just mold the disk so that we use the entire capacity.
228  * HPUX also sometimes doesn't abide by cylinder boundaries, we attempt to
229  * whenever possible.
230  *
231  * DISK		REAL (256 BPS)		HPUX (1024 BPS)		BSD (512 BPS)
232  * 		SPT x HD x CYL		SPT x HD x CYL		SPT x HD x CYL
233  * -----	---------------		---------------		--------------
234  * 7936H:	123 x  7 x 1396		 25 x  7 x 1716		123 x  7 x  698
235  * 7937H:	123 x 13 x 1396		 25 x 16 x 1395		123 x 13 x  698
236  *
237  * 7957A:	 63 x  5 x 1013		 11 x  7 x 1036		 22 x  7 x 1036
238  * 7958A:	 63 x  8 x 1013		 21 x  6 x 1013		 36 x  7 x 1013
239  *
240  * 7957B:	 63 x  4 x 1269		  9 x  7 x 1269		 18 x  7 x 1269
241  * 7958B:	 63 x  6 x 1572		 21 x  9 x  786		 42 x  9 x  786
242  * 7959B:	 63 x 12 x 1572		 21 x  9 x 1572		 42 x  9 x 1572
243  *
244  * 2200A:	113 x  8 x 1449		113 x  2 x 1449		113 x  4 x 1449
245  * 2203A:	113 x 16 x 1449		113 x  4 x 1449		113 x  8 x 1449
246  * 2202A:	113 x 16 x 1449		113 x  4 x 1449		113 x  8 x 1449
247  *
248  * 7908A:	 35 x  5 x  370		??? x  ? x  ???		 35 x  5 x  185
249  */
250 #define	NRD7936HBPT	123
251 #define	NRD7936HTRK	7
252 #define	NRD7936HCYL	698
253 #define	NRD7936HBLK	600978
254 
255 #define	NRD7937HBPT	123
256 #define	NRD7937HTRK	13
257 #define	NRD7937HCYL	698
258 #define	NRD7937HBLK	1116102
259 
260 #define	NRD7957ABPT	22
261 #define	NRD7957ATRK	7
262 #define	NRD7957ACYL	1036
263 #define	NRD7957ABLK	159544
264 
265 #define	NRD7958ABPT	36
266 #define	NRD7958ATRK	7
267 #define	NRD7958ACYL	1013
268 #define	NRD7958ABLK	255276
269 
270 #define	NRD7957BBPT	18
271 #define	NRD7957BTRK	7
272 #define	NRD7957BCYL	1269
273 #define	NRD7957BBLK	159894
274 
275 #define	NRD7958BBPT	42
276 #define	NRD7958BTRK	9
277 #define	NRD7958BCYL	786
278 #define	NRD7958BBLK	297108
279 
280 #define	NRD7959BBPT	42
281 #define	NRD7959BTRK	9
282 #define	NRD7959BCYL	1572
283 #define	NRD7959BBLK	594216
284 
285 #define	NRD2200ABPT	113
286 #define	NRD2200ATRK	4
287 #define	NRD2200ACYL	1449
288 #define	NRD2200ABLK	654948
289 
290 #define	NRD2203ABPT	113
291 #define	NRD2203ATRK	8
292 #define	NRD2203ACYL	1449
293 #define	NRD2203ABLK	1309896
294 
295 #define	NRD2202ABPT	113
296 #define	NRD2202ATRK	8
297 #define	NRD2202ACYL	1449
298 #define	NRD2202ABLK	1309896
299 
300 #define	NRD7908ABPT	35
301 #define	NRD7908ATRK	5
302 #define	NRD7908ACYL	185
303 #define	NRD7908ABLK	32375
304 
305 /* controller "unit" number */
306 #define	RDCTLR		15
307 
308 /* convert 512 byte count into DEV_BSIZE count */
309 #define	RDSZ(x)		((x) >> (DEV_BSHIFT-9))
310 
311 /* convert block number into sector number and back */
312 #define	RDBTOS(x)	((x) << (DEV_BSHIFT-8))
313 #define	RDSTOB(x)	((x) >> (DEV_BSHIFT-8))
314 
315 /* extract cyl/head/sect info from three-vector address */
316 #define	RDCYL(tva)	((uint32_t)(tva).cu_cyhd >> 8)
317 #define	RDHEAD(tva)	((tva).cu_cyhd & 0xFF)
318 #define	RDSECT(tva)	((tva).cu_sect)
319 
320 #define	REF_MASK	0x0
321 #define	FEF_MASK	0x0
322 #define	AEF_MASK	0x0
323 #define	IEF_MASK	0xF970
324 
325 #define	FEF_CU		0x4000	/* cross-unit */
326 #define	FEF_DR		0x0080	/* diagnostic result */
327 #define	FEF_IMR		0x0008	/* internal maintenance release */
328 #define	FEF_PF		0x0002	/* power fail */
329 #define	FEF_REXMT	0x0001	/* retransmit */
330 #define	AEF_UD		0x0040	/* unrecoverable data */
331 #define	IEF_RRMASK	0xe000	/* request release bits */
332 #define	IEF_MD		0x0020	/* marginal data */
333 #define	IEF_RD		0x0010	/* recoverable data */
334 
335 #define	C_READ		0x00
336 #define	C_RAM		0x00	/* single vector (i.e. sector number) */
337 #define	C_WRITE		0x02
338 #define	C_CLEAR		0x08
339 #define	C_STATUS	0x0d
340 #define	C_SADDR		0x10
341 #define	C_SLEN		0x18
342 #define	C_SUNIT(x)	(0x20 | (x))
343 #define	C_SVOL(x)	(0x40 | (x))
344 #define	C_NOP		0x34
345 #define	C_DESC		0x35
346 #define	C_SREL		0x3b
347 #define	C_SSM		0x3e
348 #define	C_SRAM		0x48
349 #define	C_REL		0xc0
350 
351 #define	C_CMD		0x05
352 #define	C_EXEC		0x0e
353 #define	C_QSTAT		0x10
354 #define	C_TCMD		0x12
355