xref: /csrg-svn/sys/vax/mba/mbavar.h (revision 2562)
1 /*	mbavar.h	4.7	81/02/19	*/
2 
3 /*
4  * VAX Massbus adapter registers
5  */
6 
7 struct mba_regs
8 {
9 	int	mba_csr;		/* configuration register */
10 	int	mba_cr;			/* control register */
11 	int	mba_sr;			/* status register */
12 	int	mba_var;		/* virtual address register */
13 	int	mba_bcr;		/* byte count register */
14 	int	mba_dr;
15 	int	mba_pad1[250];
16 	struct mba_drv {		/* per drive registers */
17 		int	mbd_cs1;		/* control status */
18 		int	mbd_ds;			/* drive status */
19 		int	mbd_er1;		/* error register */
20 		int	mbd_mr1;		/* maintenance register */
21 		int	mbd_as;			/* attention status */
22 		int	mbd_da;			/* desired address (disks) */
23 #define	mbd_fc	mbd_da				/* frame count (tapes) */
24 		int	mbd_dt;			/* drive type */
25 		int	mbd_la;			/* look ahead (disks) */
26 #define	mbd_ck	mbd_la				/* ??? (tapes) */
27 		int	mbd_sn;			/* serial number */
28 		int	mbd_of;			/* ??? */
29 #define	mbd_tc	mbd_of				/* ??? */
30 		int	mbd_fill[22];
31 	} mba_drv[8];
32 	struct	pte mba_map[256];	/* io space virtual map */
33 	int	mba_pad2[256*5];	/* to size of a nexus */
34 };
35 
36 /*
37  * Bits in mba_cr
38  */
39 #define	MBAINIT		0x1		/* init mba */
40 #define	MBAIE		0x4		/* enable mba interrupts */
41 
42 /*
43  * Bits in mba_sr
44  */
45 #define	MBS_DTBUSY	0x80000000	/* data transfer busy */
46 #define	MBS_NRCONF	0x40000000	/* no response confirmation */
47 #define	MBS_CRD		0x20000000	/* corrected read data */
48 #define	MBS_CBHUNG	0x00800000	/* control bus hung */
49 #define	MBS_PGE		0x00080000	/* programming error */
50 #define	MBS_NED		0x00040000	/* non-existant drive */
51 #define	MBS_MCPE	0x00020000	/* massbus control parity error */
52 #define	MBS_ATTN	0x00010000	/* attention from massbus */
53 #define	MBS_SPE		0x00004000	/* silo parity error */
54 #define	MBS_DTCMP	0x00002000	/* data transfer completed */
55 #define	MBS_DTABT	0x00001000	/* data transfer aborted */
56 #define	MBS_DLT		0x00000800	/* data late */
57 #define	MBS_WCKUP	0x00000400	/* write check upper */
58 #define	MBS_WCKLWR	0x00000200	/* write check lower */
59 #define	MBS_MXF		0x00000100	/* miss transfer error */
60 #define	MBS_MBEXC	0x00000080	/* massbus exception */
61 #define	MBS_MDPE	0x00000040	/* massbus data parity error */
62 #define	MBS_MAPPE	0x00000020	/* page frame map parity error */
63 #define	MBS_INVMAP	0x00000010	/* invalid map */
64 #define	MBS_ERRCONF	0x00000008	/* error confirmation */
65 #define	MBS_RDS		0x00000004	/* read data substitute */
66 #define	MBS_ISTIMO	0x00000002	/* interface sequence timeout */
67 #define	MBS_RDTIMO	0x00000001	/* read data timeout */
68 
69 #define MBAEBITS	(~(MBS_DTBUSY|MBS_CRD|MBS_ATTN|MBS_DTCMP))
70 
71 /*
72  * Commands for mbd_cs1
73  */
74 #define	MBD_WCOM	0x30
75 #define	MBD_RCOM	0x38
76 #define	MBD_GO		0x1
77 
78 /*
79  * Bits in mbd_ds.
80  */
81 #define	MBD_DRY		0x80		/* drive ready */
82 #define	MBD_MOL		0x1000		/* medium on line */
83 #define	MBD_DPR		0x100		/* drive present */
84 #define	MBD_ERR		0x4000		/* error in drive */
85 
86 /*
87  * Bits in mbd_dt
88  */
89 #define	MBDT_NSA	0x8000		/* not sector addressible */
90 #define	MBDT_TAP	0x4000		/* is a tape */
91 #define	MBDT_MOH	0x2000		/* moving head */
92 #define	MBDT_7CH	0x1000		/* 7 channel */
93 #define	MBDT_DRQ	0x800		/* drive request required */
94 #define	MBDT_SPR	0x400		/* slave present */
95 
96 #define	MBDT_TYPE	0x1ff
97 #define	MBDT_MASK	(MBDT_NSA|MBDT_TAP|MBDT_TYPE)
98 
99 /* type codes for disk drives */
100 #define	MBDT_RP04	020
101 #define	MBDT_RP05	021
102 #define	MBDT_RP06	022
103 #define	MBDT_RP07	042
104 #define	MBDT_RM03	024
105 #define	MBDT_RM05	027
106 #define	MBDT_RM80	026
107 
108 /* type codes for tape drives */
109 #define	MBDT_TM03	050
110 #define	MBDT_TE16	051
111 #define	MBDT_TU45	052
112 #define	MBDT_TU77	054
113 #define	MBDT_TU78	0140		/* can't handle these (yet) */
114 
115 /*
116  * Each driver has an array of pointers to these structures, one for
117  * each device it is willing to handle.  At bootstrap time, the
118  * driver tables are filled in;
119  */
120 struct	mba_info {
121 	struct	mba_driver *mi_driver;
122 	short	mi_name;	/* two character generic name */
123 	short	mi_unit;	/* unit number to the system */
124 	short	mi_mbanum;	/* the mba it is on */
125 	short	mi_drive;	/* controller on mba */
126 	short	mi_slave;	/* slave to controller (TM03/TU16) */
127 	short	mi_dk;		/* driver number for iostat */
128 	short	mi_alive;	/* device exists */
129 	short	mi_type;	/* driver specific unit type */
130 	struct	buf mi_tab;	/* head of queue for this device */
131 	struct	mba_info *mi_forw;
132 /* we could compute these every time, but hereby save time */
133 	struct	mba_regs *mi_mba;
134 	struct	mba_drv *mi_drv;
135 	struct	mba_hd *mi_hd;
136 };
137 
138 /*
139  * The initialization routine uses the information in the mbinit table
140  * to initialize the drive type routines in the drivers and the
141  * mbahd array summarizing which devices are hooked to which massbus slots.
142  */
143 struct	mba_hd {
144 	short	mh_active;
145 	short	mh_flags;
146 	struct	mba_regs *mh_mba;	/* virt addr of mba */
147 	struct	mba_regs *mh_physmba;	/* phys addr of mba */
148 	struct	mba_info *mh_mbip[8];	/* what is attached */
149 	struct	mba_info *mh_actf;	/* head of queue to transfer */
150 	struct	mba_info *mh_actl;	/* tail of queue to transfer */
151 } mba_hd[4];
152 /*
153  * Values for flags; normally MH_NOSEEK will be set when there is
154  * only a single drive on an massbus.
155  */
156 #define	MH_NOSEEK	1
157 #define	MH_NOSEARCH	2
158 
159 /*
160  * Each massbus driver defines entries for a set of routines
161  * as well as an array of types which are acceptable to it.
162  */
163 struct mba_driver {
164 	int	(*md_dkinit)();		/* setup dk info (mspw) */
165 	int	(*md_ustart)();		/* unit start routine */
166 	int	(*md_start)();		/* setup a data transfer */
167 	int	(*md_dtint)();		/* data transfer complete */
168 	int	(*md_ndint)();		/* non-data transfer interrupt */
169 	short	*md_type;		/* array of drive type codes */
170 	struct	mba_info **md_info;	/* backpointers to mbinit structs */
171 };
172 
173 /*
174  * Possible return values from unit start routines.
175  */
176 #define	MBU_NEXT	0		/* skip to next operation */
177 #define	MBU_BUSY	1		/* dual port busy; wait for intr */
178 #define	MBU_STARTED	2		/* non-data transfer started */
179 #define	MBU_DODATA	3		/* data transfer ready; start mba */
180 
181 /*
182  * Possible return values from data transfer interrupt handling routines
183  */
184 #define	MBD_DONE	0		/* data transfer complete */
185 #define	MBD_RETRY	1		/* error occurred, please retry */
186 #define	MBD_RESTARTED	2		/* driver restarted i/o itself */
187 
188 /*
189  * Possible return values from non-data-transfer interrupt handling routines
190  */
191 #define	MBN_DONE	0		/* non-data transfer complete */
192 #define	MBN_RETRY	1		/* failed; retry the operation */
193 
194 /*
195  * Clear attention status for specified drive.
196  */
197 #define	mbclrattn(mi)	((mi)->mi_mba->mba_drv[0].mbd_as = 1 << (mi)->mi_drive)
198 
199 /*
200  * Kernel definitions related to mba.
201  */
202 #ifdef KERNEL
203 extern	Xmba0int(), Xmba1int(), Xmba2int(), Xmba3int();
204 extern	struct	mba_info mbinit[];	/* blanks for filling mba_info */
205 int	nummba;
206 #endif
207