xref: /original-bsd/sys/vax/mba/mbavar.h (revision 889e8222)
1 /*-
2  * Copyright (c) 1982, 1986 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  *
7  *	@(#)mbavar.h	7.2 (Berkeley) 05/08/91
8  */
9 
10 /*
11  * This file contains definitions related to the kernel structures
12  * for dealing with the massbus adapters.
13  *
14  * Each mba has a mba_hd structure.
15  * Each massbus device has a mba_device structure.
16  * Each massbus slave has a mba_slave structure.
17  *
18  * At boot time we prowl the structures and fill in the pointers
19  * for devices which we find.
20  */
21 
22 /*
23  * Per-mba structure.
24  *
25  * The initialization routine uses the information in the mbdinit table
26  * to initialize the what is attached to each massbus slot information.
27  * It counts the number of devices on each mba (to see if bothering to
28  * search/seek is appropriate).
29  *
30  * During normal operation, the devices attached to the mba which wish
31  * to transfer are queued on the mh_act? links.
32  */
33 struct	mba_hd {
34 	short	mh_active;		/* set if mba is active */
35 	short	mh_ndrive;		/* number of devices, to avoid seeks */
36 	struct	mba_regs *mh_mba;	/* virt addr of mba */
37 	struct	mba_regs *mh_physmba;	/* phys addr of mba */
38 	struct	mba_device *mh_mbip[8];	/* what is attached to each dev */
39 	struct	mba_device *mh_actf;	/* head of queue to transfer */
40 	struct	mba_device *mh_actl;	/* tail of queue to transfer */
41 };
42 
43 /*
44  * Per-device structure
45  * (one for each RM/RP disk, and one for each tape formatter).
46  *
47  * This structure is used by the device driver as its argument
48  * to the massbus driver, and by the massbus driver to locate
49  * the device driver for a particular massbus slot.
50  *
51  * The device drivers hang ready buffers on this structure,
52  * and the massbus driver will start i/o on the first such buffer
53  * when appropriate.
54  */
55 struct	mba_device {
56 	struct	mba_driver *mi_driver;
57 	short	mi_unit;	/* unit number to the system */
58 	short	mi_mbanum;	/* the mba it is on */
59 	short	mi_drive;	/* controller on mba */
60 	short	mi_dk;		/* driver number for iostat */
61 	short	mi_alive;	/* device exists */
62 	short	mi_type;	/* driver specific unit type */
63 	struct	buf mi_tab;	/* head of queue for this device */
64 	struct	mba_device *mi_forw;
65 /* we could compute these every time, but hereby save time */
66 	struct	mba_regs *mi_mba;
67 	struct	mba_drv *mi_drv;
68 	struct	mba_hd *mi_hd;
69 };
70 
71 #define	b_bdone	b_bufsize		/* redefinition for mi_tab XXX */
72 
73 /*
74  * Tape formatter slaves are specified by
75  * the following information which is used
76  * at boot time to initialize the tape driver
77  * internal tables.
78  */
79 struct	mba_slave {
80 	struct	mba_driver *ms_driver;
81 	short	ms_ctlr;		/* which of several formatters */
82 	short	ms_unit;		/* which unit to system */
83 	short	ms_slave;		/* which slave to formatter */
84 	short	ms_alive;
85 };
86 
87 /*
88  * Per device-type structure.
89  *
90  * Each massbus driver defines entries for a set of routines used
91  * by the massbus driver, as well as an array of types which are
92  * acceptable to it.
93  */
94 struct mba_driver {
95 	int	(*md_attach)();		/* attach a device */
96 	int	(*md_slave)();		/* attach a slave */
97 	int	(*md_ustart)();		/* unit start routine */
98 	int	(*md_start)();		/* setup a data transfer */
99 	int	(*md_dtint)();		/* data transfer complete */
100 	int	(*md_ndint)();		/* non-data transfer interrupt */
101 	short	*md_type;		/* array of drive type codes */
102 	char	*md_dname, *md_sname;	/* device, slave names */
103 	struct	mba_device **md_info;	/* backpointers to mbinit structs */
104 };
105 
106 /*
107  * Possible return values from unit start routines.
108  */
109 #define	MBU_NEXT	0		/* skip to next operation */
110 #define	MBU_BUSY	1		/* dual port busy; wait for intr */
111 #define	MBU_STARTED	2		/* non-data transfer started */
112 #define	MBU_DODATA	3		/* data transfer ready; start mba */
113 
114 /*
115  * Possible return values from data transfer interrupt handling routines
116  */
117 #define	MBD_DONE	0		/* data transfer complete */
118 #define	MBD_RETRY	1		/* error occurred, please retry */
119 #define	MBD_RESTARTED	2		/* driver restarted i/o itself */
120 #define	MBD_REPOSITION	3		/* driver started unit, not transfer */
121 
122 /*
123  * Possible return values from non-data-transfer interrupt handling routines
124  */
125 #define	MBN_DONE	0		/* non-data transfer complete */
126 #define	MBN_RETRY	1		/* failed; retry the operation */
127 #define	MBN_SKIP	2		/* don't do anything */
128 
129 /*
130  * Clear attention status for specified device.
131  */
132 #define	mbclrattn(mi)	((mi)->mi_mba->mba_drv[0].mbd_as = 1 << (mi)->mi_drive)
133 
134 /*
135  * Kernel definitions related to mba.
136  */
137 #ifdef KERNEL
138 int	nummba;
139 #if NMBA > 0
140 struct	mba_hd mba_hd[NMBA];
141 extern	Xmba0int(), Xmba1int(), Xmba2int(), Xmba3int();
142 
143 extern	struct	mba_device mbdinit[];
144 extern	struct	mba_slave mbsinit[];
145 #endif
146 #endif
147