xref: /csrg-svn/sys/vax/mba/mbavar.h (revision 23314)
1*23314Smckusick /*
2*23314Smckusick  * Copyright (c) 1982 Regents of the University of California.
3*23314Smckusick  * All rights reserved.  The Berkeley software License Agreement
4*23314Smckusick  * specifies the terms and conditions for redistribution.
5*23314Smckusick  *
6*23314Smckusick  *	@(#)mbavar.h	6.2 (Berkeley) 06/08/85
7*23314Smckusick  */
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 
702388Swnj /*
713066Swnj  * Tape formatter slaves are specified by
723066Swnj  * the following information which is used
733066Swnj  * at boot time to initialize the tape driver
743066Swnj  * internal tables.
752388Swnj  */
763066Swnj struct	mba_slave {
773066Swnj 	struct	mba_driver *ms_driver;
783066Swnj 	short	ms_ctlr;		/* which of several formatters */
793066Swnj 	short	ms_unit;		/* which unit to system */
803066Swnj 	short	ms_slave;		/* which slave to formatter */
813066Swnj 	short	ms_alive;
822736Swnj };
832332Swnj 
842388Swnj /*
853066Swnj  * Per device-type structure.
863066Swnj  *
873066Swnj  * Each massbus driver defines entries for a set of routines used
883066Swnj  * by the massbus driver, as well as an array of types which are
893066Swnj  * acceptable to it.
902388Swnj  */
912388Swnj struct mba_driver {
923066Swnj 	int	(*md_attach)();		/* attach a device */
933066Swnj 	int	(*md_slave)();		/* attach a slave */
942388Swnj 	int	(*md_ustart)();		/* unit start routine */
952388Swnj 	int	(*md_start)();		/* setup a data transfer */
962388Swnj 	int	(*md_dtint)();		/* data transfer complete */
972388Swnj 	int	(*md_ndint)();		/* non-data transfer interrupt */
982388Swnj 	short	*md_type;		/* array of drive type codes */
993066Swnj 	char	*md_dname, *md_sname;	/* device, slave names */
1003066Swnj 	struct	mba_device **md_info;	/* backpointers to mbinit structs */
10160Sbill };
10260Sbill 
1032388Swnj /*
1042388Swnj  * Possible return values from unit start routines.
1052388Swnj  */
1062388Swnj #define	MBU_NEXT	0		/* skip to next operation */
1072388Swnj #define	MBU_BUSY	1		/* dual port busy; wait for intr */
1082388Swnj #define	MBU_STARTED	2		/* non-data transfer started */
1092388Swnj #define	MBU_DODATA	3		/* data transfer ready; start mba */
11060Sbill 
1112388Swnj /*
1122388Swnj  * Possible return values from data transfer interrupt handling routines
1132388Swnj  */
1142388Swnj #define	MBD_DONE	0		/* data transfer complete */
1152388Swnj #define	MBD_RETRY	1		/* error occurred, please retry */
1162388Swnj #define	MBD_RESTARTED	2		/* driver restarted i/o itself */
11760Sbill 
1182388Swnj /*
1192388Swnj  * Possible return values from non-data-transfer interrupt handling routines
1202388Swnj  */
1212388Swnj #define	MBN_DONE	0		/* non-data transfer complete */
1222388Swnj #define	MBN_RETRY	1		/* failed; retry the operation */
1233066Swnj #define	MBN_SKIP	2		/* don't do anything */
12460Sbill 
1252388Swnj /*
1263066Swnj  * Clear attention status for specified device.
1272388Swnj  */
1282388Swnj #define	mbclrattn(mi)	((mi)->mi_mba->mba_drv[0].mbd_as = 1 << (mi)->mi_drive)
1292547Swnj 
1302547Swnj /*
1312547Swnj  * Kernel definitions related to mba.
1322547Swnj  */
1332547Swnj #ifdef KERNEL
1343491Sroot int	nummba;
1352727Swnj #if NMBA > 0
1362736Swnj struct	mba_hd mba_hd[NMBA];
1372547Swnj extern	Xmba0int(), Xmba1int(), Xmba2int(), Xmba3int();
1383066Swnj 
1393066Swnj extern	struct	mba_device mbdinit[];
1403066Swnj extern	struct	mba_slave mbsinit[];
1412547Swnj #endif
1422727Swnj #endif
143