xref: /csrg-svn/sys/vax/mba/mbavar.h (revision 49439)
1*49439Sbostic /*-
2*49439Sbostic  * Copyright (c) 1982, 1986 The Regents of the University of California.
3*49439Sbostic  * All rights reserved.
423314Smckusick  *
5*49439Sbostic  * %sccs.include.proprietary.c%
6*49439Sbostic  *
7*49439Sbostic  *	@(#)mbavar.h	7.2 (Berkeley) 05/08/91
823314Smckusick  */
960Sbill 
1060Sbill /*
113066Swnj  * This file contains definitions related to the kernel structures
123066Swnj  * for dealing with the massbus adapters.
133066Swnj  *
143066Swnj  * Each mba has a mba_hd structure.
153066Swnj  * Each massbus device has a mba_device structure.
163066Swnj  * Each massbus slave has a mba_slave structure.
173066Swnj  *
183066Swnj  * At boot time we prowl the structures and fill in the pointers
193066Swnj  * for devices which we find.
2060Sbill  */
2160Sbill 
222332Swnj /*
233066Swnj  * Per-mba structure.
243066Swnj  *
253066Swnj  * The initialization routine uses the information in the mbdinit table
263066Swnj  * to initialize the what is attached to each massbus slot information.
273066Swnj  * It counts the number of devices on each mba (to see if bothering to
283066Swnj  * search/seek is appropriate).
293066Swnj  *
303066Swnj  * During normal operation, the devices attached to the mba which wish
313066Swnj  * to transfer are queued on the mh_act? links.
322332Swnj  */
333066Swnj struct	mba_hd {
343066Swnj 	short	mh_active;		/* set if mba is active */
353066Swnj 	short	mh_ndrive;		/* number of devices, to avoid seeks */
363066Swnj 	struct	mba_regs *mh_mba;	/* virt addr of mba */
373066Swnj 	struct	mba_regs *mh_physmba;	/* phys addr of mba */
383066Swnj 	struct	mba_device *mh_mbip[8];	/* what is attached to each dev */
393066Swnj 	struct	mba_device *mh_actf;	/* head of queue to transfer */
403066Swnj 	struct	mba_device *mh_actl;	/* tail of queue to transfer */
413066Swnj };
422388Swnj 
432388Swnj /*
443066Swnj  * Per-device structure
453066Swnj  * (one for each RM/RP disk, and one for each tape formatter).
463066Swnj  *
473066Swnj  * This structure is used by the device driver as its argument
483066Swnj  * to the massbus driver, and by the massbus driver to locate
493066Swnj  * the device driver for a particular massbus slot.
503066Swnj  *
513066Swnj  * The device drivers hang ready buffers on this structure,
523066Swnj  * and the massbus driver will start i/o on the first such buffer
533066Swnj  * when appropriate.
542388Swnj  */
553066Swnj struct	mba_device {
562388Swnj 	struct	mba_driver *mi_driver;
572388Swnj 	short	mi_unit;	/* unit number to the system */
582388Swnj 	short	mi_mbanum;	/* the mba it is on */
592388Swnj 	short	mi_drive;	/* controller on mba */
602547Swnj 	short	mi_dk;		/* driver number for iostat */
612388Swnj 	short	mi_alive;	/* device exists */
622388Swnj 	short	mi_type;	/* driver specific unit type */
632388Swnj 	struct	buf mi_tab;	/* head of queue for this device */
643066Swnj 	struct	mba_device *mi_forw;
652388Swnj /* we could compute these every time, but hereby save time */
662388Swnj 	struct	mba_regs *mi_mba;
672388Swnj 	struct	mba_drv *mi_drv;
682388Swnj 	struct	mba_hd *mi_hd;
692388Swnj };
702332Swnj 
7126040Skarels #define	b_bdone	b_bufsize		/* redefinition for mi_tab XXX */
7226040Skarels 
732388Swnj /*
743066Swnj  * Tape formatter slaves are specified by
753066Swnj  * the following information which is used
763066Swnj  * at boot time to initialize the tape driver
773066Swnj  * internal tables.
782388Swnj  */
793066Swnj struct	mba_slave {
803066Swnj 	struct	mba_driver *ms_driver;
813066Swnj 	short	ms_ctlr;		/* which of several formatters */
823066Swnj 	short	ms_unit;		/* which unit to system */
833066Swnj 	short	ms_slave;		/* which slave to formatter */
843066Swnj 	short	ms_alive;
852736Swnj };
862332Swnj 
872388Swnj /*
883066Swnj  * Per device-type structure.
893066Swnj  *
903066Swnj  * Each massbus driver defines entries for a set of routines used
913066Swnj  * by the massbus driver, as well as an array of types which are
923066Swnj  * acceptable to it.
932388Swnj  */
942388Swnj struct mba_driver {
953066Swnj 	int	(*md_attach)();		/* attach a device */
963066Swnj 	int	(*md_slave)();		/* attach a slave */
972388Swnj 	int	(*md_ustart)();		/* unit start routine */
982388Swnj 	int	(*md_start)();		/* setup a data transfer */
992388Swnj 	int	(*md_dtint)();		/* data transfer complete */
1002388Swnj 	int	(*md_ndint)();		/* non-data transfer interrupt */
1012388Swnj 	short	*md_type;		/* array of drive type codes */
1023066Swnj 	char	*md_dname, *md_sname;	/* device, slave names */
1033066Swnj 	struct	mba_device **md_info;	/* backpointers to mbinit structs */
10460Sbill };
10560Sbill 
1062388Swnj /*
1072388Swnj  * Possible return values from unit start routines.
1082388Swnj  */
1092388Swnj #define	MBU_NEXT	0		/* skip to next operation */
1102388Swnj #define	MBU_BUSY	1		/* dual port busy; wait for intr */
1112388Swnj #define	MBU_STARTED	2		/* non-data transfer started */
1122388Swnj #define	MBU_DODATA	3		/* data transfer ready; start mba */
11360Sbill 
1142388Swnj /*
1152388Swnj  * Possible return values from data transfer interrupt handling routines
1162388Swnj  */
1172388Swnj #define	MBD_DONE	0		/* data transfer complete */
1182388Swnj #define	MBD_RETRY	1		/* error occurred, please retry */
1192388Swnj #define	MBD_RESTARTED	2		/* driver restarted i/o itself */
12025200Skarels #define	MBD_REPOSITION	3		/* driver started unit, not transfer */
12160Sbill 
1222388Swnj /*
1232388Swnj  * Possible return values from non-data-transfer interrupt handling routines
1242388Swnj  */
1252388Swnj #define	MBN_DONE	0		/* non-data transfer complete */
1262388Swnj #define	MBN_RETRY	1		/* failed; retry the operation */
1273066Swnj #define	MBN_SKIP	2		/* don't do anything */
12860Sbill 
1292388Swnj /*
1303066Swnj  * Clear attention status for specified device.
1312388Swnj  */
1322388Swnj #define	mbclrattn(mi)	((mi)->mi_mba->mba_drv[0].mbd_as = 1 << (mi)->mi_drive)
1332547Swnj 
1342547Swnj /*
1352547Swnj  * Kernel definitions related to mba.
1362547Swnj  */
1372547Swnj #ifdef KERNEL
1383491Sroot int	nummba;
1392727Swnj #if NMBA > 0
1402736Swnj struct	mba_hd mba_hd[NMBA];
1412547Swnj extern	Xmba0int(), Xmba1int(), Xmba2int(), Xmba3int();
1423066Swnj 
1433066Swnj extern	struct	mba_device mbdinit[];
1443066Swnj extern	struct	mba_slave mbsinit[];
1452547Swnj #endif
1462727Swnj #endif
147