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 634866Sbostic * provided that the above copyright notice and this paragraph are 734866Sbostic * duplicated in all such forms and that any documentation, 834866Sbostic * advertising materials, and other materials related to such 934866Sbostic * distribution and use acknowledge that the software was developed 1034866Sbostic * by the University of California, Berkeley. The name of the 1134866Sbostic * University may not be used to endorse or promote products derived 1234866Sbostic * from this software without specific prior written permission. 1334866Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1434866Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1534866Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1634406Skarels * 17*37119Skarels * @(#)vbavar.h 7.3 (Berkeley) 03/09/89 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 /* 146*37119Skarels * hardware memory-addressing limits: highest physical address 147*37119Skarels * that each address length can use for main memory access. 14830601Skarels */ 14930601Skarels #define VB_MAXADDR20 0x000fffff /* highest addr for 20-bit */ 150*37119Skarels #define VB_MAXADDR24 0x00efffff /* highest addr for 23/24-bit */ 15130601Skarels #define VB_MAXADDR32 0x3effffff /* highest addr for 32-bit */ 15230601Skarels 15330601Skarels /* 15430601Skarels * Statistics on vba operations. 15530601Skarels */ 15630601Skarels struct vbastat { 15730718Skarels u_long k_raw; /* to/from contiguous kernel DMA buffer */ 15830718Skarels u_long u_raw; /* to/from contiguous user DMA buffer */ 15930718Skarels u_long k_copy; /* copied to/from kernel */ 16030718Skarels u_long u_copy; /* copied to/from user */ 16130718Skarels u_long k_sg; /* scatter-gather to/from kernel */ 16230718Skarels u_long u_sg; /* scatter-gather to/from user */ 16330601Skarels }; 16430601Skarels 16523998Ssam #ifndef LOCORE 16623998Ssam #ifdef KERNEL 16723998Ssam /* 16823998Ssam * VBA related kernel variables 16923998Ssam */ 17025857Ssam int numvba; /* number of uba's */ 17125857Ssam struct vba_hd vba_hd[]; 17230601Skarels struct vbastat vbastat; 17323998Ssam 17423998Ssam /* 17523998Ssam * Vbminit and vbdinit initialize the mass storage controller and 17623998Ssam * device tables specifying possible devices. 17723998Ssam */ 17823998Ssam extern struct vba_ctlr vbminit[]; 17923998Ssam extern struct vba_device vbdinit[]; 18023998Ssam 18123998Ssam /* 18225923Ssam * VERSAbus device address space is mapped by VMEMmap 18325923Ssam * into virtual address vmem[][]. 18423998Ssam */ 18523998Ssam extern struct pte VMEMmap[]; /* vba device addr pte's */ 18630294Ssam extern caddr_t vmem; /* vba device addr space */ 18730601Skarels u_long vbasetup(); 18823998Ssam #endif KERNEL 18923998Ssam #endif !LOCORE 190