1 /* 2 * Copyright (c) 1982, 1986, 1988 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)mba.c 7.9 (Berkeley) 12/16/90 7 */ 8 9 #include "../include/pte.h" 10 11 #include "sys/param.h" 12 #include "sys/vm.h" 13 14 #include "../include/mtpr.h" 15 #include "../mba/mbareg.h" 16 #include "../mba/hpreg.h" 17 18 #include "stand/saio.h" 19 #include "savax.h" 20 21 mbastart(io, unit, func) 22 register struct iob *io; 23 int unit, func; 24 { 25 struct mba_regs *mba = mbamba(io->i_adapt); 26 struct mba_drv *drv = mbadrv(io->i_adapt, unit); 27 register struct pte *pte = mba->mba_map; 28 unsigned int v; 29 int npf, o, vaddr; 30 31 v = btop(io->i_ma); 32 o = (int)io->i_ma & PGOFSET; 33 npf = btoc(io->i_cc + o); 34 vaddr = o; 35 while (--npf >= 0) 36 *(int *)pte++ = v++ | PG_V; 37 mba->mba_sr = -1; 38 mba->mba_bcr = -io->i_cc; 39 mba->mba_var = vaddr; 40 if (io->i_flgs&F_SSI) 41 drv->mbd_of |= HPOF_SSEI; 42 switch (io->i_flgs & F_TYPEMASK) { 43 44 case F_RDDATA: /* standard read */ 45 drv->mbd_cs1 = MB_RCOM|MB_GO; 46 mbawait(io, unit); 47 return(0); 48 49 case F_WRDATA: /* standard write */ 50 drv->mbd_cs1 = MB_WCOM|MB_GO; 51 mbawait(io, unit); 52 return(0); 53 54 /* the following commands apply to disks only */ 55 56 case F_HDR|F_RDDATA: 57 drv->mbd_cs1 = HP_RHDR|HP_GO; 58 break; 59 60 case F_HDR|F_WRDATA: 61 drv->mbd_cs1 = HP_WHDR|HP_GO; 62 break; 63 64 case F_CHECK|F_WRDATA: 65 case F_CHECK|F_RDDATA: 66 drv->mbd_cs1 = HP_WCDATA|HP_GO; 67 break; 68 69 case F_HCHECK|F_WRDATA: 70 case F_HCHECK|F_RDDATA: 71 drv->mbd_cs1 = HP_WCHDR|HP_GO; 72 break; 73 74 default: 75 goto error; 76 } 77 mbawait(io, unit); 78 if ((drv->mbd_dt & MBDT_TAP) == 0) 79 return (0); 80 error: 81 io->i_error = ECMD; 82 io->i_flgs &= ~F_TYPEMASK; 83 return (1); 84 } 85 86 mbawait(io, unit) 87 register struct iob *io; 88 int unit; 89 { 90 struct mba_regs *mba = mbamba(io->i_adapt); 91 struct mba_drv *drv = mbadrv(io->i_adapt, unit); 92 93 while (mba->mba_sr & MBSR_DTBUSY) 94 DELAY(100); 95 } 96 97 mbainit(mbanum) 98 int mbanum; 99 { 100 register struct mba_regs *mba; 101 102 if (mbanum >= nmba) 103 return (0); 104 mba = mbaddr[mbanum]; 105 if (badaddr((char *)mba, sizeof(long))) 106 return (0); 107 if ((mbaact & (1<<mbanum)) == 0) { 108 mba->mba_cr = MBCR_INIT; 109 mbaact |= 1<<mbanum; 110 } 111 return (1); 112 } 113