| 1 | /* ubavar.h 4.19 81/08/31 */ |
| 2 | |
| 3 | /* |
| 4 | * This file contains definitions related to the kernel structures |
| 5 | * for dealing with the unibus adapters. |
| 6 | * |
| 7 | * Each uba has a uba_hd structure. |
| 8 | * Each unibus controller which is not a device has a uba_ctlr structure. |
| 9 | * Each unibus device has a uba_device structure. |
| 10 | */ |
| 11 | |
| 12 | #ifndef LOCORE |
| 13 | /* |
| 14 | * Per-uba structure. |
| 15 | * |
| 16 | * This structure holds the interrupt vector for the uba, |
| 17 | * and its address in physical and virtual space. At boot time |
| 18 | * we determine the devices attached to the uba's and their |
| 19 | * interrupt vectors, filling in uh_vec. We free the map |
| 20 | * register and bdp resources of the uba into the structures |
| 21 | * defined here. |
| 22 | * |
| 23 | * During normal operation, resources are allocated and returned |
| 24 | * to the structures here. We watch the number of passive releases |
| 25 | * on each uba, and if the number is excessive may reset the uba. |
| 26 | * |
| 27 | * When uba resources are needed and not available, or if a device |
| 28 | * which can tolerate no other uba activity (rk07) gets on the bus, |
| 29 | * then device drivers may have to wait to get to the bus and are |
| 30 | * queued here. It is also possible for processes to block in |
| 31 | * the unibus driver in resource wait (mrwant, bdpwant); these |
| 32 | * wait states are also recorded here. |
| 33 | */ |
| 34 | struct uba_hd { |
| 35 | struct uba_regs *uh_uba; /* virt addr of uba */ |
| 36 | struct uba_regs *uh_physuba; /* phys addr of uba */ |
| 37 | int (**uh_vec)(); /* interrupt vector */ |
| 38 | struct uba_device *uh_actf; /* head of queue to transfer */ |
| 39 | struct uba_device *uh_actl; /* tail of queue to transfer */ |
| 40 | short uh_mrwant; /* someone is waiting for map reg */ |
| 41 | short uh_bdpwant; /* someone awaits bdp's */ |
| 42 | int uh_bdpfree; /* free bdp's */ |
| 43 | int uh_hangcnt; /* number of ticks hung */ |
| 44 | int uh_zvcnt; /* number of 0 vectors */ |
| 45 | int uh_errcnt; /* number of errors */ |
| 46 | short uh_users; /* transient bdp use count */ |
| 47 | short uh_xclu; /* an rk07 is using this uba! */ |
| 48 | #define UAMSIZ 25 |
| 49 | struct map *uh_map; /* buffered data path regs free */ |
| 50 | }; |
| 51 | |
| 52 | #ifndef LOCORE |
| 53 | /* |
| 54 | * Per-controller structure. |
| 55 | * (E.g. one for each disk and tape controller, and other things |
| 56 | * which use and release buffered data paths.) |
| 57 | * |
| 58 | * If a controller has devices attached, then there are |
| 59 | * cross-referenced uba_drive structures. |
| 60 | * This structure is the one which is queued in unibus resource wait, |
| 61 | * and saves the information about unibus resources which are used. |
| 62 | * The queue of devices waiting to transfer is also attached here. |
| 63 | */ |
| 64 | struct uba_ctlr { |
| 65 | struct uba_driver *um_driver; |
| 66 | short um_ctlr; /* controller index in driver */ |
| 67 | short um_ubanum; /* the uba it is on */ |
| 68 | short um_alive; /* controller exists */ |
| 69 | int (**um_intr)(); /* interrupt handler(s) */ |
| 70 | caddr_t um_addr; /* address of device in i/o space */ |
| 71 | struct uba_hd *um_hd; |
| 72 | /* the driver saves the prototype command here for use in its go routine */ |
| 73 | int um_cmd; /* communication to dgo() */ |
| 74 | int um_ubinfo; /* save unibus registers, etc */ |
| 75 | struct buf um_tab; /* queue of devices for this controller */ |
| 76 | }; |
| 77 | |
| 78 | /* |
| 79 | * Per ``device'' structure. |
| 80 | * (A controller has devices or uses and releases buffered data paths). |
| 81 | * (Everything else is a ``device''.) |
| 82 | * |
| 83 | * If a controller has many drives attached, then there will |
| 84 | * be several uba_device structures associated with a single uba_ctlr |
| 85 | * structure. |
| 86 | * |
| 87 | * This structure contains all the information necessary to run |
| 88 | * a unibus device such as a dz or a dh. It also contains information |
| 89 | * for slaves of unibus controllers as to which device on the slave |
| 90 | * this is. A flags field here can also be given in the system specification |
| 91 | * and is used to tell which dz lines are hard wired or other device |
| 92 | * specific parameters. |
| 93 | */ |
| 94 | struct uba_device { |
| 95 | struct uba_driver *ui_driver; |
| 96 | short ui_unit; /* unit number on the system */ |
| 97 | short ui_ctlr; /* mass ctlr number; -1 if none */ |
| 98 | short ui_ubanum; /* the uba it is on */ |
| 99 | short ui_slave; /* slave on controller */ |
| 100 | int (**ui_intr)(); /* interrupt handler(s) */ |
| 101 | caddr_t ui_addr; /* address of device in i/o space */ |
| 102 | short ui_dk; /* if init 1 set to number for iostat */ |
| 103 | short ui_flags; /* parameter from system specification */ |
| 104 | short ui_alive; /* device exists */ |
| 105 | short ui_type; /* driver specific type information */ |
| 106 | caddr_t ui_physaddr; /* phys addr, for standalone (dump) code */ |
| 107 | /* this is the forward link in a list of devices on a controller */ |
| 108 | struct uba_device *ui_forw; |
| 109 | /* if the device is connected to a controller, this is the controller */ |
| 110 | struct uba_ctlr *ui_mi; |
| 111 | struct uba_hd *ui_hd; |
| 112 | }; |
| 113 | #endif |
| 114 | |
| 115 | /* |
| 116 | * Per-driver structure. |
| 117 | * |
| 118 | * Each unibus driver defines entries for a set of routines |
| 119 | * as well as an array of types which are acceptable to it. |
| 120 | * These are used at boot time by the configuration program. |
| 121 | */ |
| 122 | struct uba_driver { |
| 123 | int (*ud_probe)(); /* see if a driver is really there */ |
| 124 | int (*ud_slave)(); /* see if a slave is there */ |
| 125 | int (*ud_attach)(); /* setup driver for a slave */ |
| 126 | int (*ud_dgo)(); /* fill csr/ba to start transfer */ |
| 127 | u_short *ud_addr; /* device csr addresses */ |
| 128 | char *ud_dname; /* name of a device */ |
| 129 | struct uba_device **ud_dinfo; /* backpointers to ubdinit structs */ |
| 130 | char *ud_mname; /* name of a controller */ |
| 131 | struct uba_ctlr **ud_minfo; /* backpointers to ubminit structs */ |
| 132 | short ud_xclu; /* want exclusive use of bdp's */ |
| 133 | }; |
| 134 | #endif |
| 135 | |
| 136 | /* |
| 137 | * Flags to UBA map/bdp allocation routines |
| 138 | */ |
| 139 | #define UBA_NEEDBDP 1 /* transfer needs a bdp */ |
| 140 | #define UBA_CANTWAIT 2 /* don't block me */ |
| 141 | #define UBA_NEED16 3 /* need 16 bit addresses only */ |
| 142 | |
| 143 | #ifndef LOCORE |
| 144 | #ifdef KERNEL |
| 145 | /* |
| 146 | * UBA related kernel variables |
| 147 | */ |
| 148 | int numuba; /* number of uba's */ |
| 149 | extern struct uba_hd uba_hd[]; |
| 150 | |
| 151 | /* |
| 152 | * Ubminit and ubdinit initialize the mass storage controller and |
| 153 | * device tables specifying possible devices. |
| 154 | */ |
| 155 | extern struct uba_ctlr ubminit[]; |
| 156 | extern struct uba_device ubdinit[]; |
| 157 | |
| 158 | /* |
| 159 | * UNIbus device address space is mapped by UMEMmap |
| 160 | * into virtual address umem[][]. |
| 161 | */ |
| 162 | extern struct pte UMEMmap[][16]; /* uba device addr pte's */ |
| 163 | extern char umem[][16*NBPG]; /* uba device addr space */ |
| 164 | |
| 165 | /* |
| 166 | * Since some VAXen vector their first (and only) unibus interrupt |
| 167 | * vector just adjacent to the system control block, we must |
| 168 | * allocate space there when running on ``any'' cpu. This space is |
| 169 | * used for the vector for uba0 on all cpu's. |
| 170 | */ |
| 171 | extern int (*UNIvec[])(); /* unibus vec for uba0 */ |
| 172 | |
| 173 | #if VAX780 |
| 174 | /* |
| 175 | * On 780's, we must set the scb vectors for the nexus of the |
| 176 | * UNIbus adaptors to vector to locore unibus adaptor interrupt dispatchers |
| 177 | * which make 780's look like the other VAXen. |
| 178 | */ |
| 179 | extern Xua0int(), Xua1int(), Xua2int(), Xua3int(); |
| 180 | #endif VAX780 |
| 181 | #endif KERNEL |
| 182 | #endif !LOCORE |