xref: /original-bsd/sys/vax/stand/hpmaptype.c (revision 9b5efc43)
1 /*
2  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)hpmaptype.c	7.11 (Berkeley) 12/16/90
7  */
8 
9 /*
10  * RP??/RM?? drive type mapping routine.
11  * Used for compatibility with unlabeled disks.
12  */
13 #ifdef COMPAT_42
14 #include "../include/pte.h"
15 
16 #include "sys/param.h"
17 #include "sys/disklabel.h"
18 
19 #include "../mba/hpreg.h"
20 #include "../mba/mbareg.h"
21 
22 #include "stand/saio.h"
23 
24 short	rp06_off[8] =	{ 0, 38, 0, -1, -1, -1, 118, -1 };
25 short	rm03_off[8] =	{ 0, 100, 0, -1, -1, -1, 309, -1 };
26 short	rm05_off[8] =	{ 0, 27, 0, 562, 589, 681, 562, 82 };
27 short	rm80_off[8] =	{ 0, 37, 0, -1, -1, -1, 115, -1 };
28 short	rp07_off[8] =	{ 0, 10, 0, 235, 245, 437, 235, 52 };
29 short	ml_off[8] =	{ 0, -1, -1, -1, -1, -1, -1, -1 };
30 /*short	cdc9775_off[8] = { 0, 13, 0, -1, -1, -1, 294, 66 };*/
31 short	cdc9730_off[8] = { 0, 50, 0, -1, -1, -1, 155, -1 };
32 short	capricorn_off[8] = { 0, 32, 0, 668, 723, 778, 668, 98 };
33 short	eagle_off[8] = { 0, 17, 0, 391, 408, 728, 391, 87 };
34 short	fj2361_off[8] = { 0, 13, 0, 294, 307, 547, 294, 66 };
35 short	fj2361a_off[8] = { 0, 12, 0, 277, 289, 515, 277, 62 };
36 
37 /*
38  * hptypes is used to translate Massbus drive type and other information
39  * into an index in hpst.  The indices of hptypes and hpst must therefore agree.
40  */
41 short	hptypes[] = {
42 	MBDT_RM03,
43 	MBDT_RM05,
44 	MBDT_RP06,
45 	MBDT_RM80,
46 	MBDT_RP05,
47 	MBDT_RP07,
48 	MBDT_ML11A,
49 	MBDT_ML11B,
50 	-1,		/* 9755 */
51 	-1,		/* 9730 */
52 	-1,		/* Capricorn */
53 	-1,		/* Eagle */
54 	MBDT_RM02,	/* actually something else */
55 	-1,		/* 9300 */
56 	-1,		/* 9766 */
57 	-1,		/* 2361 */
58 	-1,		/* 2361A */
59 	0
60 };
61 
62 struct st hpst[] = {
63 #define	HPDT_RM03	0
64 	32,	5,	32*5,	823,	rm03_off,	/* RM03 */
65 #define	HPDT_RM05	1
66 	32,	19,	32*19,	823,	rm05_off,	/* RM05 */
67 #define	HPDT_RP06	2
68 	22,	19,	22*19,	815,	rp06_off,	/* RP06 */
69 #define	HPDT_RM80	3
70 	31,	14, 	31*14,	559,	rm80_off,	/* RM80 */
71 #define	HPDT_RP05	4
72 	22,	19,	22*19,	411,	rp06_off,	/* RP05 */
73 #define	HPDT_RP07	5
74 	50,	32,	50*32,	630,	rp07_off,	/* RP07 */
75 #define	HPDT_ML11A	6
76 	1,	1,	1,	1,	ml_off,		/* ML11A */
77 #define	HPDT_ML11B	7
78 	1,	1,	1,	1,	ml_off,		/* ML11B */
79 #define	HPDT_9775	8
80 	32,	40,	32*40,	843,	fj2361_off,	/* 9775 */
81 #define	HPDT_9730	9
82 	32,	10,	32*10,	823,	cdc9730_off,	/* 9730 */
83 #define	HPDT_CAP	10
84 	32,	16,	32*16,	1024,	capricorn_off,	/* Ampex capricorn */
85 #define	HPDT_EAGLE	11
86 	48,	20,	48*20,	842,	eagle_off,	/* Fuji Eagle */
87 #define	HPDT_RM02	12
88 	32,	5,	32*5,	823,	rm03_off,	/* rm02 - not used */
89 #define	HPDT_9300	13
90 	32,	19,	32*19,	815,	rm05_off,	/* Ampex 9300 */
91 #define	HPDT_9766	14
92 	32,	19,	32*19,	823,	rm05_off,	/* CDC 9766 */
93 #define HPDT_2361	15
94 	64,	20,	64*20,	842,	fj2361_off,	/* Fuji 2361 */
95 #define HPDT_2361A
96 	68,	20,	68*20,	842,	fj2361a_off,	/* Fuji 2361a */
97 };
98 #define	NTYPES	(sizeof(hpst) / sizeof(hpst[0]))
99 
100 #define	MASKREG(reg)	((reg)&0xffff)
101 
102 hpmaptype(hpaddr, type, unit, lp)
103 	register struct hpdevice *hpaddr;
104 	register unsigned type;
105 	int unit;
106 	register struct disklabel *lp;
107 {
108 	register i;
109 	register struct st *st;
110 	int hpsn;
111 
112 	for (i = 0; hptypes[i]; i++)
113 		if (hptypes[i] == type)
114 			goto found;
115 	printf("unknown drive type\n");
116 	return (0);
117 
118 found:
119 	type = i;
120 	/*
121 	 * Handle SI model byte stuff when
122 	 * we think it's an RM03 or RM05.
123 	 */
124 	if (type == HPDT_RM03 || type == HPDT_RM05) {
125 		hpsn = hpaddr->hpsn;
126 		if ((hpsn & SIMB_LU) == unit)
127 		switch ((hpsn & SIMB_MB) &~ (SIMB_S6|SIRM03|SIRM05)) {
128 
129 		case SI9775D:
130 			type = HPDT_9775;
131 			break;
132 
133 		case SI9730D:
134 			type = HPDT_9730;
135 			break;
136 
137 		case SI9766:
138 			type = HPDT_9766;
139 			break;
140 
141 		case SI9762:
142 			type = HPDT_RM03;
143 			break;
144 
145 		case SICAPD:
146 			type = HPDT_CAP;
147 			break;
148 
149 		case SI9751D:
150 			type = HPDT_EAGLE;
151 			break;
152 		}
153 	}
154 	/*
155 	 * RM02: EMULEX controller.  Map to correct
156 	 * drive type by checking the holding
157 	 * register for the disk geometry.
158 	 */
159 	if (type == HPDT_RM02) {
160 		int nsectors, ntracks, ncyl;
161 
162 		hpaddr->hpcs1 = HP_NOP;
163 		hpaddr->hphr = HPHR_MAXTRAK;
164 		ntracks = MASKREG(hpaddr->hphr) + 1;
165 		DELAY(100);
166 		hpaddr->hpcs1 = HP_NOP;
167 		hpaddr->hphr = HPHR_MAXSECT;
168 		nsectors = MASKREG(hpaddr->hphr) + 1;
169 		DELAY(100);
170 		hpaddr->hpcs1 = HP_NOP;
171 		hpaddr->hphr = HPHR_MAXCYL;
172 		ncyl = MASKREG(hpaddr->hphr) + 1;
173 		for (type = 0; type < NTYPES; type++)
174 			if (hpst[type].nsect == nsectors &&
175 			    hpst[type].ntrak == ntracks &&
176 			    hpst[type].ncyl == ncyl)
177 				goto done;
178 
179 		printf("%d sectors, %d tracks, %d cyl?\n",
180 			nsectors, ntracks, ncyl);
181 		type = HPDT_RM02;
182 	done:
183 		hpaddr->hpcs1 = HP_DCLR|HP_GO;
184 	}
185 
186 	/*
187 	 * set up minimal disk label.
188 	 */
189 	st = &hpst[type];
190 	lp->d_nsectors = st->nsect;
191 	lp->d_ntracks = st->ntrak;
192 	lp->d_secpercyl = st->nspc;
193 	lp->d_ncylinders = st->ncyl;
194 	lp->d_secperunit = st->nspc * st->ncyl;
195 	lp->d_npartitions = 8;
196 	for (i = 0; i < 8; i++) {
197 		if (st->off[i] == -1)
198 			lp->d_partitions[i].p_size = 0;
199 		else {
200 			lp->d_partitions[i].p_offset = st->off[i] *
201 			    lp->d_secpercyl;
202 			lp->d_partitions[i].p_size = lp->d_secperunit;
203 		}
204 	}
205 	return (1);
206 }
207 #endif COMPAT_42
208