Annotation of Net2/arch/vax/uba/ubavar.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1982, 1986 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  * 1. Redistributions of source code must retain the above copyright
                      9:  *    notice, this list of conditions and the following disclaimer.
                     10:  * 2. Redistributions in binary form must reproduce the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer in the
                     12:  *    documentation and/or other materials provided with the distribution.
                     13:  * 3. All advertising materials mentioning features or use of this software
                     14:  *    must display the following acknowledgement:
                     15:  *     This product includes software developed by the University of
                     16:  *     California, Berkeley and its contributors.
                     17:  * 4. Neither the name of the University nor the names of its contributors
                     18:  *    may be used to endorse or promote products derived from this software
                     19:  *    without specific prior written permission.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31:  * SUCH DAMAGE.
                     32:  *
                     33:  *     @(#)ubavar.h    7.7 (Berkeley) 6/28/90
                     34:  */
                     35: 
                     36: /*
                     37:  * This file contains definitions related to the kernel structures
                     38:  * for dealing with the unibus adapters.
                     39:  *
                     40:  * Each uba has a uba_hd structure.
                     41:  * Each unibus controller which is not a device has a uba_ctlr structure.
                     42:  * Each unibus device has a uba_device structure.
                     43:  */
                     44: 
                     45: #ifndef LOCORE
                     46: /*
                     47:  * Per-uba structure.
                     48:  *
                     49:  * This structure holds the interrupt vector for the uba,
                     50:  * and its address in physical and virtual space.  At boot time
                     51:  * we determine the devices attached to the uba's and their
                     52:  * interrupt vectors, filling in uh_vec.  We free the map
                     53:  * register and bdp resources of the uba into the structures
                     54:  * defined here.
                     55:  *
                     56:  * During normal operation, resources are allocated and returned
                     57:  * to the structures here.  We watch the number of passive releases
                     58:  * on each uba, and if the number is excessive may reset the uba.
                     59:  * 
                     60:  * When uba resources are needed and not available, or if a device
                     61:  * which can tolerate no other uba activity (rk07) gets on the bus,
                     62:  * then device drivers may have to wait to get to the bus and are
                     63:  * queued here.  It is also possible for processes to block in
                     64:  * the unibus driver in resource wait (mrwant, bdpwant); these
                     65:  * wait states are also recorded here.
                     66:  */
                     67: struct uba_hd {
                     68:        int     uh_type;                /* type of adaptor */
                     69:        struct  uba_regs *uh_uba;       /* virt addr of uba adaptor regs */
                     70:        struct  uba_regs *uh_physuba;   /* phys addr of uba adaptor regs */
                     71:        struct  pte *uh_mr;             /* start of page map */
                     72:        int     uh_memsize;             /* size of uba memory, pages */
                     73:        caddr_t uh_mem;                 /* start of uba memory address space */
                     74:        caddr_t uh_iopage;              /* start of uba io page */
                     75:        int     (**uh_vec)();           /* interrupt vector */
                     76:        struct  uba_device *uh_actf;    /* head of queue to transfer */
                     77:        struct  uba_device *uh_actl;    /* tail of queue to transfer */
                     78:        short   uh_mrwant;              /* someone is waiting for map reg */
                     79:        short   uh_bdpwant;             /* someone awaits bdp's */
                     80:        int     uh_bdpfree;             /* free bdp's */
                     81:        int     uh_hangcnt;             /* number of ticks hung */
                     82:        int     uh_zvcnt;               /* number of recent 0 vectors */
                     83:        long    uh_zvtime;              /* time over which zvcnt accumulated */
                     84:        int     uh_zvtotal;             /* total number of 0 vectors */
                     85:        int     uh_errcnt;              /* number of errors */
                     86:        int     uh_lastiv;              /* last free interrupt vector */
                     87:        short   uh_users;               /* transient bdp use count */
                     88:        short   uh_xclu;                /* an rk07 is using this uba! */
                     89:        int     uh_lastmem;             /* limit of any unibus memory */
                     90: #define        UAMSIZ  100
                     91:        struct  map *uh_map;            /* register free map */
                     92: };
                     93: 
                     94: /* given a pointer to uba_regs, find DWBUA registers */
                     95: /* this should be replaced with a union in uba_hd */
                     96: #define        BUA(uba)        ((struct dwbua_regs *)(uba))
                     97: 
                     98: /*
                     99:  * Per-controller structure.
                    100:  * (E.g. one for each disk and tape controller, and other things
                    101:  * which use and release buffered data paths.)
                    102:  *
                    103:  * If a controller has devices attached, then there are
                    104:  * cross-referenced uba_drive structures.
                    105:  * This structure is the one which is queued in unibus resource wait,
                    106:  * and saves the information about unibus resources which are used.
                    107:  * The queue of devices waiting to transfer is also attached here.
                    108:  */
                    109: struct uba_ctlr {
                    110:        struct  uba_driver *um_driver;
                    111:        short   um_ctlr;        /* controller index in driver */
                    112:        short   um_ubanum;      /* the uba it is on */
                    113:        short   um_alive;       /* controller exists */
                    114:        int     (**um_intr)();  /* interrupt handler(s) */
                    115:        caddr_t um_addr;        /* address of device in i/o space */
                    116:        struct  uba_hd *um_hd;
                    117: /* the driver saves the prototype command here for use in its go routine */
                    118:        int     um_cmd;         /* communication to dgo() */
                    119:        int     um_ubinfo;      /* save unibus registers, etc */
                    120:        int     um_bdp;         /* for controllers that hang on to bdp's */
                    121:        struct  buf um_tab;     /* queue of devices for this controller */
                    122: };
                    123: 
                    124: /*
                    125:  * Per ``device'' structure.
                    126:  * (A controller has devices or uses and releases buffered data paths).
                    127:  * (Everything else is a ``device''.)
                    128:  *
                    129:  * If a controller has many drives attached, then there will
                    130:  * be several uba_device structures associated with a single uba_ctlr
                    131:  * structure.
                    132:  *
                    133:  * This structure contains all the information necessary to run
                    134:  * a unibus device such as a dz or a dh.  It also contains information
                    135:  * for slaves of unibus controllers as to which device on the slave
                    136:  * this is.  A flags field here can also be given in the system specification
                    137:  * and is used to tell which dz lines are hard wired or other device
                    138:  * specific parameters.
                    139:  */
                    140: struct uba_device {
                    141:        struct  uba_driver *ui_driver;
                    142:        short   ui_unit;        /* unit number on the system */
                    143:        short   ui_ctlr;        /* mass ctlr number; -1 if none */
                    144:        short   ui_ubanum;      /* the uba it is on */
                    145:        short   ui_slave;       /* slave on controller */
                    146:        int     (**ui_intr)();  /* interrupt handler(s) */
                    147:        caddr_t ui_addr;        /* address of device in i/o space */
                    148:        short   ui_dk;          /* if init 1 set to number for iostat */
                    149:        int     ui_flags;       /* parameter from system specification */
                    150:        short   ui_alive;       /* device exists */
                    151:        short   ui_type;        /* driver specific type information */
                    152:        caddr_t ui_physaddr;    /* phys addr, for standalone (dump) code */
                    153: /* this is the forward link in a list of devices on a controller */
                    154:        struct  uba_device *ui_forw;
                    155: /* if the device is connected to a controller, this is the controller */
                    156:        struct  uba_ctlr *ui_mi;
                    157:        struct  uba_hd *ui_hd;
                    158: };
                    159: 
                    160: /*
                    161:  * Per-driver structure.
                    162:  *
                    163:  * Each unibus driver defines entries for a set of routines
                    164:  * as well as an array of types which are acceptable to it.
                    165:  * These are used at boot time by the configuration program.
                    166:  */
                    167: struct uba_driver {
                    168:        int     (*ud_probe)();          /* see if a driver is really there */
                    169:        int     (*ud_slave)();          /* see if a slave is there */
                    170:        int     (*ud_attach)();         /* setup driver for a slave */
                    171:        int     (*ud_dgo)();            /* fill csr/ba to start transfer */
                    172:        u_short *ud_addr;               /* device csr addresses */
                    173:        char    *ud_dname;              /* name of a device */
                    174:        struct  uba_device **ud_dinfo;  /* backpointers to ubdinit structs */
                    175:        char    *ud_mname;              /* name of a controller */
                    176:        struct  uba_ctlr **ud_minfo;    /* backpointers to ubminit structs */
                    177:        short   ud_xclu;                /* want exclusive use of bdp's */
                    178:        short   ud_keepbdp;             /* hang on to bdp's once allocated */
                    179:        int     (*ud_ubamem)();         /* see if dedicated memory is present */
                    180: };
                    181: #endif
                    182: 
                    183: /*
                    184:  * Flags to UBA map/bdp allocation routines
                    185:  */
                    186: #define        UBA_NEEDBDP     0x01            /* transfer needs a bdp */
                    187: #define        UBA_CANTWAIT    0x02            /* don't block me */
                    188: #define        UBA_NEED16      0x04            /* need 16 bit addresses only */
                    189: #define        UBA_HAVEBDP     0x08            /* use bdp specified in high bits */
                    190: 
                    191: /*
                    192:  * Macros to bust return word from map allocation routines.
                    193:  * SHOULD USE STRUCTURE TO STORE UBA RESOURCE ALLOCATION:
                    194:  */
                    195: #ifdef notyet
                    196: struct ubinfo {
                    197:        long    ub_addr;        /* unibus address: mr + boff */
                    198:        int     ub_nmr;         /* number of registers, 0 if empty */
                    199:        int     ub_bdp;         /* bdp number, 0 if none */
                    200: };
                    201: #define        UBAI_MR(i)      (((i) >> 9) & 0x7ff)    /* starting map register */
                    202: #define        UBAI_BOFF(i)    ((i)&0x1ff)             /* page offset */
                    203: #else
                    204: #define        UBAI_BDP(i)     ((int)(((unsigned)(i)) >> 28))
                    205: #define        BDPMASK         0xf0000000
                    206: #define        UBAI_NMR(i)     ((int)((i) >> 20) & 0xff)       /* max 255 (=127.5K) */
                    207: #define        UBA_MAXNMR      255
                    208: #define        UBAI_MR(i)      ((int)((i) >> 9) & 0x7ff)       /* max 2047 */
                    209: #define        UBA_MAXMR       2047
                    210: #define        UBAI_BOFF(i)    ((int)((i) & 0x1ff))
                    211: #define        UBAI_ADDR(i)    ((int)((i) & 0xfffff))  /* uba addr (boff+mr) */
                    212: #define        UBAI_INFO(off, mr, nmr, bdp) \
                    213:        (((bdp) << 28) | ((nmr) << 20) | ((mr) << 9) | (off))
                    214: #endif
                    215: 
                    216: #ifndef LOCORE
                    217: #ifdef KERNEL
                    218: #define        ubago(ui)       ubaqueue(ui, 0)
                    219: 
                    220: /*
                    221:  * UBA related kernel variables
                    222:  */
                    223: int    numuba;                                 /* number of uba's */
                    224: struct uba_hd uba_hd[];
                    225: 
                    226: /*
                    227:  * Ubminit and ubdinit initialize the mass storage controller and
                    228:  * device tables specifying possible devices.
                    229:  */
                    230: extern struct  uba_ctlr ubminit[];
                    231: extern struct  uba_device ubdinit[];
                    232: 
                    233: /*
                    234:  * UNIBUS device address space is mapped by UMEMmap
                    235:  * into virtual address umem[][].
                    236:  * The IO page is mapped to the last 8K of each.
                    237:  * This should be enlarged for the Q22 bus.
                    238:  */
                    239: extern struct pte UMEMmap[][512];      /* uba device addr pte's */
                    240: extern char umem[][512*NBPG];          /* uba device addr space */
                    241: 
                    242: /*
                    243:  * Since some VAXen vector their unibus interrupts
                    244:  * just adjacent to the system control block, we must
                    245:  * allocate space there when running on ``any'' cpu.  This space is
                    246:  * used for the vectors for all ubas.
                    247:  */
                    248: extern int (*UNIvec[][128])();                 /* unibus vec for ubas */
                    249: extern int (*eUNIvec)();                       /* end of unibus vec */
                    250: 
                    251: #if defined(VAX780) || defined(VAX8600)
                    252: /*
                    253:  * On DW780's, we must set the scb vectors for the nexus of the
                    254:  * UNIbus adaptors to vector to locore unibus adaptor interrupt dispatchers
                    255:  * which make 780's look like the other VAXen.
                    256:  */
                    257: extern Xua0int(), Xua1int(), Xua2int(), Xua3int();
                    258: #endif VAX780
                    259: #endif KERNEL
                    260: #endif !LOCORE

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.