1*30601Skarels /* vbavar.h 1.5 87/03/10 */ 223998Ssam 323998Ssam /* 423998Ssam * This file contains definitions related to the kernel structures 525923Ssam * for dealing with the VERSAbus adapters. 623998Ssam * 725923Ssam * Each VERSAbus has a vba_hd structure. 825923Ssam * Each VERSAbus controller which is not a device has a vba_ctlr structure. 925923Ssam * Each VERSAbus device has a vba_device structure. 1023998Ssam */ 1123998Ssam 1223998Ssam #ifndef LOCORE 1323998Ssam /* 1425857Ssam * Per-vba structure. 1525857Ssam */ 1625857Ssam struct vba_hd { 1725857Ssam int vh_lastiv; /* last interrupt vector assigned */ 1825857Ssam }; 1925857Ssam 2025857Ssam /* 2123998Ssam * Per-controller structure. 2223998Ssam * (E.g. one for each disk and tape controller, and other things 2323998Ssam * which use and release buffered data paths.) 2423998Ssam * 2523998Ssam * If a controller has devices attached, then there are 2623998Ssam * cross-referenced vba_drive structures. 2725923Ssam * This structure is the one which is queued in VERSAbus resource wait, 2825923Ssam * and saves the information about VERSAbus resources which are used. 2923998Ssam * The queue of devices waiting to transfer is also attached here. 3023998Ssam */ 3123998Ssam struct vba_ctlr { 3223998Ssam struct vba_driver *um_driver; 3323998Ssam short um_ctlr; /* controller index in driver */ 3423998Ssam short um_vbanum; /* the vba it is on */ 3523998Ssam short um_alive; /* controller exists */ 3623998Ssam int (**um_intr)(); /* interrupt handler(s) */ 3723998Ssam caddr_t um_addr; /* address of device in i/o space */ 3825857Ssam struct vba_hd *um_hd; 3923998Ssam /* the driver saves the prototype command here for use in its go routine */ 4023998Ssam int um_cmd; /* communication to dgo() */ 4125923Ssam int um_vbinfo; /* save VERSAbus registers, etc */ 4223998Ssam struct buf um_tab; /* queue of devices for this controller */ 4323998Ssam }; 4423998Ssam 4523998Ssam /* 4623998Ssam * Per ``device'' structure. 4723998Ssam * (A controller has devices or uses and releases buffered data paths). 4823998Ssam * (Everything else is a ``device''.) 4923998Ssam * 5023998Ssam * If a controller has many drives attached, then there will 5123998Ssam * be several vba_device structures associated with a single vba_ctlr 5223998Ssam * structure. 5323998Ssam * 5423998Ssam * This structure contains all the information necessary to run 5525923Ssam * a VERSAbus device. It also contains information 5625923Ssam * for slaves of VERSAbus controllers as to which device on the slave 5723998Ssam * this is. A flags field here can also be given in the system specification 5825923Ssam * and is used to tell which tty lines are hard wired or other device 5923998Ssam * specific parameters. 6023998Ssam */ 6123998Ssam struct vba_device { 6223998Ssam struct vba_driver *ui_driver; 6323998Ssam short ui_unit; /* unit number on the system */ 6423998Ssam short ui_ctlr; /* mass ctlr number; -1 if none */ 6523998Ssam short ui_vbanum; /* the vba it is on */ 6623998Ssam short ui_slave; /* slave on controller */ 6723998Ssam int (**ui_intr)(); /* interrupt handler(s) */ 6823998Ssam caddr_t ui_addr; /* address of device in i/o space */ 6923998Ssam short ui_dk; /* if init 1 set to number for iostat */ 7025923Ssam long ui_flags; /* parameter from system specification */ 7123998Ssam short ui_alive; /* device exists */ 7223998Ssam short ui_type; /* driver specific type information */ 7323998Ssam caddr_t ui_physaddr; /* phys addr, for standalone (dump) code */ 7423998Ssam /* this is the forward link in a list of devices on a controller */ 7523998Ssam struct vba_device *ui_forw; 7623998Ssam /* if the device is connected to a controller, this is the controller */ 7723998Ssam struct vba_ctlr *ui_mi; 7825857Ssam struct vba_hd *ui_hd; 7923998Ssam }; 8023998Ssam #endif 8123998Ssam 8223998Ssam /* 8323998Ssam * Per-driver structure. 8423998Ssam * 8525923Ssam * Each VERSAbus driver defines entries for a set of routines 8623998Ssam * as well as an array of types which are acceptable to it. 8723998Ssam * These are used at boot time by the configuration program. 8823998Ssam */ 8923998Ssam struct vba_driver { 9023998Ssam int (*ud_probe)(); /* see if a driver is really there */ 9123998Ssam int (*ud_slave)(); /* see if a slave is there */ 9223998Ssam int (*ud_attach)(); /* setup driver for a slave */ 9323998Ssam int (*ud_dgo)(); /* fill csr/ba to start transfer */ 9423998Ssam long *ud_addr; /* device csr addresses */ 9523998Ssam char *ud_dname; /* name of a device */ 9623998Ssam struct vba_device **ud_dinfo; /* backpointers to vbdinit structs */ 9723998Ssam char *ud_mname; /* name of a controller */ 9823998Ssam struct vba_ctlr **ud_minfo; /* backpointers to vbminit structs */ 9923998Ssam }; 10023998Ssam 101*30601Skarels /* 102*30601Skarels * Common state for Versabus driver I/O resources, 103*30601Skarels * including memory for intermediate buffer and page map, 104*30601Skarels * allocated by vbainit. 105*30601Skarels */ 106*30601Skarels struct vb_buf { 107*30601Skarels /* these fields set up once by vbainit */ 108*30601Skarels int vb_flags; /* device parameters */ 109*30601Skarels struct pte *vb_map; /* private page entries */ 110*30601Skarels caddr_t vb_utl; /* virtual addresses mapped by vb_map */ 111*30601Skarels caddr_t vb_rawbuf; /* intermediate buffer */ 112*30601Skarels u_long vb_physbuf; /* phys addr of intermediate buffer */ 113*30601Skarels u_long vb_maxphys; /* physical address limit */ 114*30601Skarels /* remaining fields apply to current transfer: */ 115*30601Skarels int vb_copy; /* copy to/from intermediate buffer */ 116*30601Skarels int vb_iskernel; /* is to/from kernel address space */ 117*30601Skarels }; 118*30601Skarels 119*30601Skarels /* 120*30601Skarels * flags to vbainit 121*30601Skarels */ 122*30601Skarels #define VB_32BIT 0x00 /* device uses 32-bit addressing */ 123*30601Skarels #define VB_24BIT 0x01 /* device uses 24-bit addressing */ 124*30601Skarels #define VB_20BIT 0x02 /* device uses 20-bit addressing */ 125*30601Skarels #define VB_SCATTER 0x04 /* device does scatter-gather */ 126*30601Skarels 127*30601Skarels /* 128*30601Skarels * hardware addressing limits 129*30601Skarels */ 130*30601Skarels #define VB_MAXADDR20 0x000fffff /* highest addr for 20-bit */ 131*30601Skarels #define VB_MAXADDR24 0x007fffff /* highest addr for 23/24-bit */ 132*30601Skarels #define VB_MAXADDR32 0x3effffff /* highest addr for 32-bit */ 133*30601Skarels 134*30601Skarels /* 135*30601Skarels * Statistics on vba operations. 136*30601Skarels */ 137*30601Skarels struct vbastat { 138*30601Skarels u_long kw_raw; /* wrote from kernel DMA buffer */ 139*30601Skarels u_long uw_raw; /* wrote from user DMA buffer */ 140*30601Skarels u_long kw_copy; /* write copied from kernel */ 141*30601Skarels u_long uw_copy; /* write copied from user */ 142*30601Skarels u_long kr_raw; /* read, purged kernel DMA buffer */ 143*30601Skarels u_long ur_raw; /* invalidated key on user DMA buffer */ 144*30601Skarels u_long kr_copy; /* read copied to kernel */ 145*30601Skarels u_long ur_copy; /* read copied to user & inval'd key */ 146*30601Skarels }; 147*30601Skarels 14823998Ssam #ifndef LOCORE 14923998Ssam #ifdef KERNEL 15023998Ssam /* 15123998Ssam * VBA related kernel variables 15223998Ssam */ 15325857Ssam int numvba; /* number of uba's */ 15425857Ssam struct vba_hd vba_hd[]; 155*30601Skarels struct vbastat vbastat; 15623998Ssam 15723998Ssam /* 15823998Ssam * Vbminit and vbdinit initialize the mass storage controller and 15923998Ssam * device tables specifying possible devices. 16023998Ssam */ 16123998Ssam extern struct vba_ctlr vbminit[]; 16223998Ssam extern struct vba_device vbdinit[]; 16323998Ssam 16423998Ssam /* 16525923Ssam * VERSAbus device address space is mapped by VMEMmap 16625923Ssam * into virtual address vmem[][]. 16723998Ssam */ 16823998Ssam extern struct pte VMEMmap[]; /* vba device addr pte's */ 16930294Ssam extern caddr_t vmem; /* vba device addr space */ 170*30601Skarels u_long vbasetup(); 17123998Ssam #endif KERNEL 17223998Ssam #endif !LOCORE 173