+
+#if VAX780
+/*
+ * Init a uba. This is called with a pointer
+ * rather than a virtual address since it is called
+ * by code which runs with memory mapping disabled.
+ * In these cases we really don't need the interrupts
+ * enabled, but since we run with ipl high, we don't care
+ * if they are, they will never happen anyways.
+ */
+ubainit(uba)
+ register struct uba_regs *uba;
+{
+
+ uba->uba_cr = UBA_ADINIT;
+ uba->uba_cr = UBA_IFS|UBA_BRIE|UBA_USEFIE|UBA_SUEFIE;
+ while ((uba->uba_cnfgr & UBA_UBIC) == 0)
+ ;
+}
+
+/*
+ * Check to make sure the UNIBUS adaptor is not hung,
+ * with an interrupt in the register to be presented,
+ * but not presenting it for an extended period (5 seconds).
+ */
+unhang()
+{
+ register int uban;
+
+ for (uban = 0; uban < numuba; uban++) {
+ register struct uba_hd *uh = &uba_hd[uban];
+ register struct uba_regs *up = uh->uh_uba;
+
+ if (up->uba_sr == 0)
+ return;
+ uh->uh_hangcnt++;
+ if (uh->uh_hangcnt > 5*hz) {
+ uh->uh_hangcnt = 0;
+ printf("uba%d: hung\n", uban);
+ ubareset(uban);
+ }
+ }
+}
+
+/*
+ * This is a timeout routine which decrements the ``i forgot to
+ * interrupt'' counts, on an 11/780. This prevents slowly growing
+ * counts from causing a UBA reset since we are interested only
+ * in hang situations.
+ */
+ubawatch()
+{
+ register struct uba_hd *uh;
+ register int uban;
+
+ if (panicstr)
+ return;
+ for (uban = 0; uban < numuba; uban++) {
+ uh = &uba_hd[uban];
+ if (uh->uh_hangcnt)
+ uh->uh_hangcnt--;
+ }
+}
+
+/*
+ * This routine is called by the locore code to
+ * process a UBA error on an 11/780. The arguments are passed
+ * on the stack, and value-result (through some trickery).
+ * In particular, the uvec argument is used for further
+ * uba processing so the result aspect of it is very important.
+ * It must not be declared register.
+ */
+/*ARGSUSED*/
+ubaerror(uban, uh, xx, uvec, uba)
+ register int uban;
+ register struct uba_hd *uh;
+ int uvec;
+ register struct uba_regs *uba;
+{
+ register sr, s;
+
+ if (uvec == 0) {
+ uh->uh_zvcnt++;
+ if (uh->uh_zvcnt > 250000) {
+ printf("uba%d: too many zero vectors\n");
+ ubareset(uban);
+ }
+ uvec = 0;
+ return;
+ }
+ if (uba->uba_cnfgr & NEX_CFGFLT) {
+ printf("uba%d: sbi fault sr=%b cnfgr=%b\n",
+ uban, uba->uba_sr, ubasr_bits,
+ uba->uba_cnfgr, nexflt_bits);
+ ubareset(uban);
+ uvec = 0;
+ return;
+ }
+ sr = uba->uba_sr;
+ s = spl7();
+ printf("uba%d: uba error sr=%x fmer=%x fubar=%o\n",
+ uban, uba->uba_sr, uba->uba_fmer, 4*uba->uba_fubar);
+ splx(s);
+ uba->uba_sr = sr;
+ uvec &= UBA_DIV;
+ return;
+}
+#endif