1 /* mba.c 3.3 06/07/80 */ 2 3 #include "../h/param.h" 4 #include "../h/buf.h" 5 #include "../h/conf.h" 6 #include "../h/systm.h" 7 #include "../h/dir.h" 8 #include "../h/user.h" 9 #include "../h/proc.h" 10 #include "../h/seg.h" 11 #include "../h/pte.h" 12 #include "../h/map.h" 13 #include "../h/mba.h" 14 #include "../h/mtpr.h" 15 #include "../h/vm.h" 16 17 /* 18 * startup routine for MBA controllers. 19 */ 20 #define MBAWCOM 0x30 21 #define MBARCOM 0x38 22 #define GO 01 23 24 int mbaboff; 25 26 mbastart(bp, adcr) 27 register struct buf *bp; 28 int *adcr; 29 { 30 register int i; 31 int npf; 32 unsigned v; 33 register struct pte *pte, *io; 34 int o; 35 int vaddr; 36 register struct mba_regs *mbap; 37 struct proc *rp; 38 extern int mbanum[], *mbaloc[]; 39 extern char buffers[NBUF][BSIZE]; 40 41 mbap = (struct mba_regs *)mbaloc[mbanum[major(bp->b_dev)]]; 42 if ((bp->b_flags & B_PHYS) == 0) 43 vaddr = (bp->b_un.b_addr - (char *)buffers) + mbaboff; 44 else { 45 io = (struct pte *)mbap; 46 io += (MBA_MAP + 128*4)/4; 47 v = btop(bp->b_un.b_addr); 48 o = (int)bp->b_un.b_addr & PGOFSET; 49 npf = btoc(bp->b_bcount + o); 50 rp = bp->b_flags&B_DIRTY ? &proc[2] : bp->b_proc; 51 vaddr = (128 << 9) | o; 52 if (bp->b_flags & B_UAREA) { 53 for (i = 0; i < UPAGES; i++) { 54 if (rp->p_addr[i].pg_pfnum == 0) 55 panic("mba: zero upage"); 56 *(int *)io++ = rp->p_addr[i].pg_pfnum | PG_V; 57 } 58 } else if ((bp->b_flags & B_PHYS) == 0) { 59 v &= 0x1fffff; /* drop to physical addr */ 60 while (--npf >= 0) 61 *(int *)io++ = v++ | PG_V; 62 } else { 63 if (bp->b_flags & B_PAGET) 64 pte = &Usrptmap[btokmx((struct pte *)bp->b_un.b_addr)]; 65 else 66 pte = vtopte(rp, v); 67 while (--npf >= 0) { 68 if (pte->pg_pfnum == 0) 69 panic("mba, zero entry"); 70 *(int *)io++ = pte++->pg_pfnum | PG_V; 71 } 72 } 73 } 74 mbap->mba_sr = -1; /* clear status (error) bits */ 75 mbap->mba_bcr = -bp->b_bcount; 76 mbap->mba_var = vaddr; 77 if (bp->b_flags & B_READ) 78 *adcr = MBARCOM | GO; 79 else 80 *adcr = MBAWCOM | GO; 81 } 82 83 mbainit() 84 { 85 register int *io0, *io1, *b, t, j; 86 extern int *mbaloc[]; 87 extern char buffers[NBUF][BSIZE]; 88 89 io0 = mbaloc[0] + (MBA_MAP/4); 90 io1 = mbaloc[1] + (MBA_MAP/4); 91 b = (int *)Sysmap + ((((int) buffers)>>9)&PG_PFNUM); 92 j = NBUF * CLSIZE + ((int)buffers & 0x1ff ? 1 : 0); 93 do { 94 t = PG_V | (*b++ & PG_PFNUM); 95 *io0++ = t; 96 *io1++ = t; 97 } while (--j>0); 98 *io0 = 0; /* invalidate next entry */ 99 *io1 = 0; 100 mbaboff = (int)buffers & 0x1ff; 101 } 102