1*30718Skarels /* vbavar.h 1.6 87/04/01 */ 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 10130601Skarels /* 10230601Skarels * Common state for Versabus driver I/O resources, 10330601Skarels * including memory for intermediate buffer and page map, 10430601Skarels * allocated by vbainit. 10530601Skarels */ 10630601Skarels struct vb_buf { 10730601Skarels /* these fields set up once by vbainit */ 10830601Skarels int vb_flags; /* device parameters */ 10930601Skarels struct pte *vb_map; /* private page entries */ 11030601Skarels caddr_t vb_utl; /* virtual addresses mapped by vb_map */ 11130601Skarels caddr_t vb_rawbuf; /* intermediate buffer */ 11230601Skarels u_long vb_physbuf; /* phys addr of intermediate buffer */ 113*30718Skarels u_long vb_bufsize; /* intermediate buffer size */ 11430601Skarels u_long vb_maxphys; /* physical address limit */ 11530601Skarels /* remaining fields apply to current transfer: */ 11630601Skarels int vb_copy; /* copy to/from intermediate buffer */ 11730601Skarels int vb_iskernel; /* is to/from kernel address space */ 11830601Skarels }; 11930601Skarels 12030601Skarels /* 12130601Skarels * flags to vbainit 12230601Skarels */ 12330601Skarels #define VB_32BIT 0x00 /* device uses 32-bit addressing */ 12430601Skarels #define VB_24BIT 0x01 /* device uses 24-bit addressing */ 12530601Skarels #define VB_20BIT 0x02 /* device uses 20-bit addressing */ 12630601Skarels #define VB_SCATTER 0x04 /* device does scatter-gather */ 12730601Skarels 12830601Skarels /* 12930601Skarels * hardware addressing limits 13030601Skarels */ 13130601Skarels #define VB_MAXADDR20 0x000fffff /* highest addr for 20-bit */ 13230601Skarels #define VB_MAXADDR24 0x007fffff /* highest addr for 23/24-bit */ 13330601Skarels #define VB_MAXADDR32 0x3effffff /* highest addr for 32-bit */ 13430601Skarels 13530601Skarels /* 13630601Skarels * Statistics on vba operations. 13730601Skarels */ 13830601Skarels struct vbastat { 139*30718Skarels u_long k_raw; /* to/from contiguous kernel DMA buffer */ 140*30718Skarels u_long u_raw; /* to/from contiguous user DMA buffer */ 141*30718Skarels u_long k_copy; /* copied to/from kernel */ 142*30718Skarels u_long u_copy; /* copied to/from user */ 143*30718Skarels u_long k_sg; /* scatter-gather to/from kernel */ 144*30718Skarels u_long u_sg; /* scatter-gather to/from user */ 14530601Skarels }; 14630601Skarels 14723998Ssam #ifndef LOCORE 14823998Ssam #ifdef KERNEL 14923998Ssam /* 15023998Ssam * VBA related kernel variables 15123998Ssam */ 15225857Ssam int numvba; /* number of uba's */ 15325857Ssam struct vba_hd vba_hd[]; 15430601Skarels struct vbastat vbastat; 15523998Ssam 15623998Ssam /* 15723998Ssam * Vbminit and vbdinit initialize the mass storage controller and 15823998Ssam * device tables specifying possible devices. 15923998Ssam */ 16023998Ssam extern struct vba_ctlr vbminit[]; 16123998Ssam extern struct vba_device vbdinit[]; 16223998Ssam 16323998Ssam /* 16425923Ssam * VERSAbus device address space is mapped by VMEMmap 16525923Ssam * into virtual address vmem[][]. 16623998Ssam */ 16723998Ssam extern struct pte VMEMmap[]; /* vba device addr pte's */ 16830294Ssam extern caddr_t vmem; /* vba device addr space */ 16930601Skarels u_long vbasetup(); 17023998Ssam #endif KERNEL 17123998Ssam #endif !LOCORE 172