11.7Sandvar/*	$NetBSD: rdreg.h,v 1.7 2024/02/10 08:24:51 andvar Exp $	*/
21.1Sgmcgarry
31.1Sgmcgarry/*
41.6Srmind * Copyright (c) 1988 University of Utah.
51.1Sgmcgarry * Copyright (c) 1982, 1990, 1993
61.1Sgmcgarry *	The Regents of the University of California.  All rights reserved.
71.2Sagc *
81.2Sagc * This code is derived from software contributed to Berkeley by
91.2Sagc * the Systems Programming Group of the University of Utah Computer
101.2Sagc * Science Department.
111.2Sagc *
121.2Sagc * Redistribution and use in source and binary forms, with or without
131.2Sagc * modification, are permitted provided that the following conditions
141.2Sagc * are met:
151.2Sagc * 1. Redistributions of source code must retain the above copyright
161.2Sagc *    notice, this list of conditions and the following disclaimer.
171.2Sagc * 2. Redistributions in binary form must reproduce the above copyright
181.2Sagc *    notice, this list of conditions and the following disclaimer in the
191.2Sagc *    documentation and/or other materials provided with the distribution.
201.2Sagc * 3. Neither the name of the University nor the names of its contributors
211.2Sagc *    may be used to endorse or promote products derived from this software
221.2Sagc *    without specific prior written permission.
231.2Sagc *
241.2Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251.2Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261.2Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271.2Sagc * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281.2Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291.2Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301.2Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311.2Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321.2Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331.2Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341.2Sagc * SUCH DAMAGE.
351.2Sagc *
361.2Sagc * from: Utah $Hdr: rdreg.h 1.2 90/10/12$
371.2Sagc *
381.2Sagc *	@(#)rdreg.h	8.1 (Berkeley) 6/10/93
391.2Sagc */
401.2Sagc
411.1Sgmcgarrystruct	rd_iocmd {
421.1Sgmcgarry	u_int8_t	c_pad;		/* alignment */
431.1Sgmcgarry	u_int8_t	c_unit;		/* punit */
441.1Sgmcgarry	u_int8_t	c_volume;	/* CS80CMD_SVOL(0) */
451.1Sgmcgarry	u_int8_t	c_saddr;	/* CS80CMD_SADDR */
461.1Sgmcgarry	u_int16_t	c_hiaddr;	/* always 0 */
471.1Sgmcgarry	u_int32_t	c_addr;		/* blkno */
481.1Sgmcgarry	u_int8_t	c_nop2;		/* CS80CMD_NOP - 32-bit alignment */
491.1Sgmcgarry	u_int8_t	c_slen;		/* CS80CMD_SLEN */
501.1Sgmcgarry	u_int32_t	c_len;		/* number of sectors */
511.1Sgmcgarry	u_int8_t	c_cmd;		/* CS80CMD_READ/CS80CMD_WRITE */
521.5Sperry} __packed;
531.1Sgmcgarry
541.1Sgmcgarrystruct	rd_rscmd {		/* different */
551.1Sgmcgarry	u_int8_t	c_unit;
561.1Sgmcgarry	u_int8_t	c_sram;
571.1Sgmcgarry	u_int8_t	c_ram;
581.1Sgmcgarry	u_int8_t	c_cmd;
591.5Sperry} __packed;
601.1Sgmcgarry
611.1Sgmcgarry/* HW ids */
621.1Sgmcgarry#define	RD7946AID	0x220	/* also 7945A */
631.1Sgmcgarry#define	RD9134DID	0x221	/* also 9122S */
641.1Sgmcgarry#define	RD9134LID	0x222	/* also 9122D */
651.1Sgmcgarry#define	RD7912PID	0x209
661.1Sgmcgarry#define RD7914CTID	0x20A
671.1Sgmcgarry#define	RD7914PID	0x20B
681.1Sgmcgarry#define	RD7958AID	0x22B
691.1Sgmcgarry#define RD7957AID	0x22A
701.1Sgmcgarry#define	RD7933HID	0x212
711.1Sgmcgarry#define	RD7936HID	0x213	/* just guessing -- as of yet unknown */
721.1Sgmcgarry#define	RD7937HID	0x214
731.1Sgmcgarry#define RD7957BID	0x22C	/* another guess based on 7958B */
741.1Sgmcgarry#define RD7958BID	0x22D
751.1Sgmcgarry#define RD7959BID	0x22E	/* another guess based on 7958B */
761.1Sgmcgarry#define RD2200AID	0x22F
771.1Sgmcgarry#define RD2203AID	0x230	/* yet another guess */
781.1Sgmcgarry
791.7Sandvar/* SW ids -- indices into rdidentinfo, order is arbitrary */
801.1Sgmcgarry#define	RD7945A		0
811.1Sgmcgarry#define	RD9134D		1
821.1Sgmcgarry#define	RD9122S		2
831.1Sgmcgarry#define	RD7912P		3
841.1Sgmcgarry#define	RD7914P		4
851.1Sgmcgarry#define	RD7958A		5
861.1Sgmcgarry#define RD7957A		6
871.1Sgmcgarry#define	RD7933H		7
881.1Sgmcgarry#define	RD9134L		8
891.1Sgmcgarry#define	RD7936H		9
901.1Sgmcgarry#define	RD7937H		10
911.1Sgmcgarry#define RD7914CT	11
921.1Sgmcgarry#define RD7946A		12
931.1Sgmcgarry#define RD9122D		13
941.1Sgmcgarry#define RD7957B		14
951.1Sgmcgarry#define RD7958B		15
961.1Sgmcgarry#define RD7959B		16
971.1Sgmcgarry
981.1Sgmcgarry#define	NRD7945ABPT	16
991.1Sgmcgarry#define	NRD7945ATRK	7
1001.1Sgmcgarry#define	NRD9134DBPT	16
1011.1Sgmcgarry#define	NRD9134DTRK	6
1021.1Sgmcgarry#define	NRD9122SBPT	8
1031.1Sgmcgarry#define	NRD9122STRK	2
1041.1Sgmcgarry#define	NRD7912PBPT	32
1051.1Sgmcgarry#define	NRD7912PTRK	7
1061.1Sgmcgarry#define	NRD7914PBPT	32
1071.1Sgmcgarry#define	NRD7914PTRK	7
1081.1Sgmcgarry#define	NRD7933HBPT	46
1091.1Sgmcgarry#define	NRD7933HTRK	13
1101.1Sgmcgarry#define	NRD9134LBPT	16
1111.1Sgmcgarry#define	NRD9134LTRK	5
1121.1Sgmcgarry
1131.1Sgmcgarry/*
1141.1Sgmcgarry * Several HP drives have an odd number of 256 byte sectors per track.
1151.1Sgmcgarry * This makes it rather difficult to break them into 512 and 1024 byte blocks.
1161.1Sgmcgarry * So...we just do like HPUX and don't bother to respect hardware track/head
1171.3Swiz * boundaries -- we just mold the disk so that we use the entire capacity.
1181.3Swiz * HPUX also sometimes doesn't abide by cylinder boundaries, we attempt to
1191.1Sgmcgarry * whenever possible.
1201.1Sgmcgarry *
1211.1Sgmcgarry * DISK		REAL (256 BPS)		HPUX (1024 BPS)		BSD (512 BPS)
1221.1Sgmcgarry * 		SPT x HD x CYL		SPT x HD x CYL		SPT x HD x CYL
1231.1Sgmcgarry * -----	---------------		---------------		--------------
1241.1Sgmcgarry * 7936:	123 x  7 x 1396		 25 x  7 x 1716		123 x  7 x  698
1251.1Sgmcgarry * 7937:	123 x 13 x 1396		 25 x 16 x 1395		123 x 13 x  698
1261.1Sgmcgarry *
1271.1Sgmcgarry * 7957A:	 63 x  5 x 1013		 11 x  7 x 1036		 22 x  7 x 1036
1281.1Sgmcgarry * 7958A:	 63 x  8 x 1013		 21 x  6 x 1013		 36 x  7 x 1013
1291.1Sgmcgarry *
1301.1Sgmcgarry * 7957B:	 63 x  4 x 1269		  9 x  7 x 1269		 18 x  7 x 1269
1311.1Sgmcgarry * 7958B:	 63 x  6 x 1572		 21 x  9 x  786		 42 x  9 x  786
1321.1Sgmcgarry * 7959B:	 63 x 12 x 1572		 21 x  9 x 1572		 42 x  9 x 1572
1331.1Sgmcgarry *
1341.1Sgmcgarry * 2200A:	113 x  8 x 1449		113 x  2 x 1449		113 x  4 x 1449
1351.1Sgmcgarry * 2203A:	113 x 16 x 1449		113 x  4 x 1449		113 x  8 x 1449
1361.1Sgmcgarry */
1371.1Sgmcgarry#define	NRD7936HBPT	123
1381.1Sgmcgarry#define	NRD7936HTRK	7
1391.1Sgmcgarry#define	NRD7937HBPT	123
1401.1Sgmcgarry#define	NRD7937HTRK	13
1411.1Sgmcgarry#define	NRD7957ABPT	22
1421.1Sgmcgarry#define	NRD7957ATRK	7
1431.1Sgmcgarry#define	NRD7958ABPT	36
1441.1Sgmcgarry#define	NRD7958ATRK	7
1451.1Sgmcgarry#define	NRD7957BBPT	18
1461.1Sgmcgarry#define	NRD7957BTRK	7
1471.1Sgmcgarry#define	NRD7958BBPT	42
1481.1Sgmcgarry#define	NRD7958BTRK	9
1491.1Sgmcgarry#define	NRD7959BBPT	42
1501.1Sgmcgarry#define	NRD7959BTRK	9
1511.1Sgmcgarry#define	NRD2200ABPT	113
1521.1Sgmcgarry#define	NRD2200ATRK	4
1531.1Sgmcgarry#define	NRD2203ABPT	113
1541.1Sgmcgarry#define	NRD2203ATRK	8
1551.1Sgmcgarry
1561.1Sgmcgarry/* convert 512 byte count into DEV_BSIZE count */
1571.1Sgmcgarry#define RDSZ(x)		((x) >> (DEV_BSHIFT-9))
1581.1Sgmcgarry
1591.1Sgmcgarry/* convert block number into sector number and back */
1601.1Sgmcgarry#define	RDBTOS(x)	((x) << (DEV_BSHIFT-8))
1611.1Sgmcgarry#define RDSTOB(x)	((x) >> (DEV_BSHIFT-8))
1621.1Sgmcgarry
1631.1Sgmcgarry/* extract cyl/head/sect info from three-vector address */
1641.1Sgmcgarry#define RDCYL(tva)	((u_int32_t)(tva).cu_cyhd >> 8)
1651.1Sgmcgarry#define RDHEAD(tva)	((tva).cu_cyhd & 0xFF)
1661.1Sgmcgarry#define RDSECT(tva)	((tva).cu_sect)
167