134406Skarels /* 234406Skarels * Copyright (c) 1988 Regents of the University of California. 334406Skarels * All rights reserved. 434406Skarels * 534406Skarels * Redistribution and use in source and binary forms are permitted 6*34866Sbostic * provided that the above copyright notice and this paragraph are 7*34866Sbostic * duplicated in all such forms and that any documentation, 8*34866Sbostic * advertising materials, and other materials related to such 9*34866Sbostic * distribution and use acknowledge that the software was developed 10*34866Sbostic * by the University of California, Berkeley. The name of the 11*34866Sbostic * University may not be used to endorse or promote products derived 12*34866Sbostic * from this software without specific prior written permission. 13*34866Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*34866Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*34866Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1634406Skarels * 17*34866Sbostic * @(#)vbavar.h 7.2 (Berkeley) 06/29/88 1834406Skarels */ 1923998Ssam 2023998Ssam /* 2123998Ssam * This file contains definitions related to the kernel structures 2225923Ssam * for dealing with the VERSAbus adapters. 2323998Ssam * 2425923Ssam * Each VERSAbus has a vba_hd structure. 2525923Ssam * Each VERSAbus controller which is not a device has a vba_ctlr structure. 2625923Ssam * Each VERSAbus device has a vba_device structure. 2723998Ssam */ 2823998Ssam 2923998Ssam #ifndef LOCORE 3023998Ssam /* 3125857Ssam * Per-vba structure. 3225857Ssam */ 3325857Ssam struct vba_hd { 3425857Ssam int vh_lastiv; /* last interrupt vector assigned */ 3525857Ssam }; 3625857Ssam 3725857Ssam /* 3823998Ssam * Per-controller structure. 3923998Ssam * (E.g. one for each disk and tape controller, and other things 4023998Ssam * which use and release buffered data paths.) 4123998Ssam * 4223998Ssam * If a controller has devices attached, then there are 4323998Ssam * cross-referenced vba_drive structures. 4425923Ssam * This structure is the one which is queued in VERSAbus resource wait, 4525923Ssam * and saves the information about VERSAbus resources which are used. 4623998Ssam * The queue of devices waiting to transfer is also attached here. 4723998Ssam */ 4823998Ssam struct vba_ctlr { 4923998Ssam struct vba_driver *um_driver; 5023998Ssam short um_ctlr; /* controller index in driver */ 5123998Ssam short um_vbanum; /* the vba it is on */ 5223998Ssam short um_alive; /* controller exists */ 5323998Ssam int (**um_intr)(); /* interrupt handler(s) */ 5423998Ssam caddr_t um_addr; /* address of device in i/o space */ 5525857Ssam struct vba_hd *um_hd; 5623998Ssam /* the driver saves the prototype command here for use in its go routine */ 5723998Ssam int um_cmd; /* communication to dgo() */ 5825923Ssam int um_vbinfo; /* save VERSAbus registers, etc */ 5923998Ssam struct buf um_tab; /* queue of devices for this controller */ 6023998Ssam }; 6123998Ssam 6223998Ssam /* 6323998Ssam * Per ``device'' structure. 6423998Ssam * (A controller has devices or uses and releases buffered data paths). 6523998Ssam * (Everything else is a ``device''.) 6623998Ssam * 6723998Ssam * If a controller has many drives attached, then there will 6823998Ssam * be several vba_device structures associated with a single vba_ctlr 6923998Ssam * structure. 7023998Ssam * 7123998Ssam * This structure contains all the information necessary to run 7225923Ssam * a VERSAbus device. It also contains information 7325923Ssam * for slaves of VERSAbus controllers as to which device on the slave 7423998Ssam * this is. A flags field here can also be given in the system specification 7525923Ssam * and is used to tell which tty lines are hard wired or other device 7623998Ssam * specific parameters. 7723998Ssam */ 7823998Ssam struct vba_device { 7923998Ssam struct vba_driver *ui_driver; 8023998Ssam short ui_unit; /* unit number on the system */ 8123998Ssam short ui_ctlr; /* mass ctlr number; -1 if none */ 8223998Ssam short ui_vbanum; /* the vba it is on */ 8323998Ssam short ui_slave; /* slave on controller */ 8423998Ssam int (**ui_intr)(); /* interrupt handler(s) */ 8523998Ssam caddr_t ui_addr; /* address of device in i/o space */ 8623998Ssam short ui_dk; /* if init 1 set to number for iostat */ 8725923Ssam long ui_flags; /* parameter from system specification */ 8823998Ssam short ui_alive; /* device exists */ 8923998Ssam short ui_type; /* driver specific type information */ 9023998Ssam caddr_t ui_physaddr; /* phys addr, for standalone (dump) code */ 9123998Ssam /* this is the forward link in a list of devices on a controller */ 9223998Ssam struct vba_device *ui_forw; 9323998Ssam /* if the device is connected to a controller, this is the controller */ 9423998Ssam struct vba_ctlr *ui_mi; 9525857Ssam struct vba_hd *ui_hd; 9623998Ssam }; 9723998Ssam #endif 9823998Ssam 9923998Ssam /* 10023998Ssam * Per-driver structure. 10123998Ssam * 10225923Ssam * Each VERSAbus driver defines entries for a set of routines 10323998Ssam * as well as an array of types which are acceptable to it. 10423998Ssam * These are used at boot time by the configuration program. 10523998Ssam */ 10623998Ssam struct vba_driver { 10723998Ssam int (*ud_probe)(); /* see if a driver is really there */ 10823998Ssam int (*ud_slave)(); /* see if a slave is there */ 10923998Ssam int (*ud_attach)(); /* setup driver for a slave */ 11023998Ssam int (*ud_dgo)(); /* fill csr/ba to start transfer */ 11123998Ssam long *ud_addr; /* device csr addresses */ 11223998Ssam char *ud_dname; /* name of a device */ 11323998Ssam struct vba_device **ud_dinfo; /* backpointers to vbdinit structs */ 11423998Ssam char *ud_mname; /* name of a controller */ 11523998Ssam struct vba_ctlr **ud_minfo; /* backpointers to vbminit structs */ 11623998Ssam }; 11723998Ssam 11830601Skarels /* 11930601Skarels * Common state for Versabus driver I/O resources, 12030601Skarels * including memory for intermediate buffer and page map, 12130601Skarels * allocated by vbainit. 12230601Skarels */ 12330601Skarels struct vb_buf { 12430601Skarels /* these fields set up once by vbainit */ 12530601Skarels int vb_flags; /* device parameters */ 12630601Skarels struct pte *vb_map; /* private page entries */ 12730601Skarels caddr_t vb_utl; /* virtual addresses mapped by vb_map */ 12830601Skarels caddr_t vb_rawbuf; /* intermediate buffer */ 12930601Skarels u_long vb_physbuf; /* phys addr of intermediate buffer */ 13030718Skarels u_long vb_bufsize; /* intermediate buffer size */ 13130601Skarels u_long vb_maxphys; /* physical address limit */ 13230601Skarels /* remaining fields apply to current transfer: */ 13330601Skarels int vb_copy; /* copy to/from intermediate buffer */ 13430601Skarels int vb_iskernel; /* is to/from kernel address space */ 13530601Skarels }; 13630601Skarels 13730601Skarels /* 13830601Skarels * flags to vbainit 13930601Skarels */ 14030601Skarels #define VB_32BIT 0x00 /* device uses 32-bit addressing */ 14130601Skarels #define VB_24BIT 0x01 /* device uses 24-bit addressing */ 14230601Skarels #define VB_20BIT 0x02 /* device uses 20-bit addressing */ 14330601Skarels #define VB_SCATTER 0x04 /* device does scatter-gather */ 14430601Skarels 14530601Skarels /* 14630601Skarels * hardware addressing limits 14730601Skarels */ 14830601Skarels #define VB_MAXADDR20 0x000fffff /* highest addr for 20-bit */ 14930601Skarels #define VB_MAXADDR24 0x007fffff /* highest addr for 23/24-bit */ 15030601Skarels #define VB_MAXADDR32 0x3effffff /* highest addr for 32-bit */ 15130601Skarels 15230601Skarels /* 15330601Skarels * Statistics on vba operations. 15430601Skarels */ 15530601Skarels struct vbastat { 15630718Skarels u_long k_raw; /* to/from contiguous kernel DMA buffer */ 15730718Skarels u_long u_raw; /* to/from contiguous user DMA buffer */ 15830718Skarels u_long k_copy; /* copied to/from kernel */ 15930718Skarels u_long u_copy; /* copied to/from user */ 16030718Skarels u_long k_sg; /* scatter-gather to/from kernel */ 16130718Skarels u_long u_sg; /* scatter-gather to/from user */ 16230601Skarels }; 16330601Skarels 16423998Ssam #ifndef LOCORE 16523998Ssam #ifdef KERNEL 16623998Ssam /* 16723998Ssam * VBA related kernel variables 16823998Ssam */ 16925857Ssam int numvba; /* number of uba's */ 17025857Ssam struct vba_hd vba_hd[]; 17130601Skarels struct vbastat vbastat; 17223998Ssam 17323998Ssam /* 17423998Ssam * Vbminit and vbdinit initialize the mass storage controller and 17523998Ssam * device tables specifying possible devices. 17623998Ssam */ 17723998Ssam extern struct vba_ctlr vbminit[]; 17823998Ssam extern struct vba_device vbdinit[]; 17923998Ssam 18023998Ssam /* 18125923Ssam * VERSAbus device address space is mapped by VMEMmap 18225923Ssam * into virtual address vmem[][]. 18323998Ssam */ 18423998Ssam extern struct pte VMEMmap[]; /* vba device addr pte's */ 18530294Ssam extern caddr_t vmem; /* vba device addr space */ 18630601Skarels u_long vbasetup(); 18723998Ssam #endif KERNEL 18823998Ssam #endif !LOCORE 189