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