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*33552Sbostic * @(#)mba.c 7.5 (Berkeley) 02/24/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 2333528Sbostic mbastart(io, unit, func) 243262Swnj register struct iob *io; 2533528Sbostic int unit, func; 26323Sbill { 2733528Sbostic struct mba_regs *mba = mbamba(io->i_adapt); 2833528Sbostic struct mba_drv *drv = mbadrv(io->i_adapt, unit); 293262Swnj register struct pte *pte = mba->mba_map; 3033528Sbostic unsigned int v; 3133528Sbostic 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; 4833528Sbostic mbawait(io, unit); 4910332Shelge return(0); 5010332Shelge 5110332Shelge case F_WRDATA: /* standard write */ 5210332Shelge drv->mbd_cs1 = MB_WCOM|MB_GO; 5333528Sbostic 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 } 7933528Sbostic 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 8833528Sbostic mbawait(io, unit) 8913569Ssam register struct iob *io; 9033528Sbostic int unit; 9113569Ssam { 9233528Sbostic struct mba_regs *mba = mbamba(io->i_adapt); 9333528Sbostic 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 104*33552Sbostic if (badaddr((char *)mba, sizeof(long))) 10530547Skarels return (0); 10633408Skarels if ((mbaact & (1<<mbanum)) == 0) { 10733408Skarels mba->mba_cr = MBCR_INIT; 10833408Skarels mbaact |= 1<<mbanum; 10933408Skarels } 11030547Skarels return (1); 111415Sbill } 112