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