Commit | Line | Data |
---|---|---|
92e67171 | 1 | /* ubavar.h 6.1 83/07/29 */ |
1cb3d36a BJ |
2 | |
3 | /* | |
4df4b0ef BJ |
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. | |
1cb3d36a BJ |
10 | */ |
11 | ||
b5fa1937 | 12 | #ifndef LOCORE |
1cb3d36a | 13 | /* |
4df4b0ef BJ |
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. | |
1cb3d36a | 33 | */ |
4df4b0ef BJ |
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 */ | |
2fa66c98 | 45 | int uh_errcnt; /* number of errors */ |
96357c8f | 46 | int uh_lastiv; /* last free interrupt vector */ |
4df4b0ef BJ |
47 | short uh_users; /* transient bdp use count */ |
48 | short uh_xclu; /* an rk07 is using this uba! */ | |
49 | #define UAMSIZ 25 | |
50 | struct map *uh_map; /* buffered data path regs free */ | |
10a50234 | 51 | }; |
10a50234 | 52 | |
b5fa1937 | 53 | #ifndef LOCORE |
10a50234 | 54 | /* |
4df4b0ef BJ |
55 | * Per-controller structure. |
56 | * (E.g. one for each disk and tape controller, and other things | |
57 | * which use and release buffered data paths.) | |
58 | * | |
59 | * If a controller has devices attached, then there are | |
60 | * cross-referenced uba_drive structures. | |
61 | * This structure is the one which is queued in unibus resource wait, | |
62 | * and saves the information about unibus resources which are used. | |
63 | * The queue of devices waiting to transfer is also attached here. | |
10a50234 | 64 | */ |
4df4b0ef | 65 | struct uba_ctlr { |
ca89a8ee BJ |
66 | struct uba_driver *um_driver; |
67 | short um_ctlr; /* controller index in driver */ | |
10a50234 BJ |
68 | short um_ubanum; /* the uba it is on */ |
69 | short um_alive; /* controller exists */ | |
ca89a8ee | 70 | int (**um_intr)(); /* interrupt handler(s) */ |
10a50234 | 71 | caddr_t um_addr; /* address of device in i/o space */ |
ca89a8ee | 72 | struct uba_hd *um_hd; |
4df4b0ef | 73 | /* the driver saves the prototype command here for use in its go routine */ |
15b39647 BJ |
74 | int um_cmd; /* communication to dgo() */ |
75 | int um_ubinfo; /* save unibus registers, etc */ | |
4df4b0ef | 76 | struct buf um_tab; /* queue of devices for this controller */ |
1cb3d36a | 77 | }; |
4df4b0ef | 78 | |
10a50234 | 79 | /* |
4df4b0ef BJ |
80 | * Per ``device'' structure. |
81 | * (A controller has devices or uses and releases buffered data paths). | |
82 | * (Everything else is a ``device''.) | |
83 | * | |
ca89a8ee | 84 | * If a controller has many drives attached, then there will |
4df4b0ef | 85 | * be several uba_device structures associated with a single uba_ctlr |
10a50234 | 86 | * structure. |
4df4b0ef BJ |
87 | * |
88 | * This structure contains all the information necessary to run | |
89 | * a unibus device such as a dz or a dh. It also contains information | |
90 | * for slaves of unibus controllers as to which device on the slave | |
91 | * this is. A flags field here can also be given in the system specification | |
92 | * and is used to tell which dz lines are hard wired or other device | |
93 | * specific parameters. | |
10a50234 | 94 | */ |
4df4b0ef | 95 | struct uba_device { |
10a50234 | 96 | struct uba_driver *ui_driver; |
10a50234 | 97 | short ui_unit; /* unit number on the system */ |
ca89a8ee | 98 | short ui_ctlr; /* mass ctlr number; -1 if none */ |
10a50234 BJ |
99 | short ui_ubanum; /* the uba it is on */ |
100 | short ui_slave; /* slave on controller */ | |
101 | int (**ui_intr)(); /* interrupt handler(s) */ | |
102 | caddr_t ui_addr; /* address of device in i/o space */ | |
15b39647 | 103 | short ui_dk; /* if init 1 set to number for iostat */ |
f0bf900e | 104 | int ui_flags; /* parameter from system specification */ |
10a50234 BJ |
105 | short ui_alive; /* device exists */ |
106 | short ui_type; /* driver specific type information */ | |
10a50234 | 107 | caddr_t ui_physaddr; /* phys addr, for standalone (dump) code */ |
4df4b0ef BJ |
108 | /* this is the forward link in a list of devices on a controller */ |
109 | struct uba_device *ui_forw; | |
110 | /* if the device is connected to a controller, this is the controller */ | |
111 | struct uba_ctlr *ui_mi; | |
10a50234 BJ |
112 | struct uba_hd *ui_hd; |
113 | }; | |
b5fa1937 | 114 | #endif |
10a50234 | 115 | |
10a50234 | 116 | /* |
4df4b0ef BJ |
117 | * Per-driver structure. |
118 | * | |
119 | * Each unibus driver defines entries for a set of routines | |
10a50234 | 120 | * as well as an array of types which are acceptable to it. |
4df4b0ef | 121 | * These are used at boot time by the configuration program. |
10a50234 BJ |
122 | */ |
123 | struct uba_driver { | |
bbe0bf68 BJ |
124 | int (*ud_probe)(); /* see if a driver is really there */ |
125 | int (*ud_slave)(); /* see if a slave is there */ | |
126 | int (*ud_attach)(); /* setup driver for a slave */ | |
127 | int (*ud_dgo)(); /* fill csr/ba to start transfer */ | |
10a50234 | 128 | u_short *ud_addr; /* device csr addresses */ |
15b39647 | 129 | char *ud_dname; /* name of a device */ |
4df4b0ef | 130 | struct uba_device **ud_dinfo; /* backpointers to ubdinit structs */ |
15b39647 | 131 | char *ud_mname; /* name of a controller */ |
4df4b0ef | 132 | struct uba_ctlr **ud_minfo; /* backpointers to ubminit structs */ |
8786ef2e | 133 | short ud_xclu; /* want exclusive use of bdp's */ |
466a1b4c | 134 | }; |
b5fa1937 | 135 | #endif |
466a1b4c | 136 | |
10a50234 | 137 | /* |
4df4b0ef BJ |
138 | * Flags to UBA map/bdp allocation routines |
139 | */ | |
96357c8f BJ |
140 | #define UBA_NEEDBDP 0x01 /* transfer needs a bdp */ |
141 | #define UBA_CANTWAIT 0x02 /* don't block me */ | |
142 | #define UBA_NEED16 0x04 /* need 16 bit addresses only */ | |
143 | #define UBA_HAVEBDP 0x08 /* use bdp specified in high bits */ | |
4df4b0ef | 144 | |
114cd253 BJ |
145 | /* |
146 | * Macros to bust return word from map allocation routines. | |
147 | */ | |
148 | #define UBAI_BDP(i) ((int)(((unsigned)(i))>>28)) | |
149 | #define UBAI_NMR(i) ((int)((i)>>18)&0x3ff) | |
150 | #define UBAI_MR(i) ((int)((i)>>9)&0x1ff) | |
151 | #define UBAI_BOFF(i) ((int)((i)&0x1ff)) | |
152 | ||
4df4b0ef BJ |
153 | #ifndef LOCORE |
154 | #ifdef KERNEL | |
155 | /* | |
156 | * UBA related kernel variables | |
10a50234 | 157 | */ |
4df4b0ef | 158 | int numuba; /* number of uba's */ |
2752c877 | 159 | struct uba_hd uba_hd[]; |
10a50234 | 160 | |
4df4b0ef BJ |
161 | /* |
162 | * Ubminit and ubdinit initialize the mass storage controller and | |
163 | * device tables specifying possible devices. | |
164 | */ | |
165 | extern struct uba_ctlr ubminit[]; | |
166 | extern struct uba_device ubdinit[]; | |
10a50234 BJ |
167 | |
168 | /* | |
4df4b0ef BJ |
169 | * UNIbus device address space is mapped by UMEMmap |
170 | * into virtual address umem[][]. | |
10a50234 | 171 | */ |
1c1f6ecf BF |
172 | extern struct pte UMEMmap[][512]; /* uba device addr pte's */ |
173 | extern char umem[][512*NBPG]; /* uba device addr space */ | |
15b39647 BJ |
174 | |
175 | /* | |
4df4b0ef BJ |
176 | * Since some VAXen vector their first (and only) unibus interrupt |
177 | * vector just adjacent to the system control block, we must | |
178 | * allocate space there when running on ``any'' cpu. This space is | |
179 | * used for the vector for uba0 on all cpu's. | |
15b39647 | 180 | */ |
4df4b0ef BJ |
181 | extern int (*UNIvec[])(); /* unibus vec for uba0 */ |
182 | ||
15b39647 | 183 | #if VAX780 |
4df4b0ef BJ |
184 | /* |
185 | * On 780's, we must set the scb vectors for the nexus of the | |
186 | * UNIbus adaptors to vector to locore unibus adaptor interrupt dispatchers | |
187 | * which make 780's look like the other VAXen. | |
188 | */ | |
15b39647 | 189 | extern Xua0int(), Xua1int(), Xua2int(), Xua3int(); |
4df4b0ef BJ |
190 | #endif VAX780 |
191 | #endif KERNEL | |
192 | #endif !LOCORE |