Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
0880b18e | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
da7c5cc6 KM |
3 | * All rights reserved. The Berkeley software License Agreement |
4 | * specifies the terms and conditions for redistribution. | |
5 | * | |
63503d24 | 6 | * @(#)ubavar.h 7.2 (Berkeley) %G% |
da7c5cc6 | 7 | */ |
1cb3d36a BJ |
8 | |
9 | /* | |
4df4b0ef BJ |
10 | * This file contains definitions related to the kernel structures |
11 | * for dealing with the unibus adapters. | |
12 | * | |
13 | * Each uba has a uba_hd structure. | |
14 | * Each unibus controller which is not a device has a uba_ctlr structure. | |
15 | * Each unibus device has a uba_device structure. | |
1cb3d36a BJ |
16 | */ |
17 | ||
b5fa1937 | 18 | #ifndef LOCORE |
1cb3d36a | 19 | /* |
4df4b0ef BJ |
20 | * Per-uba structure. |
21 | * | |
22 | * This structure holds the interrupt vector for the uba, | |
23 | * and its address in physical and virtual space. At boot time | |
24 | * we determine the devices attached to the uba's and their | |
25 | * interrupt vectors, filling in uh_vec. We free the map | |
26 | * register and bdp resources of the uba into the structures | |
27 | * defined here. | |
28 | * | |
29 | * During normal operation, resources are allocated and returned | |
30 | * to the structures here. We watch the number of passive releases | |
31 | * on each uba, and if the number is excessive may reset the uba. | |
32 | * | |
33 | * When uba resources are needed and not available, or if a device | |
34 | * which can tolerate no other uba activity (rk07) gets on the bus, | |
35 | * then device drivers may have to wait to get to the bus and are | |
36 | * queued here. It is also possible for processes to block in | |
37 | * the unibus driver in resource wait (mrwant, bdpwant); these | |
38 | * wait states are also recorded here. | |
1cb3d36a | 39 | */ |
4df4b0ef | 40 | struct uba_hd { |
63503d24 MK |
41 | int uh_type; /* type of adaptor */ |
42 | struct uba_regs *uh_uba; /* virt addr of uba adaptor regs */ | |
43 | struct uba_regs *uh_physuba; /* phys addr of uba adaptor regs */ | |
44 | struct pte *uh_mr; /* start of page map */ | |
45 | int uh_memsize; /* size of uba memory, pages */ | |
46 | caddr_t uh_mem; /* start of uba memory address space */ | |
47 | caddr_t uh_iopage; /* start of uba io page */ | |
4df4b0ef BJ |
48 | int (**uh_vec)(); /* interrupt vector */ |
49 | struct uba_device *uh_actf; /* head of queue to transfer */ | |
50 | struct uba_device *uh_actl; /* tail of queue to transfer */ | |
51 | short uh_mrwant; /* someone is waiting for map reg */ | |
52 | short uh_bdpwant; /* someone awaits bdp's */ | |
53 | int uh_bdpfree; /* free bdp's */ | |
54 | int uh_hangcnt; /* number of ticks hung */ | |
45d4a789 MK |
55 | int uh_zvcnt; /* number of recent 0 vectors */ |
56 | long uh_zvtime; /* time over which zvcnt accumulated */ | |
57 | int uh_zvtotal; /* total number of 0 vectors */ | |
2fa66c98 | 58 | int uh_errcnt; /* number of errors */ |
96357c8f | 59 | int uh_lastiv; /* last free interrupt vector */ |
4df4b0ef BJ |
60 | short uh_users; /* transient bdp use count */ |
61 | short uh_xclu; /* an rk07 is using this uba! */ | |
ee0fdd94 | 62 | int uh_lastmem; /* limit of any unibus memory */ |
bce08673 | 63 | #define UAMSIZ 100 |
4df4b0ef | 64 | struct map *uh_map; /* buffered data path regs free */ |
10a50234 | 65 | }; |
10a50234 BJ |
66 | |
67 | /* | |
4df4b0ef BJ |
68 | * Per-controller structure. |
69 | * (E.g. one for each disk and tape controller, and other things | |
70 | * which use and release buffered data paths.) | |
71 | * | |
72 | * If a controller has devices attached, then there are | |
73 | * cross-referenced uba_drive structures. | |
74 | * This structure is the one which is queued in unibus resource wait, | |
75 | * and saves the information about unibus resources which are used. | |
76 | * The queue of devices waiting to transfer is also attached here. | |
10a50234 | 77 | */ |
4df4b0ef | 78 | struct uba_ctlr { |
ca89a8ee BJ |
79 | struct uba_driver *um_driver; |
80 | short um_ctlr; /* controller index in driver */ | |
10a50234 BJ |
81 | short um_ubanum; /* the uba it is on */ |
82 | short um_alive; /* controller exists */ | |
ca89a8ee | 83 | int (**um_intr)(); /* interrupt handler(s) */ |
10a50234 | 84 | caddr_t um_addr; /* address of device in i/o space */ |
ca89a8ee | 85 | struct uba_hd *um_hd; |
4df4b0ef | 86 | /* the driver saves the prototype command here for use in its go routine */ |
15b39647 BJ |
87 | int um_cmd; /* communication to dgo() */ |
88 | int um_ubinfo; /* save unibus registers, etc */ | |
4df4b0ef | 89 | struct buf um_tab; /* queue of devices for this controller */ |
1cb3d36a | 90 | }; |
4df4b0ef | 91 | |
10a50234 | 92 | /* |
4df4b0ef BJ |
93 | * Per ``device'' structure. |
94 | * (A controller has devices or uses and releases buffered data paths). | |
95 | * (Everything else is a ``device''.) | |
96 | * | |
ca89a8ee | 97 | * If a controller has many drives attached, then there will |
4df4b0ef | 98 | * be several uba_device structures associated with a single uba_ctlr |
10a50234 | 99 | * structure. |
4df4b0ef BJ |
100 | * |
101 | * This structure contains all the information necessary to run | |
102 | * a unibus device such as a dz or a dh. It also contains information | |
103 | * for slaves of unibus controllers as to which device on the slave | |
104 | * this is. A flags field here can also be given in the system specification | |
105 | * and is used to tell which dz lines are hard wired or other device | |
106 | * specific parameters. | |
10a50234 | 107 | */ |
4df4b0ef | 108 | struct uba_device { |
10a50234 | 109 | struct uba_driver *ui_driver; |
10a50234 | 110 | short ui_unit; /* unit number on the system */ |
ca89a8ee | 111 | short ui_ctlr; /* mass ctlr number; -1 if none */ |
10a50234 BJ |
112 | short ui_ubanum; /* the uba it is on */ |
113 | short ui_slave; /* slave on controller */ | |
114 | int (**ui_intr)(); /* interrupt handler(s) */ | |
115 | caddr_t ui_addr; /* address of device in i/o space */ | |
15b39647 | 116 | short ui_dk; /* if init 1 set to number for iostat */ |
f0bf900e | 117 | int ui_flags; /* parameter from system specification */ |
10a50234 BJ |
118 | short ui_alive; /* device exists */ |
119 | short ui_type; /* driver specific type information */ | |
10a50234 | 120 | caddr_t ui_physaddr; /* phys addr, for standalone (dump) code */ |
4df4b0ef BJ |
121 | /* this is the forward link in a list of devices on a controller */ |
122 | struct uba_device *ui_forw; | |
123 | /* if the device is connected to a controller, this is the controller */ | |
124 | struct uba_ctlr *ui_mi; | |
10a50234 BJ |
125 | struct uba_hd *ui_hd; |
126 | }; | |
127 | ||
10a50234 | 128 | /* |
4df4b0ef BJ |
129 | * Per-driver structure. |
130 | * | |
131 | * Each unibus driver defines entries for a set of routines | |
10a50234 | 132 | * as well as an array of types which are acceptable to it. |
4df4b0ef | 133 | * These are used at boot time by the configuration program. |
10a50234 BJ |
134 | */ |
135 | struct uba_driver { | |
bbe0bf68 BJ |
136 | int (*ud_probe)(); /* see if a driver is really there */ |
137 | int (*ud_slave)(); /* see if a slave is there */ | |
138 | int (*ud_attach)(); /* setup driver for a slave */ | |
139 | int (*ud_dgo)(); /* fill csr/ba to start transfer */ | |
10a50234 | 140 | u_short *ud_addr; /* device csr addresses */ |
15b39647 | 141 | char *ud_dname; /* name of a device */ |
4df4b0ef | 142 | struct uba_device **ud_dinfo; /* backpointers to ubdinit structs */ |
15b39647 | 143 | char *ud_mname; /* name of a controller */ |
4df4b0ef | 144 | struct uba_ctlr **ud_minfo; /* backpointers to ubminit structs */ |
8786ef2e | 145 | short ud_xclu; /* want exclusive use of bdp's */ |
ee0fdd94 | 146 | int (*ud_ubamem)(); /* see if dedicated memory is present */ |
466a1b4c | 147 | }; |
b5fa1937 | 148 | #endif |
466a1b4c | 149 | |
10a50234 | 150 | /* |
4df4b0ef BJ |
151 | * Flags to UBA map/bdp allocation routines |
152 | */ | |
96357c8f BJ |
153 | #define UBA_NEEDBDP 0x01 /* transfer needs a bdp */ |
154 | #define UBA_CANTWAIT 0x02 /* don't block me */ | |
155 | #define UBA_NEED16 0x04 /* need 16 bit addresses only */ | |
156 | #define UBA_HAVEBDP 0x08 /* use bdp specified in high bits */ | |
4df4b0ef | 157 | |
114cd253 BJ |
158 | /* |
159 | * Macros to bust return word from map allocation routines. | |
160 | */ | |
161 | #define UBAI_BDP(i) ((int)(((unsigned)(i))>>28)) | |
162 | #define UBAI_NMR(i) ((int)((i)>>18)&0x3ff) | |
163 | #define UBAI_MR(i) ((int)((i)>>9)&0x1ff) | |
164 | #define UBAI_BOFF(i) ((int)((i)&0x1ff)) | |
e2aa5a54 | 165 | #define UBAI_ADDR(i) ((int)((i)&0x3ffff)) /* uba addr (boff+mr) */ |
114cd253 | 166 | |
4df4b0ef BJ |
167 | #ifndef LOCORE |
168 | #ifdef KERNEL | |
169 | /* | |
170 | * UBA related kernel variables | |
10a50234 | 171 | */ |
4df4b0ef | 172 | int numuba; /* number of uba's */ |
2752c877 | 173 | struct uba_hd uba_hd[]; |
10a50234 | 174 | |
4df4b0ef BJ |
175 | /* |
176 | * Ubminit and ubdinit initialize the mass storage controller and | |
177 | * device tables specifying possible devices. | |
178 | */ | |
179 | extern struct uba_ctlr ubminit[]; | |
180 | extern struct uba_device ubdinit[]; | |
10a50234 BJ |
181 | |
182 | /* | |
4df4b0ef BJ |
183 | * UNIbus device address space is mapped by UMEMmap |
184 | * into virtual address umem[][]. | |
63503d24 MK |
185 | * The IO page is mapped to the last 8K of each. |
186 | * This should be enlarged for the Q22 bus. | |
10a50234 | 187 | */ |
1c1f6ecf BF |
188 | extern struct pte UMEMmap[][512]; /* uba device addr pte's */ |
189 | extern char umem[][512*NBPG]; /* uba device addr space */ | |
15b39647 BJ |
190 | |
191 | /* | |
0dcd89e1 SL |
192 | * Since some VAXen vector their unibus interrupts |
193 | * just adjacent to the system control block, we must | |
4df4b0ef | 194 | * allocate space there when running on ``any'' cpu. This space is |
63503d24 | 195 | * used for the vectors for uba0 and uba1 on all cpu's but 8600's. |
15b39647 | 196 | */ |
4df4b0ef | 197 | extern int (*UNIvec[])(); /* unibus vec for uba0 */ |
0dcd89e1 SL |
198 | #if NUBA > 1 |
199 | extern int (*UNI1vec[])(); /* unibus vec for uba1 */ | |
200 | #endif | |
4df4b0ef | 201 | |
bce08673 | 202 | #if defined(VAX780) || defined(VAX8600) |
4df4b0ef | 203 | /* |
63503d24 | 204 | * On DW780's, we must set the scb vectors for the nexus of the |
4df4b0ef BJ |
205 | * UNIbus adaptors to vector to locore unibus adaptor interrupt dispatchers |
206 | * which make 780's look like the other VAXen. | |
207 | */ | |
15b39647 | 208 | extern Xua0int(), Xua1int(), Xua2int(), Xua3int(); |
4df4b0ef BJ |
209 | #endif VAX780 |
210 | #endif KERNEL | |
211 | #endif !LOCORE |