xref: /csrg-svn/sys/vax/stand/hpmaptype.c (revision 11361)
1 /*	hpmaptype.c	4.6	83/03/01	*/
2 
3 /*
4  * RP??/RM?? drive type mapping routine.
5  */
6 #include "../machine/pte.h"
7 
8 #include "../h/param.h"
9 #include "../h/inode.h"
10 #include "../h/fs.h"
11 
12 #include "../vaxmba/hpreg.h"
13 #include "../vaxmba/mbareg.h"
14 
15 #include "saio.h"
16 #include "savax.h"
17 
18 /* THIS SHOULD BE READ IN OFF THE PACK, PER DRIVE */
19 short	rp06_off[8] =	{ 0, 38, 0, -1, -1, -1, 118, -1 };
20 short	rm03_off[8] =	{ 0, 100, 0, -1, -1, -1, 309, -1 };
21 short	rm05_off[8] =	{ 0, 27, 0, 562, 589, 681, 562, 82 };
22 short	rm80_off[8] =	{ 0, 37, 0, -1, -1, -1, 115, -1 };
23 short	rp07_off[8] = 	{ 0, 10, 0, 235, 245, 437, 235, 52 };
24 short	ml_off[8] =	{ 0, -1, -1, -1, -1, -1, -1, -1 };
25 short	cdc9775_off[8] = { 0, 13, 0, -1, -1, -1, 294, 66 };
26 short	cdc9730_off[8] = { 0, 50, 0, -1, -1, -1, 155, -1 };
27 short	capricorn_off[8] = { 0, 32, 0, 668, 723, 778, 668, 98 };
28 short	eagle_off[8] =	{ 0, 17, 0, 391, 408, 728, 391, 87 };
29 /* END SHOULD BE READ IN */
30 
31 struct st hpst[] = {
32 #define	HPDT_RM03	0
33 	32,	5,	32*5,	823,	rm03_off,	/* RM03 */
34 #define	HPDT_RM05	1
35 	32,	19,	32*19,	823,	rm05_off,	/* RM05 */
36 #define	HPDT_RP06	2
37 	22,	19,	22*19,	815,	rp06_off,	/* RP06 */
38 #define	HPDT_RM80	3
39 	31,	14, 	31*14,	559,	rm80_off,	/* RM80 */
40 #define	HPDT_RP05	4
41 	22,	19,	22*19,	411,	rp06_off,	/* RP05 */
42 #define	HPDT_RP07	5
43 	50,	32,	50*32,	630,	rp07_off,	/* RP07 */
44 #define	HPDT_ML11A	6
45 	1,	1,	1,	1,	ml_off,		/* ML11A */
46 #define	HPDT_ML11B	7
47 	1,	1,	1,	1,	ml_off,		/* ML11B */
48 #define	HPDT_9775	8
49 	32,	40,	32*40,	843,	cdc9775_off,	/* 9775 */
50 #define	HPDT_9730	9
51 	32,	10,	32*10,	823,	cdc9730_off,	/* 9730 */
52 #define	HPDT_CAP	10
53 	32,	16,	32*16,	1024,	capricorn_off,	/* Ampex capricorn */
54 #define	HPDT_EAGLE	11
55 	48,	20,	43*20,	842,	eagle_off,	/* Fuji Eagle */
56 #define	HPDT_RM02	12
57 	1,	1,	1,	1,	0,		/* rm02 - not used */
58 #define	HPDT_9300	13
59 	32,	19,	32*19,	815,	rm05_off,	/* Ampex 9300 */
60 
61 };
62 
63 #define	MASKREG(reg)	((reg)&0xffff)
64 
65 hpmaptype(hpaddr, type, unit)
66 	register struct hpdevice *hpaddr;
67 	unsigned type;
68 	int unit;
69 {
70 	int ntracks, hpsn;
71 
72 	/*
73 	 * Handle SI model byte stuff when
74 	 * we think it's an RM03 or RM05.
75 	 */
76 	if (type == HPDT_RM03 || type == HPDT_RM05) {
77 		hpsn = hpaddr->hpsn;
78 		if ((hpsn & SIMB_LU) != unit)
79 			return (type);
80 		switch ((hpsn & SIMB_MB) &~ (SIMB_S6|SIRM03|SIRM05)) {
81 
82 		case SI9775D:
83 			return (HPDT_9775);
84 
85 		case SI9730D:
86 			return (HPDT_9730);
87 
88 		/*
89 		 * Beware, since the only have SI controller we
90 		 * have has a 9300 instead of a 9766, we map the
91 		 * drive type into the 9300.  This means that
92 		 * on a 9766 you lose the last 8 cylinders (argh).
93 		 */
94 		case SI9766:
95 			return (HPDT_9300);
96 
97 		case SI9762:
98 			return (HPDT_RM03);
99 
100 		case SICAPD:
101 			return (HPDT_CAP);
102 
103 		case SI9751D:
104 			return (HPDT_EAGLE);
105 		}
106 		return (type);
107 	}
108 	/*
109 	 * RM03: EMULEX controller.  Map to correct
110 	 * drive type by checking the holding
111 	 * register for the disk geometry.
112 	 */
113 	if (type == HPDT_RM02) {
114 		int newtype = type;
115 
116 		hpaddr->hpcs1 = HP_NOP;
117 		hpaddr->hphr = HPHR_MAXTRAK;
118 		ntracks = MASKREG(hpaddr->hphr) + 1;
119 		if (ntracks == 16) {
120 			newtype = HPDT_CAP;	/* AMPEX capricorn */
121 			goto done;
122 		}
123 		hpaddr->hpcs1 = HP_NOP;
124 		hpaddr->hphr = HPHR_MAXSECT;
125 		ntracks = MASKREG(hpaddr->hphr) + 1;
126 		if (ntracks == 48) {
127 			newtype = HPDT_EAGLE;	/* 48 sector Eagle */
128 			goto done;
129 		}
130 		printf("RM02 with %d sectors/track?\n", ntracks);
131 	done:
132 		hpaddr->hpcs1 = HP_DCLR|HP_GO;
133 		return (newtype);
134 	}
135 	/*
136 	 * ML11's all map to the same type.
137 	 */
138 	if (type == HPDT_ML11A || type == HPDT_ML11B)
139 		return (HPDT_ML11A);
140 	return (type);
141 }
142