xref: /original-bsd/sys/hp300/stand/autoconf.c (revision 7c3db03c)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: autoconf.c 1.9 89/10/07$
13  *
14  *	@(#)autoconf.c	7.4 (Berkeley) 12/16/90
15  */
16 
17 #include "samachdep.h"
18 #include "sys/param.h"
19 
20 #include "../dev/device.h"
21 #include "../dev/grfvar.h"
22 
23 struct hp_hw sc_table[MAX_CTLR];
24 
25 extern int internalhpib;
26 
27 #if 0
28 #include "rominfo.h"
29 printrominfo()
30 {
31 	struct rominfo *rp = (struct rominfo *)ROMADDR;
32 	printf("boottype %x, name %s, lowram %x, sysflag %x\n",
33 	       rp->boottype, rp->name, rp->lowram, rp->sysflag&0xff);
34 	printf("rambase %x, ndrives %x, sysflag2 %x, msus %x\n",
35 	       rp->rambase, rp->ndrives, rp->sysflag2&0xff, rp->msus);
36 }
37 #endif
38 
39 configure()
40 {
41 	find_devs();
42 	cninit();
43 #if 0
44 	printrominfo();
45 #endif
46 	hpibinit();
47 	scsiinit();
48 }
49 
50 sctoaddr(sc)
51 	int sc;
52 {
53 	if (sc == -1)
54 		return(GRFIADDR);
55 	if (sc == 7 && internalhpib)
56 		return(internalhpib);
57 	if (sc < 32)
58 		return(0x600000+(0x10000*sc));
59 	if (sc >= 132 && sc < 134)
60 		return(0x1000000+((sc-132)*0x400000));
61 	return(sc);
62 }
63 
64 /*
65  * Probe all DIO select codes (0 - 32), the internal display address,.
66  * and DIO-II select codes 132 (hack) and 133 (hack).
67  *
68  * Note that we only care about displays, SCSIs and HP-IBs.
69  */
70 find_devs()
71 {
72 	u_char *id_reg;
73 	register short sc;
74 	register int addr;
75 	register struct hp_hw *hw;
76 
77 	hw = sc_table;
78 	for (sc = -1; sc < 32; sc++) {
79 		addr = sctoaddr(sc);
80 		if (badaddr(addr))
81 			continue;
82 
83 		id_reg = (u_char *) addr;
84 		hw->hw_addr = (char *) addr;
85 		hw->hw_id = id_reg[1] & 0xff;
86 		hw->hw_sc = sc;
87 
88 		/*
89 		 * Not all internal HP-IBs respond rationally to id requests
90 		 * so we just go by the "internal HPIB" indicator in SYSFLAG.
91 		 */
92 		if (sc == 7 && internalhpib) {
93 			hw->hw_type = HPIB;
94 			hw++;
95 			continue;
96 		}
97 
98 		switch (hw->hw_id) {
99 		case 5:		/* 98642A */
100 		case 128+5:	/* 98642A remote */
101 			hw->hw_type = COMMDCM;
102 			break;
103 		case 8:		/* 98625B */
104 		case 128:	/* 98624A */
105 			hw->hw_type = HPIB;
106 			break;
107 		case 57:	/* Displays */
108 			hw->hw_type = BITMAP;
109 			hw->hw_id2 = id_reg[0x15];
110 			switch (hw->hw_id2) {
111 			case 4:	/* renaissance */
112 			case 8: /* davinci */
113 				sc++;		/* occupy 2 select codes */
114 				break;
115 			}
116 			break;
117 		case 9:
118 			hw->hw_type = KEYBOARD;
119 			break;
120 		case 7:
121 		case 39:
122 		case 71:
123 		case 103:
124 			hw->hw_type = SCSI;
125 			break;
126 		default:	/* who cares */
127 			hw->hw_type = MISC;
128 			break;
129 		}
130 		hw++;
131 	}
132 	/*
133 	 * Look for displays in DIO-II space
134 	 */
135 	for (sc = 132; sc < 134; sc++) {
136 		addr = sctoaddr(sc);
137 		if (badaddr(addr))
138 			continue;
139 
140 		id_reg = (u_char *) addr;
141 		hw->hw_addr = (char *) addr;
142 		hw->hw_id = id_reg[1] & 0xff;
143 		hw->hw_sc = sc;
144 
145 		switch (hw->hw_id) {
146 		case 57:	/* Displays */
147 			hw->hw_type = BITMAP;
148 			hw->hw_id2 = id_reg[0x15];
149 			switch (hw->hw_id2) {
150 			case 4:	/* renaissance */
151 			case 8: /* davinci */
152 				sc++;		/* occupy 2 select codes */
153 				break;
154 			}
155 			break;
156 		default:	/* who cares */
157 			hw->hw_type = MISC;
158 			break;
159 		}
160 		hw++;
161 	}
162 }
163