123234Smckusick /* 229303Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 323234Smckusick * All rights reserved. The Berkeley software License Agreement 423234Smckusick * specifies the terms and conditions for redistribution. 523234Smckusick * 6*33528Sbostic * @(#)mba.c 7.4 (Berkeley) 02/22/88 723234Smckusick */ 8323Sbill 99806Ssam #include "../machine/pte.h" 109806Ssam 1133408Skarels #include "param.h" 1233408Skarels #include "inode.h" 1333408Skarels #include "fs.h" 1433408Skarels #include "vm.h" 159186Ssam 169186Ssam #include "../vax/mtpr.h" 179186Ssam #include "../vaxmba/mbareg.h" 1810332Shelge #include "../vaxmba/hpreg.h" 199186Ssam 20323Sbill #include "saio.h" 213262Swnj #include "savax.h" 22323Sbill 23*33528Sbostic mbastart(io, unit, func) 243262Swnj register struct iob *io; 25*33528Sbostic int unit, func; 26323Sbill { 27*33528Sbostic struct mba_regs *mba = mbamba(io->i_adapt); 28*33528Sbostic struct mba_drv *drv = mbadrv(io->i_adapt, unit); 293262Swnj register struct pte *pte = mba->mba_map; 30*33528Sbostic unsigned int v; 31*33528Sbostic int npf, o, vaddr; 32323Sbill 33323Sbill v = btop(io->i_ma); 34323Sbill o = (int)io->i_ma & PGOFSET; 35323Sbill npf = btoc(io->i_cc + o); 363262Swnj vaddr = o; 37323Sbill while (--npf >= 0) 38323Sbill *(int *)pte++ = v++ | PG_V; 393262Swnj mba->mba_sr = -1; 403262Swnj mba->mba_bcr = -io->i_cc; 413262Swnj mba->mba_var = vaddr; 4211142Ssam if (io->i_flgs&F_SSI) 4310623Shelge drv->mbd_of |= HPOF_SSEI; 4410332Shelge switch (io->i_flgs & F_TYPEMASK) { 4510332Shelge 4610332Shelge case F_RDDATA: /* standard read */ 4710332Shelge drv->mbd_cs1 = MB_RCOM|MB_GO; 48*33528Sbostic mbawait(io, unit); 4910332Shelge return(0); 5010332Shelge 5110332Shelge case F_WRDATA: /* standard write */ 5210332Shelge drv->mbd_cs1 = MB_WCOM|MB_GO; 53*33528Sbostic mbawait(io, unit); 5410332Shelge return(0); 5510332Shelge 5610332Shelge /* the following commands apply to disks only */ 5710332Shelge 5810332Shelge case F_HDR|F_RDDATA: 5910332Shelge drv->mbd_cs1 = HP_RHDR|HP_GO; 6010332Shelge break; 6110332Shelge 6210332Shelge case F_HDR|F_WRDATA: 6310332Shelge drv->mbd_cs1 = HP_WHDR|HP_GO; 6410332Shelge break; 6510332Shelge 6610332Shelge case F_CHECK|F_WRDATA: 6710332Shelge case F_CHECK|F_RDDATA: 6810332Shelge drv->mbd_cs1 = HP_WCDATA|HP_GO; 6910332Shelge break; 7010332Shelge 7110332Shelge case F_HCHECK|F_WRDATA: 7210332Shelge case F_HCHECK|F_RDDATA: 7310332Shelge drv->mbd_cs1 = HP_WCHDR|HP_GO; 7410332Shelge break; 7510332Shelge 7610332Shelge default: 7711142Ssam goto error; 7810332Shelge } 79*33528Sbostic mbawait(io, unit); 8010332Shelge if ((drv->mbd_dt & MBDT_TAP) == 0) 8110332Shelge return (0); 8211142Ssam error: 8311142Ssam io->i_error = ECMD; 8411142Ssam io->i_flgs &= ~F_TYPEMASK; 8511142Ssam return (1); 86323Sbill } 87415Sbill 88*33528Sbostic mbawait(io, unit) 8913569Ssam register struct iob *io; 90*33528Sbostic int unit; 9113569Ssam { 92*33528Sbostic struct mba_regs *mba = mbamba(io->i_adapt); 93*33528Sbostic struct mba_drv *drv = mbadrv(io->i_adapt, unit); 9413569Ssam 9513569Ssam while (mba->mba_sr & MBSR_DTBUSY) 9613569Ssam DELAY(100); 9713569Ssam } 9813569Ssam 99415Sbill mbainit(mbanum) 100415Sbill int mbanum; 101415Sbill { 1023262Swnj register struct mba_regs *mba = mbaddr[mbanum]; 103415Sbill 10433408Skarels if (badaddr((char *)mba, sizeof(long))) { 10533408Skarels printf("nonexistent mba"); 10630547Skarels return (0); 10733408Skarels } 10833408Skarels if ((mbaact & (1<<mbanum)) == 0) { 10933408Skarels mba->mba_cr = MBCR_INIT; 11033408Skarels mbaact |= 1<<mbanum; 11133408Skarels } 11230547Skarels return (1); 113415Sbill } 114