+ uh->uh_lastmem = 0;
+ for (ui = ubdinit; ui->ui_driver; ui++) {
+ if (ui->ui_ubanum != uban && ui->ui_ubanum != '?')
+ continue;
+ if (ui->ui_driver->ud_ubamem) {
+ /*
+ * During autoconfiguration, need to fudge ui_addr.
+ */
+ addr = ui->ui_addr;
+ ui->ui_addr = umembase + ubaoff(addr);
+ switch ((*ui->ui_driver->ud_ubamem)(ui, uban)) {
+ case 1:
+ ui->ui_alive = 1;
+ /* FALLTHROUGH */
+ case 0:
+ ui->ui_ubanum = uban;
+ break;
+ }
+ ui->ui_addr = addr;
+ }
+ }
+#if VAX780
+ /*
+ * On a 780, throw away any map registers disabled by rounding
+ * the map disable in the configuration register
+ * up to the next 8K boundary, or below the last unibus memory.
+ */
+ if (cpu == VAX_780) {
+ register i;
+
+ i = btop(((uh->uh_lastmem + 8191) / 8192) * 8192);
+ while (i)
+ (void) rmget(uh->uh_map, 1, i--);
+ }
+#endif
+}
+
+/*
+ * Allocate UNIBUS memory. Allocates and initializes
+ * sufficient mapping registers for access. On a 780,
+ * the configuration register is setup to disable UBA
+ * response on DMA transfers to addresses controlled
+ * by the disabled mapping registers.
+ * On a 780, should only be called from ubameminit, or in ascending order
+ * from 0 with 8K-sized and -aligned addresses; freeing memory that isn't
+ * the last unibus memory would free unusable map registers.
+ * Doalloc is 1 to allocate, 0 to deallocate.
+ */
+ubamem(uban, addr, npg, doalloc)
+ int uban, addr, npg, doalloc;
+{
+ register struct uba_hd *uh = &uba_hd[uban];
+ register int a;
+ int s;
+
+ a = (addr >> 9) + 1;
+ s = spl6();
+ if (doalloc)
+ a = rmget(uh->uh_map, npg, a);
+ else
+ rmfree(uh->uh_map, (long)npg, (long)a);
+ splx(s);