134406Skarels /* 234406Skarels * Copyright (c) 1988 Regents of the University of California. 334406Skarels * All rights reserved. 434406Skarels * 5*44534Sbostic * %sccs.include.redist.c% 634406Skarels * 7*44534Sbostic * @(#)vbavar.h 7.5 (Berkeley) 06/28/90 834406Skarels */ 923998Ssam 1023998Ssam /* 1123998Ssam * This file contains definitions related to the kernel structures 1225923Ssam * for dealing with the VERSAbus adapters. 1323998Ssam * 1425923Ssam * Each VERSAbus has a vba_hd structure. 1525923Ssam * Each VERSAbus controller which is not a device has a vba_ctlr structure. 1625923Ssam * Each VERSAbus device has a vba_device structure. 1723998Ssam */ 1823998Ssam 1923998Ssam #ifndef LOCORE 2023998Ssam /* 2125857Ssam * Per-vba structure. 2225857Ssam */ 2325857Ssam struct vba_hd { 2425857Ssam int vh_lastiv; /* last interrupt vector assigned */ 2525857Ssam }; 2625857Ssam 2725857Ssam /* 2823998Ssam * Per-controller structure. 2923998Ssam * (E.g. one for each disk and tape controller, and other things 3023998Ssam * which use and release buffered data paths.) 3123998Ssam * 3223998Ssam * If a controller has devices attached, then there are 3323998Ssam * cross-referenced vba_drive structures. 3425923Ssam * This structure is the one which is queued in VERSAbus resource wait, 3525923Ssam * and saves the information about VERSAbus resources which are used. 3623998Ssam * The queue of devices waiting to transfer is also attached here. 3723998Ssam */ 3823998Ssam struct vba_ctlr { 3923998Ssam struct vba_driver *um_driver; 4023998Ssam short um_ctlr; /* controller index in driver */ 4123998Ssam short um_vbanum; /* the vba it is on */ 4223998Ssam short um_alive; /* controller exists */ 4323998Ssam int (**um_intr)(); /* interrupt handler(s) */ 4423998Ssam caddr_t um_addr; /* address of device in i/o space */ 4525857Ssam struct vba_hd *um_hd; 4623998Ssam /* the driver saves the prototype command here for use in its go routine */ 4723998Ssam int um_cmd; /* communication to dgo() */ 4825923Ssam int um_vbinfo; /* save VERSAbus registers, etc */ 4923998Ssam struct buf um_tab; /* queue of devices for this controller */ 5023998Ssam }; 5123998Ssam 5223998Ssam /* 5323998Ssam * Per ``device'' structure. 5423998Ssam * (A controller has devices or uses and releases buffered data paths). 5523998Ssam * (Everything else is a ``device''.) 5623998Ssam * 5723998Ssam * If a controller has many drives attached, then there will 5823998Ssam * be several vba_device structures associated with a single vba_ctlr 5923998Ssam * structure. 6023998Ssam * 6123998Ssam * This structure contains all the information necessary to run 6225923Ssam * a VERSAbus device. It also contains information 6325923Ssam * for slaves of VERSAbus controllers as to which device on the slave 6423998Ssam * this is. A flags field here can also be given in the system specification 6525923Ssam * and is used to tell which tty lines are hard wired or other device 6623998Ssam * specific parameters. 6723998Ssam */ 6823998Ssam struct vba_device { 6923998Ssam struct vba_driver *ui_driver; 7023998Ssam short ui_unit; /* unit number on the system */ 7123998Ssam short ui_ctlr; /* mass ctlr number; -1 if none */ 7223998Ssam short ui_vbanum; /* the vba it is on */ 7323998Ssam short ui_slave; /* slave on controller */ 7423998Ssam int (**ui_intr)(); /* interrupt handler(s) */ 7523998Ssam caddr_t ui_addr; /* address of device in i/o space */ 7623998Ssam short ui_dk; /* if init 1 set to number for iostat */ 7725923Ssam long ui_flags; /* parameter from system specification */ 7823998Ssam short ui_alive; /* device exists */ 7923998Ssam short ui_type; /* driver specific type information */ 8023998Ssam caddr_t ui_physaddr; /* phys addr, for standalone (dump) code */ 8123998Ssam /* this is the forward link in a list of devices on a controller */ 8223998Ssam struct vba_device *ui_forw; 8323998Ssam /* if the device is connected to a controller, this is the controller */ 8423998Ssam struct vba_ctlr *ui_mi; 8525857Ssam struct vba_hd *ui_hd; 8623998Ssam }; 8723998Ssam #endif 8823998Ssam 8923998Ssam /* 9023998Ssam * Per-driver structure. 9123998Ssam * 9225923Ssam * Each VERSAbus driver defines entries for a set of routines 9323998Ssam * as well as an array of types which are acceptable to it. 9423998Ssam * These are used at boot time by the configuration program. 9523998Ssam */ 9623998Ssam struct vba_driver { 9723998Ssam int (*ud_probe)(); /* see if a driver is really there */ 9823998Ssam int (*ud_slave)(); /* see if a slave is there */ 9923998Ssam int (*ud_attach)(); /* setup driver for a slave */ 10023998Ssam int (*ud_dgo)(); /* fill csr/ba to start transfer */ 10123998Ssam long *ud_addr; /* device csr addresses */ 10223998Ssam char *ud_dname; /* name of a device */ 10323998Ssam struct vba_device **ud_dinfo; /* backpointers to vbdinit structs */ 10423998Ssam char *ud_mname; /* name of a controller */ 10523998Ssam struct vba_ctlr **ud_minfo; /* backpointers to vbminit structs */ 10623998Ssam }; 10723998Ssam 10830601Skarels /* 10930601Skarels * Common state for Versabus driver I/O resources, 11030601Skarels * including memory for intermediate buffer and page map, 11130601Skarels * allocated by vbainit. 11230601Skarels */ 11330601Skarels struct vb_buf { 11430601Skarels /* these fields set up once by vbainit */ 11530601Skarels int vb_flags; /* device parameters */ 11630601Skarels struct pte *vb_map; /* private page entries */ 11730601Skarels caddr_t vb_utl; /* virtual addresses mapped by vb_map */ 11830601Skarels caddr_t vb_rawbuf; /* intermediate buffer */ 11930601Skarels u_long vb_physbuf; /* phys addr of intermediate buffer */ 12030718Skarels u_long vb_bufsize; /* intermediate buffer size */ 12130601Skarels u_long vb_maxphys; /* physical address limit */ 12230601Skarels /* remaining fields apply to current transfer: */ 12330601Skarels int vb_copy; /* copy to/from intermediate buffer */ 12430601Skarels int vb_iskernel; /* is to/from kernel address space */ 12530601Skarels }; 12630601Skarels 12730601Skarels /* 12830601Skarels * flags to vbainit 12930601Skarels */ 13030601Skarels #define VB_32BIT 0x00 /* device uses 32-bit addressing */ 13130601Skarels #define VB_24BIT 0x01 /* device uses 24-bit addressing */ 13230601Skarels #define VB_20BIT 0x02 /* device uses 20-bit addressing */ 13330601Skarels #define VB_SCATTER 0x04 /* device does scatter-gather */ 13430601Skarels 13530601Skarels /* 13637119Skarels * hardware memory-addressing limits: highest physical address 13737119Skarels * that each address length can use for main memory access. 13830601Skarels */ 13930601Skarels #define VB_MAXADDR20 0x000fffff /* highest addr for 20-bit */ 14037119Skarels #define VB_MAXADDR24 0x00efffff /* highest addr for 23/24-bit */ 14130601Skarels #define VB_MAXADDR32 0x3effffff /* highest addr for 32-bit */ 14230601Skarels 14330601Skarels /* 14430601Skarels * Statistics on vba operations. 14530601Skarels */ 14630601Skarels struct vbastat { 14730718Skarels u_long k_raw; /* to/from contiguous kernel DMA buffer */ 14830718Skarels u_long u_raw; /* to/from contiguous user DMA buffer */ 14930718Skarels u_long k_copy; /* copied to/from kernel */ 15030718Skarels u_long u_copy; /* copied to/from user */ 15130718Skarels u_long k_sg; /* scatter-gather to/from kernel */ 15230718Skarels u_long u_sg; /* scatter-gather to/from user */ 15330601Skarels }; 15430601Skarels 15523998Ssam #ifndef LOCORE 15623998Ssam #ifdef KERNEL 15723998Ssam /* 15823998Ssam * VBA related kernel variables 15923998Ssam */ 16025857Ssam int numvba; /* number of uba's */ 16125857Ssam struct vba_hd vba_hd[]; 16230601Skarels struct vbastat vbastat; 16323998Ssam 16423998Ssam /* 16523998Ssam * Vbminit and vbdinit initialize the mass storage controller and 16623998Ssam * device tables specifying possible devices. 16723998Ssam */ 16823998Ssam extern struct vba_ctlr vbminit[]; 16923998Ssam extern struct vba_device vbdinit[]; 17023998Ssam 17123998Ssam /* 17225923Ssam * VERSAbus device address space is mapped by VMEMmap 17340216Skarels * into virtual address vmem[]. 17423998Ssam */ 17523998Ssam extern struct pte VMEMmap[]; /* vba device addr pte's */ 17640216Skarels extern char vmem[]; /* vba device addr space */ 17730601Skarels u_long vbasetup(); 17823998Ssam #endif KERNEL 17923998Ssam #endif !LOCORE 180