Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
0880b18e | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
0a762656 | 3 | * All rights reserved. |
da7c5cc6 | 4 | * |
af359dea C |
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. | |
0a762656 | 20 | * |
af359dea C |
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. | |
0a762656 | 32 | * |
1c15e888 | 33 | * @(#)ubavar.h 7.7 (Berkeley) 6/28/90 |
da7c5cc6 | 34 | */ |
1cb3d36a BJ |
35 | |
36 | /* | |
4df4b0ef BJ |
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. | |
1cb3d36a BJ |
43 | */ |
44 | ||
b5fa1937 | 45 | #ifndef LOCORE |
1cb3d36a | 46 | /* |
4df4b0ef BJ |
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. | |
1cb3d36a | 66 | */ |
4df4b0ef | 67 | struct uba_hd { |
63503d24 MK |
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 */ | |
4df4b0ef BJ |
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 */ | |
45d4a789 MK |
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 */ | |
2fa66c98 | 85 | int uh_errcnt; /* number of errors */ |
96357c8f | 86 | int uh_lastiv; /* last free interrupt vector */ |
4df4b0ef BJ |
87 | short uh_users; /* transient bdp use count */ |
88 | short uh_xclu; /* an rk07 is using this uba! */ | |
ee0fdd94 | 89 | int uh_lastmem; /* limit of any unibus memory */ |
bce08673 | 90 | #define UAMSIZ 100 |
b00a6fef | 91 | struct map *uh_map; /* register free map */ |
10a50234 | 92 | }; |
10a50234 | 93 | |
b0a4a8c6 MK |
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 | ||
10a50234 | 98 | /* |
4df4b0ef BJ |
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. | |
10a50234 | 108 | */ |
4df4b0ef | 109 | struct uba_ctlr { |
ca89a8ee BJ |
110 | struct uba_driver *um_driver; |
111 | short um_ctlr; /* controller index in driver */ | |
10a50234 BJ |
112 | short um_ubanum; /* the uba it is on */ |
113 | short um_alive; /* controller exists */ | |
ca89a8ee | 114 | int (**um_intr)(); /* interrupt handler(s) */ |
10a50234 | 115 | caddr_t um_addr; /* address of device in i/o space */ |
ca89a8ee | 116 | struct uba_hd *um_hd; |
4df4b0ef | 117 | /* the driver saves the prototype command here for use in its go routine */ |
15b39647 BJ |
118 | int um_cmd; /* communication to dgo() */ |
119 | int um_ubinfo; /* save unibus registers, etc */ | |
cd768dfd | 120 | int um_bdp; /* for controllers that hang on to bdp's */ |
4df4b0ef | 121 | struct buf um_tab; /* queue of devices for this controller */ |
1cb3d36a | 122 | }; |
4df4b0ef | 123 | |
10a50234 | 124 | /* |
4df4b0ef BJ |
125 | * Per ``device'' structure. |
126 | * (A controller has devices or uses and releases buffered data paths). | |
127 | * (Everything else is a ``device''.) | |
128 | * | |
ca89a8ee | 129 | * If a controller has many drives attached, then there will |
4df4b0ef | 130 | * be several uba_device structures associated with a single uba_ctlr |
10a50234 | 131 | * structure. |
4df4b0ef BJ |
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. | |
10a50234 | 139 | */ |
4df4b0ef | 140 | struct uba_device { |
10a50234 | 141 | struct uba_driver *ui_driver; |
10a50234 | 142 | short ui_unit; /* unit number on the system */ |
ca89a8ee | 143 | short ui_ctlr; /* mass ctlr number; -1 if none */ |
10a50234 BJ |
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 */ | |
15b39647 | 148 | short ui_dk; /* if init 1 set to number for iostat */ |
f0bf900e | 149 | int ui_flags; /* parameter from system specification */ |
10a50234 BJ |
150 | short ui_alive; /* device exists */ |
151 | short ui_type; /* driver specific type information */ | |
10a50234 | 152 | caddr_t ui_physaddr; /* phys addr, for standalone (dump) code */ |
4df4b0ef BJ |
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; | |
10a50234 BJ |
157 | struct uba_hd *ui_hd; |
158 | }; | |
159 | ||
10a50234 | 160 | /* |
4df4b0ef BJ |
161 | * Per-driver structure. |
162 | * | |
163 | * Each unibus driver defines entries for a set of routines | |
10a50234 | 164 | * as well as an array of types which are acceptable to it. |
4df4b0ef | 165 | * These are used at boot time by the configuration program. |
10a50234 BJ |
166 | */ |
167 | struct uba_driver { | |
bbe0bf68 BJ |
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 */ | |
10a50234 | 172 | u_short *ud_addr; /* device csr addresses */ |
15b39647 | 173 | char *ud_dname; /* name of a device */ |
4df4b0ef | 174 | struct uba_device **ud_dinfo; /* backpointers to ubdinit structs */ |
15b39647 | 175 | char *ud_mname; /* name of a controller */ |
4df4b0ef | 176 | struct uba_ctlr **ud_minfo; /* backpointers to ubminit structs */ |
8786ef2e | 177 | short ud_xclu; /* want exclusive use of bdp's */ |
cd768dfd | 178 | short ud_keepbdp; /* hang on to bdp's once allocated */ |
ee0fdd94 | 179 | int (*ud_ubamem)(); /* see if dedicated memory is present */ |
466a1b4c | 180 | }; |
b5fa1937 | 181 | #endif |
466a1b4c | 182 | |
10a50234 | 183 | /* |
4df4b0ef BJ |
184 | * Flags to UBA map/bdp allocation routines |
185 | */ | |
96357c8f BJ |
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 */ | |
4df4b0ef | 190 | |
114cd253 BJ |
191 | /* |
192 | * Macros to bust return word from map allocation routines. | |
b00a6fef | 193 | * SHOULD USE STRUCTURE TO STORE UBA RESOURCE ALLOCATION: |
114cd253 | 194 | */ |
b00a6fef MK |
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 | |
114cd253 | 215 | |
4df4b0ef BJ |
216 | #ifndef LOCORE |
217 | #ifdef KERNEL | |
cd768dfd KB |
218 | #define ubago(ui) ubaqueue(ui, 0) |
219 | ||
4df4b0ef BJ |
220 | /* |
221 | * UBA related kernel variables | |
10a50234 | 222 | */ |
4df4b0ef | 223 | int numuba; /* number of uba's */ |
2752c877 | 224 | struct uba_hd uba_hd[]; |
10a50234 | 225 | |
4df4b0ef BJ |
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[]; | |
10a50234 BJ |
232 | |
233 | /* | |
b0a4a8c6 | 234 | * UNIBUS device address space is mapped by UMEMmap |
4df4b0ef | 235 | * into virtual address umem[][]. |
63503d24 MK |
236 | * The IO page is mapped to the last 8K of each. |
237 | * This should be enlarged for the Q22 bus. | |
10a50234 | 238 | */ |
1c1f6ecf BF |
239 | extern struct pte UMEMmap[][512]; /* uba device addr pte's */ |
240 | extern char umem[][512*NBPG]; /* uba device addr space */ | |
15b39647 BJ |
241 | |
242 | /* | |
0dcd89e1 SL |
243 | * Since some VAXen vector their unibus interrupts |
244 | * just adjacent to the system control block, we must | |
4df4b0ef | 245 | * allocate space there when running on ``any'' cpu. This space is |
b0a4a8c6 | 246 | * used for the vectors for all ubas. |
15b39647 | 247 | */ |
b0a4a8c6 MK |
248 | extern int (*UNIvec[][128])(); /* unibus vec for ubas */ |
249 | extern int (*eUNIvec)(); /* end of unibus vec */ | |
4df4b0ef | 250 | |
bce08673 | 251 | #if defined(VAX780) || defined(VAX8600) |
4df4b0ef | 252 | /* |
63503d24 | 253 | * On DW780's, we must set the scb vectors for the nexus of the |
4df4b0ef BJ |
254 | * UNIbus adaptors to vector to locore unibus adaptor interrupt dispatchers |
255 | * which make 780's look like the other VAXen. | |
256 | */ | |
15b39647 | 257 | extern Xua0int(), Xua1int(), Xua2int(), Xua3int(); |
4df4b0ef BJ |
258 | #endif VAX780 |
259 | #endif KERNEL | |
260 | #endif !LOCORE |