xref: /csrg-svn/sys/tahoe/vba/vbavar.h (revision 34406)
1*34406Skarels /*
2*34406Skarels  * Copyright (c) 1988 Regents of the University of California.
3*34406Skarels  * All rights reserved.
4*34406Skarels  *
5*34406Skarels  * Redistribution and use in source and binary forms are permitted
6*34406Skarels  * provided that this notice is preserved and that due credit is given
7*34406Skarels  * to the University of California at Berkeley. The name of the University
8*34406Skarels  * may not be used to endorse or promote products derived from this
9*34406Skarels  * software without specific prior written permission. This software
10*34406Skarels  * is provided ``as is'' without express or implied warranty.
11*34406Skarels  *
12*34406Skarels  *	@(#)vbavar.h	7.1 (Berkeley) 05/21/88
13*34406Skarels  */
1423998Ssam 
1523998Ssam /*
1623998Ssam  * This file contains definitions related to the kernel structures
1725923Ssam  * for dealing with the VERSAbus adapters.
1823998Ssam  *
1925923Ssam  * Each VERSAbus has a vba_hd structure.
2025923Ssam  * Each VERSAbus controller which is not a device has a vba_ctlr structure.
2125923Ssam  * Each VERSAbus device has a vba_device structure.
2223998Ssam  */
2323998Ssam 
2423998Ssam #ifndef LOCORE
2523998Ssam /*
2625857Ssam  * Per-vba structure.
2725857Ssam  */
2825857Ssam struct	vba_hd {
2925857Ssam 	int	vh_lastiv;		/* last interrupt vector assigned */
3025857Ssam };
3125857Ssam 
3225857Ssam /*
3323998Ssam  * Per-controller structure.
3423998Ssam  * (E.g. one for each disk and tape controller, and other things
3523998Ssam  * which use and release buffered data paths.)
3623998Ssam  *
3723998Ssam  * If a controller has devices attached, then there are
3823998Ssam  * cross-referenced vba_drive structures.
3925923Ssam  * This structure is the one which is queued in VERSAbus resource wait,
4025923Ssam  * and saves the information about VERSAbus resources which are used.
4123998Ssam  * The queue of devices waiting to transfer is also attached here.
4223998Ssam  */
4323998Ssam struct vba_ctlr {
4423998Ssam 	struct	vba_driver *um_driver;
4523998Ssam 	short	um_ctlr;	/* controller index in driver */
4623998Ssam 	short	um_vbanum;	/* the vba it is on */
4723998Ssam 	short	um_alive;	/* controller exists */
4823998Ssam 	int	(**um_intr)();	/* interrupt handler(s) */
4923998Ssam 	caddr_t	um_addr;	/* address of device in i/o space */
5025857Ssam 	struct	vba_hd *um_hd;
5123998Ssam /* the driver saves the prototype command here for use in its go routine */
5223998Ssam 	int	um_cmd;		/* communication to dgo() */
5325923Ssam 	int	um_vbinfo;	/* save VERSAbus registers, etc */
5423998Ssam 	struct	buf um_tab;	/* queue of devices for this controller */
5523998Ssam };
5623998Ssam 
5723998Ssam /*
5823998Ssam  * Per ``device'' structure.
5923998Ssam  * (A controller has devices or uses and releases buffered data paths).
6023998Ssam  * (Everything else is a ``device''.)
6123998Ssam  *
6223998Ssam  * If a controller has many drives attached, then there will
6323998Ssam  * be several vba_device structures associated with a single vba_ctlr
6423998Ssam  * structure.
6523998Ssam  *
6623998Ssam  * This structure contains all the information necessary to run
6725923Ssam  * a VERSAbus device.  It also contains information
6825923Ssam  * for slaves of VERSAbus controllers as to which device on the slave
6923998Ssam  * this is.  A flags field here can also be given in the system specification
7025923Ssam  * and is used to tell which tty lines are hard wired or other device
7123998Ssam  * specific parameters.
7223998Ssam  */
7323998Ssam struct vba_device {
7423998Ssam 	struct	vba_driver *ui_driver;
7523998Ssam 	short	ui_unit;	/* unit number on the system */
7623998Ssam 	short	ui_ctlr;	/* mass ctlr number; -1 if none */
7723998Ssam 	short	ui_vbanum;	/* the vba it is on */
7823998Ssam 	short	ui_slave;	/* slave on controller */
7923998Ssam 	int	(**ui_intr)();	/* interrupt handler(s) */
8023998Ssam 	caddr_t	ui_addr;	/* address of device in i/o space */
8123998Ssam 	short	ui_dk;		/* if init 1 set to number for iostat */
8225923Ssam 	long	ui_flags;	/* parameter from system specification */
8323998Ssam 	short	ui_alive;	/* device exists */
8423998Ssam 	short	ui_type;	/* driver specific type information */
8523998Ssam 	caddr_t	ui_physaddr;	/* phys addr, for standalone (dump) code */
8623998Ssam /* this is the forward link in a list of devices on a controller */
8723998Ssam 	struct	vba_device *ui_forw;
8823998Ssam /* if the device is connected to a controller, this is the controller */
8923998Ssam 	struct	vba_ctlr *ui_mi;
9025857Ssam 	struct	vba_hd *ui_hd;
9123998Ssam };
9223998Ssam #endif
9323998Ssam 
9423998Ssam /*
9523998Ssam  * Per-driver structure.
9623998Ssam  *
9725923Ssam  * Each VERSAbus driver defines entries for a set of routines
9823998Ssam  * as well as an array of types which are acceptable to it.
9923998Ssam  * These are used at boot time by the configuration program.
10023998Ssam  */
10123998Ssam struct vba_driver {
10223998Ssam 	int	(*ud_probe)();		/* see if a driver is really there */
10323998Ssam 	int	(*ud_slave)();		/* see if a slave is there */
10423998Ssam 	int	(*ud_attach)();		/* setup driver for a slave */
10523998Ssam 	int	(*ud_dgo)();		/* fill csr/ba to start transfer */
10623998Ssam 	long	*ud_addr;		/* device csr addresses */
10723998Ssam 	char	*ud_dname;		/* name of a device */
10823998Ssam 	struct	vba_device **ud_dinfo;	/* backpointers to vbdinit structs */
10923998Ssam 	char	*ud_mname;		/* name of a controller */
11023998Ssam 	struct	vba_ctlr **ud_minfo;	/* backpointers to vbminit structs */
11123998Ssam };
11223998Ssam 
11330601Skarels /*
11430601Skarels  * Common state for Versabus driver I/O resources,
11530601Skarels  * including memory for intermediate buffer and page map,
11630601Skarels  * allocated by vbainit.
11730601Skarels  */
11830601Skarels struct vb_buf {
11930601Skarels 	/* these fields set up once by vbainit */
12030601Skarels 	int	vb_flags;		/* device parameters */
12130601Skarels 	struct	pte *vb_map;		/* private page entries */
12230601Skarels 	caddr_t	vb_utl;			/* virtual addresses mapped by vb_map */
12330601Skarels 	caddr_t	vb_rawbuf;		/* intermediate buffer */
12430601Skarels 	u_long	vb_physbuf;		/* phys addr of intermediate buffer */
12530718Skarels 	u_long	vb_bufsize;		/* intermediate buffer size */
12630601Skarels 	u_long	vb_maxphys;		/* physical address limit */
12730601Skarels 	/* remaining fields apply to current transfer: */
12830601Skarels 	int	vb_copy;		/* copy to/from intermediate buffer */
12930601Skarels 	int	vb_iskernel;		/* is to/from kernel address space */
13030601Skarels };
13130601Skarels 
13230601Skarels /*
13330601Skarels  * flags to vbainit
13430601Skarels  */
13530601Skarels #define	VB_32BIT	0x00		/* device uses 32-bit addressing */
13630601Skarels #define	VB_24BIT	0x01		/* device uses 24-bit addressing */
13730601Skarels #define	VB_20BIT	0x02		/* device uses 20-bit addressing */
13830601Skarels #define	VB_SCATTER	0x04		/* device does scatter-gather */
13930601Skarels 
14030601Skarels /*
14130601Skarels  * hardware addressing limits
14230601Skarels  */
14330601Skarels #define	VB_MAXADDR20	0x000fffff	/* highest addr for 20-bit */
14430601Skarels #define	VB_MAXADDR24	0x007fffff	/* highest addr for 23/24-bit */
14530601Skarels #define	VB_MAXADDR32	0x3effffff	/* highest addr for 32-bit */
14630601Skarels 
14730601Skarels /*
14830601Skarels  * Statistics on vba operations.
14930601Skarels  */
15030601Skarels struct vbastat {
15130718Skarels 	u_long	k_raw;		/* to/from contiguous kernel DMA buffer */
15230718Skarels 	u_long	u_raw;		/* to/from contiguous user DMA buffer */
15330718Skarels 	u_long	k_copy;		/* copied to/from kernel */
15430718Skarels 	u_long	u_copy;		/* copied to/from user */
15530718Skarels 	u_long	k_sg;		/* scatter-gather to/from kernel */
15630718Skarels 	u_long	u_sg;		/* scatter-gather to/from user */
15730601Skarels };
15830601Skarels 
15923998Ssam #ifndef LOCORE
16023998Ssam #ifdef KERNEL
16123998Ssam /*
16223998Ssam  * VBA related kernel variables
16323998Ssam  */
16425857Ssam int	numvba;					/* number of uba's */
16525857Ssam struct	vba_hd vba_hd[];
16630601Skarels struct	vbastat vbastat;
16723998Ssam 
16823998Ssam /*
16923998Ssam  * Vbminit and vbdinit initialize the mass storage controller and
17023998Ssam  * device tables specifying possible devices.
17123998Ssam  */
17223998Ssam extern	struct	vba_ctlr vbminit[];
17323998Ssam extern	struct	vba_device vbdinit[];
17423998Ssam 
17523998Ssam /*
17625923Ssam  * VERSAbus device address space is mapped by VMEMmap
17725923Ssam  * into virtual address vmem[][].
17823998Ssam  */
17923998Ssam extern	struct pte VMEMmap[];	/* vba device addr pte's */
18030294Ssam extern	caddr_t vmem;		/* vba device addr space */
18130601Skarels u_long	vbasetup();
18223998Ssam #endif KERNEL
18323998Ssam #endif !LOCORE
184