xref: /original-bsd/sys/hp300/stand/autoconf.c (revision 2e5c0888)
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.1 (Berkeley) 05/08/90
15  */
16 
17 #include "samachdep.h"
18 #include "param.h"
19 
20 #include "../hpdev/device.h"
21 #include "../hpdev/grfvar.h"
22 
23 struct hp_hw sc_table[MAX_CTLR];
24 
25 configure()
26 {
27 	find_devs();
28 	cninit();
29 	hpibinit();
30 	scsiinit();
31 }
32 
33 sctoaddr(sc)
34 	int sc;
35 {
36 	extern int internalhpib;
37 
38 	if (sc == -2)
39 		return(0x1000000);
40 	if (sc == -1)
41 		return(GRFIADDR);
42 	if (sc == 7)
43 		return(internalhpib);
44 	if (sc < 32)
45 		return(0x600000+(0x10000*sc));
46 	return(sc);
47 }
48 
49 /*
50  * Probe all select codes (0 - 32) and internal display address.
51  * Note that we only care about displays, SCSIs and HP-IBs.
52  */
53 find_devs()
54 {
55 	u_char *id_reg;
56 	register short sc;
57 	register int addr;
58 	register struct hp_hw *hw;
59 
60 	hw = sc_table;
61 	for (sc = -2; sc < 32; sc++) {
62 		addr = sctoaddr(sc);
63 		if (badaddr(addr))
64 			continue;
65 
66 		id_reg = (u_char *) addr;
67 		hw->hw_addr = (char *) addr;
68 		hw->hw_id = id_reg[1] & 0xff;
69 		hw->hw_sc = sc;
70 
71 		switch (hw->hw_id) {
72 		case 8:		/* 98625B */
73 		case 128:	/* 98624A */
74 			hw->hw_type = HPIB;
75 			break;
76 		case 57:	/* Displays */
77 			hw->hw_type = BITMAP;
78 			hw->hw_id2 = id_reg[0x15];
79 			switch (hw->hw_id2) {
80 			case 4:	/* renaissance */
81 			case 8: /* davinci */
82 				sc++;		/* occupy 2 select codes */
83 				break;
84 			}
85 			break;
86 		case 9:
87 			hw->hw_type = KEYBOARD;
88 			break;
89 		case 7:
90 		case 39:
91 		case 71:
92 		case 103:
93 			hw->hw_type = SCSI;
94 			break;
95 		default:	/* who cares */
96 			hw->hw_type = MISC;
97 			break;
98 		}
99 		hw++;
100 	}
101 }
102