xref: /csrg-svn/sys/vax/mba/mbavar.h (revision 26040)
123314Smckusick /*
223314Smckusick  * Copyright (c) 1982 Regents of the University of California.
323314Smckusick  * All rights reserved.  The Berkeley software License Agreement
423314Smckusick  * specifies the terms and conditions for redistribution.
523314Smckusick  *
6*26040Skarels  *	@(#)mbavar.h	6.4 (Berkeley) 02/02/86
723314Smckusick  */
860Sbill 
960Sbill /*
103066Swnj  * This file contains definitions related to the kernel structures
113066Swnj  * for dealing with the massbus adapters.
123066Swnj  *
133066Swnj  * Each mba has a mba_hd structure.
143066Swnj  * Each massbus device has a mba_device structure.
153066Swnj  * Each massbus slave has a mba_slave structure.
163066Swnj  *
173066Swnj  * At boot time we prowl the structures and fill in the pointers
183066Swnj  * for devices which we find.
1960Sbill  */
2060Sbill 
212332Swnj /*
223066Swnj  * Per-mba structure.
233066Swnj  *
243066Swnj  * The initialization routine uses the information in the mbdinit table
253066Swnj  * to initialize the what is attached to each massbus slot information.
263066Swnj  * It counts the number of devices on each mba (to see if bothering to
273066Swnj  * search/seek is appropriate).
283066Swnj  *
293066Swnj  * During normal operation, the devices attached to the mba which wish
303066Swnj  * to transfer are queued on the mh_act? links.
312332Swnj  */
323066Swnj struct	mba_hd {
333066Swnj 	short	mh_active;		/* set if mba is active */
343066Swnj 	short	mh_ndrive;		/* number of devices, to avoid seeks */
353066Swnj 	struct	mba_regs *mh_mba;	/* virt addr of mba */
363066Swnj 	struct	mba_regs *mh_physmba;	/* phys addr of mba */
373066Swnj 	struct	mba_device *mh_mbip[8];	/* what is attached to each dev */
383066Swnj 	struct	mba_device *mh_actf;	/* head of queue to transfer */
393066Swnj 	struct	mba_device *mh_actl;	/* tail of queue to transfer */
403066Swnj };
412388Swnj 
422388Swnj /*
433066Swnj  * Per-device structure
443066Swnj  * (one for each RM/RP disk, and one for each tape formatter).
453066Swnj  *
463066Swnj  * This structure is used by the device driver as its argument
473066Swnj  * to the massbus driver, and by the massbus driver to locate
483066Swnj  * the device driver for a particular massbus slot.
493066Swnj  *
503066Swnj  * The device drivers hang ready buffers on this structure,
513066Swnj  * and the massbus driver will start i/o on the first such buffer
523066Swnj  * when appropriate.
532388Swnj  */
543066Swnj struct	mba_device {
552388Swnj 	struct	mba_driver *mi_driver;
562388Swnj 	short	mi_unit;	/* unit number to the system */
572388Swnj 	short	mi_mbanum;	/* the mba it is on */
582388Swnj 	short	mi_drive;	/* controller on mba */
592547Swnj 	short	mi_dk;		/* driver number for iostat */
602388Swnj 	short	mi_alive;	/* device exists */
612388Swnj 	short	mi_type;	/* driver specific unit type */
622388Swnj 	struct	buf mi_tab;	/* head of queue for this device */
633066Swnj 	struct	mba_device *mi_forw;
642388Swnj /* we could compute these every time, but hereby save time */
652388Swnj 	struct	mba_regs *mi_mba;
662388Swnj 	struct	mba_drv *mi_drv;
672388Swnj 	struct	mba_hd *mi_hd;
682388Swnj };
692332Swnj 
70*26040Skarels #define	b_bdone	b_bufsize		/* redefinition for mi_tab XXX */
71*26040Skarels 
722388Swnj /*
733066Swnj  * Tape formatter slaves are specified by
743066Swnj  * the following information which is used
753066Swnj  * at boot time to initialize the tape driver
763066Swnj  * internal tables.
772388Swnj  */
783066Swnj struct	mba_slave {
793066Swnj 	struct	mba_driver *ms_driver;
803066Swnj 	short	ms_ctlr;		/* which of several formatters */
813066Swnj 	short	ms_unit;		/* which unit to system */
823066Swnj 	short	ms_slave;		/* which slave to formatter */
833066Swnj 	short	ms_alive;
842736Swnj };
852332Swnj 
862388Swnj /*
873066Swnj  * Per device-type structure.
883066Swnj  *
893066Swnj  * Each massbus driver defines entries for a set of routines used
903066Swnj  * by the massbus driver, as well as an array of types which are
913066Swnj  * acceptable to it.
922388Swnj  */
932388Swnj struct mba_driver {
943066Swnj 	int	(*md_attach)();		/* attach a device */
953066Swnj 	int	(*md_slave)();		/* attach a slave */
962388Swnj 	int	(*md_ustart)();		/* unit start routine */
972388Swnj 	int	(*md_start)();		/* setup a data transfer */
982388Swnj 	int	(*md_dtint)();		/* data transfer complete */
992388Swnj 	int	(*md_ndint)();		/* non-data transfer interrupt */
1002388Swnj 	short	*md_type;		/* array of drive type codes */
1013066Swnj 	char	*md_dname, *md_sname;	/* device, slave names */
1023066Swnj 	struct	mba_device **md_info;	/* backpointers to mbinit structs */
10360Sbill };
10460Sbill 
1052388Swnj /*
1062388Swnj  * Possible return values from unit start routines.
1072388Swnj  */
1082388Swnj #define	MBU_NEXT	0		/* skip to next operation */
1092388Swnj #define	MBU_BUSY	1		/* dual port busy; wait for intr */
1102388Swnj #define	MBU_STARTED	2		/* non-data transfer started */
1112388Swnj #define	MBU_DODATA	3		/* data transfer ready; start mba */
11260Sbill 
1132388Swnj /*
1142388Swnj  * Possible return values from data transfer interrupt handling routines
1152388Swnj  */
1162388Swnj #define	MBD_DONE	0		/* data transfer complete */
1172388Swnj #define	MBD_RETRY	1		/* error occurred, please retry */
1182388Swnj #define	MBD_RESTARTED	2		/* driver restarted i/o itself */
11925200Skarels #define	MBD_REPOSITION	3		/* driver started unit, not transfer */
12060Sbill 
1212388Swnj /*
1222388Swnj  * Possible return values from non-data-transfer interrupt handling routines
1232388Swnj  */
1242388Swnj #define	MBN_DONE	0		/* non-data transfer complete */
1252388Swnj #define	MBN_RETRY	1		/* failed; retry the operation */
1263066Swnj #define	MBN_SKIP	2		/* don't do anything */
12760Sbill 
1282388Swnj /*
1293066Swnj  * Clear attention status for specified device.
1302388Swnj  */
1312388Swnj #define	mbclrattn(mi)	((mi)->mi_mba->mba_drv[0].mbd_as = 1 << (mi)->mi_drive)
1322547Swnj 
1332547Swnj /*
1342547Swnj  * Kernel definitions related to mba.
1352547Swnj  */
1362547Swnj #ifdef KERNEL
1373491Sroot int	nummba;
1382727Swnj #if NMBA > 0
1392736Swnj struct	mba_hd mba_hd[NMBA];
1402547Swnj extern	Xmba0int(), Xmba1int(), Xmba2int(), Xmba3int();
1413066Swnj 
1423066Swnj extern	struct	mba_device mbdinit[];
1433066Swnj extern	struct	mba_slave mbsinit[];
1442547Swnj #endif
1452727Swnj #endif
146