xref: /csrg-svn/sys/vax/stand/hpmaptype.c (revision 45803)
123226Smckusick /*
234519Skarels  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
323226Smckusick  * All rights reserved.  The Berkeley software License Agreement
423226Smckusick  * specifies the terms and conditions for redistribution.
523226Smckusick  *
6*45803Sbostic  *	@(#)hpmaptype.c	7.11 (Berkeley) 12/16/90
723226Smckusick  */
811133Ssam 
911133Ssam /*
1011133Ssam  * RP??/RM?? drive type mapping routine.
1130547Skarels  * Used for compatibility with unlabeled disks.
1211133Ssam  */
1330547Skarels #ifdef COMPAT_42
14*45803Sbostic #include "../include/pte.h"
1511133Ssam 
16*45803Sbostic #include "sys/param.h"
17*45803Sbostic #include "sys/disklabel.h"
1811133Ssam 
19*45803Sbostic #include "../mba/hpreg.h"
20*45803Sbostic #include "../mba/mbareg.h"
2111133Ssam 
22*45803Sbostic #include "stand/saio.h"
2311133Ssam 
2411213Ssam short	rp06_off[8] =	{ 0, 38, 0, -1, -1, -1, 118, -1 };
2511213Ssam short	rm03_off[8] =	{ 0, 100, 0, -1, -1, -1, 309, -1 };
2611213Ssam short	rm05_off[8] =	{ 0, 27, 0, 562, 589, 681, 562, 82 };
2711213Ssam short	rm80_off[8] =	{ 0, 37, 0, -1, -1, -1, 115, -1 };
2834734Sbostic short	rp07_off[8] =	{ 0, 10, 0, 235, 245, 437, 235, 52 };
2911133Ssam short	ml_off[8] =	{ 0, -1, -1, -1, -1, -1, -1, -1 };
3030547Skarels /*short	cdc9775_off[8] = { 0, 13, 0, -1, -1, -1, 294, 66 };*/
3111213Ssam short	cdc9730_off[8] = { 0, 50, 0, -1, -1, -1, 155, -1 };
3211213Ssam short	capricorn_off[8] = { 0, 32, 0, 668, 723, 778, 668, 98 };
3334734Sbostic short	eagle_off[8] = { 0, 17, 0, 391, 408, 728, 391, 87 };
3428909Skarels short	fj2361_off[8] = { 0, 13, 0, 294, 307, 547, 294, 66 };
3534734Sbostic short	fj2361a_off[8] = { 0, 12, 0, 277, 289, 515, 277, 62 };
3611133Ssam 
3725440Skarels /*
3825440Skarels  * hptypes is used to translate Massbus drive type and other information
3925440Skarels  * into an index in hpst.  The indices of hptypes and hpst must therefore agree.
4025440Skarels  */
4125440Skarels short	hptypes[] = {
4225440Skarels 	MBDT_RM03,
4325440Skarels 	MBDT_RM05,
4425440Skarels 	MBDT_RP06,
4525440Skarels 	MBDT_RM80,
4625440Skarels 	MBDT_RP05,
4725440Skarels 	MBDT_RP07,
4825440Skarels 	MBDT_ML11A,
4925440Skarels 	MBDT_ML11B,
5025440Skarels 	-1,		/* 9755 */
5125440Skarels 	-1,		/* 9730 */
5225440Skarels 	-1,		/* Capricorn */
5325440Skarels 	-1,		/* Eagle */
5425440Skarels 	MBDT_RM02,	/* actually something else */
5525440Skarels 	-1,		/* 9300 */
5625440Skarels 	-1,		/* 9766 */
5728909Skarels 	-1,		/* 2361 */
5834734Sbostic 	-1,		/* 2361A */
5925440Skarels 	0
6025440Skarels };
6125440Skarels 
6211133Ssam struct st hpst[] = {
6311361Ssam #define	HPDT_RM03	0
6411213Ssam 	32,	5,	32*5,	823,	rm03_off,	/* RM03 */
6511361Ssam #define	HPDT_RM05	1
6611213Ssam 	32,	19,	32*19,	823,	rm05_off,	/* RM05 */
6711361Ssam #define	HPDT_RP06	2
6811213Ssam 	22,	19,	22*19,	815,	rp06_off,	/* RP06 */
6911361Ssam #define	HPDT_RM80	3
7011133Ssam 	31,	14, 	31*14,	559,	rm80_off,	/* RM80 */
7111361Ssam #define	HPDT_RP05	4
7211361Ssam 	22,	19,	22*19,	411,	rp06_off,	/* RP05 */
7311361Ssam #define	HPDT_RP07	5
7411213Ssam 	50,	32,	50*32,	630,	rp07_off,	/* RP07 */
7511361Ssam #define	HPDT_ML11A	6
7611133Ssam 	1,	1,	1,	1,	ml_off,		/* ML11A */
7711361Ssam #define	HPDT_ML11B	7
7811133Ssam 	1,	1,	1,	1,	ml_off,		/* ML11B */
7911361Ssam #define	HPDT_9775	8
8030547Skarels 	32,	40,	32*40,	843,	fj2361_off,	/* 9775 */
8111361Ssam #define	HPDT_9730	9
8211213Ssam 	32,	10,	32*10,	823,	cdc9730_off,	/* 9730 */
8311361Ssam #define	HPDT_CAP	10
8411213Ssam 	32,	16,	32*16,	1024,	capricorn_off,	/* Ampex capricorn */
8511361Ssam #define	HPDT_EAGLE	11
8611390Ssam 	48,	20,	48*20,	842,	eagle_off,	/* Fuji Eagle */
8711361Ssam #define	HPDT_RM02	12
8825440Skarels 	32,	5,	32*5,	823,	rm03_off,	/* rm02 - not used */
8911361Ssam #define	HPDT_9300	13
9011213Ssam 	32,	19,	32*19,	815,	rm05_off,	/* Ampex 9300 */
9125440Skarels #define	HPDT_9766	14
9225440Skarels 	32,	19,	32*19,	823,	rm05_off,	/* CDC 9766 */
9328909Skarels #define HPDT_2361	15
9428909Skarels 	64,	20,	64*20,	842,	fj2361_off,	/* Fuji 2361 */
9534734Sbostic #define HPDT_2361A
9634734Sbostic 	68,	20,	68*20,	842,	fj2361a_off,	/* Fuji 2361a */
9711133Ssam };
9825440Skarels #define	NTYPES	(sizeof(hpst) / sizeof(hpst[0]))
9911133Ssam 
10011133Ssam #define	MASKREG(reg)	((reg)&0xffff)
10111133Ssam 
hpmaptype(hpaddr,type,unit,lp)10230547Skarels hpmaptype(hpaddr, type, unit, lp)
10311133Ssam 	register struct hpdevice *hpaddr;
10430547Skarels 	register unsigned type;
10511133Ssam 	int unit;
10630547Skarels 	register struct disklabel *lp;
10711133Ssam {
10830547Skarels 	register i;
10930547Skarels 	register struct st *st;
11025440Skarels 	int hpsn;
11111133Ssam 
11230547Skarels 	for (i = 0; hptypes[i]; i++)
11330547Skarels 		if (hptypes[i] == type)
11430547Skarels 			goto found;
11534519Skarels 	printf("unknown drive type\n");
11634519Skarels 	return (0);
11730547Skarels 
11830547Skarels found:
11930547Skarels 	type = i;
12011133Ssam 	/*
12111133Ssam 	 * Handle SI model byte stuff when
12211133Ssam 	 * we think it's an RM03 or RM05.
12311133Ssam 	 */
12411361Ssam 	if (type == HPDT_RM03 || type == HPDT_RM05) {
12511133Ssam 		hpsn = hpaddr->hpsn;
12630547Skarels 		if ((hpsn & SIMB_LU) == unit)
12711133Ssam 		switch ((hpsn & SIMB_MB) &~ (SIMB_S6|SIRM03|SIRM05)) {
12811133Ssam 
12911133Ssam 		case SI9775D:
13030547Skarels 			type = HPDT_9775;
13130547Skarels 			break;
13211133Ssam 
13311133Ssam 		case SI9730D:
13430547Skarels 			type = HPDT_9730;
13530547Skarels 			break;
13611133Ssam 
13711133Ssam 		case SI9766:
13830547Skarels 			type = HPDT_9766;
13930547Skarels 			break;
14011133Ssam 
14111133Ssam 		case SI9762:
14230547Skarels 			type = HPDT_RM03;
14330547Skarels 			break;
14411133Ssam 
14511133Ssam 		case SICAPD:
14630547Skarels 			type = HPDT_CAP;
14730547Skarels 			break;
14811133Ssam 
14911133Ssam 		case SI9751D:
15030547Skarels 			type = HPDT_EAGLE;
15130547Skarels 			break;
15211133Ssam 		}
15311133Ssam 	}
15411133Ssam 	/*
15525440Skarels 	 * RM02: EMULEX controller.  Map to correct
15611133Ssam 	 * drive type by checking the holding
15711133Ssam 	 * register for the disk geometry.
15811133Ssam 	 */
15911361Ssam 	if (type == HPDT_RM02) {
16030547Skarels 		int nsectors, ntracks, ncyl;
16111316Ssam 
16211133Ssam 		hpaddr->hpcs1 = HP_NOP;
16311133Ssam 		hpaddr->hphr = HPHR_MAXTRAK;
16411133Ssam 		ntracks = MASKREG(hpaddr->hphr) + 1;
16525440Skarels 		DELAY(100);
16611316Ssam 		hpaddr->hpcs1 = HP_NOP;
16711133Ssam 		hpaddr->hphr = HPHR_MAXSECT;
16825440Skarels 		nsectors = MASKREG(hpaddr->hphr) + 1;
16925440Skarels 		DELAY(100);
17025440Skarels 		hpaddr->hpcs1 = HP_NOP;
17125440Skarels 		hpaddr->hphr = HPHR_MAXCYL;
17225440Skarels 		ncyl = MASKREG(hpaddr->hphr) + 1;
17330547Skarels 		for (type = 0; type < NTYPES; type++)
17430547Skarels 			if (hpst[type].nsect == nsectors &&
17530547Skarels 			    hpst[type].ntrak == ntracks &&
17630547Skarels 			    hpst[type].ncyl == ncyl)
17733408Skarels 				goto done;
17825440Skarels 
17933408Skarels 		printf("%d sectors, %d tracks, %d cyl?\n",
18033408Skarels 			nsectors, ntracks, ncyl);
18133408Skarels 		type = HPDT_RM02;
18211316Ssam 	done:
18311316Ssam 		hpaddr->hpcs1 = HP_DCLR|HP_GO;
18411133Ssam 	}
18533408Skarels 
18611133Ssam 	/*
18730547Skarels 	 * set up minimal disk label.
18811133Ssam 	 */
18930547Skarels 	st = &hpst[type];
19030547Skarels 	lp->d_nsectors = st->nsect;
19130547Skarels 	lp->d_ntracks = st->ntrak;
19230547Skarels 	lp->d_secpercyl = st->nspc;
19330547Skarels 	lp->d_ncylinders = st->ncyl;
19430547Skarels 	lp->d_secperunit = st->nspc * st->ncyl;
19530547Skarels 	lp->d_npartitions = 8;
19630547Skarels 	for (i = 0; i < 8; i++) {
19730547Skarels 		if (st->off[i] == -1)
19830547Skarels 			lp->d_partitions[i].p_size = 0;
19930547Skarels 		else {
20030547Skarels 			lp->d_partitions[i].p_offset = st->off[i] *
20130547Skarels 			    lp->d_secpercyl;
20230547Skarels 			lp->d_partitions[i].p_size = lp->d_secperunit;
20330547Skarels 		}
20430547Skarels 	}
20534519Skarels 	return (1);
20611133Ssam }
20730547Skarels #endif COMPAT_42
208